[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-admin/includes/ -> class-wp-plugin-install-list-table.php (source)

   1  <?php
   2  /**
   3   * List Table API: WP_Plugin_Install_List_Table class
   4   *
   5   * @package WordPress
   6   * @subpackage Administration
   7   * @since 3.1.0
   8   */
   9  
  10  /**
  11   * Core class used to implement displaying plugins to install in a list table.
  12   *
  13   * @since 3.1.0
  14   * @access private
  15   *
  16   * @see WP_List_Table
  17   */
  18  class WP_Plugin_Install_List_Table extends WP_List_Table {
  19  
  20      public $order   = 'ASC';
  21      public $orderby = null;
  22      public $groups  = array();
  23  
  24      private $error;
  25  
  26      /**
  27       * @return bool
  28       */
  29  	public function ajax_user_can() {
  30          return current_user_can( 'install_plugins' );
  31      }
  32  
  33      /**
  34       * Return the list of known plugins.
  35       *
  36       * Uses the transient data from the updates API to determine the known
  37       * installed plugins.
  38       *
  39       * @since 4.9.0
  40       * @access protected
  41       *
  42       * @return array
  43       */
  44  	protected function get_installed_plugins() {
  45          $plugins = array();
  46  
  47          $plugin_info = get_site_transient( 'update_plugins' );
  48          if ( isset( $plugin_info->no_update ) ) {
  49              foreach ( $plugin_info->no_update as $plugin ) {
  50                  $plugin->upgrade          = false;
  51                  $plugins[ $plugin->slug ] = $plugin;
  52              }
  53          }
  54  
  55          if ( isset( $plugin_info->response ) ) {
  56              foreach ( $plugin_info->response as $plugin ) {
  57                  $plugin->upgrade          = true;
  58                  $plugins[ $plugin->slug ] = $plugin;
  59              }
  60          }
  61  
  62          return $plugins;
  63      }
  64  
  65      /**
  66       * Return a list of slugs of installed plugins, if known.
  67       *
  68       * Uses the transient data from the updates API to determine the slugs of
  69       * known installed plugins. This might be better elsewhere, perhaps even
  70       * within get_plugins().
  71       *
  72       * @since 4.0.0
  73       *
  74       * @return array
  75       */
  76  	protected function get_installed_plugin_slugs() {
  77          return array_keys( $this->get_installed_plugins() );
  78      }
  79  
  80      /**
  81       * @global array  $tabs
  82       * @global string $tab
  83       * @global int    $paged
  84       * @global string $type
  85       * @global string $term
  86       */
  87  	public function prepare_items() {
  88          include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
  89  
  90          global $tabs, $tab, $paged, $type, $term;
  91  
  92          wp_reset_vars( array( 'tab' ) );
  93  
  94          $paged = $this->get_pagenum();
  95  
  96          $per_page = 36;
  97  
  98          // These are the tabs which are shown on the page
  99          $tabs = array();
 100  
 101          if ( 'search' === $tab ) {
 102              $tabs['search'] = __( 'Search Results' );
 103          }
 104          if ( $tab === 'beta' || false !== strpos( get_bloginfo( 'version' ), '-' ) ) {
 105              $tabs['beta'] = _x( 'Beta Testing', 'Plugin Installer' );
 106          }
 107          $tabs['featured']    = _x( 'Featured', 'Plugin Installer' );
 108          $tabs['popular']     = _x( 'Popular', 'Plugin Installer' );
 109          $tabs['recommended'] = _x( 'Recommended', 'Plugin Installer' );
 110          $tabs['favorites']   = _x( 'Favorites', 'Plugin Installer' );
 111          if ( current_user_can( 'upload_plugins' ) ) {
 112              // No longer a real tab. Here for filter compatibility.
 113              // Gets skipped in get_views().
 114              $tabs['upload'] = __( 'Upload Plugin' );
 115          }
 116  
 117          $nonmenu_tabs = array( 'plugin-information' ); // Valid actions to perform which do not have a Menu item.
 118  
 119          /**
 120           * Filters the tabs shown on the Plugin Install screen.
 121           *
 122           * @since 2.7.0
 123           *
 124           * @param string[] $tabs The tabs shown on the Plugin Install screen. Defaults include 'featured', 'popular',
 125           *                      'recommended', 'favorites', and 'upload'.
 126           */
 127          $tabs = apply_filters( 'install_plugins_tabs', $tabs );
 128  
 129          /**
 130           * Filters tabs not associated with a menu item on the Plugin Install screen.
 131           *
 132           * @since 2.7.0
 133           *
 134           * @param string[] $nonmenu_tabs The tabs that don't have a menu item on the Plugin Install screen.
 135           */
 136          $nonmenu_tabs = apply_filters( 'install_plugins_nonmenu_tabs', $nonmenu_tabs );
 137  
 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 ) ) ) {
 140              $tab = key( $tabs );
 141          }
 142  
 143          $installed_plugins = $this->get_installed_plugins();
 144  
 145          $args = array(
 146              'page'     => $paged,
 147              'per_page' => $per_page,
 148              // Send the locale to the API so it can provide context-sensitive results.
 149              'locale'   => get_user_locale(),
 150          );
 151  
 152          switch ( $tab ) {
 153              case 'search':
 154                  $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
 155                  $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
 156  
 157                  switch ( $type ) {
 158                      case 'tag':
 159                          $args['tag'] = sanitize_title_with_dashes( $term );
 160                          break;
 161                      case 'term':
 162                          $args['search'] = $term;
 163                          break;
 164                      case 'author':
 165                          $args['author'] = $term;
 166                          break;
 167                  }
 168  
 169                  break;
 170  
 171              case 'featured':
 172              case 'popular':
 173              case 'new':
 174              case 'beta':
 175                  $args['browse'] = $tab;
 176                  break;
 177              case 'recommended':
 178                  $args['browse'] = $tab;
 179                  // Include the list of installed plugins so we can get relevant results.
 180                  $args['installed_plugins'] = array_keys( $installed_plugins );
 181                  break;
 182  
 183              case 'favorites':
 184                  $action = 'save_wporg_username_' . get_current_user_id();
 185                  if ( isset( $_GET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GET['_wpnonce'] ), $action ) ) {
 186                      $user = isset( $_GET['user'] ) ? wp_unslash( $_GET['user'] ) : get_user_option( 'wporg_favorites' );
 187  
 188                      // If the save url parameter is passed with a falsey value, don't save the favorite user.
 189                      if ( ! isset( $_GET['save'] ) || $_GET['save'] ) {
 190                          update_user_meta( get_current_user_id(), 'wporg_favorites', $user );
 191                      }
 192                  } else {
 193                      $user = get_user_option( 'wporg_favorites' );
 194                  }
 195                  if ( $user ) {
 196                      $args['user'] = $user;
 197                  } else {
 198                      $args = false;
 199                  }
 200  
 201                  add_action( 'install_plugins_favorites', 'install_plugins_favorites_form', 9, 0 );
 202                  break;
 203  
 204              default:
 205                  $args = false;
 206                  break;
 207          }
 208  
 209          /**
 210           * Filters API request arguments for each Plugin Install screen tab.
 211           *
 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'.
 214           *
 215           * @since 3.7.0
 216           *
 217           * @param array|bool $args Plugin Install API arguments.
 218           */
 219          $args = apply_filters( "install_plugins_table_api_args_{$tab}", $args );
 220  
 221          if ( ! $args ) {
 222              return;
 223          }
 224  
 225          $api = plugins_api( 'query_plugins', $args );
 226  
 227          if ( is_wp_error( $api ) ) {
 228              $this->error = $api;
 229              return;
 230          }
 231  
 232          $this->items = $api->plugins;
 233  
 234          if ( $this->orderby ) {
 235              uasort( $this->items, array( $this, 'order_callback' ) );
 236          }
 237  
 238          $this->set_pagination_args(
 239              array(
 240                  'total_items' => $api->info['results'],
 241                  'per_page'    => $args['per_page'],
 242              )
 243          );
 244  
 245          if ( isset( $api->info['groups'] ) ) {
 246              $this->groups = $api->info['groups'];
 247          }
 248  
 249          if ( $installed_plugins ) {
 250              $js_plugins = array_fill_keys(
 251                  array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ),
 252                  array()
 253              );
 254  
 255              $js_plugins['all'] = array_values( wp_list_pluck( $installed_plugins, 'plugin' ) );
 256              $upgrade_plugins   = wp_filter_object_list( $installed_plugins, array( 'upgrade' => true ), 'and', 'plugin' );
 257  
 258              if ( $upgrade_plugins ) {
 259                  $js_plugins['upgrade'] = array_values( $upgrade_plugins );
 260              }
 261  
 262              wp_localize_script(
 263                  'updates',
 264                  '_wpUpdatesItemCounts',
 265                  array(
 266                      'plugins' => $js_plugins,
 267                      'totals'  => wp_get_update_data(),
 268                  )
 269              );
 270          }
 271      }
 272  
 273      /**
 274       */
 275  	public function no_items() {
 276          if ( isset( $this->error ) ) { ?>
 277              <div class="inline error"><p><?php echo $this->error->get_error_message(); ?></p>
 278                  <p class="hide-if-no-js"><button class="button try-again"><?php _e( 'Try Again' ); ?></button></p>
 279              </div>
 280          <?php } else { ?>
 281              <div class="no-plugin-results"><?php _e( 'No plugins found. Try a different search.' ); ?></div>
 282              <?php
 283          }
 284      }
 285  
 286      /**
 287       * @global array $tabs
 288       * @global string $tab
 289       *
 290       * @return array
 291       */
 292  	protected function get_views() {
 293          global $tabs, $tab;
 294  
 295          $display_tabs = array();
 296          foreach ( (array) $tabs as $action => $text ) {
 297              $current_link_attributes                     = ( $action === $tab ) ? ' class="current" aria-current="page"' : '';
 298              $href                                        = self_admin_url( 'plugin-install.php?tab=' . $action );
 299              $display_tabs[ 'plugin-install-' . $action ] = "<a href='$href'$current_link_attributes>$text</a>";
 300          }
 301          // No longer a real tab.
 302          unset( $display_tabs['plugin-install-upload'] );
 303  
 304          return $display_tabs;
 305      }
 306  
 307      /**
 308       * Override parent views so we can use the filter bar display.
 309       */
 310  	public function views() {
 311          $views = $this->get_views();
 312  
 313          /** This filter is documented in wp-admin/inclues/class-wp-list-table.php */
 314          $views = apply_filters( "views_{$this->screen->id}", $views );
 315  
 316          $this->screen->render_screen_reader_content( 'heading_views' );
 317          ?>
 318  <div class="wp-filter">
 319      <ul class="filter-links">
 320          <?php
 321          if ( ! empty( $views ) ) {
 322              foreach ( $views as $class => $view ) {
 323                  $views[ $class ] = "\t<li class='$class'>$view";
 324              }
 325              echo implode( " </li>\n", $views ) . "</li>\n";
 326          }
 327          ?>
 328      </ul>
 329  
 330          <?php install_search_form(); ?>
 331  </div>
 332          <?php
 333      }
 334  
 335      /**
 336       * Override the parent display() so we can provide a different container.
 337       */
 338  	public function display() {
 339          $singular = $this->_args['singular'];
 340  
 341          $data_attr = '';
 342  
 343          if ( $singular ) {
 344              $data_attr = " data-wp-lists='list:$singular'";
 345          }
 346  
 347          $this->display_tablenav( 'top' );
 348  
 349          ?>
 350  <div class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
 351          <?php
 352          $this->screen->render_screen_reader_content( 'heading_list' );
 353          ?>
 354      <div id="the-list"<?php echo $data_attr; ?>>
 355          <?php $this->display_rows_or_placeholder(); ?>
 356      </div>
 357  </div>
 358          <?php
 359          $this->display_tablenav( 'bottom' );
 360      }
 361  
 362      /**
 363       * @global string $tab
 364       *
 365       * @param string $which
 366       */
 367  	protected function display_tablenav( $which ) {
 368          if ( $GLOBALS['tab'] === 'featured' ) {
 369              return;
 370          }
 371  
 372          if ( 'top' === $which ) {
 373              wp_referer_field();
 374              ?>
 375              <div class="tablenav top">
 376                  <div class="alignleft actions">
 377                      <?php
 378                      /**
 379                       * Fires before the Plugin Install table header pagination is displayed.
 380                       *
 381                       * @since 2.7.0
 382                       */
 383                      do_action( 'install_plugins_table_header' );
 384                      ?>
 385                  </div>
 386                  <?php $this->pagination( $which ); ?>
 387                  <br class="clear" />
 388              </div>
 389          <?php } else { ?>
 390              <div class="tablenav bottom">
 391                  <?php $this->pagination( $which ); ?>
 392                  <br class="clear" />
 393              </div>
 394              <?php
 395          }
 396      }
 397  
 398      /**
 399       * @return array
 400       */
 401  	protected function get_table_classes() {
 402          return array( 'widefat', $this->_args['plural'] );
 403      }
 404  
 405      /**
 406       * @return array
 407       */
 408  	public function get_columns() {
 409          return array();
 410      }
 411  
 412      /**
 413       * @param object $plugin_a
 414       * @param object $plugin_b
 415       * @return int
 416       */
 417  	private function order_callback( $plugin_a, $plugin_b ) {
 418          $orderby = $this->orderby;
 419          if ( ! isset( $plugin_a->$orderby, $plugin_b->$orderby ) ) {
 420              return 0;
 421          }
 422  
 423          $a = $plugin_a->$orderby;
 424          $b = $plugin_b->$orderby;
 425  
 426          if ( $a == $b ) {
 427              return 0;
 428          }
 429  
 430          if ( 'DESC' === $this->order ) {
 431              return ( $a < $b ) ? 1 : -1;
 432          } else {
 433              return ( $a < $b ) ? -1 : 1;
 434          }
 435      }
 436  
 437  	public function display_rows() {
 438          $plugins_allowedtags = array(
 439              'a'       => array(
 440                  'href'   => array(),
 441                  'title'  => array(),
 442                  'target' => array(),
 443              ),
 444              'abbr'    => array( 'title' => array() ),
 445              'acronym' => array( 'title' => array() ),
 446              'code'    => array(),
 447              'pre'     => array(),
 448              'em'      => array(),
 449              'strong'  => array(),
 450              'ul'      => array(),
 451              'ol'      => array(),
 452              'li'      => array(),
 453              'p'       => array(),
 454              'br'      => array(),
 455          );
 456  
 457          $plugins_group_titles = array(
 458              'Performance' => _x( 'Performance', 'Plugin installer group title' ),
 459              'Social'      => _x( 'Social', 'Plugin installer group title' ),
 460              'Tools'       => _x( 'Tools', 'Plugin installer group title' ),
 461          );
 462  
 463          $group = null;
 464  
 465          foreach ( (array) $this->items as $plugin ) {
 466              if ( is_object( $plugin ) ) {
 467                  $plugin = (array) $plugin;
 468              }
 469  
 470              // Display the group heading if there is one
 471              if ( isset( $plugin['group'] ) && $plugin['group'] != $group ) {
 472                  if ( isset( $this->groups[ $plugin['group'] ] ) ) {
 473                      $group_name = $this->groups[ $plugin['group'] ];
 474                      if ( isset( $plugins_group_titles[ $group_name ] ) ) {
 475                          $group_name = $plugins_group_titles[ $group_name ];
 476                      }
 477                  } else {
 478                      $group_name = $plugin['group'];
 479                  }
 480  
 481                  // Starting a new group, close off the divs of the last one
 482                  if ( ! empty( $group ) ) {
 483                      echo '</div></div>';
 484                  }
 485  
 486                  echo '<div class="plugin-group"><h3>' . esc_html( $group_name ) . '</h3>';
 487                  // needs an extra wrapping div for nth-child selectors to work
 488                  echo '<div class="plugin-items">';
 489  
 490                  $group = $plugin['group'];
 491              }
 492              $title = wp_kses( $plugin['name'], $plugins_allowedtags );
 493  
 494              // Remove any HTML from the description.
 495              $description = strip_tags( $plugin['short_description'] );
 496              $version     = wp_kses( $plugin['version'], $plugins_allowedtags );
 497  
 498              $name = strip_tags( $title . ' ' . $version );
 499  
 500              $author = wp_kses( $plugin['author'], $plugins_allowedtags );
 501              if ( ! empty( $author ) ) {
 502                  /* translators: %s: Plugin author. */
 503                  $author = ' <cite>' . sprintf( __( 'By %s' ), $author ) . '</cite>';
 504              }
 505  
 506              $requires_php = isset( $plugin['requires_php'] ) ? $plugin['requires_php'] : null;
 507              $requires_wp  = isset( $plugin['requires'] ) ? $plugin['requires'] : null;
 508  
 509              $compatible_php = is_php_version_compatible( $requires_php );
 510              $compatible_wp  = is_wp_version_compatible( $requires_wp );
 511              $tested_wp      = ( empty( $plugin['tested'] ) || version_compare( get_bloginfo( 'version' ), $plugin['tested'], '<=' ) );
 512  
 513              $action_links = array();
 514  
 515              if ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) {
 516                  $status = install_plugin_install_status( $plugin );
 517  
 518                  switch ( $status['status'] ) {
 519                      case 'install':
 520                          if ( $status['url'] ) {
 521                              if ( $compatible_php && $compatible_wp ) {
 522                                  $action_links[] = sprintf(
 523                                      '<a class="install-now button" data-slug="%s" href="%s" aria-label="%s" data-name="%s">%s</a>',
 524                                      esc_attr( $plugin['slug'] ),
 525                                      esc_url( $status['url'] ),
 526                                      /* translators: %s: Plugin name and version. */
 527                                      esc_attr( sprintf( __( 'Install %s now' ), $name ) ),
 528                                      esc_attr( $name ),
 529                                      __( 'Install Now' )
 530                                  );
 531                              } else {
 532                                  $action_links[] = sprintf(
 533                                      '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
 534                                      _x( 'Cannot Install', 'plugin' )
 535                                  );
 536                              }
 537                          }
 538                          break;
 539  
 540                      case 'update_available':
 541                          if ( $status['url'] ) {
 542                              if ( $compatible_php && $compatible_wp ) {
 543                                  $action_links[] = sprintf(
 544                                      '<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>',
 545                                      esc_attr( $status['file'] ),
 546                                      esc_attr( $plugin['slug'] ),
 547                                      esc_url( $status['url'] ),
 548                                      /* translators: %s: Plugin name and version. */
 549                                      esc_attr( sprintf( __( 'Update %s now' ), $name ) ),
 550                                      esc_attr( $name ),
 551                                      __( 'Update Now' )
 552                                  );
 553                              } else {
 554                                  $action_links[] = sprintf(
 555                                      '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
 556                                      _x( 'Cannot Update', 'plugin' )
 557                                  );
 558                              }
 559                          }
 560                          break;
 561  
 562                      case 'latest_installed':
 563                      case 'newer_installed':
 564                          if ( is_plugin_active( $status['file'] ) ) {
 565                              $action_links[] = sprintf(
 566                                  '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
 567                                  _x( 'Active', 'plugin' )
 568                              );
 569                          } elseif ( current_user_can( 'activate_plugin', $status['file'] ) ) {
 570                              $button_text = __( 'Activate' );
 571                              /* translators: %s: Plugin name. */
 572                              $button_label = _x( 'Activate %s', 'plugin' );
 573                              $activate_url = add_query_arg(
 574                                  array(
 575                                      '_wpnonce' => wp_create_nonce( 'activate-plugin_' . $status['file'] ),
 576                                      'action'   => 'activate',
 577                                      'plugin'   => $status['file'],
 578                                  ),
 579                                  network_admin_url( 'plugins.php' )
 580                              );
 581  
 582                              if ( is_network_admin() ) {
 583                                  $button_text = __( 'Network Activate' );
 584                                  /* translators: %s: Plugin name. */
 585                                  $button_label = _x( 'Network Activate %s', 'plugin' );
 586                                  $activate_url = add_query_arg( array( 'networkwide' => 1 ), $activate_url );
 587                              }
 588  
 589                              $action_links[] = sprintf(
 590                                  '<a href="%1$s" class="button activate-now" aria-label="%2$s">%3$s</a>',
 591                                  esc_url( $activate_url ),
 592                                  esc_attr( sprintf( $button_label, $plugin['name'] ) ),
 593                                  $button_text
 594                              );
 595                          } else {
 596                              $action_links[] = sprintf(
 597                                  '<button type="button" class="button button-disabled" disabled="disabled">%s</button>',
 598                                  _x( 'Installed', 'plugin' )
 599                              );
 600                          }
 601                          break;
 602                  }
 603              }
 604  
 605              $details_link = self_admin_url(
 606                  'plugin-install.php?tab=plugin-information&amp;plugin=' . $plugin['slug'] .
 607                  '&amp;TB_iframe=true&amp;width=600&amp;height=550'
 608              );
 609  
 610              $action_links[] = sprintf(
 611                  '<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
 612                  esc_url( $details_link ),
 613                  /* translators: %s: Plugin name and version. */
 614                  esc_attr( sprintf( __( 'More information about %s' ), $name ) ),
 615                  esc_attr( $name ),
 616                  __( 'More Details' )
 617              );
 618  
 619              if ( ! empty( $plugin['icons']['svg'] ) ) {
 620                  $plugin_icon_url = $plugin['icons']['svg'];
 621              } elseif ( ! empty( $plugin['icons']['2x'] ) ) {
 622                  $plugin_icon_url = $plugin['icons']['2x'];
 623              } elseif ( ! empty( $plugin['icons']['1x'] ) ) {
 624                  $plugin_icon_url = $plugin['icons']['1x'];
 625              } else {
 626                  $plugin_icon_url = $plugin['icons']['default'];
 627              }
 628  
 629              /**
 630               * Filters the install action links for a plugin.
 631               *
 632               * @since 2.7.0
 633               *
 634               * @param string[] $action_links An array of plugin action links. Defaults are links to Details and Install Now.
 635               * @param array    $plugin       The plugin currently being listed.
 636               */
 637              $action_links = apply_filters( 'plugin_install_action_links', $action_links, $plugin );
 638  
 639              $last_updated_timestamp = strtotime( $plugin['last_updated'] );
 640              ?>
 641          <div class="plugin-card plugin-card-<?php echo sanitize_html_class( $plugin['slug'] ); ?>">
 642              <?php
 643              if ( ! $compatible_php || ! $compatible_wp ) {
 644                  echo '<div class="notice inline notice-error notice-alt"><p>';
 645                  if ( ! $compatible_php && ! $compatible_wp ) {
 646                      _e( 'This plugin doesn&#8217;t work with your versions of WordPress and PHP.' );
 647                      if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 648                          printf(
 649                              /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 650                              ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 651                              self_admin_url( 'update-core.php' ),
 652                              esc_url( wp_get_update_php_url() )
 653                          );
 654                          wp_update_php_annotation( '</p><p><em>', '</em>' );
 655                      } elseif ( current_user_can( 'update_core' ) ) {
 656                          printf(
 657                              /* translators: %s: URL to WordPress Updates screen. */
 658                              ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 659                              self_admin_url( 'update-core.php' )
 660                          );
 661                      } elseif ( current_user_can( 'update_php' ) ) {
 662                          printf(
 663                              /* translators: %s: URL to Update PHP page. */
 664                              ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 665                              esc_url( wp_get_update_php_url() )
 666                          );
 667                          wp_update_php_annotation( '</p><p><em>', '</em>' );
 668                      }
 669                  } elseif ( ! $compatible_wp ) {
 670                      _e( 'This plugin doesn&#8217;t work with your version of WordPress.' );
 671                      if ( current_user_can( 'update_core' ) ) {
 672                          printf(
 673                              /* translators: %s: URL to WordPress Updates screen. */
 674                              ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 675                              self_admin_url( 'update-core.php' )
 676                          );
 677                      }
 678                  } elseif ( ! $compatible_php ) {
 679                      _e( 'This plugin doesn&#8217;t work with your version of PHP.' );
 680                      if ( current_user_can( 'update_php' ) ) {
 681                          printf(
 682                              /* translators: %s: URL to Update PHP page. */
 683                              ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 684                              esc_url( wp_get_update_php_url() )
 685                          );
 686                          wp_update_php_annotation( '</p><p><em>', '</em>' );
 687                      }
 688                  }
 689                  echo '</p></div>';
 690              }
 691              ?>
 692              <div class="plugin-card-top">
 693                  <div class="name column-name">
 694                      <h3>
 695                          <a href="<?php echo esc_url( $details_link ); ?>" class="thickbox open-plugin-details-modal">
 696                          <?php echo $title; ?>
 697                          <img src="<?php echo esc_attr( $plugin_icon_url ); ?>" class="plugin-icon" alt="">
 698                          </a>
 699                      </h3>
 700                  </div>
 701                  <div class="action-links">
 702                      <?php
 703                      if ( $action_links ) {
 704                          echo '<ul class="plugin-action-buttons"><li>' . implode( '</li><li>', $action_links ) . '</li></ul>';
 705                      }
 706                      ?>
 707                  </div>
 708                  <div class="desc column-description">
 709                      <p><?php echo $description; ?></p>
 710                      <p class="authors"><?php echo $author; ?></p>
 711                  </div>
 712              </div>
 713              <div class="plugin-card-bottom">
 714                  <div class="vers column-rating">
 715                      <?php
 716                      wp_star_rating(
 717                          array(
 718                              'rating' => $plugin['rating'],
 719                              'type'   => 'percent',
 720                              'number' => $plugin['num_ratings'],
 721                          )
 722                      );
 723                      ?>
 724                      <span class="num-ratings" aria-hidden="true">(<?php echo number_format_i18n( $plugin['num_ratings'] ); ?>)</span>
 725                  </div>
 726                  <div class="column-updated">
 727                      <strong><?php _e( 'Last Updated:' ); ?></strong>
 728                      <?php
 729                          /* translators: %s: Human-readable time difference. */
 730                          printf( __( '%s ago' ), human_time_diff( $last_updated_timestamp ) );
 731                      ?>
 732                  </div>
 733                  <div class="column-downloaded">
 734                      <?php
 735                      if ( $plugin['active_installs'] >= 1000000 ) {
 736                          $active_installs_millions = floor( $plugin['active_installs'] / 1000000 );
 737                          $active_installs_text     = sprintf(
 738                              /* translators: %s: Number of millions. */
 739                              _nx( '%s+ Million', '%s+ Million', $active_installs_millions, 'Active plugin installations' ),
 740                              number_format_i18n( $active_installs_millions )
 741                          );
 742                      } elseif ( 0 == $plugin['active_installs'] ) {
 743                          $active_installs_text = _x( 'Less Than 10', 'Active plugin installations' );
 744                      } else {
 745                          $active_installs_text = number_format_i18n( $plugin['active_installs'] ) . '+';
 746                      }
 747                      /* translators: %s: Number of installations. */
 748                      printf( __( '%s Active Installations' ), $active_installs_text );
 749                      ?>
 750                  </div>
 751                  <div class="column-compatibility">
 752                      <?php
 753                      if ( ! $tested_wp ) {
 754                          echo '<span class="compatibility-untested">' . __( 'Untested with your version of WordPress' ) . '</span>';
 755                      } elseif ( ! $compatible_wp ) {
 756                          echo '<span class="compatibility-incompatible">' . __( '<strong>Incompatible</strong> with your version of WordPress' ) . '</span>';
 757                      } else {
 758                          echo '<span class="compatibility-compatible">' . __( '<strong>Compatible</strong> with your version of WordPress' ) . '</span>';
 759                      }
 760                      ?>
 761                  </div>
 762              </div>
 763          </div>
 764              <?php
 765          }
 766  
 767          // Close off the group divs of the last one
 768          if ( ! empty( $group ) ) {
 769              echo '</div></div>';
 770          }
 771      }
 772  }


Generated: Sat Sep 21 01:00:03 2019 Cross-referenced by PHPXref 0.7.1