/home/techb158/public_html/wp-content/plugins/meta-box/inc/fields
NameSizeModeActions
autocomplete.php30720644editdlrm
background.php54570644editdlrm
block-editor.php49910644editdlrm
button-group.php18820644editdlrm
button.php12900644editdlrm
checkbox-list.php4680644editdlrm
checkbox.php12840644editdlrm
choice.php18880644editdlrm
color.php25530644editdlrm
custom-html.php6020644editdlrm
date.php6100644editdlrm
datetime.php100930644editdlrm
divider.php6070644editdlrm
fieldset-text.php34790644editdlrm
file-input.php19770644editdlrm
file-upload.php9530644editdlrm
file.php176650644editdlrm
heading.php7130644editdlrm
icon.php88130644editdlrm
image-advanced.php22290644editdlrm
image-select.php24440644editdlrm
image-upload.php7190644editdlrm
image.php48930644editdlrm
input-list.php27140644editdlrm
input.php30200644editdlrm
key-value.php29510644editdlrm
link.php41340644editdlrm
map.php67380644editdlrm
media.php69350644editdlrm
multiple-values.php13610644editdlrm
number.php9100644editdlrm
object-choice.php44750644editdlrm
oembed.php41500644editdlrm
osm.php59360644editdlrm
password.php22630644editdlrm
post.php67250644editdlrm
radio.php2700644editdlrm
range.php15440644editdlrm
select-advanced.php24570644editdlrm
select-tree.php15470644editdlrm
select.php25520644editdlrm
sidebar.php12500644editdlrm
single-image.php17700644editdlrm
slider.php23490644editdlrm
switch.php24260644editdlrm
taxonomy-advanced.php29130644editdlrm
taxonomy.php92930644editdlrm
text-list.php34780644editdlrm
textarea.php16120644editdlrm
time.php11760644editdlrm
user.php52100644editdlrm
video.php38710644editdlrm
wysiwyg.php23350644editdlrm
Edit: /home/techb158/public_html/wp-content/plugins/meta-box/inc/fields/post.php (6725B)
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. $field['query_args']['s'] = $request->filter_post( 'term' ); // Pagination. if ( '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_posts', $items, $field, $request ); $data = [ 'items' => $items ]; // More items for pagination. $limit = (int) $field['query_args']['posts_per_page']; if ( -1 !== $limit && count( $items ) === $limit ) { $data['more'] = true; } wp_send_json_success( $data ); } /** * Normalize parameters for field. * * @param array $field Field parameters. * @return array */ public static function normalize( $field ) { $field = wp_parse_args( $field, [ 'post_type' => 'post', 'parent' => false, 'query_args' => [], ] ); $field['post_type'] = (array) $field['post_type']; /* * Set default placeholder: * - If multiple post types: show 'Select a post'. * - If single post type: show 'Select a %post_type_name%'. */ $placeholder = __( 'Select a post', 'meta-box' ); if ( 1 === count( $field['post_type'] ) ) { $post_type = reset( $field['post_type'] ); $post_type_object = get_post_type_object( $post_type ); if ( ! empty( $post_type_object ) ) { // Translators: %s is the post singular label. $placeholder = sprintf( __( 'Select a %s', 'meta-box' ), strtolower( $post_type_object->labels->singular_name ) ); } } $field = wp_parse_args( $field, [ 'placeholder' => $placeholder, ] ); // Set parent option, which will change field name to `parent_id` to save as post parent. if ( $field['parent'] ) { $field['multiple'] = false; $field['field_name'] = 'parent_id'; } $field = parent::normalize( $field ); // Set default query args. $posts_per_page = $field['ajax'] ? 10 : -1; $field['query_args'] = wp_parse_args( $field['query_args'], [ 'post_type' => $field['post_type'], 'post_status' => 'publish', 'posts_per_page' => $posts_per_page, ] ); parent::set_ajax_params( $field ); return $field; } public static function query( $meta, array $field ): array { $args = wp_parse_args( $field['query_args'], [ 'search_columns' => [ 'post_title' ], 'no_found_rows' => true, 'update_post_meta_cache' => false, 'update_post_term_cache' => false, 'mb_field_id' => $field['id'], ] ); $meta = wp_parse_id_list( (array) $meta ); // Query only selected items. if ( ! empty( $field['ajax'] ) && ! empty( $meta ) ) { $args['posts_per_page'] = count( $meta ); $args['post__in'] = $meta; } // Get from cache to prevent same queries. $last_changed = wp_cache_get_last_changed( 'posts' ); // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions.serialize_serialize $key = md5( serialize( $args ) ); $cache_key = "$key:$last_changed"; $options = wp_cache_get( $cache_key, 'meta-box-post-field' ); if ( false !== $options ) { return $options; } $query = new WP_Query( $args ); $options = []; foreach ( $query->posts as $post ) { if ( ! current_user_can( 'read_post', $post->ID ) ) { continue; } $label = $post->post_title ? $post->post_title : __( '(No title)', 'meta-box' ); $label = self::filter( 'choice_label', $label, $field, $post ); $options[ $post->ID ] = [ 'value' => $post->ID, 'label' => $label, 'parent' => $post->post_parent, ]; } // Cache the query. wp_cache_set( $cache_key, $options, 'meta-box-post-field' ); return $options; } /** * Get meta value. * If field is cloneable, value is saved as a single entry in DB. * Otherwise value is saved as multiple entries (for backward compatibility). * * @see "save" method for better understanding * * @param int $post_id Post ID. * @param bool $saved Is the meta box saved. * @param array $field Field parameters. * * @return mixed */ public static function meta( $post_id, $saved, $field ) { return $field['parent'] ? wp_get_post_parent_id( $post_id ) : parent::meta( $post_id, $saved, $field ); } /** * Format a single value for the helper functions. Sub-fields should overwrite this method if necessary. * * @param array $field Field parameters. * @param int $value The value. * @param array $args Additional arguments. Rarely used. See specific fields for details. * @param ?int $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 ''; } /** * Allow developers to change the value of the post. Used for WPML integration. * @var int|string $value The post ID. * @var array $field The field parameters. * @internal */ $value = apply_filters( '_rwmb_post_format_single_value', $value, $field ); $link = $args['link'] ?? 'view'; $text = get_the_title( $value ); if ( false === $link ) { return $text; } $url = get_permalink( $value ); if ( 'edit' === $link ) { $url = get_edit_post_link( $value ); } return sprintf( '%s', esc_url( $url ), wp_kses_post( $text ) ); } public static function add_new_form( array $field ): string { if ( ! current_user_can( 'edit_posts' ) ) { return ''; } if ( 1 !== count( $field['post_type'] ) ) { return ''; } $post_type = reset( $field['post_type'] ); if ( ! post_type_exists( $post_type ) ) { return ''; } $post_type_object = get_post_type_object( $post_type ); return sprintf( '%s', admin_url( $post_type === 'post' ? 'post-new.php' : 'post-new.php?post_type=' . $post_type ), esc_html( $post_type_object->labels->add_new_item ) ); } }