83 * @global int $paged |
83 * @global int $paged |
84 * @global string $type |
84 * @global string $type |
85 * @global string $term |
85 * @global string $term |
86 */ |
86 */ |
87 public function prepare_items() { |
87 public function prepare_items() { |
88 include( ABSPATH . 'wp-admin/includes/plugin-install.php' ); |
88 include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; |
89 |
89 |
90 global $tabs, $tab, $paged, $type, $term; |
90 global $tabs, $tab, $paged, $type, $term; |
91 |
91 |
92 wp_reset_vars( array( 'tab' ) ); |
92 wp_reset_vars( array( 'tab' ) ); |
93 |
93 |
94 $paged = $this->get_pagenum(); |
94 $paged = $this->get_pagenum(); |
95 |
95 |
96 $per_page = 36; |
96 $per_page = 36; |
97 |
97 |
98 // These are the tabs which are shown on the page |
98 // These are the tabs which are shown on the page. |
99 $tabs = array(); |
99 $tabs = array(); |
100 |
100 |
101 if ( 'search' === $tab ) { |
101 if ( 'search' === $tab ) { |
102 $tabs['search'] = __( 'Search Results' ); |
102 $tabs['search'] = __( 'Search Results' ); |
103 } |
103 } |
104 if ( $tab === 'beta' || false !== strpos( get_bloginfo( 'version' ), '-' ) ) { |
104 if ( 'beta' === $tab || false !== strpos( get_bloginfo( 'version' ), '-' ) ) { |
105 $tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' ); |
105 $tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' ); |
106 } |
106 } |
107 $tabs['featured'] = _x( 'Featured', 'Plugin Installer' ); |
107 $tabs['featured'] = _x( 'Featured', 'Plugin Installer' ); |
108 $tabs['popular'] = _x( 'Popular', 'Plugin Installer' ); |
108 $tabs['popular'] = _x( 'Popular', 'Plugin Installer' ); |
109 $tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' ); |
109 $tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' ); |
115 } |
115 } |
116 |
116 |
117 $nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item. |
117 $nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item. |
118 |
118 |
119 /** |
119 /** |
120 * Filters the tabs shown on the Plugin Install screen. |
120 * Filters the tabs shown on the Add Plugins screen. |
121 * |
121 * |
122 * @since 2.7.0 |
122 * @since 2.7.0 |
123 * |
123 * |
124 * @param string[] $tabs The tabs shown on the Plugin Install screen. Defaults include 'featured', 'popular', |
124 * @param string[] $tabs The tabs shown on the Add Plugins screen. Defaults include |
125 * 'recommended', 'favorites', and 'upload'. |
125 * 'featured', 'popular', 'recommended', 'favorites', and 'upload'. |
126 */ |
126 */ |
127 $tabs = apply_filters( 'install_plugins_tabs', $tabs ); |
127 $tabs = apply_filters( 'install_plugins_tabs', $tabs ); |
128 |
128 |
129 /** |
129 /** |
130 * Filters tabs not associated with a menu item on the Plugin Install screen. |
130 * Filters tabs not associated with a menu item on the Add Plugins screen. |
131 * |
131 * |
132 * @since 2.7.0 |
132 * @since 2.7.0 |
133 * |
133 * |
134 * @param string[] $nonmenu_tabs The tabs that don't have a menu item on the Plugin Install screen. |
134 * @param string[] $nonmenu_tabs The tabs that don't have a menu item on the Add Plugins screen. |
135 */ |
135 */ |
136 $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); |
136 $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs ); |
137 |
137 |
138 // If a non-valid menu tab has been selected, And it's not a non-menu action. |
138 // If a non-valid menu tab has been selected, And it's not a non-menu action. |
139 if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs ) ) ) { |
139 if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs, true ) ) ) { |
140 $tab = key( $tabs ); |
140 $tab = key( $tabs ); |
141 } |
141 } |
142 |
142 |
143 $installed_plugins = $this->get_installed_plugins(); |
143 $installed_plugins = $this->get_installed_plugins(); |
144 |
144 |
205 $args = false; |
205 $args = false; |
206 break; |
206 break; |
207 } |
207 } |
208 |
208 |
209 /** |
209 /** |
210 * Filters API request arguments for each Plugin Install screen tab. |
210 * Filters API request arguments for each Add Plugins screen tab. |
211 * |
211 * |
212 * The dynamic portion of the hook name, `$tab`, refers to the plugin install tabs. |
212 * The dynamic portion of the hook name, `$tab`, refers to the plugin install tabs. |
213 * Default tabs include 'featured', 'popular', 'recommended', 'favorites', and 'upload'. |
213 * Default tabs include 'featured', 'popular', 'recommended', 'favorites', and 'upload'. |
214 * |
214 * |
215 * @since 3.7.0 |
215 * @since 3.7.0 |
216 * |
216 * |
217 * @param array|bool $args Plugin Install API arguments. |
217 * @param array|false $args Plugin install API arguments. |
218 */ |
218 */ |
219 $args = apply_filters( "install_plugins_table_api_args_{$tab}", $args ); |
219 $args = apply_filters( "install_plugins_table_api_args_{$tab}", $args ); |
220 |
220 |
221 if ( ! $args ) { |
221 if ( ! $args ) { |
222 return; |
222 return; |
465 foreach ( (array) $this->items as $plugin ) { |
469 foreach ( (array) $this->items as $plugin ) { |
466 if ( is_object( $plugin ) ) { |
470 if ( is_object( $plugin ) ) { |
467 $plugin = (array) $plugin; |
471 $plugin = (array) $plugin; |
468 } |
472 } |
469 |
473 |
470 // Display the group heading if there is one |
474 // Display the group heading if there is one. |
471 if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { |
475 if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) { |
472 if ( isset( $this->groups[ $plugin['group'] ] ) ) { |
476 if ( isset( $this->groups[ $plugin['group'] ] ) ) { |
473 $group_name = $this->groups[ $plugin['group'] ]; |
477 $group_name = $this->groups[ $plugin['group'] ]; |
474 if ( isset( $plugins_group_titles[ $group_name ] ) ) { |
478 if ( isset( $plugins_group_titles[ $group_name ] ) ) { |
475 $group_name = $plugins_group_titles[ $group_name ]; |
479 $group_name = $plugins_group_titles[ $group_name ]; |
476 } |
480 } |
477 } else { |
481 } else { |
478 $group_name = $plugin['group']; |
482 $group_name = $plugin['group']; |
479 } |
483 } |
480 |
484 |
481 // Starting a new group, close off the divs of the last one |
485 // Starting a new group, close off the divs of the last one. |
482 if ( ! empty( $group ) ) { |
486 if ( ! empty( $group ) ) { |
483 echo '</div></div>'; |
487 echo '</div></div>'; |
484 } |
488 } |
485 |
489 |
486 echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; |
490 echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>'; |
487 // needs an extra wrapping div for nth-child selectors to work |
491 // Needs an extra wrapping div for nth-child selectors to work. |
488 echo '<div class="plugin-items">'; |
492 echo '<div class="plugin-items">'; |
489 |
493 |
490 $group = $plugin['group']; |
494 $group = $plugin['group']; |
491 } |
495 } |
492 $title = wp_kses( $plugin['name'], $plugins_allowedtags ); |
496 $title = wp_kses( $plugin['name'], $plugins_allowedtags ); |
497 |
501 |
498 $name = strip_tags( $title . ' ' . $version ); |
502 $name = strip_tags( $title . ' ' . $version ); |
499 |
503 |
500 $author = wp_kses( $plugin['author'], $plugins_allowedtags ); |
504 $author = wp_kses( $plugin['author'], $plugins_allowedtags ); |
501 if ( ! empty( $author ) ) { |
505 if ( ! empty( $author ) ) { |
|
506 /* translators: %s: Plugin author. */ |
502 $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; |
507 $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>'; |
503 } |
508 } |
504 |
509 |
505 $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null; |
510 $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null; |
506 $requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null; |
511 $requires_wp = isset( $plugin['requires'] ) ? $plugin['requires'] : null; |
520 if ( $compatible_php && $compatible_wp ) { |
525 if ( $compatible_php && $compatible_wp ) { |
521 $action_links[] = sprintf( |
526 $action_links[] = sprintf( |
522 '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', |
527 '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', |
523 esc_attr( $plugin['slug'] ), |
528 esc_attr( $plugin['slug'] ), |
524 esc_url( $status['url'] ), |
529 esc_url( $status['url'] ), |
525 /* translators: %s: plugin name and version */ |
530 /* translators: %s: Plugin name and version. */ |
526 esc_attr( sprintf( __( 'Install %s now' ), $name ) ), |
531 esc_attr( sprintf( _x( 'Install %s now', 'plugin' ), $name ) ), |
527 esc_attr( $name ), |
532 esc_attr( $name ), |
528 __( 'Install Now' ) |
533 __( 'Install Now' ) |
529 ); |
534 ); |
530 } else { |
535 } else { |
531 $action_links[] = sprintf( |
536 $action_links[] = sprintf( |
542 $action_links[] = sprintf( |
547 $action_links[] = sprintf( |
543 '<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', |
548 '<a class="update-now button aria-button-if-js" data-plugin="%s" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>', |
544 esc_attr( $status['file'] ), |
549 esc_attr( $status['file'] ), |
545 esc_attr( $plugin['slug'] ), |
550 esc_attr( $plugin['slug'] ), |
546 esc_url( $status['url'] ), |
551 esc_url( $status['url'] ), |
547 /* translators: %s: plugin name and version */ |
552 /* translators: %s: Plugin name and version. */ |
548 esc_attr( sprintf( __( 'Update %s now' ), $name ) ), |
553 esc_attr( sprintf( _x( 'Update %s now', 'plugin' ), $name ) ), |
549 esc_attr( $name ), |
554 esc_attr( $name ), |
550 __( 'Update Now' ) |
555 __( 'Update Now' ) |
551 ); |
556 ); |
552 } else { |
557 } else { |
553 $action_links[] = sprintf( |
558 $action_links[] = sprintf( |
565 '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
570 '<button type="button" class="button button-disabled" disabled="disabled">%s</button>', |
566 _x( 'Active', 'plugin' ) |
571 _x( 'Active', 'plugin' ) |
567 ); |
572 ); |
568 } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) { |
573 } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) { |
569 $button_text = __( 'Activate' ); |
574 $button_text = __( 'Activate' ); |
570 /* translators: %s: plugin name */ |
575 /* translators: %s: Plugin name. */ |
571 $button_label = _x( 'Activate %s', 'plugin' ); |
576 $button_label = _x( 'Activate %s', 'plugin' ); |
572 $activate_url = add_query_arg( |
577 $activate_url = add_query_arg( |
573 array( |
578 array( |
574 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ), |
579 '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ), |
575 'action' => 'activate', |
580 'action' => 'activate', |
578 network_admin_url( 'plugins.php' ) |
583 network_admin_url( 'plugins.php' ) |
579 ); |
584 ); |
580 |
585 |
581 if ( is_network_admin() ) { |
586 if ( is_network_admin() ) { |
582 $button_text = __( 'Network Activate' ); |
587 $button_text = __( 'Network Activate' ); |
583 /* translators: %s: plugin name */ |
588 /* translators: %s: Plugin name. */ |
584 $button_label = _x( 'Network Activate %s', 'plugin' ); |
589 $button_label = _x( 'Network Activate %s', 'plugin' ); |
585 $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url ); |
590 $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url ); |
586 } |
591 } |
587 |
592 |
588 $action_links[] = sprintf( |
593 $action_links[] = sprintf( |
643 echo '<div class="notice inline notice-error notice-alt"><p>'; |
648 echo '<div class="notice inline notice-error notice-alt"><p>'; |
644 if ( ! $compatible_php && ! $compatible_wp ) { |
649 if ( ! $compatible_php && ! $compatible_wp ) { |
645 _e( 'This plugin doesn’t work with your versions of WordPress and PHP.' ); |
650 _e( 'This plugin doesn’t work with your versions of WordPress and PHP.' ); |
646 if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
651 if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { |
647 printf( |
652 printf( |
648 /* translators: 1: "Update WordPress" screen URL, 2: "Update PHP" page URL */ |
653 /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ |
649 ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
654 ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ), |
650 self_admin_url( 'update-core.php' ), |
655 self_admin_url( 'update-core.php' ), |
651 esc_url( wp_get_update_php_url() ) |
656 esc_url( wp_get_update_php_url() ) |
652 ); |
657 ); |
653 wp_update_php_annotation( '</p><p><em>', '</em>' ); |
658 wp_update_php_annotation( '</p><p><em>', '</em>' ); |
654 } elseif ( current_user_can( 'update_core' ) ) { |
659 } elseif ( current_user_can( 'update_core' ) ) { |
655 printf( |
660 printf( |
656 /* translators: %s: "Update WordPress" screen URL */ |
661 /* translators: %s: URL to WordPress Updates screen. */ |
657 ' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
662 ' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
658 self_admin_url( 'update-core.php' ) |
663 self_admin_url( 'update-core.php' ) |
659 ); |
664 ); |
660 } elseif ( current_user_can( 'update_php' ) ) { |
665 } elseif ( current_user_can( 'update_php' ) ) { |
661 printf( |
666 printf( |
662 /* translators: %s: "Update PHP" page URL */ |
667 /* translators: %s: URL to Update PHP page. */ |
663 ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
668 ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
664 esc_url( wp_get_update_php_url() ) |
669 esc_url( wp_get_update_php_url() ) |
665 ); |
670 ); |
666 wp_update_php_annotation( '</p><p><em>', '</em>' ); |
671 wp_update_php_annotation( '</p><p><em>', '</em>' ); |
667 } |
672 } |
668 } elseif ( ! $compatible_wp ) { |
673 } elseif ( ! $compatible_wp ) { |
669 _e( 'This plugin doesn’t work with your version of WordPress.' ); |
674 _e( 'This plugin doesn’t work with your version of WordPress.' ); |
670 if ( current_user_can( 'update_core' ) ) { |
675 if ( current_user_can( 'update_core' ) ) { |
671 printf( |
676 printf( |
672 /* translators: %s: "Update WordPress" screen URL */ |
677 /* translators: %s: URL to WordPress Updates screen. */ |
673 ' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
678 ' ' . __( '<a href="%s">Please update WordPress</a>.' ), |
674 self_admin_url( 'update-core.php' ) |
679 self_admin_url( 'update-core.php' ) |
675 ); |
680 ); |
676 } |
681 } |
677 } elseif ( ! $compatible_php ) { |
682 } elseif ( ! $compatible_php ) { |
678 _e( 'This plugin doesn’t work with your version of PHP.' ); |
683 _e( 'This plugin doesn’t work with your version of PHP.' ); |
679 if ( current_user_can( 'update_php' ) ) { |
684 if ( current_user_can( 'update_php' ) ) { |
680 printf( |
685 printf( |
681 /* translators: %s: "Update PHP" page URL */ |
686 /* translators: %s: URL to Update PHP page. */ |
682 ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
687 ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ), |
683 esc_url( wp_get_update_php_url() ) |
688 esc_url( wp_get_update_php_url() ) |
684 ); |
689 ); |
685 wp_update_php_annotation( '</p><p><em>', '</em>' ); |
690 wp_update_php_annotation( '</p><p><em>', '</em>' ); |
686 } |
691 } |
721 ); |
726 ); |
722 ?> |
727 ?> |
723 <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> |
728 <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span> |
724 </div> |
729 </div> |
725 <div class="column-updated"> |
730 <div class="column-updated"> |
726 <strong><?php _e( 'Last Updated:' ); ?></strong> <?php printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); ?> |
731 <strong><?php _e( 'Last Updated:' ); ?></strong> |
|
732 <?php |
|
733 /* translators: %s: Human-readable time difference. */ |
|
734 printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) ); |
|
735 ?> |
727 </div> |
736 </div> |
728 <div class="column-downloaded"> |
737 <div class="column-downloaded"> |
729 <?php |
738 <?php |
730 if ( $plugin['active_installs'] >= 1000000 ) { |
739 if ( $plugin['active_installs'] >= 1000000 ) { |
731 $active_installs_millions = floor( $plugin['active_installs'] / 1000000 ); |
740 $active_installs_millions = floor( $plugin['active_installs'] / 1000000 ); |
732 $active_installs_text = sprintf( |
741 $active_installs_text = sprintf( |
|
742 /* translators: %s: Number of millions. */ |
733 _nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ), |
743 _nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ), |
734 number_format_i18n( $active_installs_millions ) |
744 number_format_i18n( $active_installs_millions ) |
735 ); |
745 ); |
736 } elseif ( 0 == $plugin['active_installs'] ) { |
746 } elseif ( 0 == $plugin['active_installs'] ) { |
737 $active_installs_text = _x( 'Less Than 10', 'Active plugin installations' ); |
747 $active_installs_text = _x( 'Less Than 10', 'Active plugin installations' ); |
738 } else { |
748 } else { |
739 $active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+'; |
749 $active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+'; |
740 } |
750 } |
|
751 /* translators: %s: Number of installations. */ |
741 printf( __( '%s Active Installations' ), $active_installs_text ); |
752 printf( __( '%s Active Installations' ), $active_installs_text ); |
742 ?> |
753 ?> |
743 </div> |
754 </div> |
744 <div class="column-compatibility"> |
755 <div class="column-compatibility"> |
745 <?php |
756 <?php |