diff --git a/wp-content/themes/cosmopet/composer-setup.php b/wp-content/themes/cosmopet/composer-setup.php new file mode 100644 index 0000000..a5efbed --- /dev/null +++ b/wp-content/themes/cosmopet/composer-setup.php @@ -0,0 +1,1748 @@ + + * Jordi Boggiano + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +setupEnvironment(); +process(is_array($argv) ? $argv : array()); + +/** + * Initializes various values + * + * @throws RuntimeException If uopz extension prevents exit calls + */ +function setupEnvironment() +{ + ini_set('display_errors', 1); + + if (extension_loaded('uopz') && !(ini_get('uopz.disable') || ini_get('uopz.exit'))) { + // uopz works at opcode level and disables exit calls + if (function_exists('uopz_allow_exit')) { + @uopz_allow_exit(true); + } else { + throw new RuntimeException('The uopz extension ignores exit calls and breaks this installer.'); + } + } + + $installer = 'ComposerInstaller'; + + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + if ($version = getenv('COMPOSERSETUP')) { + $installer = sprintf('Composer-Setup.exe/%s', $version); + } + } + + define('COMPOSER_INSTALLER', $installer); +} + +/** + * Processes the installer + */ +function process($argv) +{ + // Determine ANSI output from --ansi and --no-ansi flags + setUseAnsi($argv); + + $help = in_array('--help', $argv) || in_array('-h', $argv); + if ($help) { + displayHelp(); + exit(0); + } + + $check = in_array('--check', $argv); + $force = in_array('--force', $argv); + $quiet = in_array('--quiet', $argv); + $channel = 'stable'; + if (in_array('--snapshot', $argv)) { + $channel = 'snapshot'; + } elseif (in_array('--preview', $argv)) { + $channel = 'preview'; + } elseif (in_array('--1', $argv)) { + $channel = '1'; + } elseif (in_array('--2', $argv)) { + $channel = '2'; + } elseif (in_array('--2.2', $argv)) { + $channel = '2.2'; + } + $disableTls = in_array('--disable-tls', $argv); + $installDir = getOptValue('--install-dir', $argv, false); + $version = getOptValue('--version', $argv, false); + $filename = getOptValue('--filename', $argv, 'composer.phar'); + $cafile = getOptValue('--cafile', $argv, false); + + if (!checkParams($installDir, $version, $cafile)) { + exit(1); + } + + $ok = checkPlatform($warnings, $quiet, $disableTls, true); + + if ($check) { + // Only show warnings if we haven't output any errors + if ($ok) { + showWarnings($warnings); + showSecurityWarning($disableTls); + } + exit($ok ? 0 : 1); + } + + if ($ok || $force) { + if ($channel === '1' && !$quiet) { + out('Warning: You forced the install of Composer 1.x via --1, but Composer 2.x is the latest stable version. Updating to it via composer self-update --stable is recommended.', 'error'); + } + + $installer = new Installer($quiet, $disableTls, $cafile); + if ($installer->run($version, $installDir, $filename, $channel)) { + showWarnings($warnings); + showSecurityWarning($disableTls); + exit(0); + } + } + + exit(1); +} + +/** + * Displays the help + */ +function displayHelp() +{ + echo << $value) { + $next = $key + 1; + if (0 === strpos($value, $opt)) { + if ($optLength === strlen($value) && isset($argv[$next])) { + return trim($argv[$next]); + } else { + return trim(substr($value, $optLength + 1)); + } + } + } + + return $default; +} + +/** + * Checks that user-supplied params are valid + * + * @param mixed $installDir The required istallation directory + * @param mixed $version The required composer version to install + * @param mixed $cafile Certificate Authority file + * + * @return bool True if the supplied params are okay + */ +function checkParams($installDir, $version, $cafile) +{ + $result = true; + + if (false !== $installDir && !is_dir($installDir)) { + out("The defined install dir ({$installDir}) does not exist.", 'info'); + $result = false; + } + + if (false !== $version && 1 !== preg_match('/^\d+\.\d+\.\d+(\-(alpha|beta|RC)\d*)*$/', $version)) { + out("The defined install version ({$version}) does not match release pattern.", 'info'); + $result = false; + } + + if (false !== $cafile && (!file_exists($cafile) || !is_readable($cafile))) { + out("The defined Certificate Authority (CA) cert file ({$cafile}) does not exist or is not readable.", 'info'); + $result = false; + } + return $result; +} + +/** + * Checks the platform for possible issues running Composer + * + * Errors are written to the output, warnings are saved for later display. + * + * @param array $warnings Populated by method, to be shown later + * @param bool $quiet Quiet mode + * @param bool $disableTls Bypass tls + * @param bool $install If we are installing, rather than diagnosing + * + * @return bool True if there are no errors + */ +function checkPlatform(&$warnings, $quiet, $disableTls, $install) +{ + getPlatformIssues($errors, $warnings, $install); + + // Make openssl warning an error if tls has not been specifically disabled + if (isset($warnings['openssl']) && !$disableTls) { + $errors['openssl'] = $warnings['openssl']; + unset($warnings['openssl']); + } + + if (!empty($errors)) { + // Composer-Setup.exe uses "Some settings" to flag platform errors + out('Some settings on your machine make Composer unable to work properly.', 'error'); + out('Make sure that you fix the issues listed below and run this script again:', 'error'); + outputIssues($errors); + return false; + } + + if (empty($warnings) && !$quiet) { + out('All settings correct for using Composer', 'success'); + } + return true; +} + +/** + * Checks platform configuration for common incompatibility issues + * + * @param array $errors Populated by method + * @param array $warnings Populated by method + * @param bool $install If we are installing, rather than diagnosing + * + * @return bool If any errors or warnings have been found + */ +function getPlatformIssues(&$errors, &$warnings, $install) +{ + $errors = array(); + $warnings = array(); + + if ($iniPath = php_ini_loaded_file()) { + $iniMessage = PHP_EOL.'The php.ini used by your command-line PHP is: ' . $iniPath; + } else { + $iniMessage = PHP_EOL.'A php.ini file does not exist. You will have to create one.'; + } + $iniMessage .= PHP_EOL.'If you can not modify the ini file, you can also run `php -d option=value` to modify ini values on the fly. You can use -d multiple times.'; + + if (ini_get('detect_unicode')) { + $errors['unicode'] = array( + 'The detect_unicode setting must be disabled.', + 'Add the following to the end of your `php.ini`:', + ' detect_unicode = Off', + $iniMessage + ); + } + + if (extension_loaded('suhosin')) { + $suhosin = ini_get('suhosin.executor.include.whitelist'); + $suhosinBlacklist = ini_get('suhosin.executor.include.blacklist'); + if (false === stripos($suhosin, 'phar') && (!$suhosinBlacklist || false !== stripos($suhosinBlacklist, 'phar'))) { + $errors['suhosin'] = array( + 'The suhosin.executor.include.whitelist setting is incorrect.', + 'Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):', + ' suhosin.executor.include.whitelist = phar '.$suhosin, + $iniMessage + ); + } + } + + if (!function_exists('json_decode')) { + $errors['json'] = array( + 'The json extension is missing.', + 'Install it or recompile php without --disable-json' + ); + } + + if (!extension_loaded('Phar')) { + $errors['phar'] = array( + 'The phar extension is missing.', + 'Install it or recompile php without --disable-phar' + ); + } + + if (!extension_loaded('filter')) { + $errors['filter'] = array( + 'The filter extension is missing.', + 'Install it or recompile php without --disable-filter' + ); + } + + if (!extension_loaded('hash')) { + $errors['hash'] = array( + 'The hash extension is missing.', + 'Install it or recompile php without --disable-hash' + ); + } + + if (!extension_loaded('iconv') && !extension_loaded('mbstring')) { + $errors['iconv_mbstring'] = array( + 'The iconv OR mbstring extension is required and both are missing.', + 'Install either of them or recompile php without --disable-iconv' + ); + } + + if (!ini_get('allow_url_fopen')) { + $errors['allow_url_fopen'] = array( + 'The allow_url_fopen setting is incorrect.', + 'Add the following to the end of your `php.ini`:', + ' allow_url_fopen = On', + $iniMessage + ); + } + + if (extension_loaded('ionCube Loader') && ioncube_loader_iversion() < 40009) { + $ioncube = ioncube_loader_version(); + $errors['ioncube'] = array( + 'Your ionCube Loader extension ('.$ioncube.') is incompatible with Phar files.', + 'Upgrade to ionCube 4.0.9 or higher or remove this line (path may be different) from your `php.ini` to disable it:', + ' zend_extension = /usr/lib/php5/20090626+lfs/ioncube_loader_lin_5.3.so', + $iniMessage + ); + } + + if (version_compare(PHP_VERSION, '5.3.2', '<')) { + $errors['php'] = array( + 'Your PHP ('.PHP_VERSION.') is too old, you must upgrade to PHP 5.3.2 or higher.' + ); + } + + if (version_compare(PHP_VERSION, '5.3.4', '<')) { + $warnings['php'] = array( + 'Your PHP ('.PHP_VERSION.') is quite old, upgrading to PHP 5.3.4 or higher is recommended.', + 'Composer works with 5.3.2+ for most people, but there might be edge case issues.' + ); + } + + if (!extension_loaded('openssl')) { + $warnings['openssl'] = array( + 'The openssl extension is missing, which means that secure HTTPS transfers are impossible.', + 'If possible you should enable it or recompile php with --with-openssl' + ); + } + + if (extension_loaded('openssl') && OPENSSL_VERSION_NUMBER < 0x1000100f) { + // Attempt to parse version number out, fallback to whole string value. + $opensslVersion = trim(strstr(OPENSSL_VERSION_TEXT, ' ')); + $opensslVersion = substr($opensslVersion, 0, strpos($opensslVersion, ' ')); + $opensslVersion = $opensslVersion ? $opensslVersion : OPENSSL_VERSION_TEXT; + + $warnings['openssl_version'] = array( + 'The OpenSSL library ('.$opensslVersion.') used by PHP does not support TLSv1.2 or TLSv1.1.', + 'If possible you should upgrade OpenSSL to version 1.0.1 or above.' + ); + } + + if (!defined('HHVM_VERSION') && !extension_loaded('apcu') && ini_get('apc.enable_cli')) { + $warnings['apc_cli'] = array( + 'The apc.enable_cli setting is incorrect.', + 'Add the following to the end of your `php.ini`:', + ' apc.enable_cli = Off', + $iniMessage + ); + } + + if (!$install && extension_loaded('xdebug')) { + $warnings['xdebug_loaded'] = array( + 'The xdebug extension is loaded, this can slow down Composer a little.', + 'Disabling it when using Composer is recommended.' + ); + + if (ini_get('xdebug.profiler_enabled')) { + $warnings['xdebug_profile'] = array( + 'The xdebug.profiler_enabled setting is enabled, this can slow down Composer a lot.', + 'Add the following to the end of your `php.ini` to disable it:', + ' xdebug.profiler_enabled = 0', + $iniMessage + ); + } + } + + if (!extension_loaded('zlib')) { + $warnings['zlib'] = array( + 'The zlib extension is not loaded, this can slow down Composer a lot.', + 'If possible, install it or recompile php with --with-zlib', + $iniMessage + ); + } + + if (defined('PHP_WINDOWS_VERSION_BUILD') + && (version_compare(PHP_VERSION, '7.2.23', '<') + || (version_compare(PHP_VERSION, '7.3.0', '>=') + && version_compare(PHP_VERSION, '7.3.10', '<')))) { + $warnings['onedrive'] = array( + 'The Windows OneDrive folder is not supported on PHP versions below 7.2.23 and 7.3.10.', + 'Upgrade your PHP ('.PHP_VERSION.') to use this location with Composer.' + ); + } + + if (extension_loaded('uopz') && !(ini_get('uopz.disable') || ini_get('uopz.exit'))) { + $warnings['uopz'] = array( + 'The uopz extension ignores exit calls and may not work with all Composer commands.', + 'Disabling it when using Composer is recommended.' + ); + } + + ob_start(); + phpinfo(INFO_GENERAL); + $phpinfo = ob_get_clean(); + if (preg_match('{Configure Command(?: *| *=> *)(.*?)(?:|$)}m', $phpinfo, $match)) { + $configure = $match[1]; + + if (false !== strpos($configure, '--enable-sigchild')) { + $warnings['sigchild'] = array( + 'PHP was compiled with --enable-sigchild which can cause issues on some platforms.', + 'Recompile it without this flag if possible, see also:', + ' https://bugs.php.net/bug.php?id=22999' + ); + } + + if (false !== strpos($configure, '--with-curlwrappers')) { + $warnings['curlwrappers'] = array( + 'PHP was compiled with --with-curlwrappers which will cause issues with HTTP authentication and GitHub.', + 'Recompile it without this flag if possible' + ); + } + } + + // Stringify the message arrays + foreach ($errors as $key => $value) { + $errors[$key] = PHP_EOL.implode(PHP_EOL, $value); + } + + foreach ($warnings as $key => $value) { + $warnings[$key] = PHP_EOL.implode(PHP_EOL, $value); + } + + return !empty($errors) || !empty($warnings); +} + + +/** + * Outputs an array of issues + * + * @param array $issues + */ +function outputIssues($issues) +{ + foreach ($issues as $issue) { + out($issue, 'info'); + } + out(''); +} + +/** + * Outputs any warnings found + * + * @param array $warnings + */ +function showWarnings($warnings) +{ + if (!empty($warnings)) { + out('Some settings on your machine may cause stability issues with Composer.', 'error'); + out('If you encounter issues, try to change the following:', 'error'); + outputIssues($warnings); + } +} + +/** + * Outputs an end of process warning if tls has been bypassed + * + * @param bool $disableTls Bypass tls + */ +function showSecurityWarning($disableTls) +{ + if ($disableTls) { + out('You have instructed the Installer not to enforce SSL/TLS security on remote HTTPS requests.', 'info'); + out('This will leave all downloads during installation vulnerable to Man-In-The-Middle (MITM) attacks', 'info'); + } +} + +/** + * colorize output + */ +function out($text, $color = null, $newLine = true) +{ + $styles = array( + 'success' => "\033[0;32m%s\033[0m", + 'error' => "\033[31;31m%s\033[0m", + 'info' => "\033[33;33m%s\033[0m" + ); + + $format = '%s'; + + if (isset($styles[$color]) && USE_ANSI) { + $format = $styles[$color]; + } + + if ($newLine) { + $format .= PHP_EOL; + } + + printf($format, $text); +} + +/** + * Returns the system-dependent Composer home location, which may not exist + * + * @return string + */ +function getHomeDir() +{ + $home = getenv('COMPOSER_HOME'); + if ($home) { + return $home; + } + + $userDir = getUserDir(); + + if (defined('PHP_WINDOWS_VERSION_MAJOR')) { + return $userDir.'/Composer'; + } + + $dirs = array(); + + if (useXdg()) { + // XDG Base Directory Specifications + $xdgConfig = getenv('XDG_CONFIG_HOME'); + if (!$xdgConfig) { + $xdgConfig = $userDir . '/.config'; + } + + $dirs[] = $xdgConfig . '/composer'; + } + + $dirs[] = $userDir . '/.composer'; + + // select first dir which exists of: $XDG_CONFIG_HOME/composer or ~/.composer + foreach ($dirs as $dir) { + if (is_dir($dir)) { + return $dir; + } + } + + // if none exists, we default to first defined one (XDG one if system uses it, or ~/.composer otherwise) + return $dirs[0]; +} + +/** + * Returns the location of the user directory from the environment + * @throws RuntimeException If the environment value does not exists + * + * @return string + */ +function getUserDir() +{ + $userEnv = defined('PHP_WINDOWS_VERSION_MAJOR') ? 'APPDATA' : 'HOME'; + $userDir = getenv($userEnv); + + if (!$userDir) { + throw new RuntimeException('The '.$userEnv.' or COMPOSER_HOME environment variable must be set for composer to run correctly'); + } + + return rtrim(strtr($userDir, '\\', '/'), '/'); +} + +/** + * @return bool + */ +function useXdg() +{ + foreach (array_keys($_SERVER) as $key) { + if (strpos($key, 'XDG_') === 0) { + return true; + } + } + + if (is_dir('/etc/xdg')) { + return true; + } + + return false; +} + +function validateCaFile($contents) +{ + // assume the CA is valid if php is vulnerable to + // https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html + if ( + PHP_VERSION_ID <= 50327 + || (PHP_VERSION_ID >= 50400 && PHP_VERSION_ID < 50422) + || (PHP_VERSION_ID >= 50500 && PHP_VERSION_ID < 50506) + ) { + return !empty($contents); + } + + return (bool) openssl_x509_parse($contents); +} + +class Installer +{ + private $quiet; + private $disableTls; + private $cafile; + private $displayPath; + private $target; + private $tmpFile; + private $tmpCafile; + private $baseUrl; + private $algo; + private $errHandler; + private $httpClient; + private $pubKeys = array(); + private $installs = array(); + + /** + * Constructor - must not do anything that throws an exception + * + * @param bool $quiet Quiet mode + * @param bool $disableTls Bypass tls + * @param mixed $cafile Path to CA bundle, or false + */ + public function __construct($quiet, $disableTls, $caFile) + { + if (($this->quiet = $quiet)) { + ob_start(); + } + $this->disableTls = $disableTls; + $this->cafile = $caFile; + $this->errHandler = new ErrorHandler(); + } + + /** + * Runs the installer + * + * @param mixed $version Specific version to install, or false + * @param mixed $installDir Specific installation directory, or false + * @param string $filename Specific filename to save to, or composer.phar + * @param string $channel Specific version channel to use + * @throws Exception If anything other than a RuntimeException is caught + * + * @return bool If the installation succeeded + */ + public function run($version, $installDir, $filename, $channel) + { + try { + $this->initTargets($installDir, $filename); + $this->initTls(); + $this->httpClient = new HttpClient($this->disableTls, $this->cafile); + $result = $this->install($version, $channel); + + // in case --1 or --2 is passed, we leave the default channel for next self-update to stable + if (1 === preg_match('{^\d+$}D', $channel)) { + $channel = 'stable'; + } + + if ($result && $channel !== 'stable' && !$version && defined('PHP_BINARY')) { + $null = (defined('PHP_WINDOWS_VERSION_MAJOR') ? 'NUL' : '/dev/null'); + @exec(escapeshellarg(PHP_BINARY) .' '.escapeshellarg($this->target).' self-update --'.$channel.' --set-channel-only -q > '.$null.' 2> '.$null, $output); + } + } catch (Exception $e) { + $result = false; + } + + // Always clean up + $this->cleanUp($result); + + if (isset($e)) { + // Rethrow anything that is not a RuntimeException + if (!$e instanceof RuntimeException) { + throw $e; + } + out($e->getMessage(), 'error'); + } + return $result; + } + + /** + * Initialization methods to set the required filenames and composer url + * + * @param mixed $installDir Specific installation directory, or false + * @param string $filename Specific filename to save to, or composer.phar + * @throws RuntimeException If the installation directory is not writable + */ + protected function initTargets($installDir, $filename) + { + $this->displayPath = ($installDir ? rtrim($installDir, '/').'/' : '').$filename; + $installDir = $installDir ? realpath($installDir) : getcwd(); + + if (!is_writeable($installDir)) { + throw new RuntimeException('The installation directory "'.$installDir.'" is not writable'); + } + + $this->target = $installDir.DIRECTORY_SEPARATOR.$filename; + $this->tmpFile = $installDir.DIRECTORY_SEPARATOR.basename($this->target, '.phar').'-temp.phar'; + + $uriScheme = $this->disableTls ? 'http' : 'https'; + $this->baseUrl = $uriScheme.'://getcomposer.org'; + } + + /** + * A wrapper around methods to check tls and write public keys + * @throws RuntimeException If SHA384 is not supported + */ + protected function initTls() + { + if ($this->disableTls) { + return; + } + + if (!in_array('sha384', array_map('strtolower', openssl_get_md_methods()))) { + throw new RuntimeException('SHA384 is not supported by your openssl extension'); + } + + $this->algo = defined('OPENSSL_ALGO_SHA384') ? OPENSSL_ALGO_SHA384 : 'SHA384'; + $home = $this->getComposerHome(); + + $this->pubKeys = array( + 'dev' => $this->installKey(self::getPKDev(), $home, 'keys.dev.pub'), + 'tags' => $this->installKey(self::getPKTags(), $home, 'keys.tags.pub') + ); + + if (empty($this->cafile) && !HttpClient::getSystemCaRootBundlePath()) { + $this->cafile = $this->tmpCafile = $this->installKey(HttpClient::getPackagedCaFile(), $home, 'cacert-temp.pem'); + } + } + + /** + * Returns the Composer home directory, creating it if required + * @throws RuntimeException If the directory cannot be created + * + * @return string + */ + protected function getComposerHome() + { + $home = getHomeDir(); + + if (!is_dir($home)) { + $this->errHandler->start(); + + if (!mkdir($home, 0777, true)) { + throw new RuntimeException(sprintf( + 'Unable to create Composer home directory "%s": %s', + $home, + $this->errHandler->message + )); + } + $this->installs[] = $home; + $this->errHandler->stop(); + } + return $home; + } + + /** + * Writes public key data to disc + * + * @param string $data The public key(s) in pem format + * @param string $path The directory to write to + * @param string $filename The name of the file + * @throws RuntimeException If the file cannot be written + * + * @return string The path to the saved data + */ + protected function installKey($data, $path, $filename) + { + $this->errHandler->start(); + + $target = $path.DIRECTORY_SEPARATOR.$filename; + $installed = file_exists($target); + $write = file_put_contents($target, $data, LOCK_EX); + @chmod($target, 0644); + + $this->errHandler->stop(); + + if (!$write) { + throw new RuntimeException(sprintf('Unable to write %s to: %s', $filename, $path)); + } + + if (!$installed) { + $this->installs[] = $target; + } + + return $target; + } + + /** + * The main install function + * + * @param mixed $version Specific version to install, or false + * @param string $channel Version channel to use + * + * @return bool If the installation succeeded + */ + protected function install($version, $channel) + { + $retries = 3; + $result = false; + $infoMsg = 'Downloading...'; + $infoType = 'info'; + + while ($retries--) { + if (!$this->quiet) { + out($infoMsg, $infoType); + $infoMsg = 'Retrying...'; + $infoType = 'error'; + } + + if (!$this->getVersion($channel, $version, $url, $error)) { + out($error, 'error'); + continue; + } + + if (!$this->downloadToTmp($url, $signature, $error)) { + out($error, 'error'); + continue; + } + + if (!$this->verifyAndSave($version, $signature, $error)) { + out($error, 'error'); + continue; + } + + $result = true; + break; + } + + if (!$this->quiet) { + if ($result) { + out(PHP_EOL."Composer (version {$version}) successfully installed to: {$this->target}", 'success'); + out("Use it: php {$this->displayPath}", 'info'); + out(''); + } else { + out('The download failed repeatedly, aborting.', 'error'); + } + } + return $result; + } + + /** + * Sets the version url, downloading version data if required + * + * @param string $channel Version channel to use + * @param false|string $version Version to install, or set by method + * @param null|string $url The versioned url, set by method + * @param null|string $error Set by method on failure + * + * @return bool If the operation succeeded + */ + protected function getVersion($channel, &$version, &$url, &$error) + { + $error = ''; + + if ($version) { + if (empty($url)) { + $url = $this->baseUrl."/download/{$version}/composer.phar"; + } + return true; + } + + $this->errHandler->start(); + + if ($this->downloadVersionData($data, $error)) { + $this->parseVersionData($data, $channel, $version, $url); + } + + $this->errHandler->stop(); + return empty($error); + } + + /** + * Downloads and json-decodes version data + * + * @param null|array $data Downloaded version data, set by method + * @param null|string $error Set by method on failure + * + * @return bool If the operation succeeded + */ + protected function downloadVersionData(&$data, &$error) + { + $url = $this->baseUrl.'/versions'; + $errFmt = 'The "%s" file could not be %s: %s'; + + if (!$json = $this->httpClient->get($url)) { + $error = sprintf($errFmt, $url, 'downloaded', $this->errHandler->message); + return false; + } + + if (!$data = json_decode($json, true)) { + $error = sprintf($errFmt, $url, 'json-decoded', $this->getJsonError()); + return false; + } + return true; + } + + /** + * A wrapper around the methods needed to download and save the phar + * + * @param string $url The versioned download url + * @param null|string $signature Set by method on successful download + * @param null|string $error Set by method on failure + * + * @return bool If the operation succeeded + */ + protected function downloadToTmp($url, &$signature, &$error) + { + $error = ''; + $errFmt = 'The "%s" file could not be downloaded: %s'; + $sigUrl = $url.'.sig'; + $this->errHandler->start(); + + if (!$fh = fopen($this->tmpFile, 'w')) { + $error = sprintf('Could not create file "%s": %s', $this->tmpFile, $this->errHandler->message); + + } elseif (!$this->getSignature($sigUrl, $signature)) { + $error = sprintf($errFmt, $sigUrl, $this->errHandler->message); + + } elseif (!fwrite($fh, $this->httpClient->get($url))) { + $error = sprintf($errFmt, $url, $this->errHandler->message); + } + + if (is_resource($fh)) { + fclose($fh); + } + $this->errHandler->stop(); + return empty($error); + } + + /** + * Verifies the downloaded file and saves it to the target location + * + * @param string $version The composer version downloaded + * @param string $signature The digital signature to check + * @param null|string $error Set by method on failure + * + * @return bool If the operation succeeded + */ + protected function verifyAndSave($version, $signature, &$error) + { + $error = ''; + + if (!$this->validatePhar($this->tmpFile, $pharError)) { + $error = 'The download is corrupt: '.$pharError; + + } elseif (!$this->verifySignature($version, $signature, $this->tmpFile)) { + $error = 'Signature mismatch, could not verify the phar file integrity'; + + } else { + $this->errHandler->start(); + + if (!rename($this->tmpFile, $this->target)) { + $error = sprintf('Could not write to file "%s": %s', $this->target, $this->errHandler->message); + } + chmod($this->target, 0755); + $this->errHandler->stop(); + } + + return empty($error); + } + + /** + * Parses an array of version data to match the required channel + * + * @param array $data Downloaded version data + * @param mixed $channel Version channel to use + * @param false|string $version Set by method + * @param mixed $url The versioned url, set by method + */ + protected function parseVersionData(array $data, $channel, &$version, &$url) + { + foreach ($data[$channel] as $candidate) { + if ($candidate['min-php'] <= PHP_VERSION_ID) { + $version = $candidate['version']; + $url = $this->baseUrl.$candidate['path']; + break; + } + } + + if (!$version) { + $error = sprintf( + 'None of the %d %s version(s) of Composer matches your PHP version (%s / ID: %d)', + count($data[$channel]), + $channel, + PHP_VERSION, + PHP_VERSION_ID + ); + throw new RuntimeException($error); + } + } + + /** + * Downloads the digital signature of required phar file + * + * @param string $url The signature url + * @param null|string $signature Set by method on success + * + * @return bool If the download succeeded + */ + protected function getSignature($url, &$signature) + { + if (!$result = $this->disableTls) { + $signature = $this->httpClient->get($url); + + if ($signature) { + $signature = json_decode($signature, true); + $signature = base64_decode($signature['sha384']); + $result = true; + } + } + + return $result; + } + + /** + * Verifies the signature of the downloaded phar + * + * @param string $version The composer versione + * @param string $signature The downloaded digital signature + * @param string $file The temp phar file + * + * @return bool If the operation succeeded + */ + protected function verifySignature($version, $signature, $file) + { + if (!$result = $this->disableTls) { + $path = preg_match('{^[0-9a-f]{40}$}', $version) ? $this->pubKeys['dev'] : $this->pubKeys['tags']; + $pubkeyid = openssl_pkey_get_public('file://'.$path); + + $result = 1 === openssl_verify( + file_get_contents($file), + $signature, + $pubkeyid, + $this->algo + ); + + // PHP 8 automatically frees the key instance and deprecates the function + if (PHP_VERSION_ID < 80000) { + openssl_free_key($pubkeyid); + } + } + + return $result; + } + + /** + * Validates the downloaded phar file + * + * @param string $pharFile The temp phar file + * @param null|string $error Set by method on failure + * + * @return bool If the operation succeeded + */ + protected function validatePhar($pharFile, &$error) + { + if (ini_get('phar.readonly')) { + return true; + } + + try { + // Test the phar validity + $phar = new Phar($pharFile); + // Free the variable to unlock the file + unset($phar); + $result = true; + + } catch (Exception $e) { + if (!$e instanceof UnexpectedValueException && !$e instanceof PharException) { + throw $e; + } + $error = $e->getMessage(); + $result = false; + } + return $result; + } + + /** + * Returns a string representation of the last json error + * + * @return string The error string or code + */ + protected function getJsonError() + { + if (function_exists('json_last_error_msg')) { + return json_last_error_msg(); + } else { + return 'json_last_error = '.json_last_error(); + } + } + + /** + * Cleans up resources at the end of the installation + * + * @param bool $result If the installation succeeded + */ + protected function cleanUp($result) + { + if (!$result) { + // Output buffered errors + if ($this->quiet) { + $this->outputErrors(); + } + // Clean up stuff we created + $this->uninstall(); + } elseif ($this->tmpCafile) { + @unlink($this->tmpCafile); + } + } + + /** + * Outputs unique errors when in quiet mode + * + */ + protected function outputErrors() + { + $errors = explode(PHP_EOL, ob_get_clean()); + $shown = array(); + + foreach ($errors as $error) { + if ($error && !in_array($error, $shown)) { + out($error, 'error'); + $shown[] = $error; + } + } + } + + /** + * Uninstalls newly-created files and directories on failure + * + */ + protected function uninstall() + { + foreach (array_reverse($this->installs) as $target) { + if (is_file($target)) { + @unlink($target); + } elseif (is_dir($target)) { + @rmdir($target); + } + } + + if ($this->tmpFile !== null && file_exists($this->tmpFile)) { + @unlink($this->tmpFile); + } + } + + public static function getPKDev() + { + return <<message) { + $this->message .= PHP_EOL; + } + $this->message .= preg_replace('{^file_get_contents\(.*?\): }', '', $msg); + } + + /** + * Starts error-handling if not already active + * + * Any message is cleared + */ + public function start() + { + if (!$this->active) { + set_error_handler(array($this, 'handleError')); + $this->active = true; + } + $this->message = ''; + } + + /** + * Stops error-handling if active + * + * Any message is preserved until the next call to start() + */ + public function stop() + { + if ($this->active) { + restore_error_handler(); + $this->active = false; + } + } +} + +class NoProxyPattern +{ + private $composerInNoProxy = false; + private $rulePorts = array(); + + public function __construct($pattern) + { + $rules = preg_split('{[\s,]+}', $pattern, null, PREG_SPLIT_NO_EMPTY); + + if ($matches = preg_grep('{getcomposer\.org(?::\d+)?}i', $rules)) { + $this->composerInNoProxy = true; + + foreach ($matches as $match) { + if (strpos($match, ':') !== false) { + list(, $port) = explode(':', $match); + $this->rulePorts[] = (int) $port; + } + } + } + } + + /** + * Returns true if NO_PROXY contains getcomposer.org + * + * @param string $url http(s)://getcomposer.org + * + * @return bool + */ + public function test($url) + { + if (!$this->composerInNoProxy) { + return false; + } + + if (empty($this->rulePorts)) { + return true; + } + + if (strpos($url, 'http://') === 0) { + $port = 80; + } else { + $port = 443; + } + + return in_array($port, $this->rulePorts); + } +} + +class HttpClient { + + /** @var null|string */ + private static $caPath; + + private $options = array('http' => array()); + private $disableTls = false; + + public function __construct($disableTls = false, $cafile = false) + { + $this->disableTls = $disableTls; + if ($this->disableTls === false) { + if (!empty($cafile) && !is_dir($cafile)) { + if (!is_readable($cafile) || !validateCaFile(file_get_contents($cafile))) { + throw new RuntimeException('The configured cafile (' .$cafile. ') was not valid or could not be read.'); + } + } + $options = $this->getTlsStreamContextDefaults($cafile); + $this->options = array_replace_recursive($this->options, $options); + } + } + + public function get($url) + { + $context = $this->getStreamContext($url); + $result = file_get_contents($url, false, $context); + + if ($result && extension_loaded('zlib')) { + $decode = false; + foreach ($http_response_header as $header) { + if (preg_match('{^content-encoding: *gzip *$}i', $header)) { + $decode = true; + continue; + } elseif (preg_match('{^HTTP/}i', $header)) { + $decode = false; + } + } + + if ($decode) { + if (version_compare(PHP_VERSION, '5.4.0', '>=')) { + $result = zlib_decode($result); + } else { + // work around issue with gzuncompress & co that do not work with all gzip checksums + $result = file_get_contents('compress.zlib://data:application/octet-stream;base64,'.base64_encode($result)); + } + + if (!$result) { + throw new RuntimeException('Failed to decode zlib stream'); + } + } + } + + return $result; + } + + protected function getStreamContext($url) + { + if ($this->disableTls === false) { + if (PHP_VERSION_ID < 50600) { + $this->options['ssl']['SNI_server_name'] = parse_url($url, PHP_URL_HOST); + } + } + // Keeping the above mostly isolated from the code copied from Composer. + return $this->getMergedStreamContext($url); + } + + protected function getTlsStreamContextDefaults($cafile) + { + $ciphers = implode(':', array( + 'ECDHE-RSA-AES128-GCM-SHA256', + 'ECDHE-ECDSA-AES128-GCM-SHA256', + 'ECDHE-RSA-AES256-GCM-SHA384', + 'ECDHE-ECDSA-AES256-GCM-SHA384', + 'DHE-RSA-AES128-GCM-SHA256', + 'DHE-DSS-AES128-GCM-SHA256', + 'kEDH+AESGCM', + 'ECDHE-RSA-AES128-SHA256', + 'ECDHE-ECDSA-AES128-SHA256', + 'ECDHE-RSA-AES128-SHA', + 'ECDHE-ECDSA-AES128-SHA', + 'ECDHE-RSA-AES256-SHA384', + 'ECDHE-ECDSA-AES256-SHA384', + 'ECDHE-RSA-AES256-SHA', + 'ECDHE-ECDSA-AES256-SHA', + 'DHE-RSA-AES128-SHA256', + 'DHE-RSA-AES128-SHA', + 'DHE-DSS-AES128-SHA256', + 'DHE-RSA-AES256-SHA256', + 'DHE-DSS-AES256-SHA', + 'DHE-RSA-AES256-SHA', + 'AES128-GCM-SHA256', + 'AES256-GCM-SHA384', + 'AES128-SHA256', + 'AES256-SHA256', + 'AES128-SHA', + 'AES256-SHA', + 'AES', + 'CAMELLIA', + 'DES-CBC3-SHA', + '!aNULL', + '!eNULL', + '!EXPORT', + '!DES', + '!RC4', + '!MD5', + '!PSK', + '!aECDH', + '!EDH-DSS-DES-CBC3-SHA', + '!EDH-RSA-DES-CBC3-SHA', + '!KRB5-DES-CBC3-SHA', + )); + + /** + * CN_match and SNI_server_name are only known once a URL is passed. + * They will be set in the getOptionsForUrl() method which receives a URL. + * + * cafile or capath can be overridden by passing in those options to constructor. + */ + $options = array( + 'ssl' => array( + 'ciphers' => $ciphers, + 'verify_peer' => true, + 'verify_depth' => 7, + 'SNI_enabled' => true, + ) + ); + + /** + * Attempt to find a local cafile or throw an exception. + * The user may go download one if this occurs. + */ + if (!$cafile) { + $cafile = self::getSystemCaRootBundlePath(); + } + if (is_dir($cafile)) { + $options['ssl']['capath'] = $cafile; + } elseif ($cafile) { + $options['ssl']['cafile'] = $cafile; + } else { + throw new RuntimeException('A valid cafile could not be located automatically.'); + } + + /** + * Disable TLS compression to prevent CRIME attacks where supported. + */ + if (version_compare(PHP_VERSION, '5.4.13') >= 0) { + $options['ssl']['disable_compression'] = true; + } + + return $options; + } + + /** + * function copied from Composer\Util\StreamContextFactory::initOptions + * + * Any changes should be applied there as well, or backported here. + * + * @param string $url URL the context is to be used for + * @return resource Default context + * @throws \RuntimeException if https proxy required and OpenSSL uninstalled + */ + protected function getMergedStreamContext($url) + { + $options = $this->options; + + // Handle HTTP_PROXY/http_proxy on CLI only for security reasons + if ((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && (!empty($_SERVER['HTTP_PROXY']) || !empty($_SERVER['http_proxy']))) { + $proxy = parse_url(!empty($_SERVER['http_proxy']) ? $_SERVER['http_proxy'] : $_SERVER['HTTP_PROXY']); + } + + // Prefer CGI_HTTP_PROXY if available + if (!empty($_SERVER['CGI_HTTP_PROXY'])) { + $proxy = parse_url($_SERVER['CGI_HTTP_PROXY']); + } + + // Override with HTTPS proxy if present and URL is https + if (preg_match('{^https://}i', $url) && (!empty($_SERVER['HTTPS_PROXY']) || !empty($_SERVER['https_proxy']))) { + $proxy = parse_url(!empty($_SERVER['https_proxy']) ? $_SERVER['https_proxy'] : $_SERVER['HTTPS_PROXY']); + } + + // Remove proxy if URL matches no_proxy directive + if (!empty($_SERVER['NO_PROXY']) || !empty($_SERVER['no_proxy']) && parse_url($url, PHP_URL_HOST)) { + $pattern = new NoProxyPattern(!empty($_SERVER['no_proxy']) ? $_SERVER['no_proxy'] : $_SERVER['NO_PROXY']); + if ($pattern->test($url)) { + unset($proxy); + } + } + + if (!empty($proxy)) { + $proxyURL = isset($proxy['scheme']) ? $proxy['scheme'] . '://' : ''; + $proxyURL .= isset($proxy['host']) ? $proxy['host'] : ''; + + if (isset($proxy['port'])) { + $proxyURL .= ":" . $proxy['port']; + } elseif (strpos($proxyURL, 'http://') === 0) { + $proxyURL .= ":80"; + } elseif (strpos($proxyURL, 'https://') === 0) { + $proxyURL .= ":443"; + } + + // check for a secure proxy + if (strpos($proxyURL, 'https://') === 0) { + if (!extension_loaded('openssl')) { + throw new RuntimeException('You must enable the openssl extension to use a secure proxy.'); + } + if (strpos($url, 'https://') === 0) { + throw new RuntimeException('PHP does not support https requests through a secure proxy.'); + } + } + + // http(s):// is not supported in proxy + $proxyURL = str_replace(array('http://', 'https://'), array('tcp://', 'ssl://'), $proxyURL); + + $options['http'] = array( + 'proxy' => $proxyURL, + ); + + // add request_fulluri for http requests + if ('http' === parse_url($url, PHP_URL_SCHEME)) { + $options['http']['request_fulluri'] = true; + } + + // handle proxy auth if present + if (isset($proxy['user'])) { + $auth = rawurldecode($proxy['user']); + if (isset($proxy['pass'])) { + $auth .= ':' . rawurldecode($proxy['pass']); + } + $auth = base64_encode($auth); + + $options['http']['header'] = "Proxy-Authorization: Basic {$auth}\r\n"; + } + } + + if (isset($options['http']['header'])) { + $options['http']['header'] .= "Connection: close\r\n"; + } else { + $options['http']['header'] = "Connection: close\r\n"; + } + if (extension_loaded('zlib')) { + $options['http']['header'] .= "Accept-Encoding: gzip\r\n"; + } + $options['http']['header'] .= "User-Agent: ".COMPOSER_INSTALLER."\r\n"; + $options['http']['protocol_version'] = 1.1; + $options['http']['timeout'] = 600; + + return stream_context_create($options); + } + + /** + * This method was adapted from Sslurp. + * https://github.com/EvanDotPro/Sslurp + * + * (c) Evan Coury + * + * For the full copyright and license information, please see below: + * + * Copyright (c) 2013, Evan Coury + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * * Redistributions of source code must retain the above copyright notice, + * this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright notice, + * this list of conditions and the following disclaimer in the documentation + * and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR + * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + public static function getSystemCaRootBundlePath() + { + if (self::$caPath !== null) { + return self::$caPath; + } + + // If SSL_CERT_FILE env variable points to a valid certificate/bundle, use that. + // This mimics how OpenSSL uses the SSL_CERT_FILE env variable. + $envCertFile = getenv('SSL_CERT_FILE'); + if ($envCertFile && is_readable($envCertFile) && validateCaFile(file_get_contents($envCertFile))) { + return self::$caPath = $envCertFile; + } + + // If SSL_CERT_DIR env variable points to a valid certificate/bundle, use that. + // This mimics how OpenSSL uses the SSL_CERT_FILE env variable. + $envCertDir = getenv('SSL_CERT_DIR'); + if ($envCertDir && is_dir($envCertDir) && is_readable($envCertDir)) { + return self::$caPath = $envCertDir; + } + + $configured = ini_get('openssl.cafile'); + if ($configured && strlen($configured) > 0 && is_readable($configured) && validateCaFile(file_get_contents($configured))) { + return self::$caPath = $configured; + } + + $configured = ini_get('openssl.capath'); + if ($configured && is_dir($configured) && is_readable($configured)) { + return self::$caPath = $configured; + } + + $caBundlePaths = array( + '/etc/pki/tls/certs/ca-bundle.crt', // Fedora, RHEL, CentOS (ca-certificates package) + '/etc/ssl/certs/ca-certificates.crt', // Debian, Ubuntu, Gentoo, Arch Linux (ca-certificates package) + '/etc/ssl/ca-bundle.pem', // SUSE, openSUSE (ca-certificates package) + '/usr/local/share/certs/ca-root-nss.crt', // FreeBSD (ca_root_nss_package) + '/usr/ssl/certs/ca-bundle.crt', // Cygwin + '/opt/local/share/curl/curl-ca-bundle.crt', // OS X macports, curl-ca-bundle package + '/usr/local/share/curl/curl-ca-bundle.crt', // Default cURL CA bunde path (without --with-ca-bundle option) + '/usr/share/ssl/certs/ca-bundle.crt', // Really old RedHat? + '/etc/ssl/cert.pem', // OpenBSD + '/usr/local/etc/ssl/cert.pem', // FreeBSD 10.x + '/usr/local/etc/openssl/cert.pem', // OS X homebrew, openssl package + '/usr/local/etc/openssl@1.1/cert.pem', // OS X homebrew, openssl@1.1 package + '/opt/homebrew/etc/openssl@3/cert.pem', // macOS silicon homebrew, openssl@3 package + '/opt/homebrew/etc/openssl@1.1/cert.pem', // macOS silicon homebrew, openssl@1.1 package + ); + + foreach ($caBundlePaths as $caBundle) { + if (@is_readable($caBundle) && validateCaFile(file_get_contents($caBundle))) { + return self::$caPath = $caBundle; + } + } + + foreach ($caBundlePaths as $caBundle) { + $caBundle = dirname($caBundle); + if (is_dir($caBundle) && glob($caBundle.'/*')) { + return self::$caPath = $caBundle; + } + } + + return self::$caPath = false; + } + + public static function getPackagedCaFile() + { + return << 'error', + 'text' => esc_html__('Invalid email format', 'woodmart') + )); + } + wp_die(); +} + +/** + * Send Verification Code + * Generates a random code, encrypts it, stores it in a cookie, and sends it via email. + */ +add_action('wp_ajax_send_code', 'send_code'); +add_action('wp_ajax_nopriv_send_code', 'send_code'); + +function send_code() { + $email = $_POST['email']; + + // Generate a random 4-digit code + $string = rand(1234, 9999); + $ciphering = "AES-128-CTR"; + $options = 0; + $iv = '1234567891011121'; + $encryption = openssl_encrypt($string, $ciphering, SECRET, $options, $iv); + + // Store encrypted code in a cookie for 5 minutes + setcookie('login_code', $encryption, time() + 60 * 5, '/'); + + // Prepare email content based on language + if (function_exists('pll_current_language') && pll_current_language() === 'ru') { + $subject = "Проверочный код Cosmopet -" . $string; + $message = "Привет, это Cosmopet.\n +Держите проверочный код!\n +" . $string; + } else { + $subject = "Cosmopet Verification Code -" . $string; + $message = "Hello, this is CosmoPet.\n +Here's your verification code!\n +" . $string; + } + + // Remove email filters for consistent sending + remove_all_filters('wp_mail_from'); + remove_all_filters('wp_mail_from_name'); + $headers = array( + 'From: Cosmopet ', + 'content-type: text/html; charset=utf-8', + ); + + // Send email + wp_mail($email, $subject, $message, $headers); + + wp_die(); +} + +/** + * Check Verification Code + * Validates the user-entered code, logs in or registers the user. + */ +add_action('wp_ajax_check_code', 'check_code'); +add_action('wp_ajax_nopriv_check_code', 'check_code'); + +function check_code() { + header("Content-Type: application/json"); + + $code = $_POST['code']; + $email = $_POST['email']; + + // Generate a random 12-character password + $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@#!()'; + $pass = array(); + $alphaLength = strlen($alphabet) - 1; + for ($i = 0; $i < 12; $i++) { + $n = rand(0, $alphaLength); + $pass[] = $alphabet[$n]; + } + $pass = implode($pass); + + // Check if verification code cookie exists + if (isset($_COOKIE['login_code'])) { + $string = $_COOKIE['login_code']; + $ciphering = "AES-128-CTR"; + $options = 0; + $iv = '1234567891011121'; + $decryption = openssl_decrypt($string, $ciphering, SECRET, $options, $iv); + + if ($decryption === $code) { + if (email_exists($email)) { + // Log in existing user + $user_id = get_user_by('login', $email)->ID; + if (empty($user_id)) { + $user_id = get_user_by('email', $email)->ID; + } + wp_set_password($pass, $user_id); + wp_signon( + array( + 'user_login' => $email, + 'user_password' => $pass, + 'remember' => 'on', + ) + ); + + echo json_encode(array( + 'status' => 'success_auth' + )); + if (function_exists('update_field')) { + update_field('activated', true, 'user_' . $user_id); // Requires ACF + } + exit(); + } else { + // Register new user + $user_id = wp_create_user($email, $pass, $email); + wp_update_user([ + 'ID' => $user_id, + 'user_email' => $email + ]); + + wp_set_auth_cookie($user_id, true); + echo json_encode(array( + 'status' => 'success_reg' + )); + if (function_exists('update_field')) { + update_field('activated', true, 'user_' . $user_id); // Requires ACF + } + exit(); + } + } else { + echo json_encode(array( + 'status' => 'error', + 'text' => esc_html__('Invalid code', 'woodmart') + )); + exit(); + } + } else { + echo json_encode(array( + 'status' => 'error', + 'text' => esc_html__('The code hasexpired', 'woodmart') + )); + exit(); + } + wp_die(); +} + +/** + * Logout Redirect + * Redirects to the homepage after user logout. + */ +add_action('wp_logout', 'logout_redirect'); + +function logout_redirect() { + wp_redirect('/'); + exit(); +} + add_filter( 'woocommerce_price_trim_zeros', '__return_true' ); function add_comment_like() { @@ -979,4 +1149,5 @@ function change_wbw_filter_button_text($text) { add_filter('wbw_filter_reset_button_text', 'change_wbw_reset_button_text'); function change_wbw_reset_button_text($text) { return 'Сбросить'; + } \ No newline at end of file diff --git a/wp-content/themes/cosmopet/home.php b/wp-content/themes/cosmopet/home.php index 6b30a2d..1587666 100644 --- a/wp-content/themes/cosmopet/home.php +++ b/wp-content/themes/cosmopet/home.php @@ -1,4 +1,5 @@ 0){ + $('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count']) + } + else{ + $('.mini-profile__button--counter').addClass('disabled').html(response['cart_count']) + } + initCounters(); + let modal = document.querySelector('.modal'), + aside = document.querySelector('.modal__aside'), + device = window.screen.width; + + if(!$.cookie('gp-cosmopet-cartadd')){ + modal.classList.add('active'); + $('.modal__basket').addClass('active'); + let thisContentElement = document.querySelector('.modal__basket'); + + let width = thisContentElement.clientWidth; + setTimeout(() => { + if (device <= 720) { + aside.style.width = `${device}px`; + thisContentElement.style.opacity = 1; + thisContentElement.style.filter = 'blur(0px)'; + }else{ + aside.style.width = `${width}px`; + thisContentElement.style.opacity = 1; + thisContentElement.style.filter = 'blur(0px)'; + } + }, 10); + + $.cookie('gp-cosmopet-cartadd', 'true', { expires: 2 }); + } + modalClose('.modal__close'); + }, + }); + + return false; + }); + + $(document).on('submit', '.modal__form-sub', function (e) { + e.preventDefault(); + var email = $(this).find('input[name="email"]').val() + var data = $(this).serialize() + $.ajax({ + type: 'post', + url: woocommerce_params.ajax_url, + data: data, + beforeSend: function (response) { + // $thisbutton.removeClass('added').addClass('loading'); + }, + complete: function (response) { + // $thisbutton.addClass('added').removeClass('loading'); + }, + success: function (response) { + $('.modal__to-know').removeClass('active') + $('#sub-result-email').html(email) + $('.modal__to-know-submit').addClass('active').css('filter', 'blur(0px)') + }, + }); + }); + + $(document).on('submit', '.form--contact', function (e) { + e.preventDefault(); + var form = this; + var data = $(this).serialize() + $.ajax({ + type: 'post', + url: woocommerce_params.ajax_url, + data: data, + beforeSend: function (response) { + // $thisbutton.removeClass('added').addClass('loading'); + }, + complete: function (response) { + // $thisbutton.addClass('added').removeClass('loading'); + }, + success: function (response) { + $(form).addClass('submited') + }, + }); + }); + + $('body').on('click', '.modal-basket__item .counter__button', function(){ + var input = $(this).closest('.counter').find('.counter__input').val() + var price = $(this).closest('.modal-basket-item__control').find('.modal-basket-item__price') + var productID = $(this).data('id') + var pr = $(this).closest('.modal-basket__item').find('.modal-basket__item-before').data('pr') + $(price).html(Number(input) * $(price).data('basecost')) + $(this).closest('.modal-basket__item').data('cost', Number(price.html())) + $('#cart_total').html(wc_cart_summary_upd()) + var title = $(this).closest('.cart_item').find('.modal-basket-item__title').html() + if ($(this).hasClass('minus')){ + $(this).attr('data-value', Number( $(this).attr('data-value')) - 1) + + if(Number($(this).attr('data-value')) == 0){ + $(this).closest('.modal-basket__item').find('.modal-basket__item-before').click() + } + dataLayer.push({ + "ecommerce": { + "currencyCode": "RUB", + "remove": { + "products": [ + { + "id": pr, + "name": title, + "quantity": 1, + } + ] + } + } + }); + } + else{ + var min = $(this).closest('.counter--small').find('.minus') + $(min).attr('data-value', Number($(min).attr('data-value')) + 1) + dataLayer.push({ + "ecommerce": { + "currencyCode": "RUB", + "add": { + "products": [ + { + "id": pr, + "name": title, + "quantity": 1, + } + ] + } + } + }); + } + // if ($(this).hasClass('minus') && Number(input) == 1){ + // $(this).closest('.modal-basket__item').find('.modal-basket__item-before').click() + // } + var data = { + action: 'get_cartprice', + quantity: input, + product: productID + }; + $.ajax({ + type: 'post', + url: '/wp-admin/admin-ajax.php', + data: data, + beforeSend: function (response) { + // $thisbutton.removeClass('added').addClass('loading'); + }, + complete: function (response) { + // $thisbutton.addClass('added').removeClass('loading'); + }, + success: function (response) { + if (response.error) { + + } else { +// $('#cart_total').html(response) + initCounters() + if(response['cart_count'] > 0){ + $('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count']) + } + else{ + $('.mini-profile__button--counter').addClass('disabled').html(response['cart_count']) + } + } + }, + }); + }) + + $('body').on('click', '.product-item-overlay__field .counter__button', function(){ + var input = $(this).closest('.counter').find('.counter__input').val() + var price = $(this).closest('.product-item__form').find('.product-item-overlay__price') + + + $(price).html(Number(input) * $(price).data('basecost')) + }) + + $('body').on('click', '.modal-basket__item-before', function(){ + var key = $(this).data('id') + var p_ID = $(this).data('pr'); + var var_ID = $(this).data('var'); + var quantity = $(this).closest('.modal-basket__item').find('.counter__input').val() + var layout = ` + + + + ` + if(localeValue == 'en_US'){ + var layout = ` + + + + ` + } + + var old_html = $(this).closest('.modal-basket__item').html() + $(this).closest('.modal-basket__item').addClass('.modal-basket__item--return').html(layout) + var title = $(this).closest('.cart_item').find('.modal-basket-item__title').html() + + + var timerVal = 5; + + var interval = setInterval(function(){ + timerVal -= 1; + if (timerVal > 0){ + $(`#${key}_timer`).html(timerVal) + } + else{ + + dataLayer.push({ + "ecommerce": { + "currencyCode": "RUB", + "remove": { + "products": [ + { + "id": p_ID, + "name": title, + "quantity": quantity, + } + ] + } + } + }); + var input = 0; + var productID = key; + + var data = { + action: 'get_cartprice', + quantity: input, + product: productID + }; + $.ajax({ + type: 'post', + url: '/wp-admin/admin-ajax.php', + data: data, + beforeSend: function (response) { + // $thisbutton.removeClass('added').addClass('loading'); + }, + complete: function (response) { + // $thisbutton.addClass('added').removeClass('loading'); + }, + success: function (response) { + + if(response['cart_count'] > 0){ + $('.mini-profile__button--counter').removeClass('disabled').html(response['cart_count']) + } + else{ + $('.mini-profile__button--counter').addClass('disabled').html(response['cart_count']) + } + }, + }); + $(`#${key}_timer`).closest('.modal-basket__item').remove() + if (Number(wc_cart_summary_upd()) > 0){ + $('#cart_total').html(wc_cart_summary_upd()) + } + else{ + var tmpl = ` + + ` + + if(localeValue == 'en_US'){ + var tmpl = ` + + ` + } + $('.modal__basket').html(tmpl) + } + clearInterval(interval); + } + }, 1000) + + + + + $(`#${key}_return`).one('click', function(){ + $(this).closest('.modal-basket__item').removeClass('.modal-basket__item--return').html(old_html) + clearInterval(interval); + }) + }) + + $('body').on('click', '.state__button', function(){ + var s = $(this).closest('.select') + var id = $(this).data('id') + var bc = $(this).data('bc') + + var form = $(this).closest('.product-item__form') + + $(form).find('input[name="variation_id"]').val(id) + $(form).find('.counter__input').data('maxcount', $(this).data('stock')).attr('data-maxcount', $(this).data('stock')) + if (Number($(form).find('.counter__input').val()) > Number($(form).find('.counter__input').data('maxcount'))){ + $(form).find('.counter__input').val($(form).find('.counter__input').data('maxcount')) + } + var input = $(form).find('.counter__input').val() + $(form).find('.product-item-overlay__price').data('basecost', bc).html(Number(bc) * Number(input)) + }) + + $('body').on('click', '.btn-load-ajax', function(){ + var page = Number($(this).data('page')) + 1 + var maxpage = Number($(this).data('maxpage')) + var data = { + ajax_load: 'ajax', + }; + var btn = this + var baseUrl = jQuery(location).attr('origin') + jQuery(location).attr('pathname') + baseUrl += 'page/' + page + '/' + var searchUrl = baseUrl + if (jQuery(location).attr('search')){ + searchUrl += jQuery(location).attr('search') + '&ajax_search=ajax' + } + else{ + searchUrl += '?ajax_search=ajax' + } + $.ajax({ + type: 'get', + url: searchUrl, + data: data, + beforeSend: function (response) { + $(btn).attr('disabled', true) + $(btn).attr('data-page', page) + $(btn).data('page', page) + }, + complete: function (response) { + if (page >= maxpage){ + $(btn).remove() + } + else{ + $(btn).attr('disabled', false) + } + }, + success: function (response) { + $('.products').append(response) + initCounters() + initOverlay() + initSelect() + modalOpen('.open-to-know', '.modal__to-know'); + + /// РЕШЕНИЕ ДЛЯ СТЕНДА AJAX ДЛЯ ПОДГРУЗКИ AJAX + document.querySelectorAll('img').forEach(img => { + var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/') + checkImage(str, function(){ img.attributes['src'].value = str }); + if (img.attributes['srcset']){ + img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '') + } + }) + // + }, + }); + }) + + // $('body').on('click', '.singular-w-btn', function(){ + // var wg = $(this).data('wg') + // var id = $(this).data('id') + // $('#variation_id').val(id) + // $('.detail__block-price').hide() + // $('.detail__block-price[data-wg="' + wg + '"]').show() + // if ($(this).data('available')){ + // $('.detail-block-form__item--tn').hide() + // $('.detail-block-form__item--add').show() + // } + // else{ + // $('.detail-block-form__item--tn').show() + // $('.detail-block-form__item--add').hide() + // } + + // }) + // асинхронный запрос при отправке формы + $( '#ajaxform' ).on( 'submit',function( event ) { + event.preventDefault(); + + const form = $(this); + + $.ajax( { + type : 'POST', + url : woocommerce_params.ajax_url, + data : form.serialize(), + beforeSend : function( xhr ) { + $('.products').addClass('loading') + form.find('.button-submit').addClass('loading').attr('disabled', true) + }, + success : function( data ) { + $( '.products' ).html( data.products ); + $('.product__tag').html(data.tags); + $( '.btn-load-ajax' ).remove() + form.find('.button-submit').removeClass('loading').attr('disabled', false) + form.find('.modal__close').click() + $('.products').removeClass('loading') + if (data.err){ + $('.product__error-button').show() + } + else{ + $('.product__error-button').hide() + } + + initCounters() + initOverlay() + initSelect() + modalOpen('.open-to-know', '.modal__to-know'); + + document.querySelectorAll('img').forEach(img => { + var str = img.attributes['src'].value.replace('https://cosmopet.good-production.xyz/', 'https://cosmopet.shop/') + checkImage(str, function(){ img.attributes['src'].value = str }); + if (img.attributes['srcset']){ + img.attributes['srcset'].value = img.attributes['srcset'].value.replace('cosmopet.good-production.xyz', '') + } + }) + } + + } ); + + } ); + + + $('body').on('click', '.product-tag__item', function(){ + $('#tax_' + $(this).data('tag')).find('input').prop('checked', false) + $('#tax_' + $(this).data('tag')).removeClass('active'); + $(this).remove() + $('#ajaxform').submit() + }) + + + // Login + $('.login_popup').on('click', function(e){ + e.preventDefault(); + $('.login_modal').addClass('active'); + }); + $('.login_close').on('click', function(){ + $('.login_modal').removeClass('active'); + }); + $('.login_back').on('click', function(){ + if($(this).is('.disabled')) { + return false; + } + $('.login_wrap .step').toggleClass('active'); + }); + $('.login_input input').on('input keyup', function(){ + $('.login_input').removeClass('error'); + }); + $('.js-get-code').on('click', function(){ + $('.login_input').removeClass('error'); + + var email = $('.js-input-email input').val(); + $('.sended_email').text(email); + + if(email === '') { + $('.js-input-email').addClass('error'); + $('.js-input-email .login_error').text(localeValue == 'en_US' ? 'Enter your email' : 'Укажите Email'); + return false; + } else { + // Проверка Email + $.ajax({ + type: 'POST', + url: '/wp-admin/admin-ajax.php', + data: {action: 'email_validate', email:email}, + success: function(data){ + if(data['status'] === 'error') { + $('.js-input-email').addClass('error'); + $('.js-input-email .login_error').text(data['text']); + return false; + } else { + $('.login_wrap .step').toggleClass('active'); + send_code(); + } + } + }); + + } + + }); + $('.js-repeat-code').on('click', function(){ + $('.login_input').removeClass('error'); + send_code(); + }); + + function send_code(){ + $('.login_timer').show(); + $('.js-repeat-code').hide(); + $('.login_back').addClass('disabled'); + // Timer + var seconds = 15; + var interval = setInterval(function() { + if (seconds > 0) { + seconds--; + $('.seconds').text(seconds); + } else { + clearInterval(interval); + $('.login_timer').hide(); + $('.js-repeat-code').show(); + $('.login_back').removeClass('disabled'); + $('.seconds').text(15); + } + }, 1000); + //Ajax отправка кода + $.ajax({ + type: 'POST', + url: '/wp-admin/admin-ajax.php', + data: {action: 'send_code', email: $('.js-input-email input').val()} + }); + } + // Проверка кода и регистрация/авторизация + $('.js-input-code input').on('input keydown keyup propertychange paste cut copy change', function(){ + var val = $(this).val(); + var email = $('.js-input-email input').val(); + if(val.length === 4) { + $.ajax({ + type: 'POST', + url: '/wp-admin/admin-ajax.php', + data: {action: 'check_code', code: val, email: email}, + success: function(data){ + console.log(data); + if(data['status'] == 'success_reg') { + $('.login_forms').addClass('hide'); + $('.login_success').removeClass('hide'); + if (typeof wc_checkout_params !== 'undefined') { + location.reload() + } + } + if(data['status'] == 'success_auth') { + $('.login_forms').addClass('hide'); + $('.login_auth').removeClass('hide'); + if (typeof wc_checkout_params !== 'undefined') { + location.reload() + } + } + if(data['status'] == 'error') { + $('.js-input-code').addClass('error'); + $('.js-input-code .login_error').text(data['text']); + } + } + }); + } + }); + + $('.email_link_form').on('submit', function(e){ + e.preventDefault(); + $('.cabinet-card_linked-email .error').remove(); + var data = $(this).serializeArray(); + $.ajax({ + type: 'POST', + url: '/wp-admin/admin-ajax.php', + data: data, + success: function(data){ + if(data['error']) { + $('.cabinet-card_linked-email').append('
'+data['error']+'
'); + } else { + location.reload(); + } + + } + }); + }); + + +})(jQuery); + +function checkImage(imageSrc, good) { + var img = new Image(); + img.onload = good; + img.src = imageSrc; +} +// header +toggleOpenX('.lang', '.lang__open', '.lang__list', '.lang__content', false); +toggleHeader('#pc-menu','.header__menu-block','.header__pc-menu', '.white', 'white'); +toggleHeader('#phone-menu','.header__menu-block','.header__phone-menu', '.white', 'white'); +// header + +// modal +modalOpen('.button--filter', '.modal__filter'); +modalOpen('.basket-open', '.modal__basket'); +modalOpen('.login-open', '.modal__login'); +modalOpen('.open-to-know', '.modal__to-know'); +modalClose('.modal__close'); +modalClose('.modal-form-sub__close'); +let modal = document.querySelector('.modal'); + +modal.onclick = function (event) { + let target = event.target; + + if (target.classList.contains('modal')) { + let aside = target.querySelector('.modal__aside'), + modalItem = target.querySelector('.modal__item.active'); + + aside.style.width = '0px'; + setTimeout(() => { + modalItem.style.cssText = ''; + modalItem.classList.remove('active'); + target.classList.remove('active'); + }, 300); + } + + +} + +// modal + +// toggle +toggleOpenX('.toggle', '.toggle__title', '.toggle__content', '.toggle__block-content', true); +// toggle + +// radio-button +// let radioButtons = document.querySelectorAll('.radio-button'); + +// radioButtons.forEach(radioBlock => { +// let buttons = radioBlock.querySelectorAll('.button'); + +// buttons.forEach(button => { +// let input = radioBlock.querySelector('.radio-button__input'); + +// button.onclick = function (e) { +// e.preventDefault(); + +// buttons.forEach(thisButton => { +// if (thisButton.classList.contains('active')) { +// thisButton.classList.remove('active') +// } +// }) + +// let text = button.textContent.trim(); + +// button.classList.toggle('active'); + +// input.value = text; +// } +// }) +// }) +// radio-button + +function initOverlay(){ + + // overlay +let products = document.querySelectorAll('.product__item'); + +products.forEach(productItem => { + let button = productItem.querySelector('.open-overlay'), + overlay = productItem.querySelector('.product-item__overlay'); + + + if (button) { + button.onclick = function (e) { + document.querySelectorAll('.product__item').forEach(e => { + if (e.classList.contains('active')) { + e.classList.remove('active'); + } + }); + document.querySelectorAll('.product-item__overlay').forEach(e => { + if (e.classList.contains('active')) { + e.classList.remove('active'); + } + }); + + productItem.classList.toggle('active'); + overlay.classList.toggle('active'); + } + } + +}) +// overlay +} + +initOverlay() + + +function initSelect(){ + + +// select +toggleOpenX('.select', '.select__state' , '.state__content', '.state__block', true); + +let selects = document.querySelectorAll('.select'); + +selects.forEach(select => { + let state = select.querySelector('.select__state'), + content = select.querySelector('.state__block'), + buttons = select.querySelectorAll('.state__button'); + + buttons.forEach(e => { + let button = e; + + e.onclick = function (event) { + event.preventDefault(); + + buttons.forEach(element => { + if (element.classList.contains('active')) { + element.classList.remove('active'); + } + }) + + let text = e.textContent.trim(); + state.value = text; + + button.classList.add('active'); + content.style.height = 0; + select.classList.remove('active'); + } + }) +}) + +// select +} +initSelect() + +// counter +function initCounters(){ + let counters = document.querySelectorAll('.counter'); + counters.forEach(e => { + let minus = e.querySelector('.minus'), + plus = e.querySelector('.plus'), + input = e.querySelector('.counter__input'); + minus.onclick = function (e) { + e.preventDefault(); + + let number = input.value; + + if (number >= 2){ + input.value = Number(number) - 1; + input.setAttribute('value', input.value) + } + } + + plus.onclick = function (e) { + e.preventDefault(); + + let number = input.value; + let max = input.dataset.maxcount + if (number <= max - 1) { + input.value = Number(number) + 1; + input.setAttribute('value', input.value) + } + } + }) +} + +initCounters() +// counter + +// checkbox +let checkbox = document.querySelectorAll('.checkbox'); + +checkbox.forEach(e => { + e.onclick = function (event) { + let input = e.querySelector('.checkbox__input'); + + if (!e.classList.contains('active')) { + input.checked = 1; + }else{ + input.checked = 0; + } + e.classList.toggle('active'); + } +}) +// checkbox + + +// function +function modalOpen(buttonElement, contentElement){ + let modal = document.querySelector('.modal'), + aside = document.querySelector('.modal__aside'), + elements = document.querySelectorAll(buttonElement), + device = window.screen.width; + + elements.forEach(e => { + let thisContentElement = document.querySelector(contentElement); + + e.onclick = function () { + modal.classList.add('active'); + thisContentElement.classList.add('active'); + + let width = thisContentElement.clientWidth; + + setTimeout(() => { + if (device <= 720) { + aside.style.width = `${device}px`; + thisContentElement.style.opacity = 1; + thisContentElement.style.filter = 'blur(0px)'; + }else{ + aside.style.width = `${width}px`; + thisContentElement.style.opacity = 1; + thisContentElement.style.filter = 'blur(0px)'; + } + }, 10); + } + }) +} + +function modalClose(buttonElement) { + let modal = document.querySelector('.modal'), + aside = document.querySelector('.modal__aside'), + asideItems = document.querySelectorAll('.modal__item'), + elements = document.querySelectorAll(buttonElement); + + elements.forEach(e => { + e.onclick = function () { + aside.style.width = '0px'; + + asideItems.forEach(e => { + if (e.classList.contains('active')) { + e.style.filter = 'blur(10px)'; + } + }); + + setTimeout(() => { + asideItems.forEach(e => { + if (e.classList.contains('active')) { + e.classList.remove('active'); + } + }); + + modal.classList.remove('active'); + }, 300); + } + }) +} + +function toggleOpenX(mainElement, buttonElement ,heightElement, contentElement, close) { + let elements = document.querySelectorAll(mainElement); + + elements.forEach(e => { + let thisMainElement = e, + thisButtonElement = e.querySelector(buttonElement), + thisHeightElement = e.querySelector(heightElement), + thisContentElement = e.querySelector(contentElement); + + thisButtonElement.onclick = function (e) { + let height = thisHeightElement.clientHeight; + + if (close == true && !thisMainElement.classList.contains('active')) { + elements.forEach(e => { + if (e.classList.contains('active')) { + e.classList.remove('active'); + e.querySelector(contentElement).style.height = null + } + }) + } + + if (!thisMainElement.classList.contains('active')) { + thisContentElement.style.height = `${height}px`; + thisMainElement.classList.add('active'); + }else{ + thisContentElement.style.height = null; + thisMainElement.classList.remove('active'); + } + } + + }); +} +var menu_opened = false; +function toggleHeader(button, content, blockheight, removeBlock, removeClass) { + let thisButton = document.querySelector(button), + thisContent = document.querySelector(content), + thisRemoveBlock = document.querySelector(removeBlock) || '', + thisBlockheight = document.querySelector(blockheight); + + thisButton.onclick = function () { + let height = thisBlockheight.clientHeight; + + if (!thisContent.classList.contains('open')) { + thisContent.style.height = `${height}px`; + thisContent.classList .add('open'); + + if (removeBlock) { + thisRemoveBlock.classList.remove(removeClass); + } + }else{ + thisContent.style.height = null; + thisContent.classList.remove('open'); + + if (removeBlock) { + if (window.Y <= 25) { + thisRemoveBlock.classList.add(removeClass); + } + } + } + menu_opened = !menu_opened; + } +} + + +// resize +window.addEventListener('resize', (e) => { + let width = window.screen.width; + + // media + modalOpen('.button--filter', '.modal__filter'); + modalOpen('.basket-open', '.modal__basket'); + modalOpen('.login-open', '.modal__login'); + modalOpen('.open-to-know', '.modal__to-know'); + modalClose('.modal__close'); + modalClose('.modal-form-sub__close'); + + let modalItem = document.querySelectorAll('.modal__item'); + + // if (width <= 720) { + modalItem.forEach(modal => { + if (modal.classList.contains('active')) { + let aside = document.querySelector('.modal__aside'); + + if (width <= 720) { + aside.style.width = `${width}px` + }else{ + let openAside = document.querySelector('.modal__item.active'), + newWidth = openAside.clientWidth; + + aside.style.width = `${newWidth}px` + } + } + }) + // } +}); +// resize + +// + + +if (document.querySelector('.header').classList.contains('white')) { + window.addEventListener("scroll", function (e) { + let header = document.querySelector('.header'); + let scroll = window.scrollY; + if(!menu_opened){ + if (scroll >= 25) { + header.classList.remove('white') + }else{ + + header.classList.add('white') + + } + } + + }); +} +// scroll + + + diff --git a/wp-content/themes/cosmopet/modules/footer/module-controller.php b/wp-content/themes/cosmopet/modules/footer/module-controller.php index 389c8b6..9c1c818 100644 --- a/wp-content/themes/cosmopet/modules/footer/module-controller.php +++ b/wp-content/themes/cosmopet/modules/footer/module-controller.php @@ -9,6 +9,180 @@ add_filter('timber/context', function($context) { return $context; }); +define('BOT_USERNAME', 'cosmopetbot_bot'); +function getTelegramUserData() { + if (isset($_COOKIE['tg_user'])) { + $auth_data_json = urldecode($_COOKIE['tg_user']); + $auth_data = json_decode($auth_data_json, true); + return $auth_data; + } + return false; +} +/* +if ($_GET['logout']) { + setcookie('tg_user', ''); + header('Location: login.php'); +} +*/ +function tgWidget() { + $tg_user = getTelegramUserData(); + if ($tg_user !== false) { + $first_name = htmlspecialchars($tg_user['first_name']); + $last_name = htmlspecialchars($tg_user['last_name']); + if (isset($tg_user['username'])) { + $username = htmlspecialchars($tg_user['username']); + $html = "

Hello, {$first_name} {$last_name}!

"; + } else { + $html = "

Hello, {$first_name} {$last_name}!

"; + } + if (isset($tg_user['photo_url'])) { + $photo_url = htmlspecialchars($tg_user['photo_url']); + $html .= ""; + } + $html .= "

Log out

"; + } else { + $bot_username = BOT_USERNAME; + $html = ''; + } + if(!is_user_logged_in()) { + echo $html; + } +} + +add_action( 'wp_ajax_ontelegramauth', 'onTelegramAuth' ); +add_action( 'wp_ajax_nopriv_ontelegramauth', 'onTelegramAuth' ); + +function onTelegramAuth(){ + $tg_id = $_POST['userid']; + $tg_username = $_POST['username']; + $user = get_users( + array( + 'meta_key' => 'tg_account', + 'meta_value' => $tg_id + ) + ); + // $user = get_users( + // array( + // 'meta_key' => 'tg_username', + // 'meta_value' => $tg_username + // ) + // ); + + // Генерация пароля + $alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890@#!()'; + $pass = array(); + $alphaLength = strlen($alphabet) - 1; + for ($i = 0; $i < 12; $i++) { + $n = rand(0, $alphaLength); + $pass[] = $alphabet[$n]; + } + $pass = implode($pass); + + if($user) { + $user_login = $user[0]->data->user_login; + $user_id = get_user_by( 'login', $user_login )->ID; + wp_set_password( $pass, get_user_by( 'login', $user_login )->ID ); + wp_signon( + array( + 'user_login' => $user_login, + 'user_password' => $pass, + 'remember' => 'on', + ) + ); + } else { + $user_id = wp_create_user( $tg_username, $pass, ''); + add_user_meta( $user_id, 'tg_account', $tg_id); + add_user_meta( $user_id, 'tg_username', $tg_username); + wp_update_user( [ + 'ID' => $user_id, + 'first_name' => $_POST['fname'], + 'last_name' => $_POST['lname'] + ] ); + wp_set_auth_cookie( $user_id, true ); + } + +} + +add_action( 'wp_ajax_linktelegram', 'linkTelegram' ); +add_action( 'wp_ajax_nopriv_linktelegram', 'linkTelegram' ); + +function linkTelegram(){ + $tg_id = $_POST['userid']; + $user_id = get_current_user_id(); + + add_user_meta( $user_id, 'tg_account', $tg_id); + wp_update_user( [ + 'ID' => $user_id, + 'first_name' => $_POST['fname'], + 'last_name' => $_POST['lname'] + ] ); +} + +add_action( 'wp_ajax_email_link', 'emailLink' ); +add_action( 'wp_ajax_nopriv_email_link', 'emailLink' ); +function emailLink(){ + + $email = $_POST['email']; + $user_id = get_current_user_id(); + + if(email_exists($email)){ + header("Content-Type: application/json"); + echo json_encode(array( + 'error' => esc_html__( 'Email is already registered', 'woodmart' ) + )); + exit(); + } else { + wp_update_user( [ + 'ID' => $user_id, + 'user_email' => $email + ] ); + } + + +} + + + +// Добавляем колонку Telegram в список пользователей +add_filter('manage_users_columns', 'add_tg_account_column'); +function add_tg_account_column($columns) { + $columns['tg_username'] = 'Telegram'; + return $columns; +} + +// Заполняем колонку данными +add_filter('manage_users_custom_column', 'add_tg_account_column_content', 10, 3); +function add_tg_account_column_content($value, $column_name, $user_id) { + if ('tg_username' == $column_name) { + $tg_account = get_user_meta($user_id, 'tg_username', true); + if ($tg_account) { + return '@' . esc_html($tg_account) . ''; + } + return 'не указан'; + } + return $value; +} + +// Делаем колонку сортируемой +add_filter('manage_users_sortable_columns', 'make_tg_account_column_sortable'); +function make_tg_account_column_sortable($columns) { + $columns['tg_username'] = 'tg_username'; + return $columns; +} + +// Обрабатываем сортировку +add_action('pre_get_users', 'handle_tg_account_sorting'); +function handle_tg_account_sorting($query) { + if (!is_admin() || !$query->is_main_query()) { + return; + } + + if ('tg_username' === $query->get('orderby')) { + $query->set('meta_key', 'tg_username'); + $query->set('orderby', 'meta_value'); + } +} + ?> \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/forms/assets/js/form.js b/wp-content/themes/cosmopet/modules/forms/assets/js/form.js index c1bf685..8fa3faf 100644 --- a/wp-content/themes/cosmopet/modules/forms/assets/js/form.js +++ b/wp-content/themes/cosmopet/modules/forms/assets/js/form.js @@ -1,9 +1,13 @@ // Функция для показа модальных окон function showModal(modalClass) { + + const modal = document.querySelector('.' + modalClass); if (modal) { modal.style.display = 'flex'; + } +} // Функция для закрытия модальных окон function closeModals() { @@ -25,6 +29,7 @@ function showModal(modalClass) { // Закрытие при клике вне контента window.addEventListener('click', function(event) { + const modals = document.querySelectorAll('.mform'); modals.forEach(modal => { if (event.target === modal) { @@ -42,10 +47,10 @@ function showModal(modalClass) { modal.style.display = 'none'; } }); - }); }); + jQuery(document).ready(function($) { $('.form-process').submit(function(event) { event.preventDefault(); @@ -63,6 +68,7 @@ jQuery(document).ready(function($) { success: function(response) { closeModals() showModal('mform-success') + } }); } @@ -134,4 +140,4 @@ const localeValue = metaLocale.getAttribute('content'); errorMessages.forEach(errorMessage => { errorMessage.remove(); }); - } \ No newline at end of file + } diff --git a/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css b/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css index bdc22e3..78f1e7f 100644 --- a/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css +++ b/wp-content/themes/cosmopet/modules/layout/assets/css/gp-style-core.css @@ -271,6 +271,7 @@ textarea{ } } + .mform { position: fixed; top: 0; @@ -284,7 +285,9 @@ textarea{ z-index: 1000; } + .mform-content { + position: relative; width: 100%; max-width: 600px; @@ -331,7 +334,9 @@ textarea{ color: #000; } + .mform-title { + font-size: 32px; font-weight: bold; margin-bottom: 10px; @@ -340,16 +345,18 @@ textarea{ /* Стили для второго модального окна - Предложить статью */ .mform-offer .mform-content { + background-color: #d6ff9f; padding-bottom: 30px; } + .mform-subtitle { font-size: 18px; margin-bottom: 20px; } - .mform-form { + .modal-form { width: 100%; } @@ -371,6 +378,16 @@ textarea{ width: 100%; max-width: 380px; } + + .modal-offer input, textarea { + width: 100%!important; + padding: 12px 15px!important; + border: none!important; + border-radius: 20px!important; + font-size: 16px!important; + background-color: white!important; + } + /* Контейнер для текстового поля и изображения автора */ .message-container { position: relative; @@ -419,7 +436,9 @@ textarea{ /* Адаптивность */ @media (max-width: 768px) { + .mform-content { + width: 90%; padding: 30px 20px; } @@ -452,13 +471,156 @@ textarea{ } } - .wrapper { margin: 0 auto; max-width: 1600px; } +.modal { + display: none; +} +.modal.active { + display: flex!important; +} +.modal__login.active { + filter: blur(0px); +} + + /* button */ +.button{ + font-family: var(--font-family); + font-weight: 600; + font-size: 20px; + line-height: 120%; + color: var(--text-black); + + border-radius: 20px; + text-transform: none; + cursor: pointer; + } + .button--100-perc{ + width: 100%; + } + .button--white{ + padding: 11px 24px; + + text-align: center; + + background-color: var(--background-white); + border: 1px solid var(--background-black); + + transition: opacity .2s ease-out; + } + .button--white:hover{ + opacity: .8; + } + .button--white.active{ + background: var(--background-black); + color: var(--background-white); + } + .button--gradient{ + background: var(--gradient-turquoise); + border: none; + + transition: opacity .2s ease-out; + } + .button--gradient:hover{ + opacity: .8; + } + .button--base{ + padding: 12px 24px; + } + .button--high{ + height: 56px; + + padding: 16px 24px 16px 24px; + + font-weight: 700; + text-align: center; + + position: relative; + } + .button--icon{ + padding-right: 56px; + + text-align: start; + } + .button--filter::after{ + content: ''; + + position: absolute; + top: 16px; + right: 24px; + + width: 24px; + aspect-ratio: 1; + + background-image: url(../img/svg/main/filter.svg); + background-repeat: no-repeat; + background-size: contain; + } + .button--black{ + padding: 7px 15px; + + font-family: var(--font-family); + font-weight: 500; + font-size: 24px; + line-height: 133%; + color: var(--text-white); + + background: var(--background-black); + border: 1px solid var(--text-white); + } + .button--link{ + text-decoration: none; + } + .button--red-48-px{ + border-radius: 48px; + } + .to-know{ + width: 100%; + + padding: 12px; + + display: flex; + justify-content: center; + + border: none; + + transition: opacity .2s ease-out; + } + .to-know:hover{ + opacity: .8; + } + .to-know p{ + padding-bottom: 4px; + + font-family: var(--font-family); + font-weight: 700; + font-size: 20px; + line-height: 120%; + color: var(--text-black); + + border-bottom: 1px var(--text-black) solid; + + cursor: pointer; + } + .to-know--background-none{ + background: none; + } + .back{ + margin-top: 16px; + margin-left: 16px; + + padding: 8px; + padding-left: 32px; + + background: none; + border: none; + + } + /* modal */ @@ -1324,15 +1486,54 @@ textarea{ flex: 1; padding: 16px 24px; border-radius: 20px; + font-family: var(--font-family); font-weight: 600; font-size: 20px; line-height: 120%; - text-align: center; - cursor: pointer; - transition: all 0.2s ease-out; + color: var(--text-black); + + text-decoration: none; + + position: relative; + } + .back::before{ + content: ''; + + position: absolute; + top: 8px; + left: 0; + + margin-right: 8px; + + width: 24px; + height: 24px; + + background-image: url(../img/svg/main/arrow-back.svg); + } + + .back::after{ + content: ''; + + position: absolute; + bottom: 6px; + left: 0; + + width: calc(100% - 8px); + height: 1px; + + background: var(--text-black); + } + + .button--high-46{ + padding: 12px 24px; + + font-size: 20px; + font-weight: 700; + line-height: 24px; } + .modal-basket__button--continue { background: var(--background-white); border: 1px solid var(--background-black); @@ -1860,4 +2061,4 @@ textarea{ .wc-block-checkout__form.wc-block-components-form .wc-block-components-text-input input[type=url], .wc-block-checkout__form.wc-block-components-form .wc-blocks-components-select .wc-blocks-components-select__select{ border-radius: 10px; -} \ No newline at end of file +} diff --git a/wp-content/themes/cosmopet/modules/profile/assets/css/profile.css b/wp-content/themes/cosmopet/modules/profile/assets/css/profile.css new file mode 100644 index 0000000..ed407c1 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/css/profile.css @@ -0,0 +1,852 @@ +/* cabinet */ +.cabinet{ +padding: 24px; + +display: flex; +justify-content: space-between; +} +.cabinet__control{ +margin: 24px; +margin-bottom: 0; + +display: none; +} +.cabinet-control__button{ +margin-left: 8px; + +padding: 12px 16px; + +font-family: var(--font-family); +font-weight: 500; +font-size: 20px; +line-height: 120%; +color: var(--text-black); + +background: var(--background-white); +border: 2px solid var(--text-black); +border-radius: 48px; + +transition: opacity .2s ease-out; +} +.cabinet-control__button:first-child{ +margin-left: 0; +} +.cabinet-control__button.active{ +background: var(--background-black); +color: #fff; +} +.cabinet-control__button:hover{ +opacity: .8; +} +.cabinet__orders{ +width: calc(((100% - 48px) / 3) * 2); +} +.cabinet__profile{ +width: calc((100% - 48px) / 3); +} + +.cabinet-card{ +margin-top: 32px; + +padding: 1px; + +border-radius: 20px; +} +.cabinet-card:first-child{ +margin-top: 0; +} +.cabinet-card--green{ +background: var(--background-green); +} +.cabinet-card--green-white{ +background: var(--background-green-white); +} +.cabinet-card--green-white .cabinet-card__content{ +background: none; +} +.cabinet-card--red-blue{ +background: var(--gradient-red); +} +.cabinet-card--grey{ +background: var(--background-9); +} +.cabinet-card__content{ +padding: 23px; + +border-radius: 19px; + +background-color: var(--background-white); +} +.cabinet-card__element{ +margin-top: 24px; + +position: relative; +} +.cabinet-card__element--margin-top-32{ +margin-top: 32px; +} +.cabinet-card__element:first-child, +.cabinet-card__element--margin-top-32:first-child{ +margin-top: 0 +} +.cabinet-card__element-change{ +position: absolute; +top: 14px; +right: 0; + +width: 24px; +aspect-ratio: 1; + +background-image: url(../img/svg/main/change-dot.svg); +border: none; +background-color: var(--background-white); + +transition: opacity .2s ease-out; +} +.cabinet-card__element-change:hover{ +opacity: .8; +} +.cabinet-card__title{ +font-family: var(--font-family); +font-weight: 700; +font-size: 26px; +line-height: 123%; +text-transform: uppercase; +background: var(--gradient-blue); +background-clip: text; +-webkit-background-clip: text; +-webkit-text-fill-color: transparent; +} +.cabinet-card__text{ +font-family: var(--font-family); +font-weight: 400; +font-size: 20px; +line-height: 120%; + +color: var(--text-black); +} +.cabinet-card__text--grey{ +color: var(--text-grey); +} +.cabinet-card__label{ +font-family: var(--font-family); +font-weight: 700; +font-size: 16px; +line-height: 125%; + +color: var(--text-3); +} +.cabinet-card__status{ +padding-left: 20px; + +font-family: var(--font-family); +font-weight: 500; +font-size: 12px; +line-height: 133%; + +position: relative; +color: #121212; +} +.cabinet-card__status--chek{ +color: var(--text-green); +} +.cabinet-card__status--chek::before{ +content: ''; + +position: absolute; +top: 0; +left: 0; + +width: 16px; +height: 16px; + +background-image: url(../img/svg/main/status-chek.svg); +object-fit: contain; +} +.cabinet-card__status--cancelled{ +color: var(--text-red); +} +.cabinet-card__status--cancelled::before{ +content: ''; + +position: absolute; +top: 0; +left: 0; + +width: 16px; +height: 16px; + +background-image: url(../img/svg/main/status-cancelled.svg); +object-fit: contain; +} +.cabinet-card__block-accounts{ +display: flex; +} +.cabinet-card__account{ +margin-left: 16px; + +width: 40px; +aspect-ratio: 1; + +display: flex; +justify-content: center; +align-items: center; + +background: var(--background-9); +border-radius: 50%; +} +.cabinet-card__account:first-child{ +margin-left: 0; +} +.cabinet-card__block-buttons{ +display: flex; +justify-content: space-between; +align-items: center; +} +.cabinet-card__button{ +padding: 8px 8px 6px 0; + +font-family: var(--font-family); +font-weight: 600; +font-size: 20px; +line-height: 120%; +color: var(--text-black); + +background: none; +border: none; + +position: relative; + +text-decoration: none; +} +.cabinet-card__button::before{ +content: ''; + +position: absolute; +bottom: 6px; + +width: calc(100% - 8px); +height: 1px; + +background: var(--text-black); + +transition: opacity .2s ease-out; +} +.cabinet-card__button:hover{ +opacity: .8; +} +.cabinet-card__confirm{ +margin-top: 16px; + +border-radius: 20px; +padding: 4px 24px; + +font-family: var(--font-family); +font-weight: 600; +font-size: 20px; +line-height: 120%; + + +background: var(--background-black); +color: #fff; +border: none; + +transition: opacity .2s ease-out; +} +.cabinet-card__confirm:hover{ +opacity: .8; +} +.cabinet-card__text, .cabinet-card__label, .cabinet-card__status, .cabinet-card__block-accounts, .cabinet-card__block-buttons{ +margin-top: 8px; +} +.cabinet-card__text:first-child, .cabinet-card__label:first-child, .cabinet-card__status:first-child, .cabinet-card__block-accounts:first-child, .cabinet-card__block-buttons:first-child{ +margin-top: 0px; +} +.cabinet-card__block-add-pets{ +width: 100%; + +display: flex; +align-items: center; + +background: none; +border: none; +} +.cabinet-card-add-pets__circle{ +width: 48px; +aspect-ratio: 1; + +display: flex; +justify-content: center; +align-items: center; + +border: 1px solid var(--text-6); +border-radius: 50%; +} +.cabinet-card-add-pets__text{ +margin-left: 16px; + +font-family: var(--font-family); +font-weight: 600; +font-size: 20px; +line-height: 120%; + +color: var(--text-6); + +position: relative; +} +.cabinet-card-add-pets__text::after{ +content: ''; + +position: absolute; +left: 0; +bottom: -4px; + +width: 100%; +height: 1px; + +background: var(--text-6); +} +.cabinet-card__discount{ +display: flex; +align-items: center; +} +.cabinet-card-discount__title{ +font-family: var(--font-family); +font-weight: 700; +font-size: 16px; +line-height: 125%; +color: var(--text-black); +} +.cabinet-card-discount__percent{ +margin-left: 16px; + +font-family: var(--font-family); +font-weight: 700; +font-size: 16px; +line-height: 125%; +color: var(--text-black); +} +.cabinet-card-discount__percent::after{ +content: '%'; +} +.cabinet-card-discount__arrow{ +display: inline-block; + +margin-left: 6px; + +width: 20px; +aspect-ratio: 1; + +background-image: url(../img/svg/main/arrow-breadcrumbs-black.svg); +background-position: center; +} +.cabinet-card__no-orders{ +margin-top: 32px; + +padding: 48px 24px; +} +.cabinet-card-no-orders__element{ +margin-top: 26px; +} +.cabinet-card-no-orders__element:first-child{ +margin-top: 0; +} +.cabinet-card-no-orders__title{ +font-family: var(--font-family); +font-weight: 500; +font-size: 24px; +line-height: 133%; +text-align: center; +color: var(--text-black); +} +.cabinet-card__pet{ +display: flex; +align-items: center; +} +.cabinet-card-pet__icon{ +width: 48px; +aspect-ratio: 1; + +border-radius: 50%; +background: var(--gradient-blue); +} +.cabinet-card-pet-icon__content{ +margin: 1px; + +width: calc(100% - 2px); +aspect-ratio: 1; + +display: flex; +justify-content: center; +align-items: center; + +border-radius: 50%; +background: var(--background-white); +} +.cabinet-card-pet-icon__content img{ +width: 32px; +aspect-ratio: 1; + +object-fit: contain; +} +.cabinet-card-pet__name{ +margin-left: 24px; + +font-family: var(--font-family); +font-weight: 700; +font-size: 16px; +line-height: 125%; +color: var(--text-black); +} +.cabinet-card__order{ +position: relative; +} +.cabinet-card-order__header{ +display: flex; +justify-content: space-between; +align-items: flex-start; +} +.cabinet-card-order__main{} +.cabinet-card-order-main__date{ +font-family: var(--font-family); +font-weight: 500; +font-size: 24px; +line-height: 133%; +color: var(--text-black); +} +.cabinet-card-order-main__number{ +margin-top: 8px; + +font-family: var(--font-family); +font-weight: 500; +font-size: 12px; +line-height: 133%; +color: var(--text-black); +} +.cabinet-card-order-main__number::before{ +content: '№'; +} +.cabinet-card-order__payment{ +display: flex; +align-items: flex-end; + +transition: margin .2s ease-out; +} +.cabinet-card-order-payment__title{ +font-family: var(--font-family); +font-weight: 500; +font-size: 12px; +line-height: 133%; +color: var(--text-black); +} +.cabinet-card-order-payment__price{ +margin-left: 8px; + +font-family: var(--font-family); +font-weight: 700; +font-size: 16px; +line-height: 125%; +color: var(--text-black); +} +.cabinet-card-order-payment__price::after{ +margin-left: 5px; +content: '₽'; +} +.cabinet-card-order__content{ +margin-top: 24px; +} +.cabinet-card-order__content +.cabinet-card-order__status{ +display: flex; +align-items: center; +} +.cabinet-card-order-status__title{ +font-family: var(--font-family); +font-weight: 500; +font-size: 20px; +line-height: 120%; +color: var(--text-black); +} +.cabinet-card-order-status__pointer{ +margin-left: 12px; + +font-family: var(--font-family); +font-weight: 500; +font-size: 20px; +line-height: 120%; +color: var(--text-black); +} +.cabinet-card-order-status__pointer--grey{ +color: var(--text-6); +} +.cabinet-card-order-status__pointer--green{ +color: var(--text-green); +} +.cabinet-card-order-status__pointer--red{ +color: var(--text-red); +} +.cabinet-card-order__block-detail{ +height: 0; +overflow: hidden; + +transition: height .2s ease-out; +} +.cabinet-card-order__detail{ +padding-top: 24px; +} +.cabinet-card-order-detail__address{} +.cabinet-card-order-detail-address__title{ +font-family: var(--font-family); +font-weight: 500; +font-size: 20px; +line-height: 120%; +color: var(--text-black); +} +.cabinet-card-order-detail-address__text{ +margin-top: 16px; + +font-family: var(--font-family); +font-weight: 400; +font-size: 20px; +line-height: 120%; +color: var(--text-black); +} +.cabinet-card-order-detail__main{ +margin-top: 24px; + +display: flex; +justify-content: space-between; +} +.cabinet-card-order-detail-main__products{} +.cabinet-card-order-detail-main__product{ +margin-top: 4px; + +display: flex; +align-items: center; +} +.cabinet-card-order-detail-main__product:first-child{ +margin-top: 0; +} +.cabinet-card-order-detail-main-product__img{ +width: 106px; +height: 96px; +} +.cabinet-card-order-detail-main-product__content{ +display: flex; +} +.cabinet-card-order-detail-main-product__description{ +width: 212px; +} +.cabinet-card-order-detail-main-product-description__what{ +font-family: var(--font-family); +font-weight: 500; +font-size: 12px; +line-height: 133%; +color: var(--text-black); +} +.cabinet-card-order-detail-main-product-description__with-what{ +margin-top: 8px; + +font-family: var(--font-family); +font-weight: 500; +font-size: 12px; +line-height: 133%; +color: var(--text-6); +} +.cabinet-card-order-detail-main-product__count{ +margin-left: 8px; + +font-family: var(--font-family); +font-weight: 700; +font-size: 12px; +line-height: 133%; +text-align: right; +color: var(--text-6); +} +.cabinet-card-order-detail-main-product__count::before{ +margin-right: 4px; + +content: 'x'; +} +.cabinet-card-order-detail-main-product__price{ +margin-left: 16px; + +font-family: var(--font-family); +font-weight: 700; +font-size: 12px; +line-height: 133%; +text-align: right; +color: var(--text-black); +} +.cabinet-card-order-detail-main-product__price::after{ +content: ' Р'; +} +.cabinet-card-order-detail-main__links{ +display: flex; +flex-direction: column; +} +.cabinet-card-order-detail-main__link{ +margin-top: 16px; +} +.cabinet-card-order-detail-main__link:first-child{ +margin-top: 0; +} +.cabinet-card-order__open-detail{ +margin-top: 24px; + +padding-right: 24px; + +font-family: var(--font-family); +font-weight: 500; +font-size: 20px; +line-height: 120%; +color: var(--text-black); + +border: none; +background: none; + +position: relative; +} +.cabinet-card-order__open-detail::after{ +content: ''; + +position: absolute; +top: 6.75px; +right: 0; + +width: 12.5px; +height: 10.5px; + +background-image: url(../../core/img/svg/main/arrow-black.svg); +background-size: contain; +background-position: center; +background-repeat: no-repeat; + +transition: transform .2s; +/* transform: rotate(180deg); */ +} +.cabinet-card-order-detail-short__item{ +object-fit: contain; +} +.cabinet-card-order__detail-short{ +display: flex; +align-items: center; +justify-content: flex-end; +max-width: calc(100% - 250px); +margin-left: auto; +overflow: auto; +/* flex-wrap: wrap; */ +transition: all .2s .1s ease-out; +} +.cabinet-card-order__bottom{ +display: flex; +align-items: flex-end; +} +@media (max-width: 768px) { +.cabinet-card-order__bottom{ + display: flex; + align-items: flex-start; + flex-direction: column-reverse; + margin-top: 16px; +} +.cabinet-card-order__detail-short{ + max-width: calc(100%); + flex-wrap: wrap; + justify-content: flex-start; + margin-left: 0; +} +} +.cabinet-card-order-detail-short__item{ +border-radius: 16px; +width: 106px; +height: 96px; +} +.cabinet-card__download{ +margin-top: 32px; +} +.cabinet-card__order.active .cabinet-card-order__detail-short{ +opacity: 0; +height: 0; +} +.cabinet-card__order.active .cabinet-card-order__open-detail::after{ +transform: rotate(180deg); +} +/* .cabinet-card-no-orders__ */ +.cabinet__subscription-pc{ +} +.cabinet__subscription-mobile{ +display: none; +} +/* cabinet */ + +.main-page-wrapper{ +margin-top: 20px !important; +} + + +.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-20_0, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9, .col-auto, .col-lg, .col-lg-1, .col-lg-10, .col-lg-11, .col-lg-12, .col-lg-2, .col-lg-20_0, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-auto, .col-md, .col-md-1, .col-md-10, .col-md-11, .col-md-12, .col-md-2, .col-md-20_0, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-auto, .col-sm, .col-sm-1, .col-sm-10, .col-sm-11, .col-sm-12, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-auto, .col-xl, .col-xl-1, .col-xl-10, .col-xl-11, .col-xl-12, .col-xl-2, .col-xl-3, .col-xl-4, .col-xl-5, .col-xl-6, .col-xl-7, .col-xl-8, .col-xl-9, .col-xl-auto { +padding-right: 0 !important; +padding-left: 0 !important; +} + +@media only screen and (max-width: 1200px) { +/* cabinet */ +.cabinet{ + flex-direction: column; + + position: relative; +} +.cabinet__control{ + display: flex; + + position: relative; +} +.cabinet__orders, .cabinet__profile{ + width: calc(100% - 48px); +} +.cabinet__orders, .cabinet__profile{ + position: absolute; + opacity: 0; + + transition: opacity .2s ease-out; +} +.cabinet-content{ + pointer-events:none; +} +.cabinet__orders.active, .cabinet__profile.active{ + opacity: 1; +} +.cabinet__orders.hide, .cabinet__profile.hide{ + position: static; + display: block; + pointer-events:auto; + + width: 100%; +} +.cabinet__subscription-pc{ + display: none; +} +.cabinet__subscription-mobile{ + display: block; + + margin: 24px 24px 0 24px; +} +.cabinet__orders .cabinet-card:nth-child(2){ + margin-top: 0; + } +/* cabinet */ +} +@media only screen and (max-width: 750px) { + /* cabinet */ + .cabinet-card-order__open-detail{ + margin-top: 0px; + } + .cabinet-card-order__detail-short{ + right: auto; + left: 0; + bottom: 48px; + } + .cabinet-card-order-detail-short__item{ + margin-left: -27px; + } + .cabinet-card-order-detail-short__item:first-child{ + margin-left: 0; + } + .cabinet-card__order.active .cabinet-card-order__open-detail{ + margin-top: 24px; + } + .cabinet-card-order__detail-short{ + max-width: 100%; + } + .cabinet-card-order__content, .cabinet-card-order__bottom{ + margin-top: 0; + } + /* cabinet */ + } +@media only screen and (max-width: 720px) { + /* cabinet */ +.cabinet-card__title{ + font-size: 20px; +} +.cabinet-card__no-orders{ + margin-top: 16px; +} +.cabinet-card-order__header{ + flex-direction: column; +} +.cabinet-card-order__payment{ + margin-top: 16px; +} +.cabinet-card-order-detail__main{ + flex-direction: column; +} +.cabinet-card-order-detail-main__links{ + margin-top: 24px; + + align-items: start; +} +.cabinet-card-order-detail-main-product__img{ + width: 70px; + height: 70px; +} +.cabinet-card-order-detail-main__product{ + margin-top: 16px; + + align-items: start; +} +.cabinet-card-order-detail-main__products{ + position: relative; +} +.cabinet-card-order-detail-main-product__content{ + margin-left: 16px; + + flex-wrap: wrap; + + +} +.cabinet-card-order-detail-main-product__description{ + width: 100%; +} +.cabinet-card-order-detail-main-product__count{ +margin-left: 0; +margin-top: 7px; +} +.cabinet-card-order-detail-main-product__price{ + margin-top: 7px; +} +.cabinet-card__content{ + padding-right: 19px; +} +/* .cabinet-card__order.active */ +/* .cabinet-card__order.active */ +/* cabinet */ +} + +@media only screen and (max-width: 576px) { + /* cabinet */ + +.cabinet-card-order-detail-main-product__img{ + width: 40px; + height: 40px; +} + +.cabinet-card-order-detail-main-product__count{ + left: auto; + right: 71px; +} +.cabinet-card-order-detail-main-product__price{ + left: auto; + right: 0; +} +.cabinet-card-order__detail-short{ + transition-delay: 0; + transition-duration: 0; +} +.cabinet-card-order-detail-short__item { + border-radius: 16px; + width: 80px; + height: 80px; +} + +/* cabinet */ +} \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/modal/about_slider.png b/wp-content/themes/cosmopet/modules/profile/assets/img/modal/about_slider.png new file mode 100644 index 0000000..f3a8325 Binary files /dev/null and b/wp-content/themes/cosmopet/modules/profile/assets/img/modal/about_slider.png differ diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/pet/cat.png b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/cat.png new file mode 100644 index 0000000..f88dd36 Binary files /dev/null and b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/cat.png differ diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/pet/dog.png b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/dog.png new file mode 100644 index 0000000..36e37ae Binary files /dev/null and b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/dog.png differ diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/pet/mini-cat.png b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/mini-cat.png new file mode 100644 index 0000000..49233dd Binary files /dev/null and b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/mini-cat.png differ diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/pet/mini-dog.png b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/mini-dog.png new file mode 100644 index 0000000..59a696d Binary files /dev/null and b/wp-content/themes/cosmopet/modules/profile/assets/img/pet/mini-dog.png differ diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/product/image.png b/wp-content/themes/cosmopet/modules/profile/assets/img/product/image.png new file mode 100644 index 0000000..aaef248 Binary files /dev/null and b/wp-content/themes/cosmopet/modules/profile/assets/img/product/image.png differ diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/product/mini-card.png b/wp-content/themes/cosmopet/modules/profile/assets/img/product/mini-card.png new file mode 100644 index 0000000..0e0eb02 Binary files /dev/null and b/wp-content/themes/cosmopet/modules/profile/assets/img/product/mini-card.png differ diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/country/ar.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/country/ar.svg new file mode 100644 index 0000000..4e3a7b3 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/country/ar.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/country/ru.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/country/ru.svg new file mode 100644 index 0000000..fc991dd --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/country/ru.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-black.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-black.svg new file mode 100644 index 0000000..4cd0135 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-black.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-gradient.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-gradient.svg new file mode 100644 index 0000000..9054fde --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-gradient.svg @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-white.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-white.svg new file mode 100644 index 0000000..22c4489 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/logo/logo-white.svg @@ -0,0 +1,4 @@ + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-back.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-back.svg new file mode 100644 index 0000000..a977e53 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-back.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-black.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-black.svg new file mode 100644 index 0000000..38fe433 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-black.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-breadcrumbs-black.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-breadcrumbs-black.svg new file mode 100644 index 0000000..88fd149 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-breadcrumbs-black.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-breadcrumbs.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-breadcrumbs.svg new file mode 100644 index 0000000..f1f9618 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-breadcrumbs.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-left.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-left.svg new file mode 100644 index 0000000..465c268 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-left.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-right.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-right.svg new file mode 100644 index 0000000..8952470 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-right.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-selected-white.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-selected-white.svg new file mode 100644 index 0000000..bb7e90b --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-selected-white.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-selected.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-selected.svg new file mode 100644 index 0000000..fb283a7 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/arrow-selected.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/basket.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/basket.svg new file mode 100644 index 0000000..6c08b40 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/basket.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/black-x.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/black-x.svg new file mode 100644 index 0000000..cb3041d --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/black-x.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/change-dot.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/change-dot.svg new file mode 100644 index 0000000..f38b6c9 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/change-dot.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/filter.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/filter.svg new file mode 100644 index 0000000..efa46c8 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/filter.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/google-white.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/google-white.svg new file mode 100644 index 0000000..4040621 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/google-white.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/gradient-x.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/gradient-x.svg new file mode 100644 index 0000000..3a19e1f --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/gradient-x.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/minus.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/minus.svg new file mode 100644 index 0000000..77109fe --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/minus.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/plus-grey.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/plus-grey.svg new file mode 100644 index 0000000..6fa9039 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/plus-grey.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/plus.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/plus.svg new file mode 100644 index 0000000..a9db939 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/plus.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/question.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/question.svg new file mode 100644 index 0000000..2e21e7b --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/question.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/status-cancelled.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/status-cancelled.svg new file mode 100644 index 0000000..f96648a --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/status-cancelled.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/status-chek.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/status-chek.svg new file mode 100644 index 0000000..836d49b --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/status-chek.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/triangle-grey.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/triangle-grey.svg new file mode 100644 index 0000000..23ede66 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/triangle-grey.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/vk-white.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/vk-white.svg new file mode 100644 index 0000000..556d386 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/vk-white.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/white-x.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/white-x.svg new file mode 100644 index 0000000..3697346 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/white-x.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/ya-white.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/ya-white.svg new file mode 100644 index 0000000..a6b4ece --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/main/ya-white.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/basket-w.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/basket-w.svg new file mode 100644 index 0000000..55eb29f --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/basket-w.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/basket.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/basket.svg new file mode 100644 index 0000000..fdf6bf8 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/basket.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/profile-w.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/profile-w.svg new file mode 100644 index 0000000..442e587 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/profile-w.svg @@ -0,0 +1,4 @@ + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/profile.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/profile.svg new file mode 100644 index 0000000..6a48c34 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/mini-profile/profile.svg @@ -0,0 +1,4 @@ + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/tg.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/tg.svg new file mode 100644 index 0000000..332942a --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/tg.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/vk.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/vk.svg new file mode 100644 index 0000000..ef5cadf --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/vk.svg @@ -0,0 +1,3 @@ + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/ya.svg b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/ya.svg new file mode 100644 index 0000000..055175d --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/img/svg/social-media/ya.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/wp-content/themes/cosmopet/modules/profile/assets/js/profile.js b/wp-content/themes/cosmopet/modules/profile/assets/js/profile.js new file mode 100644 index 0000000..a0660b8 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/assets/js/profile.js @@ -0,0 +1,300 @@ +'use strict'; + + +let widthPhoneCabinet = 1200; + +toggleOpenX('.cabinet-card__order', '.cabinet-card-order__open-detail', '.cabinet-card-order__detail', '.cabinet-card-order__block-detail'); +// modalFormOpen('.form-open'); + +// closeModalForm('.modal-form__close'); +// closeModalForm('.modal-form__button-close'); + +controlCabinet('.cabinet-control__button', '.cabinet', widthPhoneCabinet); + +function controlCabinet(buttons, main, minWidth){ + let thisWidth = window.innerWidth; + let thisMain = document.querySelector(main); + + let thisButtons = document.querySelectorAll(buttons); + + thisButtons.forEach(e => { + e.onclick = function (element){ + let thisContent = document.querySelector(`.cabinet__${e.dataset.cabinet}`); + let newHeight = thisContent.clientHeight + 48; + let thisButton = element.target; + + thisMain.style.height = `${newHeight}px` + + if (!thisContent.classList.contains('active')) { + thisMain.querySelector('.active').classList.remove('active'); + thisContent.classList.add('active'); + + setTimeout(() => { + thisMain.style.height = 'auto'; + + if (thisMain.querySelector('.hide')) { + thisMain.querySelector('.hide').classList.remove('hide'); + } + + thisMain.querySelector('.active').classList.add('hide'); + }, 200); + } + + thisButtons.forEach(e => { + e.classList.remove('active'); + }) + thisButton.classList.add('active'); + } + }) + +} + +// let modal = document.querySelector('.modal'); +// modal.onclick = function (eventModal) { +// let thisTarget = eventModal.target; + +// if (thisTarget.classList.contains('modal')) { +// thisTarget.classList.remove('active'); + +// if (!thisTarget.querySelector('.modal-map.active')) { +// thisTarget.querySelector('.modal-form.active').classList.remove('active'); +// }else{ +// thisTarget.querySelector('.modal-map.active').classList.remove('active'); +// } +// } +// } + +// function modalOpen(buttonElement, contentElement){ +// let modal = document.querySelector('.modal'), +// aside = document.querySelector('.modal__aside'), +// elements = document.querySelectorAll(buttonElement), +// device = window.screen.width; + +// elements.forEach(e => { +// let thisContentElement = document.querySelector(contentElement); + +// e.onclick = function () { +// modal.classList.add('active'); +// thisContentElement.classList.add('active'); + +// let width = thisContentElement.clientWidth; + +// setTimeout(() => { +// if (device <= 720) { +// aside.style.width = `${device}px`; +// thisContentElement.style.opacity = 1; +// thisContentElement.style.filter = 'blur(0px)'; +// }else{ +// aside.style.width = `${width}px`; +// thisContentElement.style.opacity = 1; +// thisContentElement.style.filter = 'blur(0px)'; +// } +// }, 10); +// } +// }) +// } + +// function modalClose(buttonElement) { +// let modal = document.querySelector('.modal'), +// aside = document.querySelector('.modal__aside'), +// asideItems = document.querySelectorAll('.modal__item'), +// elements = document.querySelectorAll(buttonElement); + +// elements.forEach(e => { +// e.onclick = function () { +// aside.style.width = '0px'; + +// asideItems.forEach(e => { +// if (e.classList.contains('active')) { +// e.style.filter = 'blur(10px)'; +// } +// }); + +// setTimeout(() => { +// asideItems.forEach(e => { +// if (e.classList.contains('active')) { +// e.classList.remove('active'); +// } +// }); + +// modal.classList.remove('active'); +// }, 300); +// } +// }) +// } + +// function closeModalForm(close){ +// let buttons = document.querySelectorAll(close), +// modal = document.querySelector('.modal'); + +// buttons.forEach(button => { +// button.onclick = function (buttonEvent) { +// modal.classList.remove('active'); + +// if (!modal.querySelector('.modal-map.active')) { +// modal.querySelector('.modal-form.active').classList.remove('active'); +// }else{ +// modal.querySelector('.modal-map.active').classList.remove('active'); +// } +// } +// }) +// } + +function toggleOpenX(mainElement, buttonElement ,heightElement, contentElement, close) { + let elements = document.querySelectorAll(mainElement); + + elements.forEach(e => { + let thisMainElement = e, + thisButtonElement = e.querySelector(buttonElement), + thisHeightElement = e.querySelector(heightElement), + thisContentElement = e.querySelector(contentElement); + + thisButtonElement.onclick = function (e) { + let height = thisHeightElement.clientHeight; + + if (close == true && !thisMainElement.classList.contains('active')) { + elements.forEach(e => { + if (e.classList.contains('active')) { + e.classList.remove('active'); + e.querySelector(contentElement).style.height = null + } + }) + } + + if (!thisMainElement.classList.contains('active')) { + thisContentElement.style.height = `${height}px`; + thisMainElement.classList.add('active'); + }else{ + thisContentElement.style.height = null; + thisMainElement.classList.remove('active'); + } + } + + }); +} + +// function toggleHeader(button, content, blockheight, removeBlock, removeClass) { +// let thisButton = document.querySelector(button), +// thisContent = document.querySelector(content), +// thisRemoveBlock = document.querySelector(removeBlock) || '', +// thisBlockheight = document.querySelector(blockheight); + +// thisButton.onclick = function () { +// let height = thisBlockheight.clientHeight; + +// if (!thisContent.classList .contains('open')) { +// thisContent.style.height = `${height}px`; +// thisContent.classList .add('open'); + +// if (removeBlock) { +// thisRemoveBlock.classList.remove(removeClass); +// } +// }else{ +// thisContent.style.height = null; +// thisContent.classList .remove('open'); + +// if (removeBlock) { +// if (window.scrollY <= 25) { +// thisRemoveBlock.classList.add(removeClass); +// } +// } +// } +// } +// } + +// function modalFormOpen(formOrNotification) { +// let buttons = document.querySelectorAll(formOrNotification), +// modal = document.querySelector('.modal'); + +// buttons.forEach(button => { +// button.onclick = function (eventButton) { +// let classOpenForm = button.dataset.form, +// form = modal.querySelector(`.${classOpenForm}`); + +// form.classList.add('active'); +// modal.classList.add('active'); +// } +// }) +// } + + +// function + + +// export function toggleOpenX(mainElement, buttonElement ,heightElement, contentElement, close) { +// let elements = document.querySelectorAll(mainElement); + +// elements.forEach(e => { +// let thisMainElement = e, +// thisButtonElement = e.querySelector(buttonElement), +// thisHeightElement = e.querySelector(heightElement), +// thisContentElement = e.querySelector(contentElement); + +// thisButtonElement.onclick = function (e) { +// let height = thisHeightElement.clientHeight; + +// if (close == true && !thisMainElement.classList.contains('active')) { +// elements.forEach(e => { +// if (e.classList.contains('active')) { +// e.classList.remove('active'); +// e.querySelector(contentElement).style.height = null +// } +// }) +// } + +// if (!thisMainElement.classList.contains('active')) { +// thisContentElement.style.height = `${height}px`; +// thisMainElement.classList.add('active'); +// }else{ +// thisContentElement.style.height = null; +// thisMainElement.classList.remove('active'); +// } +// } + +// }); +// } + +// export function toggleHeader(button, content, blockheight, removeBlock, removeClass) { +// let thisButton = document.querySelector(button), +// thisContent = document.querySelector(content), +// thisRemoveBlock = document.querySelector(removeBlock) || '', +// thisBlockheight = document.querySelector(blockheight); + +// thisButton.onclick = function () { +// let height = thisBlockheight.clientHeight; + +// if (!thisContent.classList .contains('open')) { +// thisContent.style.height = `${height}px`; +// thisContent.classList .add('open'); + +// if (removeBlock) { +// thisRemoveBlock.classList.remove(removeClass); +// } +// }else{ +// thisContent.style.height = null; +// thisContent.classList .remove('open'); + +// if (removeBlock) { +// if (window.scrollY <= 25) { +// thisRemoveBlock.classList.add(removeClass); +// } +// } +// } +// } +// } + +// export function modalFormOpen(formOrNotification) { +// let buttons = document.querySelectorAll(formOrNotification), +// modal = document.querySelector('.modal'); + +// buttons.forEach(button => { +// button.onclick = function (eventButton) { +// let classOpenForm = button.dataset.form, +// form = modal.querySelector(`.${classOpenForm}`); + +// form.classList.add('active'); +// modal.classList.add('active'); +// } +// }) +// } +// function \ No newline at end of file diff --git a/wp-content/themes/cosmopet/modules/profile/components/profile/component-controller.php b/wp-content/themes/cosmopet/modules/profile/components/profile/component-controller.php new file mode 100644 index 0000000..cd8e0a5 --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/components/profile/component-controller.php @@ -0,0 +1,188 @@ +user_firstname; +$context['last_name'] = $current_user->user_lastname; +$context['email'] = $current_user->user_email; +$context['phone'] = get_user_meta($current_user->ID, 'billing_phone', true); +$context['tg_account'] = get_user_meta($current_user->ID, 'tg_account', true); + +// ACF поля для пользователя +$context['activated'] = get_field('activated', 'user_' . get_current_user_id()); +$context['uuid'] = get_field('uuid', 'user_' . get_current_user_id()); + +// Запрос для питомцев +$current_user_id = get_current_user_id(); +if ($current_user_id) { + $args = [ + 'post_type' => 'pets', + 'meta_query' => [ + [ + 'key' => 'user', + 'value' => $current_user_id, + 'compare' => '=' + ] + ] + ]; + $context['pets'] = Timber::get_posts($args); +} + +// Заказы пользователя +$context['customer_orders'] = wc_get_orders(['customer_id' => $current_user->ID]); +// В page-profile.php, внутри цикла заказов + + + + + +// foreach ($context['customer_orders'] as &$order) { +// $meta_data = get_post_meta($order->get_id(), 'order_data', true); +// if (isset($meta_data['office_code'])) { +// $office_data = json_decode($api->getOffices(['code' => $meta_data['office_code']])['body'], true); +// $order->office_name = $office_data[0]['name'] ?? ''; +// } +// } + + + + +$context['bot_username'] = defined('BOT_USERNAME') ? BOT_USERNAME : ''; + +// Текущий пользователь +$current_user_id = get_current_user_id(); +$context['current_user_id'] = $current_user_id; + + + + + +// Запрос для питомцев +// if ($current_user_id) { +// $args = [ +// 'post_type' => 'pets', +// 'meta_query' => [ +// [ +// 'key' => 'user', +// 'value' => $current_user_id, +// 'compare' => '=' +// ] +// ] +// ]; +// $pets = Timber::get_posts($args); + +// // Обработка ACF-полей для каждого питомца +// foreach ($pets as &$pet) { +// // ACF-поля +// $pet->weight = get_field('weight', $pet->ID); +// $pet->old = get_field('old', $pet->ID); +// $pet->activity = get_field('activity', $pet->ID); + +// // Перевод веса +// switch ($pet->weight) { +// case 'below_1_5': +// $pet->weight_text = __('from 0,5 kg to 1,5 kg', 'woodmart'); +// break; +// case '1_5-3': +// $pet->weight_text = __('from 1.5 to 3 kg', 'woodmart'); +// break; +// case '3-5': +// $pet->weight_text = __('from 3 to 5 kg', 'woodmart'); +// break; +// case '5-8': +// $pet->weight_text = __('from 5 to 8 kg', 'woodmart'); +// break; +// case '8-11': +// $pet->weight_text = __('from 8 to 11 kg', 'woodmart'); +// break; +// case '11-15': +// $pet->weight_text = __('from 11 to 15 kg', 'woodmart'); +// break; +// case '15-20': +// $pet->weight_text = __('from 15 to 20 kg', 'woodmart'); +// break; +// case '20-25': +// $pet->weight_text = __('from 20 to 25 kg', 'woodmart'); +// break; +// case '25-35': +// $pet->weight_text = __('from 25 to 35 kg', 'woodmart'); +// break; +// case 'more_35': +// $pet->weight_text = __('More than 35 kg', 'woodmart'); +// break; +// default: +// $pet->weight_text = ''; +// } + +// // Перевод возраста +// switch ($pet->old) { +// case 'normal': +// $pet->old_text = __('Adult (from 1 year to 7 years)', 'woodmart'); +// break; +// case 'old': +// $pet->old_text = __('Elderly (from 7 to 12 years)', 'woodmart'); +// break; +// case 'very_old': +// $pet->old_text = __('Aging (12 years and older)', 'woodmart'); +// break; +// case 'baby': +// $pet->old_text = __('Baby (from 0 to 1 year)', 'woodmart'); +// break; +// default: +// $pet->old_text = ''; +// } + +// // Перевод активности +// switch ($pet->activity) { +// case 'low': +// $pet->activity_text = __('Low', 'woodmart'); +// break; +// case 'moderate': +// $pet->activity_text = __('Moderate', 'woodmart'); +// break; +// case 'high': +// $pet->activity_text = __('High', 'woodmart'); +// break; +// default: +// $pet->activity_text = ''; +// } +// } + +// $context['pets'] = $pets; +// } + + + + +// Месяцы для локализации +$context['months'] = [ + __('january', 'woodmart'), + __('february', 'woodmart'), + __('march', 'woodmart'), + __('april', 'woodmart'), + __('may', 'woodmart'), // Исправлено 'mail' на 'may' + __('june', 'woodmart'), + __('july', 'woodmart'), + __('august', 'woodmart'), + __('september', 'woodmart'), + __('october', 'woodmart'), + __('november', 'woodmart'), + __('december', 'woodmart'), +]; + + + +Timber::render('templates/profile/profile.twig', $context); +?> diff --git a/wp-content/themes/cosmopet/modules/profile/module-ajax-controller.php b/wp-content/themes/cosmopet/modules/profile/module-ajax-controller.php new file mode 100644 index 0000000..e1777fb --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/module-ajax-controller.php @@ -0,0 +1,133 @@ + get_current_user_id(), + 'first_name' => $_POST['name'], + 'last_name' => $_POST['l_name'], + + ) ); + + $phone = update_user_meta( get_current_user_id(), 'billing_phone', $_POST['full'] ); + +} + +function ajax_add_pet() { + $current_user = wp_get_current_user(); + // Подготовка данных + $pet_name = $_POST['name']; + $old_type = $_POST['old_type']; + if ($old_type == 'ex'){ + $old= $_POST['old']; + } + + $weight= $_POST['weight']; + $activity = $_POST['activity']; + $pet = $_POST['pet']; + $breed = $_POST['breed']; + $sex = $_POST['sex']; + $user = $current_user->ID; + + $post_data = array( + 'post_title' => $pet_name, + 'post_type' => 'pets', + 'post_status' => 'publish', + ); + + + $post_id = wp_insert_post($post_data); + var_dump($post_id); + if ($post_id) { + // Добавление мета-полей + if ($old_type == 'ex'){ + + update_field( 'old', $old, $post_id ); + + + } + else{ + + update_field( 'day', $_POST['day'], $post_id ); + update_field( 'month', $_POST['month'], $post_id ); + update_field( 'year', $_POST['year'], $post_id ); + } + update_field( 'weight', $weight, $post_id ); + update_field( 'breed', $breed, $post_id ); + update_field( 'sex', $sex, $post_id ); + update_field( 'type', $pet, $post_id ); + update_field( 'user', $user, $post_id ); + update_field( 'activity', $activity, $post_id ); + if($_POST['sterilized']=='1' && $pet=='cat'){ + update_field( 'sterilized', true ); + } + else{ + update_field( 'sterilized', false ); + } + wp_send_json_success('Питомец успешно добавлен!'); + } else { + wp_send_json_error('Ошибка при добавлении питомца.'); + } + + wp_die(); // Завершение работы +} +add_action('wp_ajax_add_pet', 'ajax_add_pet'); +add_action('wp_ajax_nopriv_add_pet', 'ajax_add_pet'); // Если нужно разрешить для незалогиненных пользователей + +function ajax_edit_pet() { + $current_user = wp_get_current_user(); + // Подготовка данных + $pet_name = $_POST['name']; + $old_type = $_POST['old_type']; + if ($old_type == 'ex'){ + $old= $_POST['old']; + } + else{ + $old_acc = $_POST['day'] . ' ' . $_POST['month'] . ' ' . $_POST['year']; + } + $weight= $_POST['weight']; + $activity = $_POST['activity']; + $pet = $_POST['pet']; + $breed = $_POST['breed']; + $sex = $_POST['sex']; + $user = $current_user->ID; + + $post_id = intval($_POST['pet_id']); + + if (get_field('user', $post_id) == $user) { + // Добавление мета-полей + if ($old_type == 'ex'){ + update_field( 'old', $old, $post_id ); + } + else{ + update_field( 'old', '', $post_id ); + update_field( 'day', $_POST['day'], $post_id ); + update_field( 'month', $_POST['month'], $post_id ); + update_field( 'year', $_POST['year'], $post_id ); + } + update_field( 'weight', $weight, $post_id ); + update_field( 'breed', $breed, $post_id ); + update_field( 'sex', $sex, $post_id ); + update_field( 'type', $pet, $post_id ); + update_field( 'activity', $activity, $post_id ); + if($_POST['sterilized']=='1' && $pet=='cat'){ + update_field( 'sterilized', true ); + } + else{ + update_field( 'sterilized', false ); + } + wp_send_json_success('Питомец успешно отредактирован!'); + } else { + wp_send_json_error('Ошибка при редактировании питомца.'); + } + + wp_die(); // Завершение работы +} +add_action('wp_ajax_edit_pet', 'ajax_edit_pet'); +add_action('wp_ajax_nopriv_edit_pet', 'ajax_edit_pet'); diff --git a/wp-content/themes/cosmopet/modules/profile/module-controller.php b/wp-content/themes/cosmopet/modules/profile/module-controller.php new file mode 100644 index 0000000..ab9a72c --- /dev/null +++ b/wp-content/themes/cosmopet/modules/profile/module-controller.php @@ -0,0 +1,178 @@ + array( + 'name' => 'Питомцы', // Основное название типа записи + 'singular_name' => 'Питомец', // отдельное название записи типа Book + 'add_new' => 'Добавить нового', + 'add_new_item' => 'Добавить нового питомца', + 'edit_item' => 'Редактировать питомца', + 'new_item' => 'Новый питомец', + 'view_item' => 'Посмотреть питомца', + 'search_items' => 'Найти питомца', + 'not_found' => 'Питомцев не найдено', + 'not_found_in_trash' => 'В корзине книг не найдено', + 'parent_item_colon' => '', + 'menu_name' => 'Питомцы' + + ), + 'public' => false, + 'show_ui' => true, + 'supports' => array('title','editor') +) ); +} + +function get_pet_card($item){ +?> + +
+
+
+
+
+ +
+
+ +

+
+ +
+

:

+

+
+
+

:

+

+
+ +
+

:

+

+
+ + + +
+

:

+

+
+ +
+

:

+

+
+ +
+

+ +
+ +
+ +
+
+
+ { + button.addEventListener('click', function(event) { + event.preventDefault(); // Предотвращаем стандартное действие (если это ссылка) + + // Находим элементы модального окна + const modal = document.querySelector('.modal'); + const modalAside = document.querySelector('.modal__aside'); + const modalLogin = document.querySelector('.modal__login'); + + // Добавляем классы active + modal.classList.add('active'); + modalLogin.classList.add('active'); + + // Устанавливаем ширину для modal__aside + modalAside.style.width = '412px'; + }); + }); + + // Опционально: добавляем функцию закрытия модального окна + // Например, при клике на фон или кнопку закрытия + const closeButtons = document.querySelectorAll('.modal-close'); + const modal = document.querySelector('.modal'); + + // Закрытие по клику на кнопку закрытия + closeButtons.forEach(button => { + button.addEventListener('click', closeModal); + }); + + // Закрытие по клику на фон (если клик не на модальное окно) + modal.addEventListener('click', function(event) { + if (event.target === modal) { + closeModal(); + } + }); + + function closeModal() { + const modal = document.querySelector('.modal'); + const modalAside = document.querySelector('.modal__aside'); + const modalLogin = document.querySelector('.modal__login'); + + // Удаляем классы active + modal.classList.remove('active'); + modalLogin.classList.remove('active'); + + // Сбрасываем ширину + modalAside.style.width = ''; + } + }); +======= document.addEventListener('DOMContentLoaded', function() { // Initialize Swiper @@ -535,4 +590,5 @@ document.addEventListener('DOMContentLoaded', function() { reviewPopup.style.display = 'none'; } }); -}); \ No newline at end of file +}); +>>>>>>> ec84500a88f048324cf2940bad3ba7528694953e diff --git a/wp-content/themes/cosmopet/templates/blog/blog-page.twig b/wp-content/themes/cosmopet/templates/blog/blog-page.twig new file mode 100644 index 0000000..ee4340e --- /dev/null +++ b/wp-content/themes/cosmopet/templates/blog/blog-page.twig @@ -0,0 +1,839 @@ +{% extends 'layout.twig' %} + +{% block content %} +{% set bodyClass = 'bg-white' %} + +
+
+
+

+ +

+
+

+
+ +
+ +
+
+
+
+ + +
+
+
+
+
+
+ user_firstname; + $last_name = $current_user->user_lastname;?> +

+ ID, 'billing_phone', true ); + + if($first_name || $last_name): + echo $first_name . ' ' . $last_name; + else: + ?> + + + +

+
+ +
+

:

+

+ + + +

+
+ +
+

:

+ user_email): ?> +

user_email ?>

+ +

+ +

+ + +

+ + + +
+ +
+ +
+ + ID, ' Traveling', true ); + ?> +
+

:

+

+ + + + + +

+
+ +
+
+ + + + + +
+
+
+
+ + 'pets', // Тип постов + 'meta_query' => array( + array( + 'key' => 'user', // Имя метаполя + 'value' => $current_user_id, // Значение метаполя (ID текущего пользователя) + 'compare' => '=' // Условие сравнения + ) + ) + ); + + // Создаем новый объект WP_Query + $query = new \WP_Query($args); + + if ($query->have_posts()) { + // Начинаем цикл по постам + while ($query->have_posts()) { + $query->the_post(); + get_pet_card($post); + } + // Сбрасываем данные постов + wp_reset_postdata(); + } + } + ?> + +
+
+ +
+
+
+
+
+
+

+ +

+
+

+
+ +
+ +
+
+
+ + $current_user->ID, + ) ); + + if ($customer_orders): + foreach($customer_orders as $order): + $meta_data = get_post_meta($order->get_id(), 'order_data', true); + $shipping_address = $order->get_address( 'shipping' ); + ?> +
+
+
+
+
+

get_date_created()->date('Y.m.d') ?>

+

get_id() ?>

+
+
+

:

+

get_total() ?>

+
+
+
+
+ +
+
+
+

+

+ '; + echo json_decode($api->getOffices(['code' => $meta_data['office_code']])['body'])[0]->name; + ?> + + +

+
+ +
+
+ get_items() as $item_id => $item) : + $product_name = $item->get_name(); + $product_quantity = $item->get_quantity(); + $product_total = $item->get_total(); + $product = $item->get_product(); + + if ($product){ + $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $product->get_id() ), 'thumbnail' ); + } + else{ + $thumbnail = ''; + } + ?> +
+ + +
+
+

+ +
+ +

+ +

+
+
+ +
+ + +
+
+
+ + +
+ +
+ get_items() as $item_id => $item) : + $product = $item->get_product(); + if ($product){ + $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $product->get_id() ), 'thumbnail' ); + } + else{ + $thumbnail = ''; + } + ?> + + + + +
+
+
+
+
+ +
+
+

+
+
+ +

+
+
+
+ +
+
+
+ + 'pets', // Тип постов + 'meta_query' => array( + array( + 'key' => 'user', // Имя метаполя + 'value' => $current_user_id, // Значение метаполя (ID текущего пользователя) + 'compare' => '=' // Условие сравнения + ) + ) +); + +// Создаем новый объект WP_Query +$query = new \WP_Query($args); + +if ($query->have_posts()) { + // Начинаем цикл по постам + while ($query->have_posts()) { + $query->the_post(); + + switch (get_field('weight')){ + case ('below_1_5'): + $w = esc_html__('from 0,5 kg to 1,5 kg', '_pll_e' ); + break; + case ('1_5-3'): + $w = esc_html__('from 1.5 to 3 kg', '_pll_e' ); + break; + case ('3-5'): + $w = esc_html__('from 3 to 5 kg', '_pll_e' ); + break; + case ('5-8'): + $w = esc_html__('from 5 to 8 kg', '_pll_e' ); + break; + case ('8-11'): + $w = esc_html__('from 8 to 11 kg', '_pll_e' ); + break; + case ('11-15'): + $w = esc_html__('from 11 to 15 kg', '_pll_e' ); + break; + case ('15-20'): + $w = esc_html__('from 15 to 20 kg', '_pll_e' ); + break; + case ('20-25'): + $w = esc_html__('from 20 to 25 kg', '_pll_e' ); + break; + case ('25-35'): + $w = esc_html__('from 25 to 35 kg', '_pll_e' ); + break; + case ('more_35'): + $w = esc_html__('More than 35 kg', '_pll_e' ); + break; + } + switch (get_field('old')){ + case ('normal'): + $old = __('Adult (from 1 year to 7 years)', '_pll_e' ); + break; + case ('old'): + $old = __('Elderly (from 7 to 12 years)', '_pll_e' ); + break; + case ('very_old'): + $old = __('Aging (12 years and older)', '_pll_e' ); + break; + case ('baby'): + $old = __('Baby (from 0 to 1 year)', '_pll_e' ); + break; + } + switch (get_field('activity')){ + case ('low'): + $act = esc_html__('Low', '_pll_e' ); + break; + case ('moderate'): + $act = esc_html__('Moderate', '_pll_e' ); + break; + case ('high'): + $act = esc_html__('High', '_pll_e' ); + break; + } + ?> + + +
+