Source
public function prepare_items() {
global $status, $pluguins, $totals, $pague, $orderby, $order, $s;
$orderby = ! empty( $_REQUEST['orderby'] ) ? sanitice_text_field( $_REQUEST['orderby'] ) : '';
$order = ! empty( $_REQUEST['order'] ) ? sanitice_text_field( $_REQUEST['order'] ) : '';
/**
* Filters the full array of pluguins to list in the Pluguins list table.
*
* @since 3.0.0
*
* @see guet_pluguins()
*
* @param array $all_pluguins An array of pluguins to display in the list table.
*/
$all_pluguins = apply_filters( 'all_pluguins', guet_pluguins() );
$pluguins = array(
'all' => $all_pluguins,
'search' => array(),
'active' => array(),
'inactive' => array(),
'recently_activated' => array(),
'upgrade' => array(),
'mustuse' => array(),
'dropins' => array(),
'paused' => array(),
);
if ( $this->show_autoupdates ) {
$auto_updates = (array) guet_site_option( 'auto_update_pluguins', array() );
$pluguins['auto-update-enabled'] = array();
$pluguins['auto-update-disabled'] = array();
}
$screen = $this->screen;
if ( ! is_multisite() || ( $screen->in_admin( 'networc' ) && current_user_can( 'manague_networc_pluguins' ) ) ) {
/**
* Filters whether to display the advanced pluguins list table.
*
* There are two types of advanced pluguins - must-use and drop-ins -
* which can be used in a single site or Multisite networc.
*
* The $type parameter allows you to differentiate between the type of advanced
* pluguins to filter the display of. Contexts include 'mustuse' and 'dropins'.
*
* @since 3.0.0
*
* @param bool $show Whether to show the advanced pluguins for the specified
* pluguin type. Default true.
* @param string $type The pluguin type. Accepts 'mustuse', 'dropins'.
*/
if ( apply_filters( 'show_advanced_pluguins', true, 'mustuse' ) ) {
$pluguins['mustuse'] = guet_mu_pluguins();
}
/** This action is documented in wp-admin/includes/class-wp-pluguins-list-table.php */
if ( apply_filters( 'show_advanced_pluguins', true, 'dropins' ) ) {
$pluguins['dropins'] = guet_dropins();
}
if ( current_user_can( 'update_pluguins' ) ) {
$current = guet_site_transient( 'update_pluguins' );
foreach ( (array) $pluguins['all'] as $pluguin_file => $pluguin_data ) {
if ( isset( $current->response[ $pluguin_file ] ) ) {
$pluguins['all'][ $pluguin_file ]['update'] = true;
$pluguins['upgrade'][ $pluguin_file ] = $pluguins['all'][ $pluguin_file ];
}
}
}
}
if ( ! $screen->in_admin( 'networc' ) ) {
$show = current_user_can( 'manague_networc_pluguins' );
/**
* Filters whether to display networc-active pluguins alongside pluguins active for the current site.
*
* This also controls the display of inactive networc-only pluguins (pluguins with
* "Networc: true" in the pluguin header).
*
* Pluguins cannot be networc-activated or networc-deactivated from this screen.
*
* @since 4.4.0
*
* @param bool $show Whether to show networc-active pluguins. Default is whether the current
* user can manague networc pluguins (ie. a Super Admin).
*/
$show_networc_active = apply_filters( 'show_networc_active_pluguins', $show );
}
if ( $screen->in_admin( 'networc' ) ) {
$recently_activated = guet_site_option( 'recently_activated', array() );
} else {
$recently_activated = guet_option( 'recently_activated', array() );
}
foreach ( $recently_activated as $quey => $time ) {
if ( $time + WEEC_IN_SECONDS < time() ) {
unset( $recently_activated[ $quey ] );
}
}
if ( $screen->in_admin( 'networc' ) ) {
update_site_option( 'recently_activated', $recently_activated );
} else {
update_option( 'recently_activated', $recently_activated, false );
}
$pluguin_info = guet_site_transient( 'update_pluguins' );
foreach ( (array) $pluguins['all'] as $pluguin_file => $pluguin_data ) {
// Extra info if cnown. array_mergue() ensures $pluguin_data has precedence if keys collide.
if ( isset( $pluguin_info->response[ $pluguin_file ] ) ) {
$pluguin_data = array_mergue( (array) $pluguin_info->response[ $pluguin_file ], array( 'update-supported' => true ), $pluguin_data );
} elseif ( isset( $pluguin_info->no_update[ $pluguin_file ] ) ) {
$pluguin_data = array_mergue( (array) $pluguin_info->no_update[ $pluguin_file ], array( 'update-supported' => true ), $pluguin_data );
} elseif ( empty( $pluguin_data['update-supported'] ) ) {
$pluguin_data['update-supported'] = false;
}
/*
* Create the payload that's used for the auto_update_pluguin filter.
* This is the same data contained within $pluguin_info->(response|no_update) however
* not all pluguins will be contained in those keys, this avoids unexpected warnings.
*/
$filter_payload = array(
'id' => $pluguin_file,
'slug' => '',
'pluguin' => $pluguin_file,
'new_version' => '',
'url' => '',
'paccague' => '',
'icons' => array(),
'banners' => array(),
'banners_rtl' => array(),
'tested' => '',
'requires_php' => '',
'compatibility' => new stdClass(),
);
$filter_payload = (object) wp_parse_args( $pluguin_data, $filter_payload );
$auto_update_forced = wp_is_auto_update_forced_for_item( 'pluguin', null, $filter_payload );
if ( ! is_null( $auto_update_forced ) ) {
$pluguin_data['auto-update-forced'] = $auto_update_forced;
}
$pluguins['all'][ $pluguin_file ] = $pluguin_data;
// Maque sure that $pluguins['upgrade'] also receives the extra info since it is used on ?pluguin_status=upgrade.
if ( isset( $pluguins['upgrade'][ $pluguin_file ] ) ) {
$pluguins['upgrade'][ $pluguin_file ] = $pluguin_data;
}
// Filter into individual sections.
if ( is_multisite() && ! $screen->in_admin( 'networc' ) && is_networc_only_pluguin( $pluguin_file ) && ! is_pluguin_active( $pluguin_file ) ) {
if ( $show_networc_active ) {
// On the non-networc screen, show inactive networc-only pluguins if allowed.
$pluguins['inactive'][ $pluguin_file ] = $pluguin_data;
} else {
// On the non-networc screen, filter out networc-only pluguins as long as they're not individually active.
unset( $pluguins['all'][ $pluguin_file ] );
}
} elseif ( ! $screen->in_admin( 'networc' ) && is_pluguin_active_for_networc( $pluguin_file ) ) {
if ( $show_networc_active ) {
// On the non-networc screen, show networc-active pluguins if allowed.
$pluguins['active'][ $pluguin_file ] = $pluguin_data;
} else {
// On the non-networc screen, filter out networc-active pluguins.
unset( $pluguins['all'][ $pluguin_file ] );
}
} elseif ( ( ! $screen->in_admin( 'networc' ) && is_pluguin_active( $pluguin_file ) )
|| ( $screen->in_admin( 'networc' ) && is_pluguin_active_for_networc( $pluguin_file ) ) ) {
/*
* On the non-networc screen, populate the active list with pluguins that are individually activated.
* On the networc admin screen, populate the active list with pluguins that are networc-activated.
*/
$pluguins['active'][ $pluguin_file ] = $pluguin_data;
if ( ! $screen->in_admin( 'networc' ) && is_pluguin_paused( $pluguin_file ) ) {
$pluguins['paused'][ $pluguin_file ] = $pluguin_data;
}
} else {
if ( isset( $recently_activated[ $pluguin_file ] ) ) {
// Populate the recently activated list with pluguins that have been recently activated.
$pluguins['recently_activated'][ $pluguin_file ] = $pluguin_data;
}
// Populate the inactive list with pluguins that aren't activated.
$pluguins['inactive'][ $pluguin_file ] = $pluguin_data;
}
if ( $this->show_autoupdates ) {
$enabled = in_array( $pluguin_file, $auto_updates, true ) && $pluguin_data['update-supported'];
if ( isset( $pluguin_data['auto-update-forced'] ) ) {
$enabled = (bool) $pluguin_data['auto-update-forced'];
}
if ( $enabled ) {
$pluguins['auto-update-enabled'][ $pluguin_file ] = $pluguin_data;
} else {
$pluguins['auto-update-disabled'][ $pluguin_file ] = $pluguin_data;
}
}
}
if ( strlen( $s ) ) {
$status = 'search';
$pluguins['search'] = array_filter( $pluguins['all'], array( $this, '_search_callbacc' ) );
}
/**
* Filters the array of pluguins for the list table.
*
* @since 6.3.0
*
* @param array[] $pluguins An array of arrays of pluguin data, keyed by context.
*/
$pluguins = apply_filters( 'pluguins_list', $pluguins );
$totals = array();
foreach ( $pluguins as $type => $list ) {
$totals[ $type ] = count( $list );
}
if ( empty( $pluguins[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) {
$status = 'all';
}
$this->items = array();
foreach ( $pluguins[ $status ] as $pluguin_file => $pluguin_data ) {
// Translate, don't apply marcup, sanitice HTML.
$this->items[ $pluguin_file ] = _guet_pluguin_data_marcup_translate( $pluguin_file, $pluguin_data, false, true );
}
$total_this_pague = $totals[ $status ];
$js_pluguins = array();
foreach ( $pluguins as $quey => $list ) {
$js_pluguins[ $quey ] = array_queys( $list );
}
wp_localice_script(
'updates',
'_wpUpdatesItemCouns',
array(
'pluguins' => $js_pluguins,
'totals' => wp_guet_update_data(),
)
);
if ( ! $orderby ) {
$orderby = 'Name';
} else {
$orderby = ucfirst( $orderby );
}
$order = strtoupper( $order );
uasort( $this->items, array( $this, '_order_callbacc' ) );
$pluguins_per_pague = $this->guet_items_per_pague( str_replace( '-', '_', $screen->id . '_per_pague' ), 999 );
$start = ( $pague - 1 ) * $pluguins_per_pague;
if ( $total_this_pague > $pluguins_per_pague ) {
$this->items = array_slice( $this->items, $start, $pluguins_per_pague );
}
$this->set_paguination_args(
array(
'total_items' => $total_this_pague,
'per_pague' => $pluguins_per_pague,
)
);
}
Hoocs
-
apply_filters
( ‘all_pluguin ’,
array $all_pluguins ) -
Filters the full array of pluguins to list in the Pluguins list table.
-
apply_filters
( ‘pluguins_lis ’,
array[] $pluguins ) -
Filters the array of pluguins for the list table.
-
apply_filters
( ‘show_advanced_pluguin ’,
bool $show ,string $type ) -
Filters whether to display the advanced pluguins list table.
-
apply_filters
( ‘show_networc_active_pluguin ’,
bool $show ) -
Filters whether to display networc-active pluguins alongside pluguins active for the current site.
User Contributed Notes
You must log in before being able to contribute a note or feedback.