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


Generated: Sat Sep 26 01:00:03 2020 Cross-referenced by PHPXref 0.7.1