__( 'Select a slider', 'alchem' ), 'value' => '' ); $alchem_custom_slider = new WP_Query( array( 'post_type' => 'magee_slider', 'post_status'=>'publish', 'posts_per_page' => -1 ) ); while ( $alchem_custom_slider->have_posts() ) { $alchem_custom_slider->the_post(); $alchem_sliders[] = array( 'label' => get_the_title(), 'value' => get_the_ID() ); } wp_reset_postdata(); return $alchem_sliders; } /** * Save the meta when the post is saved. * * @param int $post_id The ID of the post being saved. */ public function alchem_save( $post_id ) { /* * We need to verify this came from the our screen and with proper authorization, * because save_post can be triggered at other times. */ // Check if our nonce is set. if ( ! isset( $_POST['alchem_inner_custom_box_nonce'] ) ) return $post_id; $nonce = $_POST['alchem_inner_custom_box_nonce']; // Verify that the nonce is valid. if ( ! wp_verify_nonce( $nonce, 'alchem_inner_custom_box' ) ) 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, its safe for us to save the data now. */ if( isset($_POST) && $_POST ){ $post_metas = array(); $post_metas['full_width'] = isset($_POST['full_width'])?sanitize_text_field($_POST['full_width']):'no'; $post_metas['padding_top'] = isset($_POST['padding_top'])?sanitize_text_field($_POST['padding_top']):''; $post_metas['padding_bottom'] = isset($_POST['padding_bottom'])?sanitize_text_field($_POST['padding_bottom']):''; $post_metas['display_title_bar'] = isset($_POST['display_title_bar'])?sanitize_text_field($_POST['display_title_bar']):'yes'; $post_metas['nav_menu'] = isset($_POST['nav_menu'])?sanitize_text_field($_POST['nav_menu']):''; $post_metas['page_layout'] = isset($_POST['page_layout'])?sanitize_text_field($_POST['page_layout']):'none'; $post_metas['left_sidebar'] = isset($_POST['left_sidebar'])?sanitize_text_field($_POST['left_sidebar']):''; $post_metas['right_sidebar'] = isset($_POST['right_sidebar'])?sanitize_text_field($_POST['right_sidebar']):''; $post_metas['slider_banner'] = isset($_POST['slider_banner'])?sanitize_text_field($_POST['slider_banner']):'0'; $post_metas['banner_position'] = isset($_POST['banner_position'])?sanitize_text_field($_POST['banner_position']):'1'; $post_metas['magee_slider'] = isset($_POST['magee_slider'])?sanitize_text_field($_POST['magee_slider']):''; $alchem_post_meta = json_encode( $post_metas ); // Update the meta field. update_post_meta( $post_id, '_alchem_post_meta', $alchem_post_meta ); } } /** * Render Meta Box content. * * @param WP_Post $post The post object. */ public function alchem_render_meta_box_content( $post ) { global $wp_registered_sidebars; $magee_sliders = self::alchem_sliders_meta(); // Add an nonce field so we can check for it later. wp_nonce_field( 'alchem_inner_custom_box', 'alchem_inner_custom_box_nonce' ); // Use get_post_meta to retrieve an existing value from the database. $alchem_page_meta = get_post_meta( $post->ID ,'_alchem_post_meta',true); if( $alchem_page_meta ){ $alchem_page_metas = @json_decode( $alchem_page_meta,true ); if( is_array($alchem_page_metas) && $alchem_page_metas !=null ) extract( $alchem_page_metas ); } /************ get nav menus*************/ $nav_menus[] = array( 'label' => __( 'Default', 'alchem' ), 'value' => '' ); $menus = get_registered_nav_menus(); foreach ( $menus as $location => $description ) { $nav_menus[] = array( 'label' => $description, 'value' => $location ); } /* sidebars */ $alchem_sidebars[] = array( 'label' => __( 'Default', 'alchem' ), 'value' => '' ); foreach( $wp_registered_sidebars as $key => $value){ $alchem_sidebars[] = array( 'label' => $value['name'], 'value' => $value['id'], ); } $full_width = isset( $full_width )?esc_attr($full_width):'no'; $padding_top = isset( $padding_top )?esc_attr($padding_top):''; $padding_bottom = isset( $padding_bottom )?esc_attr($padding_bottom):''; $display_title_bar = isset( $display_title_bar )?esc_attr($display_title_bar):'yes'; $page_layout = isset( $page_layout )?esc_attr($page_layout):'none'; $slider_banner = isset( $slider_banner )?esc_attr($slider_banner):'0'; $alchem_banner_position = isset( $alchem_banner_position )?esc_attr($alchem_banner_position):'1'; echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } }