This commit is contained in:
Italo Izaac 2017-07-21 11:16:32 +00:00 committed by GitHub
commit 51fe3e916b
5 changed files with 73 additions and 28 deletions

View File

@ -82,6 +82,7 @@ if ( !class_exists('Puc_v4p2_Plugin_UpdateChecker', false) ):
//Override requests for plugin information
add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
add_filter('plugin_row_meta', array($this, 'addDetailsUpdatesLink'), 10, 2);
add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2);
add_action('admin_init', array($this, 'handleManualCheck'));
add_action('all_admin_notices', array($this, 'displayManualCheckResult'));
@ -327,9 +328,49 @@ if ( !class_exists('Puc_v4p2_Plugin_UpdateChecker', false) ):
}
/**
* Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
* Add a "Show details" link to the plugin row in the "Plugins" page. By default,
* the new link will appear after the "Visit plugin site" link.
*
* You can change the link text by using the "puc_manual_details_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 addDetailsUpdatesLink($pluginMeta, $pluginFile) {
$isRelevant = ($pluginFile == $this->pluginFile)
|| (!empty($this->muPluginFile) && $pluginFile == $this->muPluginFile);
if ( $isRelevant && $this->userCanInstallUpdates() ) {
$linkUrl = add_query_arg(
array(
'tab' => 'plugin-information',
'plugin' => $this->slug,
'TB_iframe' => 'true',
'width' => 850,
'height' => 620
),
admin_url('plugin-install.php')
);
$linkText = apply_filters(
$this->getUniqueName('manual_details_link'),
_x( 'Show details', 'the plugin row meta', 'plugin-update-checker' )
);
if ( !empty($linkText) && !$this->getUpdate() ) {
/** @noinspection HtmlUnknownTarget */
$pluginMeta[] = sprintf( '<a href="%s" class="thickbox open-plugin-details-modal">%s</a>', esc_attr($linkUrl), $linkText );
}
}
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 "Show 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.
*

View File

@ -1,11 +1,9 @@
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"
"POT-Creation-Date: 2017-05-20 22:07-0300\n"
"PO-Revision-Date: 2017-05-20 22:08-0300\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"
@ -13,26 +11,33 @@ msgstr ""
"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-KeywordsList: __;_e;_x:1,2c;_x\n"
"Last-Translator: \n"
"Language: pt_BR\n"
"X-Poedit-SearchPath-0: .\n"
#: Puc/v4p1/Plugin/UpdateChecker.php:358
#: Puc/v4p1/Plugin/UpdateChecker.php:359
msgctxt "the plugin row meta"
msgid "Show details"
msgstr "Ver detalhes"
#: Puc/v4p1/Plugin/UpdateChecker.php:399
msgid "Check for updates"
msgstr "Verificar Atualizações"
#: Puc/v4p1/Plugin/UpdateChecker.php:401 Puc/v4p1/Plugin/UpdateChecker.php:406
#: Puc/v4p1/Plugin/UpdateChecker.php:446
#, 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
#: Puc/v4p1/Plugin/UpdateChecker.php:448
#, 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
#: Puc/v4p1/Plugin/UpdateChecker.php:450
#, php-format
msgid "Unknown update checker status \"%s\""
msgstr "Status \"%s\" desconhecido."
@ -40,9 +45,3 @@ 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."

View File

@ -2,7 +2,7 @@
msgid ""
msgstr ""
"Project-Id-Version: plugin-update-checker\n"
"POT-Creation-Date: 2017-05-20 10:53+0300\n"
"POT-Creation-Date: 2017-05-20 22:07-0300\n"
"PO-Revision-Date: 2016-01-10 20:59+0100\n"
"Last-Translator: Tamás András Horváth <htomy92@gmail.com>\n"
"Language-Team: \n"
@ -10,30 +10,35 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: Poedit 2.0.2\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:1,2c;_x\n"
"X-Poedit-SearchPath-0: .\n"
#: Puc/v4p1/Plugin/UpdateChecker.php:358
#: Puc/v4p1/Plugin/UpdateChecker.php:359
msgctxt "the plugin row meta"
msgid "Show details"
msgstr ""
#: Puc/v4p1/Plugin/UpdateChecker.php:399
msgid "Check for updates"
msgstr ""
#: Puc/v4p1/Plugin/UpdateChecker.php:405
#: Puc/v4p1/Plugin/UpdateChecker.php:446
#, php-format
msgctxt "the plugin title"
msgid "The %s plugin is up to date."
msgstr ""
#: Puc/v4p1/Plugin/UpdateChecker.php:407
#: Puc/v4p1/Plugin/UpdateChecker.php:448
#, php-format
msgctxt "the plugin title"
msgid "A new version of the %s plugin is available."
msgstr ""
#: Puc/v4p1/Plugin/UpdateChecker.php:409
#: Puc/v4p1/Plugin/UpdateChecker.php:450
#, php-format
msgid "Unknown update checker status \"%s\""
msgstr ""

View File

@ -124,25 +124,26 @@ class PucReadmeParser {
for ( $i=1; $i <= count($_sections); $i +=2 ) {
$_sections[$i] = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1<h4>$2</h4>', $_sections[$i]);
$_sections[$i] = $this->filter_text( $_sections[$i], true );
$title = $this->sanitize_text( $_sections[$i-1] );
$sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $_sections[$i]);
}
$title = $this->sanitize_text( $_sections[$i-1] );
$sectionSlug = str_replace(' ', '_', strtolower($title));
$sections[ $sectionSlug ] = array('title' => $title, 'content' => $_sections[$i]);
}
// Special sections
// This is where we nab our special sections, so we can enforce their order and treat them differently, if needed
// upgrade_notice is not a section, but parse it like it is for now
$final_sections = array();
foreach ( array('description', 'installation', 'frequently_asked_questions', 'screenshots', 'changelog', 'change_log', 'upgrade_notice') as $special_section ) {
foreach ( apply_filters('puc_readme_section_allowed', array('description', 'installation', 'frequently_asked_questions', 'faq', 'screenshots', 'changelog', 'change_log', 'upgrade_notice')) as $special_section ) {
if ( isset($sections[$special_section]) ) {
$final_sections[$special_section] = $sections[$special_section]['content'];
unset($sections[$special_section]);
}
}
if ( isset($final_sections['change_log']) && empty($final_sections['changelog']) )
$final_sections['changelog'] = $final_sections['change_log'];
$final_screenshots = array();
if ( isset($final_sections['screenshots']) ) {
preg_match_all('|<li>(.*?)</li>|s', $final_sections['screenshots'], $screenshots, PREG_SET_ORDER);
@ -180,7 +181,6 @@ class PucReadmeParser {
}
$remaining_content = trim($remaining_content);
// All done!
// $r['tags'] and $r['contributors'] are simple arrays
// $r['sections'] is an array with named elements