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


Generated: Mon Nov 29 01:00:03 2021 Cross-referenced by PHPXref 0.7.1