true, 'type' => 'string', 'single' => true, 'sanitize_callback' => 'sanitize_text_field', 'auth_callback' => function() { return current_user_can('edit_posts'); } )); } add_action( 'add_meta_boxes', 'dwp23_guten_add_media_meta_box' ); function dwp23_guten_add_media_meta_box() { add_meta_box( 'dwp23_guten_post_options_metabox', 'Post Options', 'dwp23_guten_post_options_metabox_callback', 'post', 'normal', 'default', array('__back_compat_meta_box' => true) ); } add_action( 'save_post', 'dwp23_guten_save_post_metabox', 10, 2 ); function dwp23_guten_post_options_metabox_callback($post) { $field_value = get_post_meta($post->ID, 'dwp23_media_url_meta', true); wp_nonce_field( 'dwp23_guten_update_post_metabox', 'dwp23_guten_update_post_nonce' ); ?>


post_type )->cap->edit_post; if( !current_user_can( $edit_cap, $post_id )) { return; } if( !isset( $_POST['dwp23_guten_update_post_nonce']) || !wp_verify_nonce( $_POST['dwp23_guten_update_post_nonce'], 'dwp23_guten_update_post_metabox' )) { return; } if(array_key_exists('dwp23_guten_media_metafield', $_POST)) { update_post_meta( $post_id, 'dwp23_media_url_meta', sanitize_text_field($_POST['dwp23_guten_media_metafield']) ); } } /*********************************************************** ########## Media Poster URL (dwp23_poster_url_meta) ########## ************************************************************/ add_action('init', 'dwp23_guten_register_poster_url_meta'); function dwp23_guten_register_poster_url_meta() { register_meta('post', 'dwp23_poster_url_meta', array( 'show_in_rest' => true, 'type' => 'string', 'single' => true, 'sanitize_callback' => 'sanitize_text_field', 'auth_callback' => function() { return current_user_can('edit_posts'); } )); } add_action( 'add_meta_boxes', 'dwp23_guten_add_poster_url_meta_box' ); function dwp23_guten_add_poster_url_meta_box() { add_meta_box( 'dwp23_guten_post_options_metabox', 'Post Options', 'dwp23_guten_post_options_metabox_poster_url', 'post', 'normal', 'default', array('__back_compat_meta_box' => true) ); } function dwp23_guten_post_options_metabox_poster_url($post) { $field_value = get_post_meta($post->ID, 'dwp23_image_meta_url', true); wp_nonce_field( 'dwp23_guten_update_post_metabox_poster_url', 'dwp23_guten_update_post_nonce' ); ?>


post_type )->cap->edit_post; if( !current_user_can( $edit_cap, $post_id )) { return; } if( !isset( $_POST['dwp23_guten_update_post_nonce_featured_image_url']) || !wp_verify_nonce( $_POST['dwp23_guten_update_post_nonce_featured_image_url'], 'dwp23_guten_update_post_metabox_featured_image_url' )) { return; } if(array_key_exists('dwp23_guten_media_metafield', $_POST)) { update_post_meta( $post_id, 'dwp23_image_meta_url', sanitize_text_field($_POST['dwp23_guten_featured_image_url_metafield']) ); } }