WP_Plugins_List_Table::single_row() –

You appear to be a bot. Output may be restricted

Description

Usage

WP_Plugins_List_Table::single_row( $item );

Parameters

$item
( array ) required

Returns

void

Source

File name: wordpress/wp-admin/includes/class-wp-plugins-list-table.php


Lines:

1 to 100 of 665
  public function single_row( $item ) {
    global $status, $page, $s, $totals;
    static $plugin_id_attrs = array();

    list( $plugin_file, $plugin_data ) = $item;

    $plugin_slug    = isset( $plugin_data['slug'] ) ? $plugin_data['slug'] : sanitize_title( $plugin_data['Name'] );
    $plugin_id_attr = $plugin_slug;

    // Ensure the ID attribute is unique.
    $suffix = 2;
    while ( in_array( $plugin_id_attr, $plugin_id_attrs, true ) ) {
      $plugin_id_attr = "$plugin_slug-$suffix";
      $suffix++;
    }

    $plugin_id_attrs[] = $plugin_id_attr;

    $context = $status;
    $screen  = $this->screen;

    // Pre-order.
    $actions = array(
      'deactivate' => '',
      'activate'   => '',
      'details'    => '',
      'delete'     => '',
    );

    // Do not restrict by default.
    $restrict_network_active = false;
    $restrict_network_only   = false;

    $requires_php = isset( $plugin_data['RequiresPHP'] ) ? $plugin_data['RequiresPHP'] : null;
    $requires_wp  = isset( $plugin_data['RequiresWP'] ) ? $plugin_data['RequiresWP'] : null;

    $compatible_php = is_php_version_compatible( $requires_php );
    $compatible_wp  = is_wp_version_compatible( $requires_wp );

    if ( 'mustuse' === $context ) {
      $is_active = true;
    } elseif ( 'dropins' === $context ) {
      $dropins     = _get_dropins();
      $plugin_name = $plugin_file;

      if ( $plugin_file !== $plugin_data['Name'] ) {
        $plugin_name .= '<br/>' . $plugin_data['Name'];
      }

      if ( true === ( $dropins[ $plugin_file ][1] ) ) { // Doesn't require a constant.
        $is_active   = true;
        $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
      } elseif ( defined( $dropins[ $plugin_file ][1] ) && constant( $dropins[ $plugin_file ][1] ) ) { // Constant is true.
        $is_active   = true;
        $description = '<p><strong>' . $dropins[ $plugin_file ][0] . '</strong></p>';
      } else {
        $is_active   = false;
        $description = '<p><strong>' . $dropins[ $plugin_file ][0] . ' <span class="error-message">' . __( 'Inactive:' ) . '</span></strong> ' .
          sprintf(
            /* translators: 1: Drop-in constant name, 2: wp-config.php */
            __( 'Requires %1$s in %2$s file.' ),
            "<code>define('" . $dropins[ $plugin_file ][1] . "', true);</code>",
            '<code>wp-config.php</code>'
          ) . '</p>';
      }

      if ( $plugin_data['Description'] ) {
        $description .= '<p>' . $plugin_data['Description'] . '</p>';
      }
    } else {
      if ( $screen->in_admin( 'network' ) ) {
        $is_active = is_plugin_active_for_network( $plugin_file );
      } else {
        $is_active               = is_plugin_active( $plugin_file );
        $restrict_network_active = ( is_multisite() && is_plugin_active_for_network( $plugin_file ) );
        $restrict_network_only   = ( is_multisite() && is_network_only_plugin( $plugin_file ) && ! $is_active );
      }

      if ( $screen->in_admin( 'network' ) ) {
        if ( $is_active ) {
          if ( current_user_can( 'manage_network_plugins' ) ) {
            $actions['deactivate'] = sprintf(
              '<a href="%s" id="deactivate-%s" aria-label="%s">%s</a>',
              wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'deactivate-plugin_' . $plugin_file ),
              esc_attr( $plugin_id_attr ),
              /* translators: %s: Plugin name. */
              esc_attr( sprintf( _x( 'Network Deactivate %s', 'plugin' ), $plugin_data['Name'] ) ),
              __( 'Network Deactivate' )
            );
          }
        } else {
          if ( current_user_can( 'manage_network_plugins' ) ) {
            if ( $compatible_php && $compatible_wp ) {
              $actions['activate'] = sprintf(
                '<a href="%s" id="activate-%s" class="edit" aria-label="%s">%s</a>',
                wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . urlencode( $plugin_file ) . '&amp;plugin_status=' . $context . '&amp;paged=' . $page . '&amp;s=' . $s, 'activate-plugin_' . $plugin_file ),
                esc_attr( $plugin_id_attr ),
                /* translators: %s: Plugin name. */

 View on GitHub View on Trac