OS : Linux
PHP Version : 7.4.33
Software : Apache/2.4.6 (CentOS) PHP/7.4.33
Information System : Linux apprendre2 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
Disable Function : compat_fields && is_array( $this->compat_fields ) ) {
array_push( $this->compat_fields, 'all_items' );
}
$this->items = $this->all_items = Jetpack_Admin::init()->get_modules();
$this->items = $this->filter_displayed_table_items( $this->items );
/**
* Filters the list of modules available to be displayed in the Jetpack Settings screen.
*
* @since 3.0.0
*
* @param array $this->items Array of Jetpack modules.
*/
$this->items = apply_filters( 'jetpack_modules_list_table_items', $this->items );
$this->_column_headers = array( $this->get_columns(), array(), array(), 'name' );
$modal_info = isset( $_GET['info'] ) ? $_GET['info'] : false;
wp_register_script(
'models.jetpack-modules',
Assets::get_file_url_for_environment(
'_inc/build/jetpack-modules.models.min.js',
'_inc/jetpack-modules.models.js'
),
array( 'backbone', 'underscore' ),
JETPACK__VERSION
);
wp_register_script(
'views.jetpack-modules',
Assets::get_file_url_for_environment(
'_inc/build/jetpack-modules.views.min.js',
'_inc/jetpack-modules.views.js'
),
array( 'backbone', 'underscore', 'wp-util' ),
JETPACK__VERSION
);
wp_register_script(
'jetpack-modules-list-table',
Assets::get_file_url_for_environment(
'_inc/build/jetpack-modules.min.js',
'_inc/jetpack-modules.js'
),
array(
'views.jetpack-modules',
'models.jetpack-modules',
'jquery',
),
JETPACK__VERSION,
true
);
wp_localize_script(
'jetpack-modules-list-table',
'jetpackModulesData',
array(
'modules' => Jetpack::get_translated_modules( $this->all_items ),
'i18n' => array(
'search_placeholder' => __( 'Search Modules…', 'jetpack' ),
),
'modalinfo' => $this->module_info_check( $modal_info, $this->all_items ),
'nonces' => array(
'bulk' => wp_create_nonce( 'bulk-jetpack_page_jetpack_modules' ),
),
)
);
wp_enqueue_script( 'jetpack-modules-list-table' );
/**
* Filters the js_templates callback value.
*
* @since 3.6.0
*
* @param array array( $this, 'js_templates' ) js_templates callback.
*/
add_action( 'admin_footer', apply_filters( 'jetpack_modules_list_table_js_template_callback', array( $this, 'js_templates' ) ), 9 );
}
function js_templates() {
?>
get_modules();
$array_of_module_tags = wp_list_pluck( $modules, 'module_tags' );
$module_tags = call_user_func_array( 'array_merge', $array_of_module_tags );
$module_tags_unique = array_count_values( $module_tags );
ksort( $module_tags_unique );
$format = '%1$s (%2$s)';
$title = __( 'All', 'jetpack' );
$count = count( $modules );
$url = esc_url( remove_query_arg( 'module_tag' ) );
$current = empty( $_GET['module_tag'] ) ? ' class="current all"' : ' class="all"';
$views = array(
'all' => sprintf( $format, $title, $count, $url, $current ),
);
foreach ( $module_tags_unique as $title => $count ) {
$key = sanitize_title( $title );
$display_title = esc_html( wptexturize( $title ) );
$url = esc_url( add_query_arg( 'module_tag', urlencode( $title ) ) );
$current = '';
if ( ! empty( $_GET['module_tag'] ) && $title == $_GET['module_tag'] ) {
$current = ' class="current"';
}
$views[ $key ] = sprintf( $format, $display_title, $count, $url, $current );
}
return $views;
}
function views() {
$views = $this->get_views();
echo "
\n";
foreach ( $views as $class => $view ) {
$views[ $class ] = "\t
';
}
function filter_displayed_table_items( $modules ) {
return array_filter( $modules, array( $this, 'is_module_displayed' ) );
}
static function is_module_displayed( $module ) {
// Handle module tag based filtering.
if ( ! empty( $_REQUEST['module_tag'] ) ) {
$module_tag = sanitize_text_field( $_REQUEST['module_tag'] );
if ( ! in_array( $module_tag, $module['module_tags'] ) ) {
return false;
}
}
// If nothing rejected it, include it!
return true;
}
static function sort_requires_connection_last( $module1, $module2 ) {
if ( $module1['requires_connection'] == $module2['requires_connection'] ) {
return 0;
}
if ( $module1['requires_connection'] ) {
return 1;
}
if ( $module2['requires_connection'] ) {
return -1;
}
return 0;
}
function get_columns() {
$columns = array(
'cb' => '',
'name' => __( 'Name', 'jetpack' ),
);
return $columns;
}
function get_bulk_actions() {
$actions = array(
'bulk-activate' => __( 'Activate', 'jetpack' ),
'bulk-deactivate' => __( 'Deactivate', 'jetpack' ),
);
return $actions;
}
function single_row( $item ) {
static $i = 0;
$row_class = ( ++$i % 2 ) ? ' alternate' : '';
if ( ! empty( $item['activated'] ) ) {
$row_class .= ' active';
}
if ( ! Jetpack_Admin::is_module_available( $item ) ) {
$row_class .= ' unavailable';
}
echo '';
$this->single_row_columns( $item );
echo ' ';
}
function get_table_classes() {
return array( 'table', 'table-bordered', 'wp-list-table', 'widefat', 'fixed', 'jetpack-modules' );
}
function column_cb( $item ) {
if ( ! Jetpack_Admin::is_module_available( $item ) ) {
return '';
}
return sprintf( '', $item['module'] );
}
function column_icon( $item ) {
$badge_text = $free_text = '';
ob_start();
?>