]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-plugin-install-list-table.php
WordPress 3.9.1-scripts
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-plugin-install-list-table.php
index 1f809b37ab73a8e75dd5189f9d7380ea8c74c966..868c08caa3d74f0fb001acd7aec9bf596efad31b 100644 (file)
@@ -29,18 +29,34 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
                $tabs['dashboard'] = __( 'Search' );
                if ( 'search' == $tab )
                        $tabs['search'] = __( 'Search Results' );
-               $tabs['upload'] = __( 'Upload' );
-               $tabs['featured'] = _x( 'Featured','Plugin Installer' );
-               $tabs['popular']  = _x( 'Popular','Plugin Installer' );
-               $tabs['new']      = _x( 'Newest','Plugin Installer' );
-               $tabs['updated']  = _x( 'Recently Updated','Plugin Installer' );
+               $tabs['upload']    = __( 'Upload' );
+               $tabs['featured']  = _x( 'Featured', 'Plugin Installer' );
+               $tabs['popular']   = _x( 'Popular', 'Plugin Installer' );
+               $tabs['new']       = _x( 'Newest', 'Plugin Installer' );
+               $tabs['favorites'] = _x( 'Favorites', 'Plugin Installer' );
 
                $nonmenu_tabs = array( 'plugin-information' ); //Valid actions to perform which do not have a Menu item.
 
+               /**
+                * Filter the tabs shown on the Plugin Install screen.
+                *
+                * @since 2.7.0
+                *
+                * @param array $tabs The tabs shown on the Plugin Install screen. Defaults are 'dashboard', 'search',
+                *                    'upload', 'featured', 'popular', 'new', and 'favorites'.
+                */
                $tabs = apply_filters( 'install_plugins_tabs', $tabs );
+
+               /**
+                * Filter tabs not associated with a menu item on the Plugin Install screen.
+                *
+                * @since 2.7.0
+                *
+                * @param array $nonmenu_tabs The tabs that don't have a Menu item on the Plugin Install screen.
+                */
                $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
 
-               // If a non-valid menu tab has been selected, And its not a non-menu action.
+               // If a non-valid menu tab has been selected, And it's not a non-menu action.
                if ( empty( $tab ) || ( !isset( $tabs[ $tab ] ) && !in_array( $tab, (array) $nonmenu_tabs ) ) )
                        $tab = key( $tabs );
 
@@ -48,8 +64,8 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
 
                switch ( $tab ) {
                        case 'search':
-                               $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : '';
-                               $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
+                               $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
+                               $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
 
                                switch ( $type ) {
                                        case 'tag':
@@ -63,20 +79,44 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
                                                break;
                                }
 
-                               add_action( 'install_plugins_table_header', 'install_search_form' );
+                               add_action( 'install_plugins_table_header', 'install_search_form', 10, 0 );
                                break;
 
                        case 'featured':
                        case 'popular':
                        case 'new':
-                       case 'updated':
                                $args['browse'] = $tab;
                                break;
 
+                       case 'favorites':
+                               $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
+                               update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
+                               if ( $user )
+                                       $args['user'] = $user;
+                               else
+                                       $args = false;
+
+                               add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
+                               break;
+
                        default:
                                $args = false;
+                               break;
                }
 
+               /**
+                * Filter API request arguments for each Plugin Install screen tab.
+                *
+                * The dynamic portion of the hook name, $tab, refers to the plugin install tabs.
+                * Default tabs are 'dashboard', 'search', 'upload', 'featured', 'popular', 'new',
+                * and 'favorites'.
+                *
+                * @since 3.7.0
+                *
+                * @param array|bool $args Plugin Install API arguments.
+                */
+               $args = apply_filters( "install_plugins_table_api_args_$tab", $args );
+
                if ( !$args )
                        return;
 
@@ -89,7 +129,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
 
                $this->set_pagination_args( array(
                        'total_items' => $api->info['results'],
-                       'per_page' => $per_page,
+                       'per_page' => $args['per_page'],
                ) );
        }
 
@@ -114,16 +154,20 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
                if ( 'top' ==  $which ) { ?>
                        <div class="tablenav top">
                                <div class="alignleft actions">
-                                       <?php do_action( 'install_plugins_table_header' ); ?>
+                                       <?php
+                                       /**
+                                        * Fires before the Plugin Install table header pagination is displayed.
+                                        *
+                                        * @since 2.7.0
+                                        */
+                                       do_action( 'install_plugins_table_header' ); ?>
                                </div>
                                <?php $this->pagination( $which ); ?>
-                               <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
                                <br class="clear" />
                        </div>
                <?php } else { ?>
                        <div class="tablenav bottom">
                                <?php $this->pagination( $which ); ?>
-                               <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading list-ajax-loading" alt="" />
                                <br class="clear" />
                        </div>
                <?php
@@ -201,15 +245,23 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
                                                break;
                                        case 'update_available':
                                                if ( $status['url'] )
-                                                       $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . sprintf( __( 'Update Now' ), $status['version'] ) . '</a>';
+                                                       $action_links[] = '<a href="' . $status['url'] . '" title="' . esc_attr( sprintf( __( 'Update to version %s' ), $status['version'] ) ) . '">' . __( 'Update Now' ) . '</a>';
                                                break;
                                        case 'latest_installed':
                                        case 'newer_installed':
-                                               $action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . __( 'Installed' ) . '</span>';
+                                               $action_links[] = '<span title="' . esc_attr__( 'This plugin is already installed and is up to date' ) . ' ">' . _x( 'Installed', 'plugin' ) . '</span>';
                                                break;
                                }
                        }
 
+                       /**
+                        * Filter the install action links for a plugin.
+                        *
+                        * @since 2.7.0
+                        *
+                        * @param array $action_links An array of plugin action hyperlinks. Defaults are links to Details and Install Now.
+                        * @param array $plugin       The plugin currently being listed.
+                        */
                        $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
                ?>
                <tr>
@@ -218,21 +270,7 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
                        </td>
                        <td class="vers column-version"<?php echo $style['version']; ?>><?php echo $version; ?></td>
                        <td class="vers column-rating"<?php echo $style['rating']; ?>>
-                               <div class="star-holder" title="<?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $plugin['num_ratings'] ), number_format_i18n( $plugin['num_ratings'] ) ) ?>">
-                                       <div class="star star-rating" style="width: <?php echo esc_attr( $plugin['rating'] ) ?>px"></div>
-                                       <?php
-                                               $color = get_user_option('admin_color');
-                                               if ( empty($color) || 'fresh' == $color )
-                                                       $star_url = admin_url( 'images/gray-star.png?v=20110615' ); // 'Fresh' Gray star for list tables
-                                               else
-                                                       $star_url = admin_url( 'images/star.png?v=20110615' ); // 'Classic' Blue star
-                                       ?>
-                                       <div class="star star5"><img src="<?php echo $star_url; ?>" alt="<?php _e( '5 stars' ) ?>" /></div>
-                                       <div class="star star4"><img src="<?php echo $star_url; ?>" alt="<?php _e( '4 stars' ) ?>" /></div>
-                                       <div class="star star3"><img src="<?php echo $star_url; ?>" alt="<?php _e( '3 stars' ) ?>" /></div>
-                                       <div class="star star2"><img src="<?php echo $star_url; ?>" alt="<?php _e( '2 stars' ) ?>" /></div>
-                                       <div class="star star1"><img src="<?php echo $star_url; ?>" alt="<?php _e( '1 star' ) ?>" /></div>
-                               </div>
+                               <?php wp_star_rating( array( 'rating' => $plugin['rating'], 'type' => 'percent', 'number' => $plugin['num_ratings'] ) ); ?>
                        </td>
                        <td class="desc column-description"<?php echo $style['description']; ?>><?php echo $description, $author; ?></td>
                </tr>
@@ -240,5 +278,3 @@ class WP_Plugin_Install_List_Table extends WP_List_Table {
                }
        }
 }
-
-?>