From 6cabab9179ffb82ede5f64fbafd6eb2b8c3cad1d Mon Sep 17 00:00:00 2001 From: Laptop 3 Date: Tue, 4 Apr 2017 01:55:45 -0400 Subject: [PATCH] Add plugin title to admin notice --- Puc/v4/Plugin/UpdateChecker.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Puc/v4/Plugin/UpdateChecker.php b/Puc/v4/Plugin/UpdateChecker.php index ca0604d..9663f01 100644 --- a/Puc/v4/Plugin/UpdateChecker.php +++ b/Puc/v4/Plugin/UpdateChecker.php @@ -400,10 +400,11 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): public function displayManualCheckResult() { if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->slug) ) { $status = strval($_GET['puc_update_check_result']); + $title = $this->getPluginTitle(); if ( $status == 'no_update' ) { - $message = __('This plugin is up to date.', 'plugin-update-checker'); + $message = sprintf( _x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title ); } else if ( $status == 'update_available' ) { - $message = __('A new version of this plugin is available.', 'plugin-update-checker'); + $message = sprintf( _x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title ); } else { $message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status)); } @@ -414,6 +415,20 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): } } + /** + * Get the translated plugin title. + * + * @return string + */ + protected function getPluginTitle() { + $title = ''; + $header = $this->getPluginHeader(); + if ( $header && ! empty( $header['Name'] ) && isset( $header['TextDomain'] ) ) { + $title = translate( $header['Name'], $header['TextDomain'] ); + } + return $title; + } + /** * Check if the current user has the required permissions to install updates. * @@ -528,4 +543,4 @@ if ( !class_exists('Puc_v4_Plugin_UpdateChecker', false) ): } } -endif; \ No newline at end of file +endif;