From dd997db92385e4debcacbaf0b8eea2400cb1a1d8 Mon Sep 17 00:00:00 2001 From: icetee Date: Mon, 5 Oct 2015 14:20:43 +0200 Subject: [PATCH] Support languages Translation beinning --- github-checker.php | 6 +- languages/plugin-update-checker-hu_HU.mo | Bin 0 -> 1903 bytes languages/plugin-update-checker-hu_HU.po | 122 ++++++++++++ languages/plugin-update-checker.pot | 0 plugin-update-checker.php | 234 +++++++++++------------ 5 files changed, 242 insertions(+), 120 deletions(-) create mode 100644 languages/plugin-update-checker-hu_HU.mo create mode 100644 languages/plugin-update-checker-hu_HU.po create mode 100644 languages/plugin-update-checker.pot diff --git a/github-checker.php b/github-checker.php index 6441176..5d9b2b6 100644 --- a/github-checker.php +++ b/github-checker.php @@ -44,7 +44,7 @@ class PucGitHubChecker_2_2 extends PluginUpdateChecker_2_2 { $this->userName = $matches['username']; $this->repositoryName = $matches['repository']; } else { - throw new InvalidArgumentException('Invalid GitHub repository URL: "' . $repositoryUrl . '"'); + throw new InvalidArgumentException( __('Invalid GitHub repository URL: ', 'plugin-update-checker') . '"' . $repositoryUrl . '"'); } parent::__construct($repositoryUrl, $pluginFile, '', $checkPeriod, $optionName, $muPluginFile); @@ -302,7 +302,7 @@ class PucGitHubChecker_2_2 extends PluginUpdateChecker_2_2 { return new WP_Error( 'puc-github-http-error', - 'GitHub API error. HTTP status: ' . $code + __('GitHub API error. HTTP status: ', 'plugin-update-checker') . $code ); } @@ -448,4 +448,4 @@ class PucGitHubChecker_2_2 extends PluginUpdateChecker_2_2 { } } -endif; \ No newline at end of file +endif; diff --git a/languages/plugin-update-checker-hu_HU.mo b/languages/plugin-update-checker-hu_HU.mo new file mode 100644 index 0000000000000000000000000000000000000000..8497c4ad0fd471ee91485ad99ec6ed9a354990c2 GIT binary patch literal 1903 zcmZvc&u<(x6vqveU)w@O5Bw5{M^LJkGLzlVifBR*AtX&iDpu{5AE)5#yxnm!V~=dl zrn@&zoH$gJOK-VU>VX4__zOn;H$d=Da6;nioo&)WEqOoly!QL$_x$_0Q$GugvzTvT z-obng^UPED!N|b(K?S}7-T_|*?}6Wfzk%<7XP*}0Rd4|e@&52=Tv&8P3BEaT*h02&fb-eFTg1y9k8B-6tM>1EClpfL;rzqZYFg(CXI#52N%=Dz_D#yccd@0X)@XLza%r6M z2438}zKvtuCd^b>?oXFp)$g-&gDTI*WLe9C(^y;&AHm^y7lNC2=igge{II<&dKm{z zVLdhMNE=V3f!AT1Y(o8S7N()bgtL$3xhlh%kk(k-)ce{T=vkVnAM(z27A?)qyE*Z7 zx5>aX8;Inf+_793&pSi*7cRngUs;XIkWi!fR*3*1Aw^a0W6`x{4=d4D8hzDVeKPYi zYVJ0g8EtjH>_uyqabZSBpToU`7TcXGQKucXuTbZ5(pkLJUTn9qF}ltp70T$z`#x&+ zZA<5)o|W3=5;;$(CyV;f(WbGZ`Va;1v6qE(aRyoX?9)^Ym6!Q}9C4ggpR~569#(S5 zQIBPj(6O9QR<*8eU0Xkis1vtaYesw4usAN^y60Pdq0FVy%SdY|QonMuw-GI!>yM|NcsS_{7SMX0GMxRN?C0tG@j$0@#EAwc>*a8Kr z(NGZG%Hnd!Gd@=?XnJ>rIv1Bu6nw$s17lOSt(;G2hnIJDPX4@sX6f@<<8(re*T=SR zu(bWG3+quE_FJO9yBE58qUs~6@7s+1gWJS8s&ZfPu)gmm^)Fb;9^9UY4Xd1kh*fOK zSwFaKClFX%Q#xfGI=nuz_2I76;)X&kdd9B*>Y~u-G;MXI&*Vae7^!VmIH%Xe_N9p9!O=!P9O2sDUf}phA`m#8cnNg?QP;qW=DPH8earj~{soRwoZ%0?h^S za2&Ees_*MD-i71D&>(~yi}eYjMj?bpR?E`L{ct0(*m4Do`6ju8CtV9}(Rn!NCY6(q fzXc&X$^TvgWCm56;~jwJv\n" +"Language-Team: \n" +"Language: hu\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"X-Generator: Poedit 1.8.5\n" +"X-Poedit-Basepath: ..\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" +"X-Poedit-KeywordsList: _e;__\n" +"X-Poedit-SourceCharset: UTF-8\n" +"X-Poedit-SearchPath-0: .\n" + +#: github-checker.php:47 +msgid "Invalid GitHub repository URL: " +msgstr "Helytelen GitHub \"repository\" URL:" + +#: github-checker.php:305 +msgid "GitHub API error. HTTP status: " +msgstr "GitHub API hiba. HTTP státusz:" + +#: plugin-update-checker.php:172 +#, php-format +msgid "Every %d hours" +msgstr "Minden %d órában" + +#: plugin-update-checker.php:237 +#, php-format +msgid "The URL %s does not point to a valid plugin metadata file. " +msgstr "Az URL %s nem egy érvényes meta adat fájl." + +#: plugin-update-checker.php:239 +msgid "WP HTTP error: " +msgstr "WP HTTP hiba:" + +#: plugin-update-checker.php:241 +msgid "HTTP response code is " +msgstr "HTTP válasz kód" + +#: plugin-update-checker.php:243 +msgid "wp_remote_get() returned an unexpected result." +msgstr "wp_remote_get() váratlan eredményt eredményezett." + +#: plugin-update-checker.php:288 +#, php-format +msgid "" +"Can't to read the Version header for '%s'. The filename is incorrect or is " +"not a plugin." +msgstr "" + +#: plugin-update-checker.php:309 +#, php-format +msgid "Can't to read the plugin header for '%s'. The file does not exist." +msgstr "" + +#: plugin-update-checker.php:336 +#, php-format +msgid "Skipping update check for %s - installed version unknown." +msgstr "" + +#: plugin-update-checker.php:614 +#, php-format +msgid "" +"The directory structure of the update is incorrect. All plugin files should " +"be inside a directory named %s, not at the root " +"of the ZIP file." +msgstr "" + +#: plugin-update-checker.php:623 +#, php-format +msgid "Renaming %s to %s…" +msgstr "Átnevezés %s erre %s…" + +#: plugin-update-checker.php:629 +msgid "Plugin directory successfully renamed." +msgstr "A kiegészítő mappájának átnevezése sikeres." + +#: plugin-update-checker.php:634 +msgid "Unable to rename the update to match the existing plugin directory." +msgstr "" + +#: plugin-update-checker.php:723 +msgid "Check for updates" +msgstr "Frissítés ellenőrzése" + +#: plugin-update-checker.php:767 +msgid "This plugin is up to date." +msgstr "Ez a plugin naprakész." + +#: plugin-update-checker.php:769 +msgid "A new version of this plugin is available." +msgstr "Új verzió érhető el a kiegészítőhőz" + +#: plugin-update-checker.php:771 +#, php-format +msgid "Unknown update checker status \"%s\"" +msgstr "Ismeretlen a frissítés ellenőrző státszusa \"%s\"" + +#: plugin-update-checker.php:943 +msgid "" +"Failed to parse plugin metadata. Try validating your .json file with http://" +"jsonlint.com/" +msgstr "" +"Sikertelen a kiegészítő meta adatainak elemzése. Próbáld meg a .json fájlt a " +"http://jsonlint.com oldalon." + +#: plugin-update-checker.php:955 +msgid "" +"The plugin metadata file does not contain the required 'name' and/or " +"'version' keys." +msgstr "" + +#~ msgid "Subtitle" +#~ msgstr "Alcím" + +#~ msgid "Alcím" +#~ msgstr "Subtitle" diff --git a/languages/plugin-update-checker.pot b/languages/plugin-update-checker.pot new file mode 100644 index 0000000..e69de29 diff --git a/plugin-update-checker.php b/plugin-update-checker.php index 218cee4..8a820e4 100644 --- a/plugin-update-checker.php +++ b/plugin-update-checker.php @@ -2,7 +2,7 @@ /** * Plugin Update Checker Library 2.2.0 * http://w-shadow.com/ - * + * * Copyright 2015 Janis Elsts * Released under the MIT license. See license.txt for details. */ @@ -10,8 +10,8 @@ if ( !class_exists('PluginUpdateChecker_2_2', false) ): /** - * A custom plugin update checker. - * + * A custom plugin update checker. + * * @author Janis Elsts * @copyright 2015 * @version 2.2 @@ -63,7 +63,7 @@ class PluginUpdateChecker_2_2 { if ( empty($this->slug) ){ $this->slug = basename($this->pluginFile, '.php'); } - + if ( empty($this->optionName) ){ $this->optionName = 'external_updates-' . $this->slug; } @@ -73,20 +73,20 @@ class PluginUpdateChecker_2_2 { if ( empty($this->muPluginFile) && (strpbrk($this->pluginFile, '/\\') === false) && $this->isMuPlugin() ) { $this->muPluginFile = $this->pluginFile; } - + $this->installHooks(); } - + /** - * Install the hooks required to run periodic update checks and inject update info - * into WP data structures. - * + * 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', array($this, 'injectInfo'), 20, 3); - + //Insert our update info into the update array maintained by WP add_filter('site_transient_update_plugins', array($this,'injectUpdate')); //WP 3.0+ add_filter('transient_update_plugins', array($this,'injectUpdate')); //WP 2.8+ @@ -102,7 +102,7 @@ class PluginUpdateChecker_2_2 { //Set up the periodic update checks $this->cronHook = 'check_plugin_updates-' . $this->slug; 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. @@ -123,11 +123,11 @@ class PluginUpdateChecker_2_2 { wp_schedule_event(time(), $scheduleName, $this->cronHook); } add_action($this->cronHook, array($this, 'maybeCheckForUpdates')); - + register_deactivation_hook($this->pluginFile, array($this, '_removeUpdaterCron')); - - //In case Cron is disabled or unreliable, we also manually trigger - //the periodic checks while the user is browsing the Dashboard. + + //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', array($this, 'maybeCheckForUpdates') ); //Like WordPress itself, we check more often on certain pages. @@ -157,10 +157,10 @@ class PluginUpdateChecker_2_2 { add_filter('upgrader_post_install', array($this, 'clearUpgradedPlugin'), 10, 1); add_action('upgrader_process_complete', array($this, 'clearUpgradedPlugin'), 10, 1); } - + /** * Add our custom schedule to the array of Cron schedules used by WP. - * + * * @param array $schedules * @return array */ @@ -168,8 +168,8 @@ class PluginUpdateChecker_2_2 { if ( $this->checkPeriod && ($this->checkPeriod > 0) ){ $scheduleName = 'every' . $this->checkPeriod . 'hours'; $schedules[$scheduleName] = array( - 'interval' => $this->checkPeriod * 3600, - 'display' => sprintf('Every %d hours', $this->checkPeriod), + 'interval' => $this->checkPeriod * 3600, + 'display' => sprintf(__('Every %d hours', 'plugin-update-checker'), $this->checkPeriod), ); } return $schedules; @@ -192,12 +192,12 @@ class PluginUpdateChecker_2_2 { public function getCronHookName() { return $this->cronHook; } - + /** * 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 PluginInfo */ @@ -206,7 +206,7 @@ class PluginUpdateChecker_2_2 { $installedVersion = $this->getInstalledVersion(); $queryArgs['installed_version'] = ($installedVersion !== null) ? $installedVersion : ''; $queryArgs = apply_filters('puc_request_info_query_args-'.$this->slug, $queryArgs); - + //Various options for the wp_remote_get() call. Plugins can filter these, too. $options = array( 'timeout' => 10, //seconds @@ -215,13 +215,13 @@ class PluginUpdateChecker_2_2 { ), ); $options = apply_filters('puc_request_info_options-'.$this->slug, $options); - + //The plugin info should be at 'http://your-api.com/url/here/$slug/info.json' - $url = $this->metadataUrl; + $url = $this->metadataUrl; if ( !empty($queryArgs) ){ $url = add_query_arg($queryArgs, $url); } - + $result = wp_remote_get( $url, $options @@ -234,13 +234,13 @@ class PluginUpdateChecker_2_2 { $pluginInfo->filename = $this->pluginFile; $pluginInfo->slug = $this->slug; } else if ( $this->debugMode ) { - $message = sprintf("The URL %s does not point to a valid plugin metadata file. ", $url); + $message = sprintf( __("The URL %s does not point to a valid plugin metadata file. ", 'plugin-update-checker'), $url); if ( is_wp_error($result) ) { - $message .= "WP HTTP error: " . $result->get_error_message(); + $message .= __("WP HTTP error: ", 'plugin-update-checker') . $result->get_error_message(); } else if ( isset($result['response']['code']) ) { - $message .= "HTTP response code is " . $result['response']['code'] . " (expected: 200)"; + $message .= __("HTTP response code is ", 'plugin-update-checker') . $result['response']['code'] . " (expected: 200)"; } else { - $message .= "wp_remote_get() returned an unexpected result."; + $message .= __("wp_remote_get() returned an unexpected result.", 'plugin-update-checker'); } trigger_error($message, E_USER_WARNING); } @@ -257,7 +257,7 @@ class PluginUpdateChecker_2_2 { * @return PluginUpdate An instance of PluginUpdate, or NULL when no updates are available. */ public function requestUpdate(){ - //For the sake of simplicity, this function just calls requestInfo() + //For the sake of simplicity, this function just calls requestInfo() //and transforms the result accordingly. $pluginInfo = $this->requestInfo(array('checking_for_updates' => '1')); if ( $pluginInfo == null ){ @@ -265,10 +265,10 @@ class PluginUpdateChecker_2_2 { } return PluginUpdate_2_2::fromPluginInfo($pluginInfo); } - + /** * Get the currently installed version of the plugin. - * + * * @return string Version number. */ public function getInstalledVersion(){ @@ -285,7 +285,7 @@ class PluginUpdateChecker_2_2 { if ( $this->debugMode ) { trigger_error( sprintf( - "Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.", + __("Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.", 'plugin-update-checker'), $this->pluginFile ), E_USER_WARNING @@ -306,7 +306,7 @@ class PluginUpdateChecker_2_2 { if ( $this->debugMode ) { trigger_error( sprintf( - "Can't to read the plugin header for '%s'. The file does not exist.", + __("Can't to read the plugin header for '%s'. The file does not exist.", 'plugin-update-checker'), $this->pluginFile ), E_USER_WARNING @@ -333,7 +333,7 @@ class PluginUpdateChecker_2_2 { if ( $installedVersion === null ) { if ( $this->debugMode ) { trigger_error( - sprintf('Skipping update check for %s - installed version unknown.', $this->pluginFile), + sprintf( __('Skipping update check for %s - installed version unknown.', 'plugin-update-checker'), $this->pluginFile), E_USER_WARNING ); } @@ -347,17 +347,17 @@ class PluginUpdateChecker_2_2 { $state->checkedVersion = ''; $state->update = null; } - + $state->lastCheck = time(); $state->checkedVersion = $installedVersion; - $this->setUpdateState($state); //Save before checking in case something goes wrong - + $this->setUpdateState($state); //Save before checking in case something goes wrong + $state->update = $this->requestUpdate(); $this->setUpdateState($state); return $this->getUpdate(); } - + /** * 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. @@ -413,10 +413,10 @@ class PluginUpdateChecker_2_2 { $this->checkForUpdates(); } } - + /** * Load the update checker state from the DB. - * + * * @return StdClass|null */ public function getUpdateState() { @@ -430,11 +430,11 @@ class PluginUpdateChecker_2_2 { } return $state; } - - + + /** * Persist the update checker state to the DB. - * + * * @param StdClass $state * @return void */ @@ -455,13 +455,13 @@ class PluginUpdateChecker_2_2 { public function resetUpdateState() { delete_site_option($this->optionName); } - + /** - * Intercept plugins_api() calls that request information about our plugin and - * use the configured API endpoint to satisfy them. - * + * 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 @@ -474,19 +474,19 @@ class PluginUpdateChecker_2_2 { if ( !$relevant ){ return $result; } - + $pluginInfo = $this->requestInfo(); $pluginInfo = apply_filters('puc_pre_inject_info-' . $this->slug, $pluginInfo); if ($pluginInfo){ return $pluginInfo->toWpFormat(); } - + return $result; } - + /** * Insert the latest update (if any) into the update list maintained by WP. - * + * * @param StdClass $updates Update list. * @return StdClass Modified update list. */ @@ -611,8 +611,8 @@ class PluginUpdateChecker_2_2 { return new WP_Error( 'puc-incorrect-directory-structure', sprintf( - 'The directory structure of the update is incorrect. All plugin files should be inside ' . - 'a directory named %s, not at the root of the ZIP file.', + __('The directory structure of the update is incorrect. All plugin files should be inside ' . + 'a directory named %s, not at the root of the ZIP file.', 'plugin-update-checker'), htmlentities($this->slug) ) ); @@ -620,18 +620,18 @@ class PluginUpdateChecker_2_2 { } $upgrader->skin->feedback(sprintf( - 'Renaming %s to %s…', + __('Renaming %s to %s…', 'plugin-update-checker'), '' . basename($source) . '', '' . $pluginDirectoryName . '' )); if ( $wp_filesystem->move($source, $correctedSource, true) ) { - $upgrader->skin->feedback('Plugin directory successfully renamed.'); + $upgrader->skin->feedback( __('Plugin directory successfully renamed.', 'plugin-update-checker')); return $correctedSource; } else { return new WP_Error( 'puc-rename-failed', - 'Unable to rename the update to match the existing plugin directory.' + __('Unable to rename the update to match the existing plugin directory.', 'plugin-update-checker') ); } } @@ -720,9 +720,9 @@ class PluginUpdateChecker_2_2 { 'puc_check_for_updates' ); - $linkText = apply_filters('puc_manual_check_link-' . $this->slug, 'Check for updates'); + $linkText = apply_filters('puc_manual_check_link-' . $this->slug, __('Check for updates', 'plugin-update-checker')); if ( !empty($linkText) ) { - $pluginMeta[] = sprintf('%s', esc_attr($linkUrl), $linkText); + $pluginMeta[] = sprintf( '%s', esc_attr($linkUrl), $linkText); } } return $pluginMeta; @@ -764,11 +764,11 @@ class PluginUpdateChecker_2_2 { if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug) ) { $status = strval($_GET['puc_update_check_result']); if ( $status == 'no_update' ) { - $message = 'This plugin is up to date.'; + $message = __('This plugin is up to date.', 'plugin-update-checker'); } else if ( $status == 'update_available' ) { - $message = 'A new version of this plugin is available.'; + $message = __('A new version of this plugin is available.', 'plugin-update-checker'); } else { - $message = sprintf('Unknown update checker status "%s"', htmlentities($status)); + $message = sprintf( __('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status)); } printf( '

%s

', @@ -809,48 +809,48 @@ class PluginUpdateChecker_2_2 { } /** - * Register a callback for filtering query arguments. - * + * 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){ add_filter('puc_request_info_query_args-'.$this->slug, $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. - * + * 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){ add_filter('puc_request_info_options-'.$this->slug, $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 + * + * 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 */ @@ -892,7 +892,7 @@ if ( !class_exists('PluginInfo_2_2', false) ): /** * A container class for holding and transforming various plugin metadata. - * + * * @author Janis Elsts * @copyright 2015 * @version 2.2 @@ -900,7 +900,7 @@ if ( !class_exists('PluginInfo_2_2', false) ): */ class PluginInfo_2_2 { //Most fields map directly to the contents of the plugin's info.json file. - //See the relevant docs for a description of their meaning. + //See the relevant docs for a description of their meaning. public $name; public $slug; public $version; @@ -911,25 +911,25 @@ class PluginInfo_2_2 { public $author; public $author_homepage; - + public $requires; public $tested; public $upgrade_notice; - + public $rating; public $num_ratings; public $downloaded; public $active_installs; public $last_updated; - + public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything. public $filename; //Plugin filename relative to the plugins directory. - + /** - * Create a new instance of PluginInfo from JSON-encoded plugin info + * Create a new instance of PluginInfo from JSON-encoded plugin info * returned by an external update API. - * + * * @param string $json Valid JSON string representing plugin info. * @param bool $triggerErrors * @return PluginInfo|null New instance of PluginInfo, or NULL on error. @@ -940,43 +940,43 @@ class PluginInfo_2_2 { if ( empty($apiResponse) || !is_object($apiResponse) ){ if ( $triggerErrors ) { trigger_error( - "Failed to parse plugin metadata. Try validating your .json file with http://jsonlint.com/", + __( "Failed to parse plugin metadata. Try validating your .json file with http://jsonlint.com/", 'plugin-update-checker'), E_USER_NOTICE ); } return null; } - + //Very, very basic validation. $valid = isset($apiResponse->name) && !empty($apiResponse->name) && isset($apiResponse->version) && !empty($apiResponse->version); if ( !$valid ){ if ( $triggerErrors ) { trigger_error( - "The plugin metadata file does not contain the required 'name' and/or 'version' keys.", + __( "The plugin metadata file does not contain the required 'name' and/or 'version' keys.", 'plugin-update-checker'), E_USER_NOTICE ); } return null; } - + $info = new self(); foreach(get_object_vars($apiResponse) as $key => $value){ $info->$key = $value; } - - return $info; + + return $info; } - + /** * 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. + //as those returned by the native WordPress.org API. These can be assigned directly. $sameFormat = array( 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice', 'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated', @@ -991,13 +991,13 @@ class PluginInfo_2_2 { //Other fields need to be renamed and/or transformed. $info->download_link = $this->download_url; - + if ( !empty($this->author_homepage) ){ $info->author = sprintf('%s', $this->author_homepage, $this->author); } else { $info->author = $this->author; } - + if ( is_object($this->sections) ){ $info->sections = get_object_vars($this->sections); } elseif ( is_array($this->sections) ) { @@ -1016,14 +1016,14 @@ class PluginInfo_2_2 { return $info; } } - + endif; if ( !class_exists('PluginUpdate_2_2', false) ): /** * A simple container class for holding information about an available update. - * + * * @author Janis Elsts * @copyright 2015 * @version 2.2 @@ -1039,10 +1039,10 @@ class PluginUpdate_2_2 { public $filename; //Plugin filename relative to the plugins directory. private static $fields = array('id', 'slug', 'version', 'homepage', 'download_url', 'upgrade_notice', 'filename'); - + /** * Create a new instance of PluginUpdate from its JSON-encoded representation. - * + * * @param string $json * @param bool $triggerErrors * @return PluginUpdate|null @@ -1062,18 +1062,18 @@ class PluginUpdate_2_2 { /** * Create a new instance of PluginUpdate based on an instance of PluginInfo. * Basically, this just copies a subset of fields from one object to another. - * + * * @param PluginInfo $info * @return PluginUpdate */ public static function fromPluginInfo($info){ return self::fromObject($info); } - + /** - * Create a new instance of PluginUpdate by copying the necessary fields from + * Create a new instance of PluginUpdate by copying the necessary fields from * another object. - * + * * @param StdClass|PluginInfo|PluginUpdate $object The source object. * @return PluginUpdate The new copy. */ @@ -1088,13 +1088,13 @@ class PluginUpdate_2_2 { } return $update; } - + /** - * Create an instance of StdClass that can later be converted back to + * Create an instance of StdClass that can later be converted back to * a PluginUpdate. 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() { @@ -1108,11 +1108,11 @@ class PluginUpdate_2_2 { } return $object; } - - + + /** * Transform the update into the format used by WordPress native plugin API. - * + * * @return object */ public function toWpFormat(){ @@ -1128,11 +1128,11 @@ class PluginUpdate_2_2 { if ( !empty($this->upgrade_notice) ){ $update->upgrade_notice = $this->upgrade_notice; } - + return $update; } } - + endif; if ( !class_exists('PucFactory', false) ):