]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-upgrader-skins.php
WordPress 3.9.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-upgrader-skins.php
index 71a1293e8bb370c16cfed86116ea9d6c9264a431..8c4840764271203981accd913bd917d160228137 100644 (file)
@@ -65,7 +65,7 @@ class WP_Upgrader_Skin {
                } 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);
                        }
@@ -92,6 +92,26 @@ class WP_Upgrader_Skin {
        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>';
+       }
 }
 
 /**
@@ -124,6 +144,8 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
                        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&amp;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>'
@@ -131,7 +153,16 @@ class Plugin_Upgrader_Skin extends WP_Upgrader_Skin {
                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));
        }
@@ -198,7 +229,7 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
                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;
                        }
@@ -252,6 +283,25 @@ class Bulk_Upgrader_Skin extends WP_Upgrader_Skin {
                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 {
@@ -272,6 +322,7 @@ 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();
@@ -282,7 +333,16 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
                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));
        }
@@ -306,6 +366,7 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
 
        function after($title = '') {
                parent::after( $this->theme_info->display('Name') );
+               $this->decrement_update_count( 'theme' );
        }
 
        function bulk_footer() {
@@ -317,7 +378,16 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
                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));
        }
@@ -380,7 +450,19 @@ class Plugin_Installer_Skin extends WP_Upgrader_Skin {
                        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));
        }
@@ -453,7 +535,17 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
                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));
        }
@@ -479,6 +571,7 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
        }
 
        function after() {
+               $this->decrement_update_count( 'theme' );
 
                $update_actions = array();
                if ( ! empty( $this->upgrader->result['destination_name'] ) && $theme_info = $this->upgrader->theme_info() ) {
@@ -514,7 +607,16 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
 
                $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));
        }
@@ -561,8 +663,17 @@ class Language_Pack_Upgrader_Skin extends WP_Upgrader_Skin {
        }
 
        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 )