From 90181a7818e5b7e7262bee50aefc6430eb57498b Mon Sep 17 00:00:00 2001 From: GuilhermeLinkNacional Date: Fri, 7 Nov 2025 15:56:17 -0300 Subject: [PATCH 1/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Removendo=20plugin=20c?= =?UTF-8?q?hecker?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Includes/GiveMultiCurrency.php | 10 - Includes/plugin-updater/Puc/Autoloader.php | 57 -- .../plugin-updater/Puc/InstalledPackage.php | 102 -- Includes/plugin-updater/Puc/Metadata.php | 131 --- Includes/plugin-updater/Puc/Plugin/Info.php | 131 --- .../plugin-updater/Puc/Plugin/Package.php | 205 ---- Includes/plugin-updater/Puc/Plugin/Ui.php | 282 ------ Includes/plugin-updater/Puc/Plugin/Update.php | 112 --- .../Puc/Plugin/UpdateChecker.php | 410 -------- Includes/plugin-updater/Puc/Scheduler.php | 254 ----- Includes/plugin-updater/Puc/StateStore.php | 220 ---- Includes/plugin-updater/Puc/Update.php | 37 - Includes/plugin-updater/Puc/UpdateChecker.php | 949 ------------------ .../plugin-updater/Puc/UpgraderStatus.php | 176 ---- Includes/plugin-updater/Puc/Utils.php | 71 -- .../languages/plugin-update-checker-ca.mo | Bin 1186 -> 0 bytes .../languages/plugin-update-checker-ca.po | 48 - .../languages/plugin-update-checker-pt_BR.mo | Bin 1014 -> 0 bytes .../languages/plugin-update-checker-pt_BR.po | 48 - .../languages/plugin-update-checker.pot | 49 - Includes/plugin-updater/license.txt | 7 - Includes/plugin-updater/load-puc.php | 6 - .../plugin-updater/plugin-update-checker.php | 10 - give-currency.php | 1 - 24 files changed, 3316 deletions(-) delete mode 100755 Includes/plugin-updater/Puc/Autoloader.php delete mode 100755 Includes/plugin-updater/Puc/InstalledPackage.php delete mode 100755 Includes/plugin-updater/Puc/Metadata.php delete mode 100755 Includes/plugin-updater/Puc/Plugin/Info.php delete mode 100755 Includes/plugin-updater/Puc/Plugin/Package.php delete mode 100755 Includes/plugin-updater/Puc/Plugin/Ui.php delete mode 100755 Includes/plugin-updater/Puc/Plugin/Update.php delete mode 100755 Includes/plugin-updater/Puc/Plugin/UpdateChecker.php delete mode 100755 Includes/plugin-updater/Puc/Scheduler.php delete mode 100755 Includes/plugin-updater/Puc/StateStore.php delete mode 100755 Includes/plugin-updater/Puc/Update.php delete mode 100755 Includes/plugin-updater/Puc/UpdateChecker.php delete mode 100755 Includes/plugin-updater/Puc/UpgraderStatus.php delete mode 100755 Includes/plugin-updater/Puc/Utils.php delete mode 100755 Includes/plugin-updater/languages/plugin-update-checker-ca.mo delete mode 100755 Includes/plugin-updater/languages/plugin-update-checker-ca.po delete mode 100755 Includes/plugin-updater/languages/plugin-update-checker-pt_BR.mo delete mode 100755 Includes/plugin-updater/languages/plugin-update-checker-pt_BR.po delete mode 100755 Includes/plugin-updater/languages/plugin-update-checker.pot delete mode 100755 Includes/plugin-updater/license.txt delete mode 100755 Includes/plugin-updater/load-puc.php delete mode 100755 Includes/plugin-updater/plugin-update-checker.php diff --git a/Includes/GiveMultiCurrency.php b/Includes/GiveMultiCurrency.php index 987861f..568adcc 100755 --- a/Includes/GiveMultiCurrency.php +++ b/Includes/GiveMultiCurrency.php @@ -160,7 +160,6 @@ private function admin_hooks(): void $plugin_admin = new GiveMultiCurrencyAdmin(); $this->loader->add_filter('give_get_settings_general', $plugin_admin, 'lkn_give_multi_currency_add_setting_into_existing_tab'); $this->loader->add_filter('give_metabox_form_data_settings', $plugin_admin, 'setup_setting', 999); - $this->loader->add_action("give_init", $this, "lkn_give_multi_currency_updater"); $this->loader->add_action('givewp_register_payment_gateway', $this, 'register_gateways_paypal', 999); } @@ -200,13 +199,4 @@ public function register_gateways_paypal(PaymentGatewayRegister $registrar) $registrar->registerGateway(GiveMultiCurrencyPaypalGateway::class); } } - - public function lkn_give_multi_currency_updater() - { - return new Lkn_Puc_Plugin_UpdateChecker( - 'https://api.linknacional.com/v2/u/?slug=give-multimoeda', - GIVE_MULTI_CURRENCY_FILE,//(caso o plugin não precise de compatibilidade com ioncube utilize: __FILE__), //Full path to the main plugin file or functions.php. - 'give-multimoeda' - ); - } } diff --git a/Includes/plugin-updater/Puc/Autoloader.php b/Includes/plugin-updater/Puc/Autoloader.php deleted file mode 100755 index ec85114..0000000 --- a/Includes/plugin-updater/Puc/Autoloader.php +++ /dev/null @@ -1,57 +0,0 @@ -rootDir = dirname(__FILE__) . '/'; - $nameParts = explode('_', __CLASS__, 3); - $this->prefix = $nameParts[0] . '_' . $nameParts[1] . '_'; - - $this->libraryDir = $this->rootDir . '../..'; - if ( !self::isPhar() ) { - $this->libraryDir = realpath($this->libraryDir); - } - $this->libraryDir = $this->libraryDir . '/'; - - spl_autoload_register([$this, 'autoload']); - } - - /** - * Determine if this file is running as part of a Phar archive. - * - * @return bool - */ - private static function isPhar() { - //Check if the current file path starts with "phar://". - static $pharProtocol = 'phar://'; - return (substr(__FILE__, 0, strlen($pharProtocol)) === $pharProtocol); - } - - public function autoload($className) { - if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) { - /** @noinspection PhpIncludeInspection */ - include $this->libraryDir . $this->staticMap[$className]; - return; - } - - if (strpos($className, $this->prefix) === 0) { - $path = substr($className, strlen($this->prefix)); - $path = str_replace('_', '/', $path); - $path = $this->rootDir . $path . '.php'; - - if (file_exists($path)) { - /** @noinspection PhpIncludeInspection */ - include $path; - } - } - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/InstalledPackage.php b/Includes/plugin-updater/Puc/InstalledPackage.php deleted file mode 100755 index 6fa4f75..0000000 --- a/Includes/plugin-updater/Puc/InstalledPackage.php +++ /dev/null @@ -1,102 +0,0 @@ -updateChecker = $updateChecker; - } - - /** - * Get the currently installed version of the plugin or theme. - * - * @return string|null Version number. - */ - abstract public function getInstalledVersion(); - - /** - * Get the full path of the plugin or theme directory (without a trailing slash). - * - * @return string - */ - abstract public function getAbsoluteDirectoryPath(); - - /** - * Check whether a regular file exists in the package's directory. - * - * @param string $relativeFileName File name relative to the package directory. - * @return bool - */ - public function fileExists($relativeFileName) { - return is_file( - $this->getAbsoluteDirectoryPath() - . DIRECTORY_SEPARATOR - . ltrim($relativeFileName, '/\\') - ); - } - - /* ------------------------------------------------------------------- - * File header parsing - * ------------------------------------------------------------------- - */ - - /** - * Parse plugin or theme metadata from the header comment. - * - * This is basically a simplified version of the get_file_data() function from /wp-includes/functions.php. - * It's intended as a utility for subclasses that detect updates by parsing files in a VCS. - * - * @param string|null $content File contents. - * @return string[] - */ - public function getFileHeader($content) { - $content = (string)$content; - - //WordPress only looks at the first 8 KiB of the file, so we do the same. - $content = substr($content, 0, 8192); - //Normalize line endings. - $content = str_replace("\r", "\n", $content); - - $headers = $this->getHeaderNames(); - $results = []; - foreach ($headers as $field => $name) { - $success = preg_match('/^[ \t\/*#@]*' . preg_quote($name, '/') . ':(.*)$/mi', $content, $matches); - - if ( ($success === 1) && $matches[1] ) { - $value = $matches[1]; - if ( function_exists('_cleanup_header_comment') ) { - $value = _cleanup_header_comment($value); - } - $results[$field] = $value; - } else { - $results[$field] = ''; - } - } - - return $results; - } - - /** - * @return array Format: ['HeaderKey' => 'Header Name'] - */ - abstract protected function getHeaderNames(); - - /** - * Get the value of a specific plugin or theme header. - * - * @param string $headerName - * @return string Either the value of the header, or an empty string if the header doesn't exist. - */ - abstract public function getHeaderValue($headerName); - } -endif; diff --git a/Includes/plugin-updater/Puc/Metadata.php b/Includes/plugin-updater/Puc/Metadata.php deleted file mode 100755 index cb974d1..0000000 --- a/Includes/plugin-updater/Puc/Metadata.php +++ /dev/null @@ -1,131 +0,0 @@ -validateMetadata($apiResponse); - if ( is_wp_error($valid) ) { - do_action('puc_api_error', $valid); - trigger_error($valid->get_error_message(), E_USER_NOTICE); - return false; - } - - foreach (get_object_vars($apiResponse) as $key => $value) { - $target->$key = $value; - } - - return true; - } - - /** - * No validation by default! Subclasses should check that the required fields are present. - * - * @param StdClass $apiResponse - * @return bool|WP_Error - */ - protected function validateMetadata(/** @noinspection PhpUnusedParameterInspection */ $apiResponse) { - return true; - } - - /** - * Create a new instance by copying the necessary fields from another object. - * - * @abstract - * @param StdClass|self $object The source object. - * @return self The new copy. - */ - public static function fromObject(/** @noinspection PhpUnusedParameterInspection */ $object) { - throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses'); - } - - /** - * Create an instance of StdClass that can later be converted back to an - * update or info container. Useful for serialization and caching, as it - * avoids the "incomplete object" problem if the cached value is loaded - * before this class. - * - * @return StdClass - */ - public function toStdClass() { - $object = new stdClass(); - $this->copyFields($this, $object); - return $object; - } - - /** - * Transform the metadata into the format used by WordPress core. - * - * @return object - */ - abstract public function toWpFormat(); - - /** - * Copy known fields from one object to another. - * - * @param StdClass|self $from - * @param StdClass|self $to - */ - protected function copyFields($from, $to) { - $fields = $this->getFieldNames(); - - if ( property_exists($from, 'slug') && !empty($from->slug) ) { - //Let plugins add extra fields without having to create subclasses. - $fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields); - } - - foreach ($fields as $field) { - if ( property_exists($from, $field) ) { - $to->$field = $from->$field; - } - } - } - - /** - * @return string[] - */ - protected function getFieldNames() { - return []; - } - - /** - * @param string $tag - * @return string - */ - protected function getPrefixedFilter($tag) { - return 'puc_' . $tag; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/Plugin/Info.php b/Includes/plugin-updater/Puc/Plugin/Info.php deleted file mode 100755 index fde1e0c..0000000 --- a/Includes/plugin-updater/Puc/Plugin/Info.php +++ /dev/null @@ -1,131 +0,0 @@ -sections = (array)$instance->sections; - $instance->icons = (array)$instance->icons; - - return $instance; - } - - /** - * Very, very basic validation. - * - * @param StdClass $apiResponse - * @return bool|WP_Error - */ - protected function validateMetadata($apiResponse) { - if ( - !isset($apiResponse->name, $apiResponse->version) - || empty($apiResponse->name) - || empty($apiResponse->version) - ) { - return new WP_Error( - 'puc-invalid-metadata', - "The plugin metadata file does not contain the required 'name' and/or 'version' keys." - ); - } - return true; - } - - /** - * Transform plugin info into the format used by the native WordPress.org API - * - * @return object - */ - public function toWpFormat() { - $info = new stdClass; - - //The custom update API is built so that many fields have the same name and format - //as those returned by the native WordPress.org API. These can be assigned directly. - $sameFormat = [ - 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice', - 'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated', - 'requires_php', - ]; - foreach ($sameFormat as $field) { - if ( isset($this->$field) ) { - $info->$field = $this->$field; - } else { - $info->$field = null; - } - } - - //Other fields need to be renamed and/or transformed. - $info->download_link = $this->download_url; - $info->author = $this->getFormattedAuthor(); - $info->sections = array_merge(['description' => ''], $this->sections); - - if ( !empty($this->banners) ) { - //WP expects an array with two keys: "high" and "low". Both are optional. - //Docs: https://wordpress.org/plugins/about/faq/#banners - $info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners; - $info->banners = array_intersect_key($info->banners, ['high' => true, 'low' => true]); - } - - return $info; - } - - protected function getFormattedAuthor() { - if ( !empty($this->author_homepage) ) { - /** @noinspection HtmlUnknownTarget */ - return sprintf('%s', $this->author_homepage, $this->author); - } - return $this->author; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/Plugin/Package.php b/Includes/plugin-updater/Puc/Plugin/Package.php deleted file mode 100755 index f51076d..0000000 --- a/Includes/plugin-updater/Puc/Plugin/Package.php +++ /dev/null @@ -1,205 +0,0 @@ -pluginAbsolutePath = $pluginAbsolutePath; - $this->pluginFile = plugin_basename($this->pluginAbsolutePath); - - parent::__construct($updateChecker); - - //Clear the version number cache when something - anything - is upgraded or WP clears the update cache. - add_filter('upgrader_post_install', [$this, 'clearCachedVersion']); - add_action('delete_site_transient_update_plugins', [$this, 'clearCachedVersion']); - } - - public function getInstalledVersion() { - if ( isset($this->cachedInstalledVersion) ) { - return $this->cachedInstalledVersion; - } - - $pluginHeader = $this->getPluginHeader(); - if ( isset($pluginHeader['Version']) ) { - $this->cachedInstalledVersion = $pluginHeader['Version']; - return $pluginHeader['Version']; - } else { - //This can happen if the filename points to something that is not a plugin. - $this->updateChecker->triggerError( - sprintf( - "Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.", - $this->updateChecker->pluginFile - ), - E_USER_WARNING - ); - return null; - } - } - - /** - * Clear the cached plugin version. This method can be set up as a filter (hook) and will - * return the filter argument unmodified. - * - * @param mixed $filterArgument - * @return mixed - */ - public function clearCachedVersion($filterArgument = null) { - $this->cachedInstalledVersion = null; - return $filterArgument; - } - - public function getAbsoluteDirectoryPath() { - return dirname($this->pluginAbsolutePath); - } - - /** - * Get the value of a specific plugin or theme header. - * - * @param string $headerName - * @param string $defaultValue - * @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty. - */ - public function getHeaderValue($headerName, $defaultValue = '') { - $headers = $this->getPluginHeader(); - if ( isset($headers[$headerName]) && ($headers[$headerName] !== '') ) { - return $headers[$headerName]; - } - return $defaultValue; - } - - protected function getHeaderNames() { - return [ - 'Name' => 'Plugin Name', - 'PluginURI' => 'Plugin URI', - 'Version' => 'Version', - 'Description' => 'Description', - 'Author' => 'Author', - 'AuthorURI' => 'Author URI', - 'TextDomain' => 'Text Domain', - 'DomainPath' => 'Domain Path', - 'Network' => 'Network', - - //The newest WordPress version that this plugin requires or has been tested with. - //We support several different formats for compatibility with other libraries. - 'Tested WP' => 'Tested WP', - 'Requires WP' => 'Requires WP', - 'Tested up to' => 'Tested up to', - 'Requires at least' => 'Requires at least', - ]; - } - - /** - * Get the translated plugin title. - * - * @return string - */ - public function getPluginTitle() { - $title = ''; - $header = $this->getPluginHeader(); - if ( $header && !empty($header['Name']) && isset($header['TextDomain']) ) { - $title = translate($header['Name'], $header['TextDomain']); - } - return $title; - } - - /** - * Get plugin's metadata from its file header. - * - * @return array - */ - public function getPluginHeader() { - if ( !is_file($this->pluginAbsolutePath) ) { - //This can happen if the plugin filename is wrong. - $this->updateChecker->triggerError( - sprintf( - "Can't to read the plugin header for '%s'. The file does not exist.", - $this->updateChecker->pluginFile - ), - E_USER_WARNING - ); - return []; - } - - if ( !function_exists('get_plugin_data') ) { - /** @noinspection PhpIncludeInspection */ - require_once ABSPATH . '/wp-admin/includes/plugin.php'; - } - return get_plugin_data($this->pluginAbsolutePath, false, false); - } - - public function removeHooks() { - remove_filter('upgrader_post_install', [$this, 'clearCachedVersion']); - remove_action('delete_site_transient_update_plugins', [$this, 'clearCachedVersion']); - } - - /** - * Check if the plugin file is inside the mu-plugins directory. - * - * @return bool - */ - public function isMuPlugin() { - static $cachedResult = null; - - if ( $cachedResult === null ) { - if ( !defined('WPMU_PLUGIN_DIR') || !is_string(WPMU_PLUGIN_DIR) ) { - $cachedResult = false; - return $cachedResult; - } - - //Convert both paths to the canonical form before comparison. - $muPluginDir = realpath(WPMU_PLUGIN_DIR); - $pluginPath = realpath($this->pluginAbsolutePath); - //If realpath() fails, just normalize the syntax instead. - if (($muPluginDir === false) || ($pluginPath === false)) { - $muPluginDir = self::normalizePath(WPMU_PLUGIN_DIR); - $pluginPath = self::normalizePath($this->pluginAbsolutePath); - } - - $cachedResult = (strpos($pluginPath, $muPluginDir) === 0); - } - - return $cachedResult; - } - - /** - * - * Normalize a filesystem path. Introduced in WP 3.9. - * Copying here allows use of the class on earlier versions. - * This version adapted from WP 4.8.2 (unchanged since 4.5.0) - * - * @param string $path Path to normalize. - * @return string Normalized path. - */ - public static function normalizePath($path) { - if ( function_exists('wp_normalize_path') ) { - return wp_normalize_path($path); - } - $path = str_replace('\\', '/', $path); - $path = preg_replace('|(?<=.)/+|', '/', $path); - if ( substr($path, 1, 1) === ':' ) { - $path = ucfirst($path); - } - return $path; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/Plugin/Ui.php b/Includes/plugin-updater/Puc/Plugin/Ui.php deleted file mode 100755 index 3625b0d..0000000 --- a/Includes/plugin-updater/Puc/Plugin/Ui.php +++ /dev/null @@ -1,282 +0,0 @@ -updateChecker = $updateChecker; - $this->manualCheckErrorTransient = $this->updateChecker->getUniqueName('manual_check_errors'); - - add_action('admin_init', [$this, 'onAdminInit']); - } - - public function onAdminInit() { - if ( $this->updateChecker->userCanInstallUpdates() ) { - $this->handleManualCheck(); - - add_filter('plugin_row_meta', [$this, 'addViewDetailsLink'], 10, 3); - add_filter('plugin_row_meta', [$this, 'addCheckForUpdatesLink'], 10, 2); - add_action('all_admin_notices', [$this, 'displayManualCheckResult']); - } - } - - /** - * Add a "View Details" link to the plugin row in the "Plugins" page. By default, - * the new link will appear before the "Visit plugin site" link (if present). - * - * You can change the link text by using the "puc_view_details_link-$slug" filter. - * Returning an empty string from the filter will disable the link. - * - * You can change the position of the link using the - * "puc_view_details_link_position-$slug" filter. - * Returning 'before' or 'after' will place the link immediately before/after - * the "Visit plugin site" link. - * Returning 'append' places the link after any existing links at the time of the hook. - * Returning 'replace' replaces the "Visit plugin site" link. - * Returning anything else disables the link when there is a "Visit plugin site" link. - * - * If there is no "Visit plugin site" link 'append' is always used! - * - * @param array $pluginMeta Array of meta links. - * @param string $pluginFile - * @param array $pluginData Array of plugin header data. - * @return array - */ - public function addViewDetailsLink($pluginMeta, $pluginFile, $pluginData = []) { - if ( $this->isMyPluginFile($pluginFile) && !isset($pluginData['slug']) ) { - $linkText = apply_filters($this->updateChecker->getUniqueName('view_details_link'), __('View details')); - if ( !empty($linkText) ) { - $viewDetailsLinkPosition = 'append'; - - //Find the "Visit plugin site" link (if present). - $visitPluginSiteLinkIndex = count($pluginMeta) - 1; - if ( $pluginData['PluginURI'] ) { - $escapedPluginUri = esc_url($pluginData['PluginURI']); - foreach ($pluginMeta as $linkIndex => $existingLink) { - if ( strpos($existingLink, $escapedPluginUri) !== false ) { - $visitPluginSiteLinkIndex = $linkIndex; - $viewDetailsLinkPosition = apply_filters( - $this->updateChecker->getUniqueName('view_details_link_position'), - 'before' - ); - break; - } - } - } - - $viewDetailsLink = sprintf('%s', - esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin=' . urlencode($this->updateChecker->slug) . - '&TB_iframe=true&width=600&height=550')), - esc_attr(sprintf(__('More information about %s'), $pluginData['Name'])), - esc_attr($pluginData['Name']), - $linkText - ); - switch ($viewDetailsLinkPosition) { - case 'before': - array_splice($pluginMeta, $visitPluginSiteLinkIndex, 0, $viewDetailsLink); - break; - case 'after': - array_splice($pluginMeta, $visitPluginSiteLinkIndex + 1, 0, $viewDetailsLink); - break; - case 'replace': - $pluginMeta[$visitPluginSiteLinkIndex] = $viewDetailsLink; - break; - case 'append': - default: - $pluginMeta[] = $viewDetailsLink; - break; - } - } - } - return $pluginMeta; - } - - /** - * Add a "Check for updates" link to the plugin row in the "Plugins" page. By default, - * the new link will appear after the "Visit plugin site" link if present, otherwise - * after the "View plugin details" link. - * - * You can change the link text by using the "puc_manual_check_link-$slug" filter. - * Returning an empty string from the filter will disable the link. - * - * @param array $pluginMeta Array of meta links. - * @param string $pluginFile - * @return array - */ - public function addCheckForUpdatesLink($pluginMeta, $pluginFile) { - if ( $this->isMyPluginFile($pluginFile) ) { - $linkUrl = wp_nonce_url( - add_query_arg( - [ - 'puc_check_for_updates' => 1, - 'puc_slug' => $this->updateChecker->slug, - ], - self_admin_url('plugins.php') - ), - 'puc_check_for_updates' - ); - - $linkText = apply_filters( - $this->updateChecker->getUniqueName('manual_check_link'), - __('Check for updates', 'plugin-update-checker') - ); - if ( !empty($linkText) ) { - /** @noinspection HtmlUnknownTarget */ - $pluginMeta[] = sprintf('%s', esc_attr($linkUrl), $linkText); - } - } - return $pluginMeta; - } - - protected function isMyPluginFile($pluginFile) { - return ($pluginFile == $this->updateChecker->pluginFile) - || (!empty($this->updateChecker->muPluginFile) && ($pluginFile == $this->updateChecker->muPluginFile)); - } - - /** - * Check for updates when the user clicks the "Check for updates" link. - * - * @see self::addCheckForUpdatesLink() - * - * @return void - */ - public function handleManualCheck() { - $shouldCheck = - isset($_GET['puc_check_for_updates'], $_GET['puc_slug']) - && $_GET['puc_slug'] == $this->updateChecker->slug - && check_admin_referer('puc_check_for_updates'); - - if ( $shouldCheck ) { - $update = $this->updateChecker->checkForUpdates(); - $status = ($update === null) ? 'no_update' : 'update_available'; - $lastRequestApiErrors = $this->updateChecker->getLastRequestApiErrors(); - - if ( ($update === null) && !empty($lastRequestApiErrors) ) { - //Some errors are not critical. For example, if PUC tries to retrieve the readme.txt - //file from GitHub and gets a 404, that's an API error, but it doesn't prevent updates - //from working. Maybe the plugin simply doesn't have a readme. - //Let's only show important errors. - $foundCriticalErrors = false; - $questionableErrorCodes = [ - 'puc-github-http-error', - 'puc-gitlab-http-error', - 'puc-bitbucket-http-error', - ]; - - foreach ($lastRequestApiErrors as $item) { - $wpError = $item['error']; - /** @var WP_Error $wpError */ - if ( !in_array($wpError->get_error_code(), $questionableErrorCodes) ) { - $foundCriticalErrors = true; - break; - } - } - - if ( $foundCriticalErrors ) { - $status = 'error'; - set_site_transient($this->manualCheckErrorTransient, $lastRequestApiErrors, 60); - } - } - - wp_redirect(add_query_arg( - [ - 'puc_update_check_result' => $status, - 'puc_slug' => $this->updateChecker->slug, - ], - self_admin_url('plugins.php') - )); - exit; - } - } - - /** - * Display the results of a manual update check. - * - * @see self::handleManualCheck() - * - * You can change the result message by using the "puc_manual_check_message-$slug" filter. - */ - public function displayManualCheckResult() { - if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->updateChecker->slug) ) { - $status = strval($_GET['puc_update_check_result']); - $title = $this->updateChecker->getInstalledPackage()->getPluginTitle(); - $noticeClass = 'updated notice-success'; - $details = ''; - - if ( $status == 'no_update' ) { - $message = sprintf(_x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title); - } else { - if ( $status == 'update_available' ) { - $message = sprintf(_x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title); - } else { - if ( $status === 'error' ) { - $message = sprintf(_x('Could not determine if updates are available for %s.', 'the plugin title', 'plugin-update-checker'), $title); - $noticeClass = 'error notice-error'; - - $details = $this->formatManualCheckErrors(get_site_transient($this->manualCheckErrorTransient)); - delete_site_transient($this->manualCheckErrorTransient); - } else { - $message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status)); - $noticeClass = 'error notice-error'; - } - } - } - printf( - '

%s

%s
', - $noticeClass, - apply_filters($this->updateChecker->getUniqueName('manual_check_message'), $message, $status), - $details - ); - } - } - - /** - * Format the list of errors that were thrown during an update check. - * - * @param array $errors - * @return string - */ - protected function formatManualCheckErrors($errors) { - if ( empty($errors) ) { - return ''; - } - $output = ''; - - $showAsList = count($errors) > 1; - if ( $showAsList ) { - $output .= '
    '; - $formatString = '
  1. %1$s %2$s
  2. '; - } else { - $formatString = '

    %1$s %2$s

    '; - } - foreach ($errors as $item) { - $wpError = $item['error']; - /** @var WP_Error $wpError */ - $output .= sprintf( - $formatString, - $wpError->get_error_message(), - $wpError->get_error_code() - ); - } - if ( $showAsList ) { - $output .= '
'; - } - - return $output; - } - - public function removeHooks() { - remove_action('admin_init', [$this, 'onAdminInit']); - remove_filter('plugin_row_meta', [$this, 'addViewDetailsLink'], 10); - remove_filter('plugin_row_meta', [$this, 'addCheckForUpdatesLink'], 10); - remove_action('all_admin_notices', [$this, 'displayManualCheckResult']); - } - } -endif; diff --git a/Includes/plugin-updater/Puc/Plugin/Update.php b/Includes/plugin-updater/Puc/Plugin/Update.php deleted file mode 100755 index 165bc35..0000000 --- a/Includes/plugin-updater/Puc/Plugin/Update.php +++ /dev/null @@ -1,112 +0,0 @@ -copyFields($object, $update); - return $update; - } - - /** - * @return string[] - */ - protected function getFieldNames() { - return array_merge(parent::getFieldNames(), self::$extraFields); - } - - /** - * Transform the update into the format used by WordPress native plugin API. - * - * @return object - */ - public function toWpFormat() { - $update = parent::toWpFormat(); - - $update->id = $this->id; - $update->url = $this->homepage; - $update->tested = $this->tested; - $update->requires_php = $this->requires_php; - $update->plugin = $this->filename; - - if ( !empty($this->upgrade_notice) ) { - $update->upgrade_notice = $this->upgrade_notice; - } - - if ( !empty($this->icons) && is_array($this->icons) ) { - //This should be an array with up to 4 keys: 'svg', '1x', '2x' and 'default'. - //Docs: https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-icons - $icons = array_intersect_key( - $this->icons, - ['svg' => true, '1x' => true, '2x' => true, 'default' => true] - ); - if ( !empty($icons) ) { - $update->icons = $icons; - - //It appears that the 'default' icon isn't used anywhere in WordPress 4.9, - //but lets set it just in case a future release needs it. - if ( !isset($update->icons['default']) ) { - $update->icons['default'] = current($update->icons); - } - } - } - - return $update; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/Plugin/UpdateChecker.php b/Includes/plugin-updater/Puc/Plugin/UpdateChecker.php deleted file mode 100755 index 2412a40..0000000 --- a/Includes/plugin-updater/Puc/Plugin/UpdateChecker.php +++ /dev/null @@ -1,410 +0,0 @@ -pluginAbsolutePath = $pluginFile; - $this->pluginFile = plugin_basename($this->pluginAbsolutePath); - $this->muPluginFile = $muPluginFile; - - //If no slug is specified, use the name of the main plugin file as the slug. - //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'. - if ( empty($slug) ) { - $slug = basename($this->pluginFile, '.php'); - } - - //Plugin slugs must be unique. - $slugCheckFilter = 'puc_is_slug_in_use-' . $slug; - $slugUsedBy = apply_filters($slugCheckFilter, false); - if ( $slugUsedBy ) { - $this->triggerError(sprintf( - 'Plugin slug "%s" is already in use by %s. Slugs must be unique.', - htmlentities($slug), - htmlentities($slugUsedBy) - ), E_USER_ERROR); - } - add_filter($slugCheckFilter, [$this, 'getAbsolutePath']); - - parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName); - - //Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume - //it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir). - if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) { - $this->muPluginFile = $this->pluginFile; - } - - //To prevent a crash during plugin uninstallation, remove updater hooks when the user removes the plugin. - //Details: https://github.com/YahnisElsts/plugin-update-checker/issues/138#issuecomment-335590964 - add_action('uninstall_' . $this->pluginFile, [$this, 'removeHooks']); - - $this->extraUi = new Lkn_Puc_Plugin_Ui($this); - } - - /** - * Create an instance of the scheduler. - * - * @param int $checkPeriod - * @return Lkn_Puc_Scheduler - */ - protected function createScheduler($checkPeriod) { - $scheduler = new Lkn_Puc_Scheduler($this, $checkPeriod, ['load-plugins.php']); - register_deactivation_hook($this->pluginFile, [$scheduler, 'removeUpdaterCron']); - return $scheduler; - } - - /** - * Install the hooks required to run periodic update checks and inject update info - * into WP data structures. - * - * @return void - */ - protected function installHooks() { - //Override requests for plugin information - add_filter('plugins_api', [$this, 'injectInfo'], 20, 3); - - parent::installHooks(); - } - - /** - * Remove update checker hooks. - * - * The intent is to prevent a fatal error that can happen if the plugin has an uninstall - * hook. During uninstallation, WP includes the main plugin file (which creates a PUC instance), - * the uninstall hook runs, WP deletes the plugin files and then updates some transients. - * If PUC hooks are still around at this time, they could throw an error while trying to - * autoload classes from files that no longer exist. - * - * The "site_transient_{$transient}" filter is the main problem here, but let's also remove - * most other PUC hooks to be safe. - * - * @internal - */ - public function removeHooks() { - parent::removeHooks(); - $this->extraUi->removeHooks(); - $this->package->removeHooks(); - - remove_filter('plugins_api', [$this, 'injectInfo'], 20); - } - - /** - * Retrieve plugin info from the configured API endpoint. - * - * @uses wp_remote_get() - * - * @param array $queryArgs Additional query arguments to append to the request. Optional. - * @return Lkn_Puc_Plugin_Info - */ - public function requestInfo($queryArgs = []) { - list($pluginInfo, $result) = $this->requestMetadata('Lkn_Puc_Plugin_Info', $queryArgs); - - if ( $pluginInfo !== null ) { - /** @var Lkn_Puc_Plugin_Info $pluginInfo */ - $pluginInfo->filename = $this->pluginFile; - $pluginInfo->slug = $this->slug; - } - - $pluginInfo = apply_filters($this->getUniqueName('request_info_result'), $pluginInfo, $result); - return $pluginInfo; - } - - /** - * Retrieve the latest update (if any) from the configured API endpoint. - * - * @uses PluginUpdateChecker::requestInfo() - * - * @return Lkn_Puc_Update|null An instance of Plugin_Update, or NULL when no updates are available. - */ - public function requestUpdate() { - //For the sake of simplicity, this function just calls requestInfo() - //and transforms the result accordingly. - $pluginInfo = $this->requestInfo(['checking_for_updates' => '1']); - if ( $pluginInfo === null ) { - return null; - } - $update = Lkn_Puc_Plugin_Update::fromPluginInfo($pluginInfo); - - $update = $this->filterUpdateResult($update); - - return $update; - } - - /** - * Intercept plugins_api() calls that request information about our plugin and - * use the configured API endpoint to satisfy them. - * - * @see plugins_api() - * - * @param mixed $result - * @param string $action - * @param array|object $args - * @return mixed - */ - public function injectInfo($result, $action = null, $args = null) { - $relevant = ($action == 'plugin_information') && isset($args->slug) && ( - ($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile)) - ); - if ( !$relevant ) { - return $result; - } - - $pluginInfo = $this->requestInfo(); - $this->fixSupportedWordpressVersion($pluginInfo); - - $pluginInfo = apply_filters($this->getUniqueName('pre_inject_info'), $pluginInfo); - if ( $pluginInfo ) { - return $pluginInfo->toWpFormat(); - } - - return $result; - } - - protected function shouldShowUpdates() { - //No update notifications for mu-plugins unless explicitly enabled. The MU plugin file - //is usually different from the main plugin file so the update wouldn't show up properly anyway. - return !$this->isUnknownMuPlugin(); - } - - /** - * @param stdClass|null $updates - * @param stdClass $updateToAdd - * @return stdClass - */ - protected function addUpdateToList($updates, $updateToAdd) { - if ( $this->package->isMuPlugin() ) { - //WP does not support automatic update installation for mu-plugins, but we can - //still display a notice. - $updateToAdd->package = null; - } - return parent::addUpdateToList($updates, $updateToAdd); - } - - /** - * @param stdClass|null $updates - * @return stdClass|null - */ - protected function removeUpdateFromList($updates) { - $updates = parent::removeUpdateFromList($updates); - if ( !empty($this->muPluginFile) && isset($updates, $updates->response) ) { - unset($updates->response[$this->muPluginFile]); - } - return $updates; - } - - /** - * For plugins, the update array is indexed by the plugin filename relative to the "plugins" - * directory. Example: "plugin-name/plugin.php". - * - * @return string - */ - protected function getUpdateListKey() { - if ( $this->package->isMuPlugin() ) { - return $this->muPluginFile; - } - return $this->pluginFile; - } - - protected function getNoUpdateItemFields() { - return array_merge( - parent::getNoUpdateItemFields(), - [ - 'id' => $this->pluginFile, - 'slug' => $this->slug, - 'plugin' => $this->pluginFile, - 'icons' => [], - 'banners' => [], - 'banners_rtl' => [], - 'tested' => '', - 'compatibility' => new stdClass(), - ] - ); - } - - /** - * Alias for isBeingUpgraded(). - * - * @deprecated - * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update. - * @return bool - */ - public function isPluginBeingUpgraded($upgrader = null) { - return $this->isBeingUpgraded($upgrader); - } - - /** - * Is there an update being installed for this plugin, right now? - * - * @param WP_Upgrader|null $upgrader - * @return bool - */ - public function isBeingUpgraded($upgrader = null) { - return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader); - } - - /** - * Get the details of the currently available update, if any. - * - * If no updates are available, or if the last known update version is below or equal - * to the currently installed version, this method will return NULL. - * - * Uses cached update data. To retrieve update information straight from - * the metadata URL, call requestUpdate() instead. - * - * @return Lkn_Puc_Plugin_Update|null - */ - public function getUpdate() { - $update = parent::getUpdate(); - if ( isset($update) ) { - /** @var Lkn_Puc_Plugin_Update $update */ - $update->filename = $this->pluginFile; - } - return $update; - } - - /** - * Get the translated plugin title. - * - * @deprecated - * @return string - */ - public function getPluginTitle() { - return $this->package->getPluginTitle(); - } - - /** - * Check if the current user has the required permissions to install updates. - * - * @return bool - */ - public function userCanInstallUpdates() { - return current_user_can('update_plugins'); - } - - /** - * Check if the plugin file is inside the mu-plugins directory. - * - * @deprecated - * @return bool - */ - protected function isMuPlugin() { - return $this->package->isMuPlugin(); - } - - /** - * MU plugins are partially supported, but only when we know which file in mu-plugins - * corresponds to this plugin. - * - * @return bool - */ - protected function isUnknownMuPlugin() { - return empty($this->muPluginFile) && $this->package->isMuPlugin(); - } - - /** - * Get absolute path to the main plugin file. - * - * @return string - */ - public function getAbsolutePath() { - return $this->pluginAbsolutePath; - } - - /** - * Register a callback for filtering query arguments. - * - * The callback function should take one argument - an associative array of query arguments. - * It should return a modified array of query arguments. - * - * @uses add_filter() This method is a convenience wrapper for add_filter(). - * - * @param callable $callback - * @return void - */ - public function addQueryArgFilter($callback) { - $this->addFilter('request_info_query_args', $callback); - } - - /** - * Register a callback for filtering arguments passed to wp_remote_get(). - * - * The callback function should take one argument - an associative array of arguments - - * and return a modified array or arguments. See the WP documentation on wp_remote_get() - * for details on what arguments are available and how they work. - * - * @uses add_filter() This method is a convenience wrapper for add_filter(). - * - * @param callable $callback - * @return void - */ - public function addHttpRequestArgFilter($callback) { - $this->addFilter('request_info_options', $callback); - } - - /** - * Register a callback for filtering the plugin info retrieved from the external API. - * - * The callback function should take two arguments. If the plugin info was retrieved - * successfully, the first argument passed will be an instance of PluginInfo. Otherwise, - * it will be NULL. The second argument will be the corresponding return value of - * wp_remote_get (see WP docs for details). - * - * The callback function should return a new or modified instance of PluginInfo or NULL. - * - * @uses add_filter() This method is a convenience wrapper for add_filter(). - * - * @param callable $callback - * @return void - */ - public function addResultFilter($callback) { - $this->addFilter('request_info_result', $callback, 10, 2); - } - - /** - * Create a package instance that represents this plugin or theme. - * - * @return Lkn_Puc_InstalledPackage - */ - protected function createInstalledPackage() { - return new Lkn_Puc_Plugin_Package($this->pluginAbsolutePath, $this); - } - - /** - * @return Lkn_Puc_Plugin_Package - */ - public function getInstalledPackage() { - return $this->package; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/Scheduler.php b/Includes/plugin-updater/Puc/Scheduler.php deleted file mode 100755 index 74347c2..0000000 --- a/Includes/plugin-updater/Puc/Scheduler.php +++ /dev/null @@ -1,254 +0,0 @@ -updateChecker = $updateChecker; - $this->checkPeriod = $checkPeriod; - - //Set up the periodic update checks - $this->cronHook = $this->updateChecker->getUniqueName('cron_check_updates'); - if ( $this->checkPeriod > 0 ) { - //Trigger the check via Cron. - //Try to use one of the default schedules if possible as it's less likely to conflict - //with other plugins and their custom schedules. - $defaultSchedules = [ - 1 => 'hourly', - 12 => 'twicedaily', - 24 => 'daily', - ]; - if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) { - $scheduleName = $defaultSchedules[$this->checkPeriod]; - } else { - //Use a custom cron schedule. - $scheduleName = 'every' . $this->checkPeriod . 'hours'; - add_filter('cron_schedules', [$this, '_addCustomSchedule']); - } - - if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) { - //Randomly offset the schedule to help prevent update server traffic spikes. Without this - //most checks may happen during times of day when people are most likely to install new plugins. - $firstCheckTime = time() - rand(0, max($this->checkPeriod * 3600 - 15 * 60, 1)); - $firstCheckTime = apply_filters( - $this->updateChecker->getUniqueName('first_check_time'), - $firstCheckTime - ); - wp_schedule_event($firstCheckTime, $scheduleName, $this->cronHook); - } - add_action($this->cronHook, [$this, 'maybeCheckForUpdates']); - - //In case Cron is disabled or unreliable, we also manually trigger - //the periodic checks while the user is browsing the Dashboard. - add_action( 'admin_init', [$this, 'maybeCheckForUpdates'] ); - - //Like WordPress itself, we check more often on certain pages. - /** @see wp_update_plugins */ - add_action('load-update-core.php', [$this, 'maybeCheckForUpdates']); - //"load-update.php" and "load-plugins.php" or "load-themes.php". - $this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks); - foreach ($this->hourlyCheckHooks as $hook) { - add_action($hook, [$this, 'maybeCheckForUpdates']); - } - //This hook fires after a bulk update is complete. - add_action('upgrader_process_complete', [$this, 'upgraderProcessComplete'], 11, 2); - } else { - //Periodic checks are disabled. - wp_clear_scheduled_hook($this->cronHook); - } - } - - /** - * Runs upon the WP action upgrader_process_complete. - * - * We look at the parameters to decide whether to call maybeCheckForUpdates() or not. - * We also check if the update checker has been removed by the update. - * - * @param WP_Upgrader $upgrader WP_Upgrader instance - * @param array $upgradeInfo extra information about the upgrade - */ - public function upgraderProcessComplete( - /** @noinspection PhpUnusedParameterInspection */ - $upgrader, $upgradeInfo - ) { - //Cancel all further actions if the current version of PUC has been deleted or overwritten - //by a different version during the upgrade. If we try to do anything more in that situation, - //we could trigger a fatal error by trying to autoload a deleted class. - clearstatcache(); - if ( !file_exists(__FILE__) ) { - $this->removeHooks(); - $this->updateChecker->removeHooks(); - return; - } - - //Sanity check and limitation to relevant types. - if ( - !is_array($upgradeInfo) || !isset($upgradeInfo['type'], $upgradeInfo['action']) - || 'update' !== $upgradeInfo['action'] || !in_array($upgradeInfo['type'], ['plugin', 'theme']) - ) { - return; - } - - if ( is_a($this->updateChecker, 'Lkn_Puc_Plugin_UpdateChecker') ) { - if ( 'plugin' !== $upgradeInfo['type'] || !isset($upgradeInfo['plugins']) ) { - return; - } - - //Themes pass in directory names in the information array, but plugins use the relative plugin path. - if ( !in_array( - strtolower($this->updateChecker->directoryName), - array_map('dirname', array_map('strtolower', $upgradeInfo['plugins'])) - ) ) { - return; - } - } - - $this->maybeCheckForUpdates(); - } - - /** - * Check for updates if the configured check interval has already elapsed. - * Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron. - * - * You can override the default behaviour by using the "puc_check_now-$slug" filter. - * The filter callback will be passed three parameters: - * - Current decision. TRUE = check updates now, FALSE = don't check now. - * - Last check time as a Unix timestamp. - * - Configured check period in hours. - * Return TRUE to check for updates immediately, or FALSE to cancel. - * - * This method is declared public because it's a hook callback. Calling it directly is not recommended. - */ - public function maybeCheckForUpdates() { - if ( empty($this->checkPeriod) ) { - return; - } - - $state = $this->updateChecker->getUpdateState(); - $shouldCheck = ($state->timeSinceLastCheck() >= $this->getEffectiveCheckPeriod()); - - //Let plugin authors substitute their own algorithm. - $shouldCheck = apply_filters( - $this->updateChecker->getUniqueName('check_now'), - $shouldCheck, - $state->getLastCheck(), - $this->checkPeriod - ); - - if ( $shouldCheck ) { - $this->updateChecker->checkForUpdates(); - } - } - - /** - * Calculate the actual check period based on the current status and environment. - * - * @return int Check period in seconds. - */ - protected function getEffectiveCheckPeriod() { - $currentFilter = current_filter(); - if ( in_array($currentFilter, ['load-update-core.php', 'upgrader_process_complete']) ) { - //Check more often when the user visits "Dashboard -> Updates" or does a bulk update. - $period = 60; - } else { - if ( in_array($currentFilter, $this->hourlyCheckHooks) ) { - //Also check more often on /wp-admin/update.php and the "Plugins" or "Themes" page. - $period = 3600; - } else { - if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) { - //Check less frequently if it's already known that an update is available. - $period = $this->throttledCheckPeriod * 3600; - } else { - if ( defined('DOING_CRON') && constant('DOING_CRON') ) { - //WordPress cron schedules are not exact, so lets do an update check even - //if slightly less than $checkPeriod hours have elapsed since the last check. - $cronFuzziness = 20 * 60; - $period = $this->checkPeriod * 3600 - $cronFuzziness; - } else { - $period = $this->checkPeriod * 3600; - } - } - } - } - - return $period; - } - - /** - * Add our custom schedule to the array of Cron schedules used by WP. - * - * @param array $schedules - * @return array - */ - public function _addCustomSchedule($schedules) { - if ( $this->checkPeriod && ($this->checkPeriod > 0) ) { - $scheduleName = 'every' . $this->checkPeriod . 'hours'; - $schedules[$scheduleName] = [ - 'interval' => $this->checkPeriod * 3600, - 'display' => sprintf('Every %d hours', $this->checkPeriod), - ]; - } - return $schedules; - } - - /** - * Remove the scheduled cron event that the library uses to check for updates. - * - * @return void - */ - public function removeUpdaterCron() { - wp_clear_scheduled_hook($this->cronHook); - } - - /** - * Get the name of the update checker's WP-cron hook. Mostly useful for debugging. - * - * @return string - */ - public function getCronHookName() { - return $this->cronHook; - } - - /** - * Remove most hooks added by the scheduler. - */ - public function removeHooks() { - remove_filter('cron_schedules', [$this, '_addCustomSchedule']); - remove_action('admin_init', [$this, 'maybeCheckForUpdates']); - remove_action('load-update-core.php', [$this, 'maybeCheckForUpdates']); - - if ( $this->cronHook !== null ) { - remove_action($this->cronHook, [$this, 'maybeCheckForUpdates']); - } - if ( !empty($this->hourlyCheckHooks) ) { - foreach ($this->hourlyCheckHooks as $hook) { - remove_action($hook, [$this, 'maybeCheckForUpdates']); - } - } - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/StateStore.php b/Includes/plugin-updater/Puc/StateStore.php deleted file mode 100755 index 5300832..0000000 --- a/Includes/plugin-updater/Puc/StateStore.php +++ /dev/null @@ -1,220 +0,0 @@ -optionName = $optionName; - } - - /** - * Get time elapsed since the last update check. - * - * If there are no recorded update checks, this method returns a large arbitrary number - * (i.e. time since the Unix epoch). - * - * @return int Elapsed time in seconds. - */ - public function timeSinceLastCheck() { - $this->lazyLoad(); - return time() - $this->lastCheck; - } - - /** - * @return int - */ - public function getLastCheck() { - $this->lazyLoad(); - return $this->lastCheck; - } - - /** - * Set the time of the last update check to the current timestamp. - * - * @return $this - */ - public function setLastCheckToNow() { - $this->lazyLoad(); - $this->lastCheck = time(); - return $this; - } - - /** - * @return null|Lkn_Puc_Update - */ - public function getUpdate() { - $this->lazyLoad(); - return $this->update; - } - - /** - * @param Lkn_Puc_Update|null $update - * @return $this - */ - public function setUpdate(Lkn_Puc_Update $update = null) { - $this->lazyLoad(); - $this->update = $update; - return $this; - } - - /** - * @return string - */ - public function getCheckedVersion() { - $this->lazyLoad(); - return $this->checkedVersion; - } - - /** - * @param string $version - * @return $this - */ - public function setCheckedVersion($version) { - $this->lazyLoad(); - $this->checkedVersion = strval($version); - return $this; - } - - /** - * Get translation updates. - * - * @return array - */ - public function getTranslations() { - $this->lazyLoad(); - if ( isset($this->update, $this->update->translations) ) { - return $this->update->translations; - } - return []; - } - - /** - * Set translation updates. - * - * @param array $translationUpdates - */ - public function setTranslations($translationUpdates) { - $this->lazyLoad(); - if ( isset($this->update) ) { - $this->update->translations = $translationUpdates; - $this->save(); - } - } - - /** - * Saves the updated state of the plugin on the database - */ - public function save() { - $state = new stdClass(); - - $state->lastCheck = $this->lastCheck; - $state->checkedVersion = $this->checkedVersion; - - if ( isset($this->update)) { - $state->update = $this->update->toStdClass(); - - $updateClass = get_class($this->update); - $state->updateClass = $updateClass; - $prefix = $this->getLibPrefix(); - if ( Lkn_Puc_Utils::startsWith($updateClass, $prefix) ) { - $state->updateBaseClass = substr($updateClass, strlen($prefix)); - } - } - - update_site_option($this->optionName, $state); - $this->isLoaded = true; - } - - /** - * Checks if the database already has a state - * - * @return $this - */ - public function lazyLoad() { - if ( !$this->isLoaded ) { - $this->load(); - } - return $this; - } - - /** - * Load the state version - */ - protected function load() { - $this->isLoaded = true; - - $state = get_site_option($this->optionName, null); - - if ( !is_object($state) ) { - $this->lastCheck = 0; - $this->checkedVersion = ''; - $this->update = null; - return; - } - - $this->lastCheck = intval(Lkn_Puc_Utils::get($state, 'lastCheck', 0)); - $this->checkedVersion = Lkn_Puc_Utils::get($state, 'checkedVersion', ''); - $this->update = null; - - if ( isset($state->update) ) { - //This mess is due to the fact that the want the update class from this version - //of the library, not the version that saved the update. - - $updateClass = null; - if ( isset($state->updateBaseClass) ) { - $updateClass = $this->getLibPrefix() . $state->updateBaseClass; - } else { - if ( isset($state->updateClass) && class_exists($state->updateClass) ) { - $updateClass = $state->updateClass; - } - } - - if ( $updateClass !== null ) { - $this->update = call_user_func([$updateClass, 'fromObject'], $state->update); - } - } - } - - /** - * Delete the option name from database - */ - public function delete() { - delete_site_option($this->optionName); - - $this->lastCheck = 0; - $this->checkedVersion = ''; - $this->update = null; - } - - private function getLibPrefix() { - $parts = explode('_', __CLASS__, 3); - return $parts[0] . '_' . $parts[1] . '_'; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/Update.php b/Includes/plugin-updater/Puc/Update.php deleted file mode 100755 index c8ad6ba..0000000 --- a/Includes/plugin-updater/Puc/Update.php +++ /dev/null @@ -1,37 +0,0 @@ -slug = $this->slug; - $update->new_version = $this->version; - $update->package = $this->download_url; - - return $update; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/UpdateChecker.php b/Includes/plugin-updater/Puc/UpdateChecker.php deleted file mode 100755 index d0c6b10..0000000 --- a/Includes/plugin-updater/Puc/UpdateChecker.php +++ /dev/null @@ -1,949 +0,0 @@ -debugMode = (bool)(constant('WP_DEBUG')); - $this->metadataUrl = $metadataUrl; - $this->directoryName = $directoryName; - $this->slug = !empty($slug) ? $slug : $this->directoryName; - - $this->optionName = $optionName; - if ( empty($this->optionName) ) { - //BC: Initially the library only supported plugin updates and didn't use type prefixes - //in the option name. Lets use the same prefix-less name when possible. - if ( $this->filterSuffix === '' ) { - $this->optionName = 'external_updates-' . $this->slug; - } else { - $this->optionName = $this->getUniqueName('external_updates'); - } - } - - $this->package = $this->createInstalledPackage(); - $this->scheduler = $this->createScheduler($checkPeriod); - $this->upgraderStatus = new Lkn_Puc_UpgraderStatus(); - $this->updateState = new Lkn_Puc_StateStore($this->optionName); - - if ( did_action('init') ) { - $this->loadTextDomain(); - } else { - add_action('init', [$this, 'loadTextDomain']); - } - - $this->installHooks(); - } - - /** - * @internal - */ - public function loadTextDomain() { - //We're not using load_plugin_textdomain() or its siblings because figuring out where - //the library is located (plugin, mu-plugin, theme, custom wp-content paths) is messy. - $domain = 'plugin-update-checker'; - $locale = apply_filters( - 'plugin_locale', - (is_admin() && function_exists('get_user_locale')) ? get_user_locale() : get_locale(), - $domain - ); - - $moFile = $domain . '-' . $locale . '.mo'; - $path = realpath(dirname(__FILE__) . '/../languages'); - - if ($path && file_exists($path)) { - load_textdomain($domain, $path . '/' . $moFile); - } - } - - protected function installHooks() { - //Insert our update info into the update array maintained by WP. - add_filter('site_transient_' . $this->updateTransient, [$this, 'injectUpdate']); - - //Insert translation updates into the update list. - add_filter('site_transient_' . $this->updateTransient, [$this, 'injectTranslationUpdates']); - - //Clear translation updates when WP clears the update cache. - //This needs to be done directly because the library doesn't actually remove obsolete plugin updates, - //it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O. - add_action( - 'delete_site_transient_' . $this->updateTransient, - [$this, 'clearCachedTranslationUpdates'] - ); - - //Rename the update directory to be the same as the existing directory. - if ( $this->directoryName !== '.' ) { - add_filter('upgrader_source_selection', [$this, 'fixDirectoryName'], 10, 3); - } - - //Allow HTTP requests to the metadata URL even if it's on a local host. - add_filter('http_request_host_is_external', [$this, 'allowMetadataHost'], 10, 2); - } - - /** - * Remove hooks that were added by this update checker instance. - */ - public function removeHooks() { - remove_filter('site_transient_' . $this->updateTransient, [$this, 'injectUpdate']); - remove_filter('site_transient_' . $this->updateTransient, [$this, 'injectTranslationUpdates']); - remove_action( - 'delete_site_transient_' . $this->updateTransient, - [$this, 'clearCachedTranslationUpdates'] - ); - - remove_filter('upgrader_source_selection', [$this, 'fixDirectoryName'], 10); - remove_filter('http_request_host_is_external', [$this, 'allowMetadataHost'], 10); - - remove_action('init', [$this, 'loadTextDomain']); - - if ( $this->scheduler ) { - $this->scheduler->removeHooks(); - } - } - - /** - * Check if the current user has the required permissions to install updates. - * - * @return bool - */ - abstract public function userCanInstallUpdates(); - - /** - * Explicitly allow HTTP requests to the metadata URL. - * - * WordPress has a security feature where the HTTP API will reject all requests that are sent to - * another site hosted on the same server as the current site (IP match), a local host, or a local - * IP, unless the host exactly matches the current site. - * - * This feature is opt-in (at least in WP 4.4). Apparently some people enable it. - * - * That can be a problem when you're developing your plugin and you decide to host the update information - * on the same server as your test site. Update requests will mysteriously fail. - * - * We fix that by adding an exception for the metadata host. - * - * @param bool $allow - * @param string $host - * @return bool - */ - public function allowMetadataHost($allow, $host) { - if ( $this->cachedMetadataHost === 0 ) { - $this->cachedMetadataHost = parse_url($this->metadataUrl, PHP_URL_HOST); - } - - if ( is_string($this->cachedMetadataHost) && (strtolower($host) === strtolower($this->cachedMetadataHost)) ) { - return true; - } - return $allow; - } - - /** - * Create a package instance that represents this plugin or theme. - * - * @return Lkn_Puc_InstalledPackage - */ - abstract protected function createInstalledPackage(); - - /** - * @return Lkn_Puc_InstalledPackage - */ - public function getInstalledPackage() { - return $this->package; - } - - /** - * Create an instance of the scheduler. - * - * This is implemented as a method to make it possible for plugins to subclass the update checker - * and substitute their own scheduler. - * - * @param int $checkPeriod - * @return Lkn_Puc_Scheduler - */ - abstract protected function createScheduler($checkPeriod); - - /** - * Check for updates. The results are stored in the DB option specified in $optionName. - * - * @return Lkn_Puc_Update|null - */ - public function checkForUpdates() { - $installedVersion = $this->getInstalledVersion(); - //Fail silently if we can't find the plugin/theme or read its header. - if ( $installedVersion === null ) { - $this->triggerError( - sprintf('Skipping update check for %s - installed version unknown.', $this->slug), - E_USER_WARNING - ); - return null; - } - - //Start collecting API errors. - $this->lastRequestApiErrors = []; - add_action('puc_api_error', [$this, 'collectApiErrors'], 10, 4); - - $state = $this->updateState; - $state->setLastCheckToNow() - ->setCheckedVersion($installedVersion) - ->save(); //Save before checking in case something goes wrong - - $state->setUpdate($this->requestUpdate()); - $state->save(); - - //Stop collecting API errors. - remove_action('puc_api_error', [$this, 'collectApiErrors'], 10); - - return $this->getUpdate(); - } - - /** - * Load the update checker state from the DB. - * - * @return Lkn_Puc_StateStore - */ - public function getUpdateState() { - return $this->updateState->lazyLoad(); - } - - /** - * Reset update checker state - i.e. last check time, cached update data and so on. - * - * Call this when your plugin is being uninstalled, or if you want to - * clear the update cache. - */ - public function resetUpdateState() { - $this->updateState->delete(); - } - - /** - * Get the details of the currently available update, if any. - * - * If no updates are available, or if the last known update version is below or equal - * to the currently installed version, this method will return NULL. - * - * Uses cached update data. To retrieve update information straight from - * the metadata URL, call requestUpdate() instead. - * - * @return Lkn_Puc_Update|null - */ - public function getUpdate() { - $update = $this->updateState->getUpdate(); - - //Is there an update available? - if ( isset($update) ) { - //Check if the update is actually newer than the currently installed version. - $installedVersion = $this->getInstalledVersion(); - if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ) { - return $update; - } - } - return null; - } - - /** - * Retrieve the latest update (if any) from the configured API endpoint. - * - * Subclasses should run the update through filterUpdateResult before returning it. - * - * @return Lkn_Puc_Update An instance of Update, or NULL when no updates are available. - */ - abstract public function requestUpdate(); - - /** - * Filter the result of a requestUpdate() call. - * - * @param Lkn_Puc_Update|null $update - * @param array|WP_Error|null $httpResult The value returned by wp_remote_get(), if any. - * @return Lkn_Puc_Update - */ - protected function filterUpdateResult($update, $httpResult = null) { - //Let plugins/themes modify the update. - $update = apply_filters($this->getUniqueName('request_update_result'), $update, $httpResult); - - $this->fixSupportedWordpressVersion($update); - - if ( isset($update, $update->translations) ) { - //Keep only those translation updates that apply to this site. - $update->translations = $this->filterApplicableTranslations($update->translations); - } - - return $update; - } - - /** - * The "Tested up to" field in the plugin metadata is supposed to be in the form of "major.minor", - * while WordPress core's list_plugin_updates() expects the $update->tested field to be an exact - * version, e.g. "major.minor.patch", to say it's compatible. In other case it shows - * "Compatibility: Unknown". - * The function mimics how wordpress.org API crafts the "tested" field out of "Tested up to". - * - * @param Lkn_Puc_Metadata|null $update - */ - protected function fixSupportedWordpressVersion(Lkn_Puc_Metadata $update = null) { - if ( !isset($update->tested) || !preg_match('/^\d++\.\d++$/', $update->tested) ) { - return; - } - - $actualWpVersions = []; - - $wpVersion = $GLOBALS['wp_version']; - - if ( function_exists('get_core_updates') ) { - $coreUpdates = get_core_updates(); - if ( is_array($coreUpdates) ) { - foreach ($coreUpdates as $coreUpdate) { - if ( isset($coreUpdate->current) ) { - $actualWpVersions[] = $coreUpdate->current; - } - } - } - } - - $actualWpVersions[] = $wpVersion; - - $actualWpPatchNumber = null; - foreach ($actualWpVersions as $version) { - if ( preg_match('/^(?P\d++\.\d++)(?:\.(?P\d++))?/', $version, $versionParts) ) { - if ( $versionParts['majorMinor'] === $update->tested ) { - $patch = isset($versionParts['patch']) ? intval($versionParts['patch']) : 0; - if ( $actualWpPatchNumber === null ) { - $actualWpPatchNumber = $patch; - } else { - $actualWpPatchNumber = max($actualWpPatchNumber, $patch); - } - } - } - } - if ( $actualWpPatchNumber === null ) { - $actualWpPatchNumber = 999; - } - - if ( $actualWpPatchNumber > 0 ) { - $update->tested .= '.' . $actualWpPatchNumber; - } - } - - /** - * Get the currently installed version of the plugin or theme. - * - * @return string|null Version number. - */ - public function getInstalledVersion() { - return $this->package->getInstalledVersion(); - } - - /** - * Get the full path of the plugin or theme directory. - * - * @return string - */ - public function getAbsoluteDirectoryPath() { - return $this->package->getAbsoluteDirectoryPath(); - } - - /** - * Trigger a PHP error, but only when $debugMode is enabled. - * - * @param string $message - * @param int $errorType - */ - public function triggerError($message, $errorType) { - if ( $this->isDebugModeEnabled() ) { - trigger_error($message, $errorType); - } - } - - /** - * @return bool - */ - protected function isDebugModeEnabled() { - if ( $this->debugMode === null ) { - $this->debugMode = (bool)(constant('WP_DEBUG')); - } - return $this->debugMode; - } - - /** - * Get the full name of an update checker filter, action or DB entry. - * - * This method adds the "puc_" prefix and the "-$slug" suffix to the filter name. - * For example, "pre_inject_update" becomes "puc_pre_inject_update-plugin-slug". - * - * @param string $baseTag - * @return string - */ - public function getUniqueName($baseTag) { - $name = 'puc_' . $baseTag; - if ( $this->filterSuffix !== '' ) { - $name .= '_' . $this->filterSuffix; - } - return $name . '-' . $this->slug; - } - - /** - * Store API errors that are generated when checking for updates. - * - * @internal - * @param WP_Error $error - * @param array|null $httpResponse - * @param string|null $url - * @param string|null $slug - */ - public function collectApiErrors($error, $httpResponse = null, $url = null, $slug = null) { - if ( isset($slug) && ($slug !== $this->slug) ) { - return; - } - - $this->lastRequestApiErrors[] = [ - 'error' => $error, - 'httpResponse' => $httpResponse, - 'url' => $url, - ]; - } - - /** - * @return array - */ - public function getLastRequestApiErrors() { - return $this->lastRequestApiErrors; - } - - /* ------------------------------------------------------------------- - * PUC filters and filter utilities - * ------------------------------------------------------------------- - */ - - /** - * Register a callback for one of the update checker filters. - * - * Identical to add_filter(), except it automatically adds the "puc_" prefix - * and the "-$slug" suffix to the filter name. For example, "request_info_result" - * becomes "puc_request_info_result-your_plugin_slug". - * - * @param string $tag - * @param callable $callback - * @param int $priority - * @param int $acceptedArgs - */ - public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) { - add_filter($this->getUniqueName($tag), $callback, $priority, $acceptedArgs); - } - - /* ------------------------------------------------------------------- - * Inject updates - * ------------------------------------------------------------------- - */ - - /** - * Insert the latest update (if any) into the update list maintained by WP. - * - * @param stdClass $updates Update list. - * @return stdClass Modified update list. - */ - public function injectUpdate($updates) { - //Is there an update to insert? - $update = $this->getUpdate(); - - if ( !$this->shouldShowUpdates() ) { - $update = null; - } - - if ( !empty($update) ) { - //Let plugins update is passed to WordPress. - $updates = $this->addUpdateToList($updates, $update->toWpFormat()); - } else { - //Clean up any stale update info. - $updates = $this->removeUpdateFromList($updates); - //Add a placeholder item to the "no_update" list to enable auto-update support. - //If we don't do this, the option to enable automatic updates will only show up - //when an update is available. - $updates = $this->addNoUpdateItem($updates); - } - - return $updates; - } - - /** - * @param stdClass|null $updates - * @param stdClass|array $updateToAdd - * @return stdClass - */ - protected function addUpdateToList($updates, $updateToAdd) { - if ( !is_object($updates) ) { - $updates = new stdClass(); - $updates->response = []; - } - - $updates->response[$this->getUpdateListKey()] = $updateToAdd; - return $updates; - } - - /** - * @param stdClass|null $updates - * @return stdClass|null - */ - protected function removeUpdateFromList($updates) { - if ( isset($updates, $updates->response) ) { - unset($updates->response[$this->getUpdateListKey()]); - } - return $updates; - } - - /** - * See this post for more information: - * @link https://make.wordpress.org/core/2020/07/30/recommended-usage-of-the-updates-api-to-support-the-auto-updates-ui-for-plugins-and-themes-in-wordpress-5-5/ - * - * @param stdClass|null $updates - * @return stdClass - */ - protected function addNoUpdateItem($updates) { - if ( !is_object($updates) ) { - $updates = new stdClass(); - $updates->response = []; - $updates->no_update = []; - } else { - if ( !isset($updates->no_update) ) { - $updates->no_update = []; - } - } - - $updates->no_update[$this->getUpdateListKey()] = (object) $this->getNoUpdateItemFields(); - - return $updates; - } - - /** - * Subclasses should override this method to add fields that are specific to plugins or themes. - * @return array - */ - protected function getNoUpdateItemFields() { - return [ - 'new_version' => $this->getInstalledVersion(), - 'url' => '', - 'package' => '', - 'requires_php' => '', - ]; - } - - /** - * Get the key that will be used when adding updates to the update list that's maintained - * by the WordPress core. The list is always an associative array, but the key is different - * for plugins and themes. - * - * @return string - */ - abstract protected function getUpdateListKey(); - - /** - * Should we show available updates? - * - * Usually the answer is "yes", but there are exceptions. For example, WordPress doesn't - * support automatic updates installation for mu-plugins, so PUC usually won't show update - * notifications in that case. See the plugin-specific subclass for details. - * - * Note: This method only applies to updates that are displayed (or not) in the WordPress - * admin. It doesn't affect APIs like requestUpdate and getUpdate. - * - * @return bool - */ - protected function shouldShowUpdates() { - return true; - } - - /* ------------------------------------------------------------------- - * JSON-based update API - * ------------------------------------------------------------------- - */ - - /** - * Retrieve plugin or theme metadata from the JSON document at $this->metadataUrl. - * - * @param string $metaClass Parse the JSON as an instance of this class. It must have a static fromJson method. - * @param array $queryArgs Additional query arguments. - * @return array [Lkn_Puc_Metadata|null, array|WP_Error] A metadata instance and the value returned by wp_remote_get(). - */ - protected function requestMetadata($metaClass, $queryArgs = []) { - //Query args to append to the URL. - $queryArgs = array_merge( - [ - 'installed_version' => strval($this->getInstalledVersion()), - 'php' => phpversion(), - 'locale' => get_locale(), - 's' => '4823a0e58074af39154f19e3de1f7443', - ], - $queryArgs - ); - - //Various options for the wp_remote_get() call. - $options = [ - 'timeout' => 10, //seconds - 'headers' => [ - 'Accept' => 'application/json', - ], - ]; - - //The metadata file should be at 'http://your-api.com/url/here/$slug/info.json' - $url = $this->metadataUrl; - if ( !empty($queryArgs) ) { - $url = add_query_arg($queryArgs, $url); - } - - $result = wp_remote_get($url, $options); - - //Try to parse the response - $status = $this->validateApiResponse($result); - $metadata = null; - if ( !is_wp_error($status) ) { - if ( version_compare(PHP_VERSION, '5.3', '>=') && (strpos($metaClass, '\\') === false) ) { - $metaClass = __NAMESPACE__ . '\\' . $metaClass; - } - $metadata = call_user_func([$metaClass, 'fromJson'], $result['body']); - } else { - do_action('puc_api_error', $status, $result, $url, $this->slug); - $this->triggerError( - sprintf('The URL %s does not point to a valid metadata file. ', $url) - . $status->get_error_message(), - E_USER_WARNING - ); - } - - return [$metadata, $result]; - } - - /** - * Check if $result is a successful update API response. - * - * @param array|WP_Error $result - * @return true|WP_Error - */ - protected function validateApiResponse($result) { - if ( is_wp_error($result) ) { /** @var WP_Error $result */ - return new WP_Error($result->get_error_code(), 'WP HTTP Error: ' . $result->get_error_message()); - } - - if ( !isset($result['response']['code']) ) { - return new WP_Error( - 'puc_no_response_code', - 'wp_remote_get() returned an unexpected result.' - ); - } - - if ( $result['response']['code'] !== 200 ) { - return new WP_Error( - 'puc_unexpected_response_code', - 'HTTP response code is ' . $result['response']['code'] . ' (expected: 200)' - ); - } - - if ( empty($result['body']) ) { - return new WP_Error('puc_empty_response', 'The metadata file appears to be empty.'); - } - - return true; - } - - /* ------------------------------------------------------------------- - * Language packs / Translation updates - * ------------------------------------------------------------------- - */ - - /** - * Filter a list of translation updates and return a new list that contains only updates - * that apply to the current site. - * - * @param array $translations - * @return array - */ - protected function filterApplicableTranslations($translations) { - $languages = array_flip(array_values(get_available_languages())); - $installedTranslations = $this->getInstalledTranslations(); - - $applicableTranslations = []; - foreach ($translations as $translation) { - //Does it match one of the available core languages? - $isApplicable = array_key_exists($translation->language, $languages); - //Is it more recent than an already-installed translation? - if ( isset($installedTranslations[$translation->language]) ) { - $updateTimestamp = strtotime($translation->updated); - $installedTimestamp = strtotime($installedTranslations[$translation->language]['PO-Revision-Date']); - $isApplicable = $updateTimestamp > $installedTimestamp; - } - - if ( $isApplicable ) { - $applicableTranslations[] = $translation; - } - } - - return $applicableTranslations; - } - - /** - * Get a list of installed translations for this plugin or theme. - * - * @return array - */ - protected function getInstalledTranslations() { - if ( !function_exists('wp_get_installed_translations') ) { - return []; - } - $installedTranslations = wp_get_installed_translations($this->translationType . 's'); - if ( isset($installedTranslations[$this->directoryName]) ) { - $installedTranslations = $installedTranslations[$this->directoryName]; - } else { - $installedTranslations = []; - } - return $installedTranslations; - } - - /** - * Insert translation updates into the list maintained by WordPress. - * - * @param stdClass $updates - * @return stdClass - */ - public function injectTranslationUpdates($updates) { - $translationUpdates = $this->getTranslationUpdates(); - if ( empty($translationUpdates) ) { - return $updates; - } - - //Being defensive. - if ( !is_object($updates) ) { - $updates = new stdClass(); - } - if ( !isset($updates->translations) ) { - $updates->translations = []; - } - - //In case there's a name collision with a plugin or theme hosted on wordpress.org, - //remove any preexisting updates that match our thing. - $updates->translations = array_values(array_filter( - $updates->translations, - [$this, 'isNotMyTranslation'] - )); - - //Add our updates to the list. - foreach ($translationUpdates as $update) { - $convertedUpdate = array_merge( - [ - 'type' => $this->translationType, - 'slug' => $this->directoryName, - 'autoupdate' => 0, - //AFAICT, WordPress doesn't actually use the "version" field for anything. - //But lets make sure it's there, just in case. - 'version' => isset($update->version) ? $update->version : ('1.' . strtotime($update->updated)), - ], - (array)$update - ); - - $updates->translations[] = $convertedUpdate; - } - - return $updates; - } - - /** - * Get a list of available translation updates. - * - * This method will return an empty array if there are no updates. - * Uses cached update data. - * - * @return array - */ - public function getTranslationUpdates() { - return $this->updateState->getTranslations(); - } - - /** - * Remove all cached translation updates. - * - * @see wp_clean_update_cache - */ - public function clearCachedTranslationUpdates() { - $this->updateState->setTranslations([]); - } - - /** - * Filter callback. Keeps only translations that *don't* match this plugin or theme. - * - * @param array $translation - * @return bool - */ - protected function isNotMyTranslation($translation) { - $isMatch = isset($translation['type'], $translation['slug']) - && ($translation['type'] === $this->translationType) - && ($translation['slug'] === $this->directoryName); - - return !$isMatch; - } - - /* ------------------------------------------------------------------- - * Fix directory name when installing updates - * ------------------------------------------------------------------- - */ - - /** - * Rename the update directory to match the existing plugin/theme directory. - * - * When WordPress installs a plugin or theme update, it assumes that the ZIP file will contain - * exactly one directory, and that the directory name will be the same as the directory where - * the plugin or theme is currently installed. - * - * GitHub and other repositories provide ZIP downloads, but they often use directory names like - * "project-branch" or "project-tag-hash". We need to change the name to the actual plugin folder. - * - * This is a hook callback. Don't call it from a plugin. - * - * @access protected - * - * @param string $source The directory to copy to /wp-content/plugins or /wp-content/themes. Usually a subdirectory of $remoteSource. - * @param string $remoteSource WordPress has extracted the update to this directory. - * @param WP_Upgrader $upgrader - * @return string|WP_Error - */ - public function fixDirectoryName($source, $remoteSource, $upgrader) { - global $wp_filesystem; - /** @var WP_Filesystem_Base $wp_filesystem */ - - //Basic sanity checks. - if ( !isset($source, $remoteSource, $upgrader, $upgrader->skin, $wp_filesystem) ) { - return $source; - } - - //If WordPress is upgrading anything other than our plugin/theme, leave the directory name unchanged. - if ( !$this->isBeingUpgraded($upgrader) ) { - return $source; - } - - //Rename the source to match the existing directory. - $correctedSource = trailingslashit($remoteSource) . $this->directoryName . '/'; - if ( $source !== $correctedSource ) { - //The update archive should contain a single directory that contains the rest of plugin/theme files. - //Otherwise, WordPress will try to copy the entire working directory ($source == $remoteSource). - //We can't rename $remoteSource because that would break WordPress code that cleans up temporary files - //after update. - if ( $this->isBadDirectoryStructure($remoteSource) ) { - return new WP_Error( - 'puc-incorrect-directory-structure', - sprintf( - 'The directory structure of the update is incorrect. All files should be inside ' . - 'a directory named %s, not at the root of the ZIP archive.', - htmlentities($this->slug) - ) - ); - } - - /** @var WP_Upgrader_Skin $upgrader ->skin */ - $upgrader->skin->feedback(sprintf( - 'Renaming %s to %s…', - '' . basename($source) . '', - '' . $this->directoryName . '' - )); - - if ( $wp_filesystem->move($source, $correctedSource, true) ) { - $upgrader->skin->feedback('Directory successfully renamed.'); - return $correctedSource; - } else { - return new WP_Error( - 'puc-rename-failed', - 'Unable to rename the update to match the existing directory.' - ); - } - } - - return $source; - } - - /** - * Is there an update being installed right now, for this plugin or theme? - * - * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update. - * @return bool - */ - abstract public function isBeingUpgraded($upgrader = null); - - /** - * Check for incorrect update directory structure. An update must contain a single directory, - * all other files should be inside that directory. - * - * @param string $remoteSource Directory path. - * @return bool - */ - protected function isBadDirectoryStructure($remoteSource) { - global $wp_filesystem; - /** @var WP_Filesystem_Base $wp_filesystem */ - - $sourceFiles = $wp_filesystem->dirlist($remoteSource); - if ( is_array($sourceFiles) ) { - $sourceFiles = array_keys($sourceFiles); - $firstFilePath = trailingslashit($remoteSource) . $sourceFiles[0]; - return (count($sourceFiles) > 1) || (!$wp_filesystem->is_dir($firstFilePath)); - } - - //Assume it's fine. - return false; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/UpgraderStatus.php b/Includes/plugin-updater/Puc/UpgraderStatus.php deleted file mode 100755 index 2b7153f..0000000 --- a/Includes/plugin-updater/Puc/UpgraderStatus.php +++ /dev/null @@ -1,176 +0,0 @@ -isBeingUpgraded('plugin', $pluginFile, $upgrader); - } - - /** - * Check if a specific theme or plugin is being upgraded. - * - * @param string $type - * @param string $id - * @param Plugin_Upgrader|WP_Upgrader|null $upgrader - * @return bool - */ - protected function isBeingUpgraded($type, $id, $upgrader = null) { - if ( isset($upgrader) ) { - list($currentType, $currentId) = $this->getThingBeingUpgradedBy($upgrader); - if ( $currentType !== null ) { - $this->currentType = $currentType; - $this->currentId = $currentId; - } - } - return ($this->currentType === $type) && ($this->currentId === $id); - } - - /** - * Figure out which theme or plugin is being upgraded by a WP_Upgrader instance. - * - * Returns an array with two items. The first item is the type of the thing that's being - * upgraded: "plugin" or "theme". The second item is either the plugin basename or - * the theme directory name. If we can't determine what the upgrader is doing, both items - * will be NULL. - * - * Examples: - * ['plugin', 'plugin-dir-name/plugin.php'] - * ['theme', 'theme-dir-name'] - * - * @param Plugin_Upgrader|WP_Upgrader $upgrader - * @return array - */ - private function getThingBeingUpgradedBy($upgrader) { - if ( !isset($upgrader, $upgrader->skin) ) { - return [null, null]; - } - - //Figure out which plugin or theme is being upgraded. - $pluginFile = null; - - $skin = $upgrader->skin; - if ( $skin instanceof Plugin_Upgrader_Skin ) { - if ( isset($skin->plugin) && is_string($skin->plugin) && ($skin->plugin !== '') ) { - $pluginFile = $skin->plugin; - } - } elseif ( isset($skin->plugin_info) && is_array($skin->plugin_info) ) { - //This case is tricky because Bulk_Plugin_Upgrader_Skin (etc) doesn't actually store the plugin - //filename anywhere. Instead, it has the plugin headers in $plugin_info. So the best we can - //do is compare those headers to the headers of installed plugins. - $pluginFile = $this->identifyPluginByHeaders($skin->plugin_info); - } - - if ( $pluginFile !== null ) { - return ['plugin', $pluginFile]; - } - return [null, null]; - } - - /** - * Identify an installed plugin based on its headers. - * - * @param array $searchHeaders The plugin file header to look for. - * @return string|null Plugin basename ("foo/bar.php"), or NULL if we can't identify the plugin. - */ - private function identifyPluginByHeaders($searchHeaders) { - if ( !function_exists('get_plugins') ) { - /** @noinspection PhpIncludeInspection */ - require_once ABSPATH . '/wp-admin/includes/plugin.php'; - } - - $installedPlugins = get_plugins(); - $matches = []; - foreach ($installedPlugins as $pluginBasename => $headers) { - $diff1 = array_diff_assoc($headers, $searchHeaders); - $diff2 = array_diff_assoc($searchHeaders, $headers); - if ( empty($diff1) && empty($diff2) ) { - $matches[] = $pluginBasename; - } - } - - //It's possible (though very unlikely) that there could be two plugins with identical - //headers. In that case, we can't unambiguously identify the plugin that's being upgraded. - if ( count($matches) !== 1 ) { - return null; - } - - return reset($matches); - } - - /** - * @access private - * - * @param mixed $input - * @param array $hookExtra - * @return mixed Returns $input unaltered. - */ - public function setUpgradedThing($input, $hookExtra) { - if ( !empty($hookExtra['plugin']) && is_string($hookExtra['plugin']) ) { - $this->currentId = $hookExtra['plugin']; - $this->currentType = 'plugin'; - } else { - $this->currentType = null; - $this->currentId = null; - } - return $input; - } - - /** - * @access private - * - * @param array $options - * @return array - */ - public function setUpgradedPluginFromOptions($options) { - if ( isset($options['hook_extra']['plugin']) && is_string($options['hook_extra']['plugin']) ) { - $this->currentType = 'plugin'; - $this->currentId = $options['hook_extra']['plugin']; - } else { - $this->currentType = null; - $this->currentId = null; - } - return $options; - } - - /** - * @access private - * - * @param mixed $input - * @return mixed Returns $input unaltered. - */ - public function clearUpgradedThing($input = null) { - $this->currentId = null; - $this->currentType = null; - return $input; - } - } - -endif; diff --git a/Includes/plugin-updater/Puc/Utils.php b/Includes/plugin-updater/Puc/Utils.php deleted file mode 100755 index faed21f..0000000 --- a/Includes/plugin-updater/Puc/Utils.php +++ /dev/null @@ -1,71 +0,0 @@ -$node) ) { - $currentValue = $currentValue->$node; - } else { - return $default; - } - } - } - - return $currentValue; - } - - /** - * Get the first array element that is not empty. - * - * @param array $values - * @param mixed|null $default Returns this value if there are no non-empty elements. - * @return mixed|null - */ - public static function findNotEmpty($values, $default = null) { - if ( empty($values) ) { - return $default; - } - - foreach ($values as $value) { - if ( !empty($value) ) { - return $value; - } - } - - return $default; - } - - /** - * Check if the input string starts with the specified prefix. - * - * @param string $input - * @param string $prefix - * @return bool - */ - public static function startsWith($input, $prefix) { - $length = strlen($prefix); - return (substr($input, 0, $length) === $prefix); - } - } - -endif; diff --git a/Includes/plugin-updater/languages/plugin-update-checker-ca.mo b/Includes/plugin-updater/languages/plugin-update-checker-ca.mo deleted file mode 100755 index 59645faba22e5f3b1358ef076a01d5a7fa3aa534..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1186 zcmZ`&%We}f6g5yD3JU~l7MF@jAn=eGUhPB?f>02mg$Po_u5xE?6T{RV*`7X-koW+0 zhy^>uFR+0P5@LzOC$M16M{p*S5}sDhoY=mPbM5P|$7Ws%jDx^&U;rEjo&)uG2OI_7 z0|a~qW`XZO7dWy8}I`73-}WF&`jfh1$+|or(n2@ z$6kD4Ca@&-k5_~^FyUI~c=Se`J*IW*s48<6*o(o49h3HCEM+5QhFsVosZFH|wN`K> zR?K5#x6H%=Hi*EEd{CkCG&|>KMHn%aMK#ohf(`}GTqVO>w8_qEYsjusZ87I}jgak^ z1b=z=Y*pmY6Da4vZbKUgT;Ekp3VMIKk87Fp(ccPYmReZ*Oiw{rQQ zQJGG}$>w0>q|R3V?m+e&tAI-6bvUP#wByS%j%9Lz;>&3}Inz$sZ5YaXys7Jor*;dn zy&#i|6wjye#l~(4XI!Zv%K@v6lv>NTmKUcY;;7x~Srga|VW$KqCtXwwgL#J#*X-o9%M(OOP zBClzLpCXloN)jJ<-gN!%O{ zB>(p8)gMt|<1=e`ScRtXSByfRLdUq(KfSFJ6!629vGE!UXnOYH)9c?7LY#*cWS6#% cwcF+j&+0z~QHeLF5H1o+|4uN~nyX0s0EpISt^fc4 diff --git a/Includes/plugin-updater/languages/plugin-update-checker-ca.po b/Includes/plugin-updater/languages/plugin-update-checker-ca.po deleted file mode 100755 index 36f3ad7..0000000 --- a/Includes/plugin-updater/languages/plugin-update-checker-ca.po +++ /dev/null @@ -1,48 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: plugin-update-checker\n" -"POT-Creation-Date: 2017-11-24 17:02+0200\n" -"PO-Revision-Date: 2019-09-25 18:15+0200\n" -"Language-Team: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.2.3\n" -"X-Poedit-Basepath: ..\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" -"Last-Translator: \n" -"Language: ca\n" -"X-Poedit-SearchPath-0: .\n" - -#: Puc/v4p3/Plugin/UpdateChecker.php:395 -msgid "Check for updates" -msgstr "Comprova si hi ha actualitzacions" - -#: Puc/v4p3/Plugin/UpdateChecker.php:548 -#, php-format -msgctxt "the plugin title" -msgid "The %s plugin is up to date." -msgstr "L’extensió %s està actualitzada." - -#: Puc/v4p3/Plugin/UpdateChecker.php:550 -#, php-format -msgctxt "the plugin title" -msgid "A new version of the %s plugin is available." -msgstr "Una nova versió de l’extensió %s està disponible." - -#: Puc/v4p3/Plugin/UpdateChecker.php:552 -#, php-format -msgctxt "the plugin title" -msgid "Could not determine if updates are available for %s." -msgstr "No s’ha pogut determinar si hi ha actualitzacions per a %s." - -#: Puc/v4p3/Plugin/UpdateChecker.php:558 -#, php-format -msgid "Unknown update checker status \"%s\"" -msgstr "Estat del comprovador d’actualitzacions desconegut \"%s\"" - -#: Puc/v4p3/Vcs/PluginUpdateChecker.php:95 -msgid "There is no changelog available." -msgstr "No hi ha cap registre de canvis disponible." diff --git a/Includes/plugin-updater/languages/plugin-update-checker-pt_BR.mo b/Includes/plugin-updater/languages/plugin-update-checker-pt_BR.mo deleted file mode 100755 index d1c0f283287da07c7060255756947399fde75ca6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1014 zcmZuv!EVz)6f{scgcF=V;_y_d5=dPW2P%rAAllGEMM|SKMcksreu>>WyVmYHZ4oE_ zfe%0&fCEQPT#)h`h+lzm97qtXGJgB)+1bhN{J6UG*2B02+yFYjW#BbXj*q|<;1fW= zS6~_V4zz%ufGFqZJntKD3|vFMdZFTNpgW5oypn^Ib=kY}AEddv&Zz?~t zX;s<@N5?eKhKf9vj;+^A*f6D*l%^<=YRH)$k{ru4lP@#&y+d`Z^og1+00#ed~o)yDXkxO01OB=CIb?>xs5u>EJ;;!s3t`_28bUuZiG31#98mK-BNl>mZ7K z9;c<(|MMCZuOqD!JtLLPq|+v(S_kJ<$RUd!%h5s)ORm4UU)$Z;-J07B{Ccgem16~& zvmAaLpSs(5CR5cc58qgJt;627SfBIC?FMYbmWp(os$od$FH={0As(}0Q~Bs>j#Ed0 zzwWQ&OVx@^X*riJ3CZ_s-K;P&6WiL1Y)A^Xh1Rwj&GPUtZQWG#fP!1i`T7H0n26hz zt&l2Tf7GAy*@-r>?WER))bBU@-0Yv?7Y3`1XhDUgiIOgSh&r6qJltA3NF!-z!xb`1 zU&+ab$rmK?+2p;ZWb%%R(LxgA)aF`EK94!`y@Pq^C}taJg*2wI_Pr<5brLBa%W3dR uv0NHSC{;9(zXh@CV~k{HTE@P&w?I3B7+Z&@l4Ogy;7B66h9le{qWB9G2Q7U7 diff --git a/Includes/plugin-updater/languages/plugin-update-checker-pt_BR.po b/Includes/plugin-updater/languages/plugin-update-checker-pt_BR.po deleted file mode 100755 index 70a0f62..0000000 --- a/Includes/plugin-updater/languages/plugin-update-checker-pt_BR.po +++ /dev/null @@ -1,48 +0,0 @@ -msgid "" -msgstr "" -"Project-Id-Version: plugin-update-checker\n" -"POT-Creation-Date: 2017-05-19 15:41-0300\n" -"PO-Revision-Date: 2017-05-19 15:42-0300\n" -"Last-Translator: \n" -"Language-Team: \n" -"Language: pt_BR\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.8.8\n" -"X-Poedit-Basepath: ..\n" -"Plural-Forms: nplurals=2; plural=(n > 1);\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-KeywordsList: __;_e;_x;_x:1,2c\n" -"X-Poedit-SearchPath-0: .\n" - -#: Puc/v4p1/Plugin/UpdateChecker.php:358 -msgid "Check for updates" -msgstr "Verificar Atualizações" - -#: Puc/v4p1/Plugin/UpdateChecker.php:401 Puc/v4p1/Plugin/UpdateChecker.php:406 -#, php-format -msgctxt "the plugin title" -msgid "The %s plugin is up to date." -msgstr "O plugin %s já está na sua versão mais recente." - -#: Puc/v4p1/Plugin/UpdateChecker.php:408 -#, php-format -msgctxt "the plugin title" -msgid "A new version of the %s plugin is available." -msgstr "Há uma nova versão para o plugin %s disponível para download." - -#: Puc/v4p1/Plugin/UpdateChecker.php:410 -#, php-format -msgid "Unknown update checker status \"%s\"" -msgstr "Status \"%s\" desconhecido." - -#: Puc/v4p1/Vcs/PluginUpdateChecker.php:83 -msgid "There is no changelog available." -msgstr "Não há um changelog disponível." - -#~ msgid "The %s plugin is up to date." -#~ msgstr "O plugin %s já está na sua versão mais recente." - -#~ msgid "A new version of the %s plugin is available." -#~ msgstr "Há uma nova versão para o plugin %s disponível para download." diff --git a/Includes/plugin-updater/languages/plugin-update-checker.pot b/Includes/plugin-updater/languages/plugin-update-checker.pot deleted file mode 100755 index 99cc24c..0000000 --- a/Includes/plugin-updater/languages/plugin-update-checker.pot +++ /dev/null @@ -1,49 +0,0 @@ -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: plugin-update-checker\n" -"POT-Creation-Date: 2020-08-08 14:36+0300\n" -"PO-Revision-Date: 2016-01-10 20:59+0100\n" -"Last-Translator: Tamás András Horváth \n" -"Language-Team: \n" -"Language: en_US\n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=UTF-8\n" -"Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 2.4\n" -"X-Poedit-Basepath: ..\n" -"Plural-Forms: nplurals=2; plural=(n != 1);\n" -"X-Poedit-SourceCharset: UTF-8\n" -"X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n" -"X-Poedit-SearchPath-0: .\n" - -#: Puc/v4p11/Plugin/Ui.php:128 -msgid "Check for updates" -msgstr "" - -#: Puc/v4p11/Plugin/Ui.php:213 -#, php-format -msgctxt "the plugin title" -msgid "The %s plugin is up to date." -msgstr "" - -#: Puc/v4p11/Plugin/Ui.php:215 -#, php-format -msgctxt "the plugin title" -msgid "A new version of the %s plugin is available." -msgstr "" - -#: Puc/v4p11/Plugin/Ui.php:217 -#, php-format -msgctxt "the plugin title" -msgid "Could not determine if updates are available for %s." -msgstr "" - -#: Puc/v4p11/Plugin/Ui.php:223 -#, php-format -msgid "Unknown update checker status \"%s\"" -msgstr "" - -#: Puc/v4p11/Vcs/PluginUpdateChecker.php:98 -msgid "There is no changelog available." -msgstr "" diff --git a/Includes/plugin-updater/license.txt b/Includes/plugin-updater/license.txt deleted file mode 100755 index be948f6..0000000 --- a/Includes/plugin-updater/license.txt +++ /dev/null @@ -1,7 +0,0 @@ -Copyright (c) 2017 Jānis Elsts - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Includes/plugin-updater/load-puc.php b/Includes/plugin-updater/load-puc.php deleted file mode 100755 index 50ebff7..0000000 --- a/Includes/plugin-updater/load-puc.php +++ /dev/null @@ -1,6 +0,0 @@ - Date: Mon, 10 Nov 2025 10:57:40 -0300 Subject: [PATCH 2/3] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Alterando=20slug=20de?= =?UTF-8?q?=20tradu=C3=A7=C3=B5es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Admin/GiveMultiCurrencyAdmin.php | 101 +++++------ Includes/GiveMultiCurrencyHelper.php | 31 ++-- give-currency.php | 6 +- languages/give-multi-currency-pt_BR.mo | Bin 0 -> 3662 bytes languages/give-multi-currency-pt_BR.po | 187 +++++++++++++++++++++ languages/give-multi-currency.pot | 191 +++++++++++++++++++++ readme.txt | 222 +++++++++++++++++++++++++ 7 files changed, 673 insertions(+), 65 deletions(-) create mode 100644 languages/give-multi-currency-pt_BR.mo create mode 100644 languages/give-multi-currency-pt_BR.po create mode 100644 languages/give-multi-currency.pot create mode 100644 readme.txt diff --git a/Admin/GiveMultiCurrencyAdmin.php b/Admin/GiveMultiCurrencyAdmin.php index eebb4a7..5ca8a11 100755 --- a/Admin/GiveMultiCurrencyAdmin.php +++ b/Admin/GiveMultiCurrencyAdmin.php @@ -41,52 +41,52 @@ public function setup_setting($settings) // Custom metabox settings. $settings["{$this->id}_tab"] = array( 'id' => "{$this->id}_tab", - 'title' => __('Opções de moedas', 'give-multi-currency'), + 'title' => __('Currency Options', 'give-multi-currency'), 'icon-html' => '', 'fields' => array( array( 'id' => "{$this->id}_status", - 'name' => __('Opções globais', 'give-multi-currency'), + 'name' => __('Global Options', 'give-multi-currency'), 'type' => 'radio_inline', - 'desc' => __('Habilitar opções globais para o formulário ou desabilitar para usar as opções definidas no formulário.', 'give-multi-currency'), + 'desc' => __('Enable global options for the form or disable to use form-specific options.', 'give-multi-currency'), 'options' => array( - 'enabled' => __('Habilitado', 'give-multi-currency'), - 'disabled' => __('Desabilitado', 'give-multi-currency'), + 'enabled' => __('Enabled', 'give-multi-currency'), + 'disabled' => __('Disabled', 'give-multi-currency'), ), 'default' => 'enabled', ), array( 'id' => "{$this->id}_default_currency", - 'name' => __('Moeda padrão', 'give-multi-currency'), + 'name' => __('Default Currency', 'give-multi-currency'), 'type' => 'radio', - 'desc' => __('Selecione a moeda padrão.', 'give-multi-currency'), + 'desc' => __('Select the default currency.', 'give-multi-currency'), 'options' => array( - 'BRL' => __('Real Brasileiro (R$)', 'give'), - 'USD' => __('Dólar Americano ($)', 'give'), - 'EUR' => __('Euro (€)', 'give'), - 'JPY' => __('Iene (¥)', 'give'), - 'GBP' => __('Libra esterlina (£)', 'give'), - 'SAR' => __('Rial Saudita (ر.س)', 'give'), - 'MXN' => __('Peso mexicano ($)', 'give'), - 'CHF' => __('Franco Suíço (CHF)', 'give') + 'BRL' => __('Brazilian Real (R$)', 'give-multi-currency'), + 'USD' => __('US Dollar ($)', 'give-multi-currency'), + 'EUR' => __('Euro (€)', 'give-multi-currency'), + 'JPY' => __('Japanese Yen (¥)', 'give-multi-currency'), + 'GBP' => __('British Pound (£)', 'give-multi-currency'), + 'SAR' => __('Saudi Riyal (ر.س)', 'give-multi-currency'), + 'MXN' => __('Mexican Peso ($)', 'give-multi-currency'), + 'CHF' => __('Swiss Franc (CHF)', 'give-multi-currency') ), 'default' => 'BRL', ), array( 'id' => "{$this->id}_active_currency", - 'name' => __('Moedas Habilitadas', 'give-multi-currency'), + 'name' => __('Enabled Currencies', 'give-multi-currency'), 'type' => 'multicheck', - 'desc' => __('Selecione as moedas que seu formulário irá aceitar.', 'give-multi-currency'), + 'desc' => __('Select the currencies your form will accept.', 'give-multi-currency'), 'default' => '1', 'options' => array( - 'BRL' => __('Real Brasileiro (R$)', 'give'), - 'USD' => __('Dólar Americano ($)', 'give'), - 'EUR' => __('Euro (€)', 'give'), - 'JPY' => __('Iene (¥)', 'give'), - 'GBP' => __('Libra esterlina (£)', 'give'), - 'SAR' => __('Rial Saudita (ر.س)', 'give'), - 'MXN' => __('Peso mexicano ($)', 'give'), - 'CHF' => __('Franco Suíço (CHF)', 'give') + 'BRL' => __('Brazilian Real (R$)', 'give-multi-currency'), + 'USD' => __('US Dollar ($)', 'give-multi-currency'), + 'EUR' => __('Euro (€)', 'give-multi-currency'), + 'JPY' => __('Japanese Yen (¥)', 'give-multi-currency'), + 'GBP' => __('British Pound (£)', 'give-multi-currency'), + 'SAR' => __('Saudi Riyal (ر.س)', 'give-multi-currency'), + 'MXN' => __('Mexican Peso ($)', 'give-multi-currency'), + 'CHF' => __('Swiss Franc (CHF)', 'give-multi-currency') ), ), ), @@ -106,33 +106,33 @@ public function lkn_give_multi_currency_add_setting_into_existing_tab($settings) foreach ($settings as $key => $setting) { if ('give_docs_link' === $setting['type']) { // You can use id to compare or create own sub section to add new setting. $new_setting[] = array( - 'name' => __('Habilitar Multi Moedas', 'give'), + 'name' => __('Enable Multi Currency', 'give-multi-currency'), 'id' => 'multi_currency_enabled_setting_field', - 'desc' => __('Ative ou desative o plugin Multi Moedas, esse plugin só funcionará com a moeda real (BRL - R$)'), + 'desc' => __('Enable or disable the Multi Currency plugin. This plugin only works with Brazilian Real (BRL - R$)', 'give-multi-currency'), 'type' => 'radio', 'default' => 'disabled', 'options' => array( - 'enabled' => __('Habilitado', 'give'), - 'disabled' => __('Desabilitado', 'give'), + 'enabled' => __('Enabled', 'give-multi-currency'), + 'disabled' => __('Disabled', 'give-multi-currency'), ), ); // Only apears if 'multi_currency_enabled_setting_field' is 'enabled' if (give_get_option('multi_currency_enabled_setting_field') == 'enabled' && give_get_option('currency') == 'BRL') { $new_setting[] = array( - 'name' => __('Moedas Habilitadas', 'give'), + 'name' => __('Enabled Currencies', 'give-multi-currency'), 'id' => 'multi_currency_active_currency', - 'desc' => __('Selecione as moedas que seu formulário irá aceitar') . '
Adicionar nova moeda', + 'desc' => __('Select the currencies your form will accept', 'give-multi-currency') . '
' . __('Add new currency', 'give-multi-currency') . '', 'type' => 'multicheck', 'default' => 1, 'options' => array( - 'brl' => __('Real Brasileiro (R$)', 'give'), - 'usd' => __('Dólar Americano ($)', 'give'), - 'eur' => __('Euro (€)', 'give'), - 'jpy' => __('Iene (¥)', 'give'), - 'gbp' => __('Libra esterlina (£)', 'give'), - 'sar' => __('Rial Saudita (ر.س)', 'give'), - 'mxn' => __('Peso mexicano ($)', 'give'), - 'chf' => __('Franco Suíço (CHF)', 'give') + 'brl' => __('Brazilian Real (R$)', 'give-multi-currency'), + 'usd' => __('US Dollar ($)', 'give-multi-currency'), + 'eur' => __('Euro (€)', 'give-multi-currency'), + 'jpy' => __('Japanese Yen (¥)', 'give-multi-currency'), + 'gbp' => __('British Pound (£)', 'give-multi-currency'), + 'sar' => __('Saudi Riyal (ر.س)', 'give-multi-currency'), + 'mxn' => __('Mexican Peso ($)', 'give-multi-currency'), + 'chf' => __('Swiss Franc (CHF)', 'give-multi-currency') ), ); } @@ -140,20 +140,20 @@ public function lkn_give_multi_currency_add_setting_into_existing_tab($settings) // Default currency option if (give_get_option('multi_currency_enabled_setting_field') == 'enabled' && give_get_option('currency') == 'BRL') { $new_setting[] = array( - 'name' => __('Moeda padrão', 'give'), + 'name' => __('Default Currency', 'give-multi-currency'), 'id' => 'multi_currency_default_currency', - 'desc' => __('Selecione a moeda padrão'), + 'desc' => __('Select the default currency', 'give-multi-currency'), 'type' => 'radio', 'default' => 'BRL', 'options' => array( - 'BRL' => __('Real Brasileiro (R$)', 'give'), - 'USD' => __('Dólar Americano ($)', 'give'), - 'EUR' => __('Euro (€)', 'give'), - 'JPY' => __('Iene (¥)', 'give'), - 'GBP' => __('Libra esterlina (£)', 'give'), - 'SAR' => __('Rial Saudita (ر.س)', 'give'), - 'MXN' => __('Peso mexicano ($)', 'give'), - 'CHF' => __('Franco Suíço (CHF)', 'give') + 'BRL' => __('Brazilian Real (R$)', 'give-multi-currency'), + 'USD' => __('US Dollar ($)', 'give-multi-currency'), + 'EUR' => __('Euro (€)', 'give-multi-currency'), + 'JPY' => __('Japanese Yen (¥)', 'give-multi-currency'), + 'GBP' => __('British Pound (£)', 'give-multi-currency'), + 'SAR' => __('Saudi Riyal (ر.س)', 'give-multi-currency'), + 'MXN' => __('Mexican Peso ($)', 'give-multi-currency'), + 'CHF' => __('Swiss Franc (CHF)', 'give-multi-currency') ), ); } @@ -180,11 +180,12 @@ public function disabled_for_non_legacy_templates_html() { ob_start(); ?>

- +

%1$s %2$s %4$s %5$s %6$s+ %7$s.', - __('Activation Error:', 'give'), - __('You must have', 'give'), + __('Activation Error:', 'give-multi-currency'), + __('You must have', 'give-multi-currency'), 'https://givewp.com', - __('Give', 'give'), - __('version', 'give'), + __('Give', 'give-multi-currency'), + __('version', 'give-multi-currency'), GIVE_MULTI_CURRENCY_MIN_GIVE_VERSION, - __('for the Give Multi Currency add-on to activate', 'give') + __('for the Give Multi Currency add-on to activate', 'give-multi-currency') ); $message = wp_kses_post( $message ); Give()->notices->register_notice(array( @@ -38,11 +38,11 @@ public static function lkn_give_multi_currency_inactive_notice(): void { // Admin notice. $message = sprintf( '

%1$s %2$s %4$s %5$s.

', - __('Activation Error:', 'give'), - __('You must have', 'give'), + __('Activation Error:', 'give-multi-currency'), + __('You must have', 'give-multi-currency'), 'https://givewp.com', - __('Give', 'give'), - __(' plugin installed and activated for the Give Multi Currency to activate', 'give') + __('Give', 'give-multi-currency'), + __(' plugin installed and activated for the Give Multi Currency to activate', 'give-multi-currency') ); echo wp_kses_post($message); @@ -62,7 +62,7 @@ public static function lkn_give_multi_currency_plugin_row_meta($plugin_meta, $pl $new_meta_links['setting'] = sprintf( '%2$s', admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general§ion=currency-settings'), - __('Settings', 'give') + __('Settings', 'give-multi-currency') ); return array_merge($plugin_meta, $new_meta_links); @@ -80,7 +80,7 @@ public static function lkn_give_multi_currency_activation(): void { // Only runs on admin. $args = array( 'file' => GIVE_MULTI_CURRENCY_FILE, - 'name' => __('Multi Currency', 'give'), + 'name' => __('Multi Currency', 'give-multi-currency'), 'version' => GIVE_MULTI_CURRENCY_VERSION, 'settings_url' => admin_url('edit.php?post_type=give_forms&page=give-settings&tab=general§ion=currency-settings'), 'documentation_url' => 'https://www.linknacional.com.br/wordpress/givewp/', @@ -101,7 +101,7 @@ public static function lkn_give_multi_currency_get_exchange_rates($currenciesCod $exRate[$currency] = $result->rates->BRL; } - // retorna um array com o rate das moedas ativas + // returns an array with the exchange rates of active currencies return wp_json_encode($exRate); } @@ -140,7 +140,12 @@ public static function lkn_multi_currency_curl_get_contents($url) { } public static function __lkn_multicurrency_linkn_inactive_notice(): void { - $message = '

Atenção: O plugin Give Multimoedas detectou que o plugin Cielo API 3.0 encontra-se inativo. Ativar na área de plugins.

'; + $message = sprintf( + '

%1$s %2$s %3$s.

', + __('Attention:', 'give-multi-currency'), + __('The Give Multi Currency plugin detected that the Cielo API 3.0 plugin is inactive.', 'give-multi-currency'), + __('Activate in plugins area', 'give-multi-currency') + ); echo wp_kses_post($message); } diff --git a/give-currency.php b/give-currency.php index 1683147..b308fa7 100755 --- a/give-currency.php +++ b/give-currency.php @@ -1,15 +1,17 @@ tC^h9;7|k#d~gQ!bs^MH=aibgC5e=4VfyBk(1+F)(%5T6S{$|ytxQdwV` zUK9)`dNmjp2p4}lx21YAJ3dEcFfA2V)PY3YCSem-w3GXYv{*Ncr=r@d_KI>J5r|sc zBoE;{1JaYL2q1D!RS(ni;`JaTy|jj;k!+Up~7bvcx#IHpl)Z#f!i->1`g zS?z35LY$rGMB_}}xT%#B>y<5O_8;GUZBB6f#ntFild~7(P#T4R-%ti={mq=%R!2HR z?%T>?Ba}aAso0fOuBoGsxis$oA-#WZPV6Gh8FB}|>Vm@2oGlxxVWf)!Wtyp>eZcSbfHNO(xgqeqAC^Fcj-!56w-!(-9Rl5a2KdA5pYz++g@Io=LzoQ^c_A_*5NjZ zwk>bMj$|`WUW!Ytc>j~rrE@V|OfSxK)UdQZ*>*jhC#zM@C3|Iy`rZ#+Ykqz-8l{Cc zw_q`p%OcInLAr0}UB$c9{7ic%>8L}^M<-Wsi(0g_u=H%QxR@+_ffkoq3k%OIV9abu z=aW4|)8Ve6kj(pPG=^u??+9v{AZ`mpD*)ATCYQ^}r^gBBWz^;NIp(wmKiJvR|) z(a?8SJ2Tsx+v_LZFQyAKYfz6imFyi4VWL+@ejb-zn`LeX)+vAa`rbzJ+=(1pdZ28w zZn82*LA2<(eeGw^P^>JH4cu7QB7@Xp>Mk!Wb9(W5dDhVLv^cjs^Y!GaGRj70+oj62 z=Q6;0oFuE#siE}!7NzOQ>Wk_aH#c`%+W8iByUSg*-0h-aq0Juo*5ZYw<*tb^S?!v# z9M+$v-ZMyMtxMU3u<3{ecr_C>36# z)QMxeO4_X7hQrAMT%I{aUNSF9k!0q=+fZ6b!<&YzTca@*1{8vP)@AqKzJw z+4xnQ8GPnOFjE`j@)jQ-zK^f&l2(G(;q2TP>`?M>o(pp8ac zk*aB<(~xsTwG!kX?@d>YToa8-L&};jZhVgpDig9#=w4K3KmLz0o$?b}Y`lWsQ6)`Q zknYpWIH`z0k=lt(T>Qw1feUM5oF>IOdL0ce47})3UDKS1c8c5JVxc zg#TgxdPb&19@(u)3Lj)k{Ev#3ZDoQ!kGqF#m-ugNe2=+uWuPqos}UpmQhi5I4!EeI SF1wl`A9j4*L6|VP%>M`Jo;t+< literal 0 HcmV?d00001 diff --git a/languages/give-multi-currency-pt_BR.po b/languages/give-multi-currency-pt_BR.po new file mode 100644 index 0000000..4ccfb0a --- /dev/null +++ b/languages/give-multi-currency-pt_BR.po @@ -0,0 +1,187 @@ +# Copyright (C) 2025 Link Nacional +# This file is distributed under the GNU General Public License v3 or later. +msgid "" +msgstr "" +"Project-Id-Version: Give - Multi Currency 3.1.3\n" +"Report-Msgid-Bugs-To: https://www.linknacional.com.br/suporte/\n" +"POT-Creation-Date: 2025-11-07 12:00+0000\n" +"PO-Revision-Date: 2025-11-07 12:00+0000\n" +"Last-Translator: Link Nacional \n" +"Language-Team: Portuguese (Brazil)\n" +"Language: pt_BR\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" +"X-Generator: Poedit 3.0\n" +"X-Poedit-Basepath: ..\n" +"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" +"X-Poedit-SearchPath-0: .\n" + +#: Admin/GiveMultiCurrencyAdmin.php:43 +msgid "Currency Options" +msgstr "Opções de Moedas" + +#: Admin/GiveMultiCurrencyAdmin.php:48 +msgid "Global Options" +msgstr "Opções Globais" + +#: Admin/GiveMultiCurrencyAdmin.php:50 +msgid "Enable global options for the form or disable to use form-specific options." +msgstr "Habilitar opções globais para o formulário ou desabilitar para usar as opções definidas no formulário." + +#: Admin/GiveMultiCurrencyAdmin.php:52 +#: Admin/GiveMultiCurrencyAdmin.php:114 +msgid "Enabled" +msgstr "Habilitado" + +#: Admin/GiveMultiCurrencyAdmin.php:53 +#: Admin/GiveMultiCurrencyAdmin.php:115 +msgid "Disabled" +msgstr "Desabilitado" + +#: Admin/GiveMultiCurrencyAdmin.php:59 +#: Admin/GiveMultiCurrencyAdmin.php:142 +msgid "Default Currency" +msgstr "Moeda Padrão" + +#: Admin/GiveMultiCurrencyAdmin.php:61 +#: Admin/GiveMultiCurrencyAdmin.php:144 +msgid "Select the default currency." +msgstr "Selecione a moeda padrão." + +#: Admin/GiveMultiCurrencyAdmin.php:63 +#: Admin/GiveMultiCurrencyAdmin.php:79 +#: Admin/GiveMultiCurrencyAdmin.php:128 +#: Admin/GiveMultiCurrencyAdmin.php:146 +msgid "Brazilian Real (R$)" +msgstr "Real Brasileiro (R$)" + +#: Admin/GiveMultiCurrencyAdmin.php:64 +#: Admin/GiveMultiCurrencyAdmin.php:80 +#: Admin/GiveMultiCurrencyAdmin.php:129 +#: Admin/GiveMultiCurrencyAdmin.php:147 +msgid "US Dollar ($)" +msgstr "Dólar Americano ($)" + +#: Admin/GiveMultiCurrencyAdmin.php:65 +#: Admin/GiveMultiCurrencyAdmin.php:81 +#: Admin/GiveMultiCurrencyAdmin.php:130 +#: Admin/GiveMultiCurrencyAdmin.php:148 +msgid "Euro (€)" +msgstr "Euro (€)" + +#: Admin/GiveMultiCurrencyAdmin.php:66 +#: Admin/GiveMultiCurrencyAdmin.php:82 +#: Admin/GiveMultiCurrencyAdmin.php:131 +#: Admin/GiveMultiCurrencyAdmin.php:149 +msgid "Japanese Yen (¥)" +msgstr "Iene (¥)" + +#: Admin/GiveMultiCurrencyAdmin.php:67 +#: Admin/GiveMultiCurrencyAdmin.php:83 +#: Admin/GiveMultiCurrencyAdmin.php:132 +#: Admin/GiveMultiCurrencyAdmin.php:150 +msgid "British Pound (£)" +msgstr "Libra Esterlina (£)" + +#: Admin/GiveMultiCurrencyAdmin.php:68 +#: Admin/GiveMultiCurrencyAdmin.php:84 +#: Admin/GiveMultiCurrencyAdmin.php:133 +#: Admin/GiveMultiCurrencyAdmin.php:151 +msgid "Saudi Riyal (ر.س)" +msgstr "Rial Saudita (ر.س)" + +#: Admin/GiveMultiCurrencyAdmin.php:69 +#: Admin/GiveMultiCurrencyAdmin.php:85 +#: Admin/GiveMultiCurrencyAdmin.php:134 +#: Admin/GiveMultiCurrencyAdmin.php:152 +msgid "Mexican Peso ($)" +msgstr "Peso Mexicano ($)" + +#: Admin/GiveMultiCurrencyAdmin.php:70 +#: Admin/GiveMultiCurrencyAdmin.php:86 +#: Admin/GiveMultiCurrencyAdmin.php:135 +#: Admin/GiveMultiCurrencyAdmin.php:153 +msgid "Swiss Franc (CHF)" +msgstr "Franco Suíço (CHF)" + +#: Admin/GiveMultiCurrencyAdmin.php:75 +#: Admin/GiveMultiCurrencyAdmin.php:122 +msgid "Enabled Currencies" +msgstr "Moedas Habilitadas" + +#: Admin/GiveMultiCurrencyAdmin.php:77 +msgid "Select the currencies your form will accept." +msgstr "Selecione as moedas que seu formulário irá aceitar." + +#: Admin/GiveMultiCurrencyAdmin.php:109 +msgid "Enable Multi Currency" +msgstr "Habilitar Multi Moedas" + +#: Admin/GiveMultiCurrencyAdmin.php:111 +msgid "Enable or disable the Multi Currency plugin. This plugin only works with Brazilian Real (BRL - R$)" +msgstr "Ative ou desative o plugin Multi Moedas. Este plugin só funciona com a moeda Real Brasileiro (BRL - R$)" + +#: Admin/GiveMultiCurrencyAdmin.php:124 +msgid "Select the currencies your form will accept" +msgstr "Selecione as moedas que seu formulário irá aceitar" + +#: Admin/GiveMultiCurrencyAdmin.php:124 +msgid "Add new currency" +msgstr "Adicionar nova moeda" + +#: Admin/GiveMultiCurrencyAdmin.php:144 +msgid "Select the default currency" +msgstr "Selecione a moeda padrão" + +#: Admin/GiveMultiCurrencyAdmin.php:183 +msgid "Custom form is not relevant for GiveWP Multi-Step forms. If you want to use the Free Form Plugin, you need to change the form template to \"Legacy\" option." +msgstr "O formulário customizado não é relevante para o formulário Multi-Step do GiveWP. Caso você deseje utilizar o Free Form Plugin é necessário mudar o Template do formulário para opção \"Legado\"." + +#: Includes/GiveMultiCurrencyHelper.php:15 +#: Includes/GiveMultiCurrencyHelper.php:34 +msgid "Activation Error:" +msgstr "Erro de Ativação:" + +#: Includes/GiveMultiCurrencyHelper.php:16 +#: Includes/GiveMultiCurrencyHelper.php:35 +msgid "You must have" +msgstr "Você deve ter" + +#: Includes/GiveMultiCurrencyHelper.php:18 +#: Includes/GiveMultiCurrencyHelper.php:37 +msgid "Give" +msgstr "Give" + +#: Includes/GiveMultiCurrencyHelper.php:19 +msgid "version" +msgstr "versão" + +#: Includes/GiveMultiCurrencyHelper.php:21 +msgid "for the Give Multi Currency add-on to activate" +msgstr "para o add-on Give Multi Currency ativar" + +#: Includes/GiveMultiCurrencyHelper.php:38 +msgid " plugin installed and activated for the Give Multi Currency to activate" +msgstr " plugin instalado e ativado para o Give Multi Currency ativar" + +#: Includes/GiveMultiCurrencyHelper.php:52 +msgid "Settings" +msgstr "Configurações" + +#: Includes/GiveMultiCurrencyHelper.php:66 +msgid "Multi Currency" +msgstr "Multi Moedas" + +#: Includes/GiveMultiCurrencyHelper.php:145 +msgid "Attention:" +msgstr "Atenção:" + +#: Includes/GiveMultiCurrencyHelper.php:146 +msgid "The Give Multi Currency plugin detected that the Cielo API 3.0 plugin is inactive." +msgstr "O plugin Give Multi Currency detectou que o plugin Cielo API 3.0 encontra-se inativo." + +#: Includes/GiveMultiCurrencyHelper.php:147 +msgid "Activate in plugins area" +msgstr "Ativar na área de plugins" diff --git a/languages/give-multi-currency.pot b/languages/give-multi-currency.pot new file mode 100644 index 0000000..7e2ae20 --- /dev/null +++ b/languages/give-multi-currency.pot @@ -0,0 +1,191 @@ +# Copyright (C) 2025 Link Nacional +# This file is distributed under the GNU General Public License v3 or later. +msgid "" +msgstr "" +"Project-Id-Version: Give - Multi Currency 3.1.3\n" +"Report-Msgid-Bugs-To: https://www.linknacional.com.br/suporte/\n" +"POT-Creation-Date: 2025-11-07 12:00+0000\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"PO-Revision-Date: 2025-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-Country: \n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c;_nc:4c,1,2;_x:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;_ex:1,2c;esc_attr__;esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c\n" +"X-Poedit-Basepath: .\n" +"X-Poedit-SearchPath-0: .\n" +"X-Poedit-Bookmarks: \n" +"X-Textdomain-Support: yes\n" +"X-Generator: grunt-wp-i18n 1.0.3\n" + +#: Admin/GiveMultiCurrencyAdmin.php:43 +msgid "Currency Options" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:48 +msgid "Global Options" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:50 +msgid "Enable global options for the form or disable to use form-specific options." +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:52 +#: Admin/GiveMultiCurrencyAdmin.php:114 +msgid "Enabled" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:53 +#: Admin/GiveMultiCurrencyAdmin.php:115 +msgid "Disabled" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:59 +#: Admin/GiveMultiCurrencyAdmin.php:142 +msgid "Default Currency" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:61 +#: Admin/GiveMultiCurrencyAdmin.php:144 +msgid "Select the default currency." +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:63 +#: Admin/GiveMultiCurrencyAdmin.php:79 +#: Admin/GiveMultiCurrencyAdmin.php:128 +#: Admin/GiveMultiCurrencyAdmin.php:146 +msgid "Brazilian Real (R$)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:64 +#: Admin/GiveMultiCurrencyAdmin.php:80 +#: Admin/GiveMultiCurrencyAdmin.php:129 +#: Admin/GiveMultiCurrencyAdmin.php:147 +msgid "US Dollar ($)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:65 +#: Admin/GiveMultiCurrencyAdmin.php:81 +#: Admin/GiveMultiCurrencyAdmin.php:130 +#: Admin/GiveMultiCurrencyAdmin.php:148 +msgid "Euro (€)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:66 +#: Admin/GiveMultiCurrencyAdmin.php:82 +#: Admin/GiveMultiCurrencyAdmin.php:131 +#: Admin/GiveMultiCurrencyAdmin.php:149 +msgid "Japanese Yen (¥)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:67 +#: Admin/GiveMultiCurrencyAdmin.php:83 +#: Admin/GiveMultiCurrencyAdmin.php:132 +#: Admin/GiveMultiCurrencyAdmin.php:150 +msgid "British Pound (£)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:68 +#: Admin/GiveMultiCurrencyAdmin.php:84 +#: Admin/GiveMultiCurrencyAdmin.php:133 +#: Admin/GiveMultiCurrencyAdmin.php:151 +msgid "Saudi Riyal (ر.س)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:69 +#: Admin/GiveMultiCurrencyAdmin.php:85 +#: Admin/GiveMultiCurrencyAdmin.php:134 +#: Admin/GiveMultiCurrencyAdmin.php:152 +msgid "Mexican Peso ($)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:70 +#: Admin/GiveMultiCurrencyAdmin.php:86 +#: Admin/GiveMultiCurrencyAdmin.php:135 +#: Admin/GiveMultiCurrencyAdmin.php:153 +msgid "Swiss Franc (CHF)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:75 +#: Admin/GiveMultiCurrencyAdmin.php:122 +msgid "Enabled Currencies" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:77 +msgid "Select the currencies your form will accept." +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:109 +msgid "Enable Multi Currency" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:111 +msgid "Enable or disable the Multi Currency plugin. This plugin only works with Brazilian Real (BRL - R$)" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:124 +msgid "Select the currencies your form will accept" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:124 +msgid "Add new currency" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:144 +msgid "Select the default currency" +msgstr "" + +#: Admin/GiveMultiCurrencyAdmin.php:183 +msgid "Custom form is not relevant for GiveWP Multi-Step forms. If you want to use the Free Form Plugin, you need to change the form template to \"Legacy\" option." +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:15 +#: Includes/GiveMultiCurrencyHelper.php:34 +msgid "Activation Error:" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:16 +#: Includes/GiveMultiCurrencyHelper.php:35 +msgid "You must have" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:18 +#: Includes/GiveMultiCurrencyHelper.php:37 +msgid "Give" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:19 +msgid "version" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:21 +msgid "for the Give Multi Currency add-on to activate" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:38 +msgid " plugin installed and activated for the Give Multi Currency to activate" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:52 +msgid "Settings" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:66 +msgid "Multi Currency" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:145 +msgid "Attention:" +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:146 +msgid "The Give Multi Currency plugin detected that the Cielo API 3.0 plugin is inactive." +msgstr "" + +#: Includes/GiveMultiCurrencyHelper.php:147 +msgid "Activate in plugins area" +msgstr "" diff --git a/readme.txt b/readme.txt new file mode 100644 index 0000000..ec8f61f --- /dev/null +++ b/readme.txt @@ -0,0 +1,222 @@ +=== Give Multi Currency === +Contributors: linknacional, MarcosAlexandre +Donate link: https://www.linknacional.com.br/wordpress/plugins/ +Tags: givewp, donations, multi-currency, currency converter, international payments +Requires at least: 5.0 +Tested up to: 6.8 +Stable tag: 3.1.3 +Requires PHP: 7.4 +Requires Plugins: give +License: GPLv3 or later +License URI: http://www.gnu.org/licenses/gpl-3.0.txt + +Transform your GiveWP donation forms with seamless multi-currency support and real-time exchange rates. + +== Description == + +**Give Multi Currency** is the ultimate solution for enabling international donations in your GiveWP-powered fundraising campaigns. This powerful plugin automatically converts foreign currencies to Brazilian Real (BRL) for payment processing while displaying donation amounts in the donor's preferred currency, creating a seamless and familiar donation experience for supporters worldwide. + +### Why Choose Give Multi Currency? + +* **Real-Time Exchange Rates**: Automatic currency conversion using live exchange rates from reliable APIs +* **Multiple Currency Support**: Accept donations in USD, EUR, JPY, GBP, SAR, MXN, CHF, and BRL +* **GiveWP 3.0+ Compatible**: Full support for modern GiveWP forms and legacy templates +* **PayPal Integration**: Special currency conversion handling for PayPal Commerce payments +* **Fallback Protection**: Multiple API sources ensure currency rates are always available +* **Easy Configuration**: Simple form-by-form or global currency settings +* **Professional Interface**: Clean, intuitive currency selector for donors + +### Key Features at a Glance + +* **8 Supported Currencies**: Brazilian Real, US Dollar, Euro, Japanese Yen, British Pound, Saudi Riyal, Mexican Peso, Swiss Franc +* **Dynamic Currency Selector**: Interactive dropdown for donors to choose their preferred currency +* **Real-Time Conversion**: Live exchange rates with automatic fallback systems +* **Form-Level Control**: Configure different currencies per donation form +* **Global Settings**: Set default currencies across all forms +* **PayPal Compatibility**: Seamless integration with PayPal Commerce Gateway +* **Legacy Support**: Works with both modern and legacy GiveWP form templates +* **Developer Friendly**: Hooks and filters for customization +* **Multilingual Ready**: Full internationalization support with English, Portuguese, and Spanish translations + +### How It Works + +1. **Currency Selection**: Donors select their preferred currency from an elegant dropdown +2. **Real-Time Conversion**: Plugin fetches current exchange rates and displays amounts +3. **Payment Processing**: Converts foreign currency to BRL for Brazilian payment processors +4. **Seamless Experience**: Donors see familiar currency while payments process correctly + +### Perfect For + +* **International Nonprofits**: Accept donations from supporters worldwide +* **Brazilian Organizations**: Process international donations through local payment systems +* **Fundraising Campaigns**: Expand reach to global donor base +* **Multi-Regional Causes**: Serve diverse communities with localized currency options + +### Technical Highlights + +* **API Integration**: Multiple exchange rate sources for reliability +* **Smart Fallback**: Offline rates ensure continuous operation +* **Performance Optimized**: Efficient currency switching and calculation +* **Security First**: Secure API calls and data handling +* **WordPress Standards**: Follows all WordPress coding and security standards + +**Note**: This plugin requires GiveWP and is optimized for Brazilian Real (BRL) as the base processing currency. + +== Installation == + +### 1. Using WordPress Admin Dashboard (Recommended) +1. Navigate to **Plugins → Add New** +2. Click **Upload Plugin** and select the plugin ZIP file +3. Click **Install Now** and then **Activate** +4. Go to **Donations → Settings → General → Currency Settings** to configure + +### 2. Manual Installation via FTP +1. Extract the plugin ZIP file +2. Upload the extracted folder to `wp-content/plugins/` +3. Activate the plugin in **Plugins** dashboard + +### 3. WP-CLI Installation +```bash +wp plugin activate give-multi-currency +``` + +== Configuration == + +### Initial Setup +1. Navigate to **Donations → Settings → General → Currency Settings** +2. Enable **Multi Currency** option +3. Set your **Default Currency** (recommended: BRL) +4. Select **Enabled Currencies** for your donation forms +5. Save settings + +### Form-Level Configuration +1. Edit any GiveWP donation form +2. Go to **Currency Options** tab +3. Choose between **Global Options** or form-specific settings +4. Configure **Default Currency** and **Enabled Currencies** for this form +5. Update form + +### Requirements +* **GiveWP Plugin**: Version 2.19.2 or higher +* **Currency Setting**: Base currency must be Brazilian Real (BRL) +* **Decimal Places**: Set to 0 in GiveWP currency settings for optimal performance + +== Frequently Asked Questions == + += What currencies are supported? = +The plugin supports 8 major currencies: Brazilian Real (BRL), US Dollar (USD), Euro (EUR), Japanese Yen (JPY), British Pound (GBP), Saudi Riyal (SAR), Mexican Peso (MXN), and Swiss Franc (CHF). + += Does it work with all payment gateways? = +The plugin works with most payment gateways, with special optimization for PayPal Commerce. It converts currencies for processing while maintaining the donor experience. + += Can I set different currencies for different forms? = +Yes! You can configure currencies globally or set specific currencies for individual donation forms. + += What happens if exchange rate APIs are unavailable? = +The plugin includes multiple fallback systems, including offline rates, to ensure continuous operation even if primary APIs are temporarily unavailable. + += Is the plugin compatible with GiveWP 3.0? = +Absolutely! The plugin fully supports both GiveWP 3.0+ modern forms and legacy templates. + += Can I customize the currency selector appearance? = +Yes, the plugin includes CSS classes and hooks for customization. Advanced users can modify the appearance through themes or custom CSS. + += Does it support recurring donations? = +Yes, the plugin works seamlessly with GiveWP's recurring donation features. + += What about transaction fees and conversion rates? = +The plugin displays current market exchange rates. Payment processor fees are handled according to your gateway's standard policies. + += Is technical support available? = +Yes! Visit our [support page](https://www.linknacional.com.br/suporte/) or create a ticket for assistance. + +== Screenshots == + +1. **Currency selector on donation form** - Clean dropdown interface for donors +2. **Global settings page** - Configure default currencies and global options +3. **Form-specific settings** - Per-form currency configuration options +4. **Admin currency options** - Complete currency management interface +5. **PayPal integration** - Seamless PayPal Commerce compatibility +6. **Multi-language support** - Interface in multiple languages + +== Changelog == + += 3.1.3 - 2025/06/27 = +* Added fallback routes for API error handling +* Improved reliability with multiple exchange rate sources +* Enhanced error handling and recovery + += 3.1.2 - 2025/05/02 = +* Fixed action hook implementation +* Improved plugin stability + += 3.1.1 - 2025/04/23 = +* Updated PayPal script integration +* Enhanced PayPal Commerce compatibility + += 3.1.0 - 2025/03/12 = +* Added currency conversion during PayPal payment processing +* Improved PayPal Commerce Gateway integration +* Enhanced payment flow for international transactions + += 3.0.3 - 2024/11/29 = +* Added Swiss Franc (CHF) currency support +* Expanded currency options for European donors + += 3.0.2 - 2024/09/26 = +* Added decimal value handling improvements +* Enhanced calculation accuracy + += 3.0.1 - 2024/08/27 = +* Visual improvements in plugin display +* UI/UX enhancements for better user experience + += 3.0.0 - 2024/08/16 = +* Added support for GiveWP 3.0.0 forms +* Major code refactoring and optimization +* Bug fixes and performance improvements +* Cleanup of legacy code + += 2.7.0 - 2024/06/13 = +* Added Mexican Peso (MXN) support +* Added notifications for inactive Link Nacional plugins +* Enhanced plugin ecosystem integration + += 2.6.0 - 2023/12/23 = +* Added Saudi Riyal (SAR) support +* Updated exchange rate API endpoints +* Added comprehensive changelog system + +[View complete changelog](https://github.com/LinkNacional/give-multimoeda/blob/main/CHANGELOG.md) + +== Upgrade Notice == + += 3.1.3 = +Important update with improved API reliability and fallback systems. Recommended for all users. + += 3.1.0 = +Major PayPal integration improvements. Essential for sites using PayPal Commerce Gateway. + += 3.0.0 = +Major update with GiveWP 3.0 support. Please test in staging environment before updating production sites. + +== Support == + +For technical support, feature requests, or bug reports: + +* **Support Portal**: [Link Nacional Support](https://www.linknacional.com.br/suporte/) +* **Documentation**: [Plugin Documentation](https://www.linknacional.com.br/wordpress/givewp/multimoeda/) +* **GitHub**: Report issues on our [GitHub repository](https://github.com/LinkNacional/give-multimoeda) + +**Professional WordPress Development**: Need custom modifications or have a special project? [Contact our development team](https://www.linknacional.com.br/wordpress/) + +== Recommended Plugins == + +* **[GiveWP](https://wordpress.org/plugins/give/)** - The #1 donation plugin for WordPress (Required) +* **[Give - Recurring Donations](https://givewp.com/addons/recurring-donations/)** - Accept recurring donations +* **[Give - Fee Recovery](https://givewp.com/addons/fee-recovery/)** - Let donors cover transaction fees +* **[Give - Form Field Manager](https://givewp.com/addons/form-field-manager/)** - Customize donation forms + +--- + +**Transform your donation forms into a global fundraising platform with Give Multi Currency today!** From b452c81d07b9b5542d475efd02254eccd17559d1 Mon Sep 17 00:00:00 2001 From: GuilhermeLinkNacional Date: Mon, 10 Nov 2025 11:28:56 -0300 Subject: [PATCH 3/3] =?UTF-8?q?=F0=9F=93=9D=20Atualizando=20vers=C3=A3o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yml | 2 +- CHANGELOG.md | 3 +++ give-currency.php | 4 ++-- readme.txt | 6 +++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1c7a8cf..aeb15f4 100755 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -57,7 +57,7 @@ jobs: uses: mathieudutour/github-tag-action@v6.0 with: github_token: ${{ secrets.GITHUB_TOKEN }} - custom_tag: '3.1.3' + custom_tag: '3.1.4' # Generate new release - name: Generate new Release diff --git a/CHANGELOG.md b/CHANGELOG.md index ef1601e..d8d29f4 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 3.1.4 - 10/11/2025 +* Remoção do plugin updater. + # 3.1.3 - 27/06/2025 * Adição de rotas de fallback em caso de erro na API. diff --git a/give-currency.php b/give-currency.php index b308fa7..ca1401e 100755 --- a/give-currency.php +++ b/give-currency.php @@ -4,7 +4,7 @@ * Plugin Name: Give - Multi Currency * Plugin URI: https://www.linknacional.com.br/wordpress/givewp/multimoeda/ * Description: Adds currency selection options to GiveWP forms. - * Version: 3.1.3 + * Version: 3.1.4 * Author: Link Nacional * Requires Plugins: give * Author URI: https://www.linknacional.com.br @@ -24,7 +24,7 @@ use Lkn\GiveMultimoedas\Includes\GiveMultiCurrency; if (! defined('GIVE_MULTI_CURRENCY_VERSION')) { - define('GIVE_MULTI_CURRENCY_VERSION', '3.1.3'); + define('GIVE_MULTI_CURRENCY_VERSION', '3.1.4'); } // Set it to latest. diff --git a/readme.txt b/readme.txt index ec8f61f..32dbbb0 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ Donate link: https://www.linknacional.com.br/wordpress/plugins/ Tags: givewp, donations, multi-currency, currency converter, international payments Requires at least: 5.0 Tested up to: 6.8 -Stable tag: 3.1.3 +Stable tag: 3.1.4 Requires PHP: 7.4 Requires Plugins: give License: GPLv3 or later @@ -140,6 +140,8 @@ Yes! Visit our [support page](https://www.linknacional.com.br/suporte/) or creat 6. **Multi-language support** - Interface in multiple languages == Changelog == += 3.1.4 - 2025/11/10 = +* Remove plugin updater. = 3.1.3 - 2025/06/27 = * Added fallback routes for API error handling @@ -190,6 +192,8 @@ Yes! Visit our [support page](https://www.linknacional.com.br/suporte/) or creat [View complete changelog](https://github.com/LinkNacional/give-multimoeda/blob/main/CHANGELOG.md) == Upgrade Notice == += 3.1.4 = +* Remove plugin updater. = 3.1.3 = Important update with improved API reliability and fallback systems. Recommended for all users.