} elseif ( is_wp_error($errors) && $errors->get_error_code() ) {
foreach ( $errors->get_error_messages() as $message ) {
if ( $errors->get_error_data() && is_string( $errors->get_error_data() ) )
- $this->feedback($message . ' ' . esc_html( $errors->get_error_data() ) );
+ $this->feedback($message . ' ' . esc_html( strip_tags( $errors->get_error_data() ) ) );
else
$this->feedback($message);
}
function before() {}
function after() {}
+ /**
+ * Output JavaScript that calls function to decrement the update counts.
+ *
+ * @since 3.9.0
+ *
+ * @param string $type Type of update count to decrement. Likely values include 'plugin',
+ * 'theme', 'translation', etc.
+ */
+ protected function decrement_update_count( $type ) {
+ if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
+ return;
+ }
+ echo '<script type="text/javascript">
+ (function( wp ) {
+ if ( wp && wp.updates.decrementCount ) {
+ wp.updates.decrementCount( "' . $type . '" );
+ }
+ })( window.wp );
+ </script>';
+ }
}
/**
echo '<iframe style="border:0;overflow:hidden" width="100%" height="170px" src="' . wp_nonce_url('update.php?action=activate-plugin&networkwide=' . $this->plugin_network_active . '&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) .'"></iframe>';
}
+ $this->decrement_update_count( 'plugin' );
+
$update_actions = array(
'activate_plugin' => '<a href="' . wp_nonce_url('plugins.php?action=activate&plugin=' . urlencode( $this->plugin ), 'activate-plugin_' . $this->plugin) . '" title="' . esc_attr__('Activate this plugin') . '" target="_parent">' . __('Activate Plugin') . '</a>',
'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>'
if ( $this->plugin_active || ! $this->result || is_wp_error( $this->result ) || ! current_user_can( 'activate_plugins' ) )
unset( $update_actions['activate_plugin'] );
- $update_actions = apply_filters('update_plugin_complete_actions', $update_actions, $this->plugin);
+ /**
+ * Filter the list of action links available following a single plugin update.
+ *
+ * @since 2.7.0
+ *
+ * @param array $update_actions Array of plugin action links.
+ * @param string $plugin Path to the plugin file.
+ */
+ $update_actions = apply_filters( 'update_plugin_complete_actions', $update_actions, $this->plugin );
+
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
if ( is_wp_error($error) ) {
foreach ( $error->get_error_messages() as $emessage ) {
if ( $error->get_error_data() && is_string( $error->get_error_data() ) )
- $messages[] = $emessage . ' ' . esc_html( $error->get_error_data() );
+ $messages[] = $emessage . ' ' . esc_html( strip_tags( $error->get_error_data() ) );
else
$messages[] = $emessage;
}
wp_ob_end_flush_all();
flush();
}
+
+ /**
+ * Output JavaScript that sends message to parent window to decrement the update counts.
+ *
+ * @since 3.9.0
+ *
+ * @param string $type Type of update count to decrement. Likely values include 'plugin',
+ * 'theme', 'translation', etc.
+ */
+ protected function decrement_update_count( $type ) {
+ if ( ! $this->result || is_wp_error( $this->result ) || 'up_to_date' === $this->result ) {
+ return;
+ }
+ echo '<script type="text/javascript">
+ if ( window.postMessage && JSON ) {
+ window.parent.postMessage( JSON.stringify( { action: "decrementUpdateCount", upgradeType: "' . $type . '" } ), window.location.protocol + "//" + window.location.hostname );
+ }
+ </script>';
+ }
}
class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
function after($title = '') {
parent::after($this->plugin_info['Title']);
+ $this->decrement_update_count( 'plugin' );
}
function bulk_footer() {
parent::bulk_footer();
if ( ! current_user_can( 'activate_plugins' ) )
unset( $update_actions['plugins_page'] );
- $update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
+ /**
+ * Filter the list of action links available following bulk plugin updates.
+ *
+ * @since 3.0.0
+ *
+ * @param array $update_actions Array of plugin action links.
+ * @param array $plugin_info Array of information for the last-updated plugin.
+ */
+ $update_actions = apply_filters( 'update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info );
+
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
function after($title = '') {
parent::after( $this->theme_info->display('Name') );
+ $this->decrement_update_count( 'theme' );
}
function bulk_footer() {
if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
unset( $update_actions['themes_page'] );
- $update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
+ /**
+ * Filter the list of action links available following bulk theme updates.
+ *
+ * @since 3.0.0
+ *
+ * @param array $update_actions Array of theme action links.
+ * @param array $theme_info Array of information for the last-updated theme.
+ */
+ $update_actions = apply_filters( 'update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
+
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
unset( $install_actions['activate_plugin'] );
}
- $install_actions = apply_filters('install_plugin_complete_actions', $install_actions, $this->api, $plugin_file);
+ /**
+ * Filter the list of action links available following a single plugin installation.
+ *
+ * @since 2.7.0
+ *
+ * @param array $install_actions Array of plugin action links.
+ * @param object $api Object containing WordPress.org API plugin data. Empty
+ * for non-API installs, such as when a plugin is installed
+ * via upload.
+ * @param string $plugin_file Path to the plugin file.
+ */
+ $install_actions = apply_filters( 'install_plugin_complete_actions', $install_actions, $this->api, $plugin_file );
+
if ( ! empty($install_actions) )
$this->feedback(implode(' | ', (array)$install_actions));
}
if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
unset( $install_actions['activate'], $install_actions['preview'] );
- $install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
+ /**
+ * Filter the list of action links available following a single theme installation.
+ *
+ * @since 2.8.0
+ *
+ * @param array $install_actions Array of theme action links.
+ * @param object $api Object containing WordPress.org API theme data.
+ * @param string $stylesheet Theme directory name.
+ * @param WP_Theme $theme_info Theme object.
+ */
+ $install_actions = apply_filters( 'install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info );
if ( ! empty($install_actions) )
$this->feedback(implode(' | ', (array)$install_actions));
}
}
function after() {
+ $this->decrement_update_count( 'theme' );
$update_actions = array();
if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
$update_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Return to Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
- $update_actions = apply_filters('update_theme_complete_actions', $update_actions, $this->theme);
+ /**
+ * Filter the list of action links available following a single theme update.
+ *
+ * @since 2.8.0
+ *
+ * @param array $update_actions Array of theme action links.
+ * @param string $theme Theme directory name.
+ */
+ $update_actions = apply_filters( 'update_theme_complete_actions', $update_actions, $this->theme );
+
if ( ! empty($update_actions) )
$this->feedback(implode(' | ', (array)$update_actions));
}
}
function bulk_footer() {
+ $this->decrement_update_count( 'translation' );
$update_actions = array();
$update_actions['updates_page'] = '<a href="' . self_admin_url( 'update-core.php' ) . '" title="' . esc_attr__( 'Go to WordPress Updates page' ) . '" target="_parent">' . __( 'Return to WordPress Updates' ) . '</a>';
+
+ /**
+ * Filter the list of action links available following a translations update.
+ *
+ * @since 3.7.0
+ *
+ * @param array $update_actions Array of translations update links.
+ */
$update_actions = apply_filters( 'update_translations_complete_actions', $update_actions );
if ( $update_actions && $this->display_footer_actions )