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


Generated: Thu May 13 01:00:05 2021 Cross-referenced by PHPXref 0.7.1