'Audio URL', 'description' => 'Audio file URL in format: mp3, ogg, wav.', 'id' => 'post-audio', 'type' => 'url', ), // url array( 'label' => 'URL', 'description' => 'Enter the URL', 'id' => 'post-link-url', 'type' => 'url', ), // quote array( 'label' => 'Cite', 'description' => 'Define the title of a work with the cite tag:', 'id' => 'post-quote-url', 'type' => 'text', ), // video array( 'label' => 'Video URL', 'description' => 'YouTube or Vimeo video URL', 'id' => 'post-video-url', 'type' => 'url', ), array( 'label' => 'Video Upload', 'description' => 'Upload video file', 'id' => 'post-video-file', 'type' => 'wysiwyg', ), ); public function __construct() { add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); add_action( 'save_post', array( $this, 'save_fields' ) ); add_action( 'admin_footer', function(){ ?> screens as $s ) { add_meta_box( 'LiquidPostMeta', __( 'Liquid Post Format Options', 'aihub' ), array( $this, 'meta_box_callback' ), $s, 'normal', 'high' ); } } public function meta_box_callback( $post ) { wp_nonce_field( 'LiquidPostMeta_data', 'LiquidPostMeta_nonce' ); $this->field_generator( $post ); } public function field_generator( $post ) { foreach ( $this->fields as $field ) { $label = ''; $description = isset( $field['description'] ) ? $field['description'] : ''; $meta_value = get_post_meta( $post->ID, $field['id'], true ); if ( empty( $meta_value ) ) { if ( isset( $field['default'] ) ) { $meta_value = $field['default']; } } switch ( $field['type'] ) { case 'select': $input = sprintf( ''; break; case 'pages': $pagesargs = array( 'selected' => $meta_value, 'echo' => 0, 'name' => $field['id'], 'id' => $field['id'], 'post_type' => $field['post_type'], 'show_option_none' => 'Select a template', ); $input = wp_dropdown_pages($pagesargs); break; case 'wysiwyg': ob_start(); wp_editor($meta_value, $field['id'], array( 'media_buttons' => true ) ); $input = ob_get_contents(); ob_end_clean(); break; default: $input = sprintf( '', $field['type'] !== 'color' ? 'style="width: 100%"' : '', $field['id'], $field['id'], $field['type'], $meta_value ); } $this->format_rows( $label, $description, $input ); } } public function format_rows( $label, $description, $input ) { printf( '
%s