true, '_builtin' => false ); $post_types = get_post_types( $args, 'names' ); $builtin_post_types = array( 'post' => 'post', 'page' => 'page'); if( !empty( $post_types ) ) { $post_types = array_merge( $post_types, $builtin_post_types ); } else { $post_types = $builtin_post_types; } $post_types = apply_filters( 'octane_inpage_supports', $post_types ); // Limit meta box to certain post types. if ( in_array( $post_type, $post_types ) ) { add_meta_box( 'octane-page-options', __( 'Octane Page Options', 'octane' ), array( $this, 'render' ), $post_type, 'advanced', 'high', array( '__back_compat_meta_box' => false, ) ); } } /** * Save the meta when the post is saved. * * @param int $post_id The ID of the post being saved. */ public function save( $post_id ) { // Check if our nonce is set. if ( ! isset( $_POST['octane_page_settings_nonce'] ) ) { return $post_id; } $nonce = $_POST['octane_page_settings_nonce']; // Verify that the nonce is valid. if ( ! wp_verify_nonce( $nonce, 'octane_page_settings' ) ) { return $post_id; } /* * If this is an autosave, our form has not been submitted, * so we don't want to do anything. */ if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return $post_id; } // Check the user's permissions. if ( 'page' == $_POST['post_type'] ) { if ( ! current_user_can( 'edit_page', $post_id ) ) { return $post_id; } } else { if ( ! current_user_can( 'edit_post', $post_id ) ) { return $post_id; } } /* OK, it's safe for us to save the data now. */ // Sanitize the user input. $page_color_select = sanitize_text_field( filter_input( INPUT_POST, 'page_colors_enable' ) ); $theme_color = sanitize_text_field( filter_input( INPUT_POST, 'theme_global_colors' ) ); $sidebar_position = sanitize_text_field( filter_input( INPUT_POST, 'page_sidebar' ) ); $header_layout = sanitize_text_field( filter_input( INPUT_POST, 'header_layout' ) ); $footer_widget = sanitize_text_field( filter_input( INPUT_POST, 'enable_footer_widget_section' ) ); $footer_copyright = sanitize_text_field( filter_input( INPUT_POST, 'enable_footer_copyright_area' ) ); // Update the meta field. Octane_Theme_Options::update_octane_page_meta( 'page-sidebar', $sidebar_position, $post_id ); Octane_Theme_Options::update_octane_page_meta( 'header-layout', $header_layout, $post_id ); Octane_Theme_Options::update_octane_page_meta( 'footer-widget-display', $footer_widget, $post_id ); } /** * Render Meta Box content. * * @param WP_Post $post The post object. */ public function render( $post ) { // Add an nonce field so we can check for it later. wp_nonce_field( 'octane_page_settings', 'octane_page_settings_nonce' ); $value = get_post_meta( $post->ID, 'octane_page_setting', true ); ?>