/
home
/
techb158
/
public_html
/
wp-content
/
plugins
/
meta-box
/
inc
/
fields
/
/home/techb158/public_html/wp-content/plugins/meta-box/inc/fields
mkdir
upload
Name
Size
Mode
Actions
autocomplete.php
3072
0666
edit
dl
rm
background.php
5457
0666
edit
dl
rm
block-editor.php
4991
0666
edit
dl
rm
button-group.php
1882
0666
edit
dl
rm
button.php
1290
0666
edit
dl
rm
checkbox-list.php
468
0666
edit
dl
rm
checkbox.php
1284
0666
edit
dl
rm
choice.php
1888
0666
edit
dl
rm
color.php
2553
0666
edit
dl
rm
custom-html.php
602
0666
edit
dl
rm
date.php
610
0666
edit
dl
rm
datetime.php
10093
0666
edit
dl
rm
divider.php
607
0666
edit
dl
rm
fieldset-text.php
3479
0666
edit
dl
rm
file-input.php
1977
0666
edit
dl
rm
file-upload.php
953
0666
edit
dl
rm
file.php
17665
0666
edit
dl
rm
heading.php
713
0666
edit
dl
rm
icon.php
8813
0666
edit
dl
rm
image-advanced.php
2229
0666
edit
dl
rm
image-select.php
2444
0666
edit
dl
rm
image-upload.php
719
0666
edit
dl
rm
image.php
4893
0666
edit
dl
rm
input-list.php
2714
0666
edit
dl
rm
input.php
3020
0666
edit
dl
rm
key-value.php
2951
0666
edit
dl
rm
link.php
4134
0666
edit
dl
rm
map.php
6738
0666
edit
dl
rm
media.php
6935
0666
edit
dl
rm
multiple-values.php
1361
0666
edit
dl
rm
number.php
910
0666
edit
dl
rm
object-choice.php
4475
0666
edit
dl
rm
oembed.php
4150
0666
edit
dl
rm
osm.php
5936
0666
edit
dl
rm
password.php
2263
0666
edit
dl
rm
post.php
6721
0666
edit
dl
rm
radio.php
270
0666
edit
dl
rm
range.php
1544
0666
edit
dl
rm
select-advanced.php
2457
0666
edit
dl
rm
select-tree.php
1547
0666
edit
dl
rm
select.php
2552
0666
edit
dl
rm
sidebar.php
1250
0666
edit
dl
rm
single-image.php
1770
0666
edit
dl
rm
slider.php
2349
0666
edit
dl
rm
switch.php
2426
0666
edit
dl
rm
taxonomy-advanced.php
2913
0666
edit
dl
rm
taxonomy.php
9293
0666
edit
dl
rm
text-list.php
3478
0666
edit
dl
rm
textarea.php
1612
0666
edit
dl
rm
time.php
1176
0666
edit
dl
rm
user.php
5210
0666
edit
dl
rm
video.php
3871
0666
edit
dl
rm
wysiwyg.php
2335
0666
edit
dl
rm
Edit:
/home/techb158/public_html/wp-content/plugins/meta-box/inc/fields/user.php
(5210B)
<?php defined( 'ABSPATH' ) || die; /** * The user select field. */ class RWMB_User_Field extends RWMB_Object_Choice_Field { public static function add_actions() { add_action( 'wp_ajax_rwmb_get_users', [ __CLASS__, 'ajax_get_users' ] ); add_action( 'wp_ajax_nopriv_rwmb_get_users', [ __CLASS__, 'ajax_get_users' ] ); add_action( 'clean_user_cache', [ __CLASS__, 'update_cache' ] ); } public static function ajax_get_users() { check_ajax_referer( 'query' ); $request = rwmb_request(); $field = $request->filter_post( 'field', FILTER_DEFAULT, FILTER_FORCE_ARRAY ); // Required for 'choice_label' filter. See self::filter(). $field['clone'] = false; $field['_original_id'] = $field['id']; // Search. $term = (string) $request->filter_post( 'term' ); if ( $term ) { $field['query_args']['search'] = "*{$term}*"; } // Pagination. $limit = $field['query_args']['number'] ?? 0; $limit = (int) $limit; if ( $limit && 'query:append' === $request->filter_post( '_type' ) ) { $field['query_args']['paged'] = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT ); } // Query the database. $items = self::query( null, $field ); $items = array_values( $items ); $items = apply_filters( 'rwmb_ajax_get_users', $items, $field, $request ); $data = [ 'items' => $items ]; // More items for pagination. if ( $limit && count( $items ) === $limit ) { $data['more'] = true; } wp_send_json_success( $data ); } /** * Update object cache to make sure query method below always get the fresh list of users. * Unlike posts and terms, WordPress doesn't set 'last_changed' for users. * So we have to do it ourselves. * * @see clean_post_cache() */ public static function update_cache() { wp_cache_set( 'last_changed', microtime(), 'users' ); } /** * Normalize parameters for field. * * @param array $field Field parameters. * * @return array */ public static function normalize( $field ) { // Set default field args. $field = wp_parse_args( $field, [ 'placeholder' => __( 'Select a user', 'meta-box' ), 'query_args' => [], 'display_field' => 'display_name', ] ); $field = parent::normalize( $field ); // Set default query args. $limit = $field['ajax'] ? 10 : 0; $field['query_args'] = wp_parse_args( $field['query_args'], [ 'number' => $limit, ] ); parent::set_ajax_params( $field ); if ( $field['ajax'] ) { $field['js_options']['ajax_data']['field']['display_field'] = $field['display_field']; } return $field; } public static function query( $meta, array $field ): array { $display_field = $field['display_field']; $args = wp_parse_args( $field['query_args'], [ 'orderby' => $display_field, 'order' => 'asc', ] ); $args['fields'] = [ 'ID', 'user_login', 'user_nicename', 'user_url', 'user_registered', 'user_status', 'display_name', ]; $meta = wp_parse_id_list( (array) $meta ); // Query only selected items. if ( ! empty( $field['ajax'] ) && ! empty( $meta ) ) { $args['include'] = $meta; $args['number'] = count( $meta ); } // Get from cache to prevent same queries. $last_changed = wp_cache_get_last_changed( 'users' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize $key = md5( serialize( $args ) ); $cache_key = "$key:$last_changed"; $options = wp_cache_get( $cache_key, 'meta-box-user-field' ); if ( false !== $options ) { return $options; } $users = get_users( $args ); $options = []; foreach ( $users as $user ) { $label = $user->$display_field ?? __( '(No title)', 'meta-box' ); $label = self::filter( 'choice_label', $label, $field, $user ); $options[ $user->ID ] = [ 'value' => $user->ID, 'label' => $label, ]; } // Cache the query. wp_cache_set( $cache_key, $options, 'meta-box-user-field' ); return $options; } /** * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary. * * @param array $field Field parameters. * @param int $value User ID. * @param array $args Additional arguments. Rarely used. See specific fields for details. * @param int|null $post_id Post ID. null for current post. Optional. * * @return string */ public static function format_single_value( $field, $value, $args, $post_id ) { if ( empty( $value ) ) { return ''; } $link = $args['link'] ?? 'view'; $user = get_userdata( $value ); $display_field = $field['display_field']; $text = $user->$display_field; if ( false === $link ) { return $text; } $url = get_author_posts_url( $value ); if ( 'edit' === $link ) { $url = get_edit_user_link( $value ); } return sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html( $text ) ); } public static function add_new_form( array $field ): string { if ( ! current_user_can( 'create_users' ) ) { return ''; } return sprintf( '<a href="#" class="rwmb-user-add-button rwmb-modal-add-button" data-url="%s">%s</a>', admin_url( 'user-new.php' ), esc_html__( 'Add New User', 'meta-box' ) ); } }
Save
cmd:
run