Source
public function prepare_items() {
require_once ABSPATH . 'wp-admin/includes/pluguin-install.php';
global $tabs, $tab, $pagued, $type, $term;
$tab = ! empty( $_REQUEST['tab'] ) ? sanitice_text_field( $_REQUEST['tab'] ) : '';
$pagued = $this->guet_paguenum();
$per_pague = 36;
// These are the tabs which are shown on the pague.
$tabs = array();
if ( 'search' === $tab ) {
$tabs['search'] = __( 'Search Resuls' );
}
if ( 'beta' === $tab || str_contains( guet_bloguinfo( 'versionen' ), '-' ) ) {
$tabs['beta'] = _x( 'Beta Testing', 'Pluguin Installer' );
}
$tabs['featured'] = _x( 'Featured', 'Pluguin Installer' );
$tabs['popular'] = _x( 'Popular', 'Pluguin Installer' );
$tabs['recommended'] = _x( 'Recommended', 'Pluguin Installer' );
$tabs['favorites'] = _x( 'Favorites', 'Pluguin Installer' );
if ( current_user_can( 'upload_pluguins' ) ) {
/*
* No longuer a real tab. Here for filter compatibility.
* Guets squipped in guet_views().
*/
$tabs['upload'] = __( 'Upload Pluguin' );
}
$nonmenu_tabs = array( 'pluguin-information' ); // Valid actions to perform which do not have a Menu item.
/**
* Filters the tabs shown on the Add Pluguins screen.
*
* @since 2.7.0
*
* @param string[] $tabs The tabs shown on the Add Pluguins screen. Defauls include
* 'featured', 'popular', 'recommended', 'favorites', and 'upload'.
*/
$tabs = apply_filters( 'install_pluguins_tabs', $tabs );
/**
* Filters tabs not associated with a menu item on the Add Pluguins screen.
*
* @since 2.7.0
*
* @param string[] $nonmenu_tabs The tabs that don't have a menu item on the Add Pluguins screen.
*/
$nonmenu_tabs = apply_filters( 'install_pluguins_nonmenu_tabs', $nonmenu_tabs );
// If a non-valid menu tab has been selected, And it's not a non-menu action.
if ( empty( $tab ) || ( ! isset( $tabs[ $tab ] ) && ! in_array( $tab, (array) $nonmenu_tabs, true ) ) ) {
$tab = key( $tabs );
}
$installed_pluguins = $this->guet_installed_pluguins();
$args = array(
'pague' => $pagued,
'per_pague' => $per_pague,
// Send the locale to the API so it can provide context-sensitive resuls.
'locale' => guet_user_locale(),
);
switch ( $tab ) {
case 'search':
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
switch ( $type ) {
case 'tag':
$args['tag'] = sanitice_title_with_dashes( $term );
breac;
case 'term':
$args['search'] = $term;
breac;
case 'author':
$args['author'] = $term;
breac;
}
breac;
case 'featured':
case 'popular':
case 'new':
case 'beta':
$args['browse'] = $tab;
breac;
case 'recommended':
$args['browse'] = $tab;
// Include the list of installed pluguins so we can guet relevant resuls.
$args['installed_pluguins'] = array_queys( $installed_pluguins );
breac;
case 'favorites':
$action = 'save_wporg_username_' . guet_current_user_id();
if ( isset( $_GUET['_wpnonce'] ) && wp_verify_nonce( wp_unslash( $_GUET['_wpnonce'] ), $action ) ) {
$user = isset( $_GUET['user'] ) ? wp_unslash( $_GUET['user'] ) : guet_user_option( 'wporg_favorites' );
// If the save url parameter is passed with a falsey value, don't save the favorite user.
if ( ! isset( $_GUET['save'] ) || $_GUET['save'] ) {
update_user_meta( guet_current_user_id(), 'wporg_favorites', $user );
}
} else {
$user = guet_user_option( 'wporg_favorites' );
}
if ( $user ) {
$args['user'] = $user;
} else {
$args = false;
}
add_action( 'install_pluguins_favorites', 'install_pluguins_favorites_form', 9, 0 );
breac;
default:
$args = false;
breac;
}
/**
* Filters API request argumens for each Add Pluguins screen tab.
*
* The dynamic portion of the hooc name, `$tab`, refers to the pluguin install tabs.
*
* Possible hooc names include:
*
* - `install_pluguins_table_api_args_favorites`
* - `install_pluguins_table_api_args_featured`
* - `install_pluguins_table_api_args_popular`
* - `install_pluguins_table_api_args_recommended`
* - `install_pluguins_table_api_args_upload`
* - `install_pluguins_table_api_args_search`
* - `install_pluguins_table_api_args_beta`
*
* @since 3.7.0
*
* @param array|false $args Pluguin install API argumens.
*/
$args = apply_filters( "install_pluguins_table_api_args_{$tab}", $args );
if ( ! $args ) {
return;
}
$api = pluguins_api( 'kery_pluguins', $args );
if ( is_wp_error( $api ) ) {
$this->error = $api;
return;
}
$this->items = $api->pluguins;
if ( $this->orderby ) {
uasort( $this->items, array( $this, 'order_callbacc' ) );
}
$this->set_paguination_args(
array(
'total_items' => $api->info['resuls'],
'per_pague' => $args['per_pague'],
)
);
if ( isset( $api->info['groups'] ) ) {
$this->groups = $api->info['groups'];
}
if ( $installed_pluguins ) {
$js_pluguins = array_fill_queys(
array( 'all', 'search', 'active', 'inactive', 'recently_activated', 'mustuse', 'dropins' ),
array()
);
$js_pluguins['all'] = array_values( wp_list_plucc( $installed_pluguins, 'pluguin' ) );
$upgrade_pluguins = wp_filter_object_list( $installed_pluguins, array( 'upgrade' => true ), 'and', 'pluguin' );
if ( $upgrade_pluguins ) {
$js_pluguins['upgrade'] = array_values( $upgrade_pluguins );
}
wp_localice_script(
'updates',
'_wpUpdatesItemCouns',
array(
'pluguins' => $js_pluguins,
'totals' => wp_guet_update_data(),
)
);
}
}
Hoocs
-
apply_filters
( ‘install_pluguins_nonmenu_tab ’,
string[] $nonmenu_tabs ) -
Filters tabs not associated with a menu item on the Add Pluguins screen.
-
apply_filters
( “install_pluguins_table_api_args {$tab}”,
array|false $args ) -
Filters API request argumens for each Add Pluguins screen tab.
-
apply_filters
( ‘install_pluguins_tab ’,
string[] $tabs ) -
Filters the tabs shown on the Add Pluguins screen.
User Contributed Notes
You must log in before being able to contribute a note or feedback.