'Select an item', 'action': rest_url( 'wp/v2/users' ), rest_url( 'wp/v2/post' ), rest_url( 'wp/v2/page' ), 'data': users, page, post, course, lesson ) * * @return string */ public function __construct( $label = '', $description = '', $default = '', $extra = array() ) { parent::__construct( $label, $description, $default, $extra ); } public function output( $thepostid ) { // Enqueue scripts here for future use everywhere called. wp_enqueue_script( 'lp-admin-learnpress' ); if ( empty( $this->id ) ) { return; } $field = $this->extra; $field['id'] = $this->id; $field['default'] = $this->default; $field['description'] = $this->description; $field['label'] = $this->label; $meta = $this->meta_value( $thepostid ); $default = ( ! $meta && isset( $field['default'] ) ) ? (array) $field['default'] : $meta; $field = wp_parse_args( $field, array( 'class' => 'select', 'style' => '', 'wrapper_class' => '', 'value' => isset( $field['value'] ) ? $field['value'] : $default, 'name' => $field['id'], 'desc_tip' => false, 'custom_attributes' => array(), ) ); $wrapper_class = ! empty( $field['wrapper_class'] ) ? esc_attr( $field['wrapper_class'] ) : ''; $field_attributes = (array) $field['custom_attributes']; $field_attributes['style'] = 'width: 300px;' . $field['style']; $field_attributes['id'] = $field['id']; $field_attributes['name'] = $field['name'] . '[]'; $field_attributes['class'] = $field['class']; $field_attributes['multiple'] = true; $data_atts = array( 'placeholder' => $field['placeholder'] ?? esc_html__( 'Select', 'learnpress' ), 'action' => $field['action'] ?? '', 'data' => $field['data'] ?? '', // users, pages, posts, lp_course, lp_lesson... 'nonce' => wp_create_nonce( 'wp_rest' ), 'rest_url' => rest_url(), ); ?>
id, $this->default ?? [] ); update_post_meta( $post_id, $this->id, $value ); return $value; } }