'Sidebar', 'id' => 'anzu_layout_sidebar', 'default' => 'customizer', 'type' => 'select', 'options' => array( 'customizer' => 'Customizer Setting', 'right' => 'Right sidebar', 'left' => 'Left sidebar', 'both' => 'Left & Right sidebars', 'none' => 'No sidebar', ), ), array( 'label' => 'Content Layout', 'id' => 'anzu_layout_content', 'default' => 'customizer', 'type' => 'select', 'options' => array( 'customizer' => 'Customizer Setting', 'container' => 'Contained', 'container-fluid' => 'Full Width', ), ), array( 'label' => 'Disable Header', 'id' => 'anzu_layout_disable_header', 'type' => 'checkbox', ), array( 'label' => 'Disable Footer', 'id' => 'anzu_layout_disable_footer', 'type' => 'checkbox', ), array( 'label' => 'Disable Title', 'id' => 'anzu_layout_disable_title', 'type' => 'checkbox', ), ); public function __construct() { add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) ); add_action( 'save_post', array( $this, 'save_fields' ) ); } public function add_meta_boxes() { foreach ( $this->screen as $single_screen ) { add_meta_box( 'anzulayout', __( 'Anzu Layout', 'anzu' ), array( $this, 'meta_box_callback' ), $single_screen, 'side', 'default' ); } } public function meta_box_callback( $post ) { wp_nonce_field( 'anzulayout_data', 'anzulayout_nonce' ); $this->field_generator( $post ); } public function field_generator( $post ) { $output = ''; foreach ( $this->meta_fields as $meta_field ) { $label = ''; $meta_value = get_post_meta( $post->ID, $meta_field['id'], true ); if ( empty( $meta_value ) ) { if ( isset( $meta_field['default'] ) ) { $meta_value = $meta_field['default']; } } switch ( $meta_field['type'] ) { case 'checkbox': $input = sprintf( '', $meta_value === '1' ? 'checked' : '', $meta_field['id'], $meta_field['id'] ); break; case 'select': $input = sprintf( ''; break; default: $input = sprintf( '', $meta_field['type'] !== 'color' ? 'style="width: 100%"' : '', $meta_field['id'], $meta_field['id'], $meta_field['type'], $meta_value ); } $output .= $this->format_rows( $label, $input ); } echo '