metadata = maybe_unserialize( get_post_meta( $post->ID, 'attire_post_meta', true ) ); } $this->Actions(); } function Actions() { add_action( 'admin_init', array( $this, 'LoadMetaBoxes' ), 0 ); add_action( 'save_post', array( $this, 'SavePostMeta' ), 10, 2 ); } function LoadMetaBoxes() { $this->meta_boxes = array( 'attire-page-width' => array( 'title' => __( 'Page Width', 'attire' ), 'callback' => array( $this, 'PageWidth' ), 'position' => 'side', 'priority' => 'core', 'post_type' => 'page' ), ); $this->meta_boxes = apply_filters( "attire_metabox", $this->meta_boxes ); foreach ( $this->meta_boxes as $ID => $meta_box ) { extract( $meta_box ); add_meta_box( $ID, $title, $callback, $post_type, $position, $priority ); } } /** * @usage Page Width * * @param $post */ function PageWidth( $post ) { if ( ! is_array( $this->metadata ) ) { $this->metadata = maybe_unserialize( get_post_meta( $post->ID, 'attire_post_meta', true ) ); } $container_fluid = ""; $container = ""; $val = get_post_meta( $post->ID, 'attire_post_meta', true ); if ( isset( $val['layout_page'] ) ) { $val = $val['layout_page']; $default = $val === "default" ? "selected" : ""; $container_fluid = $val === "container-fluid" ? "selected" : ""; $container = $val === "container" ? "selected" : ""; } elseif ( $container_fluid === "" && $container === "" ) { $default = "selected"; } wp_nonce_field( 'attire_page_layout_nonce', 'attire_page_layout_nonce' ); echo ''; $this->SidebarLayout($post); } public function SidebarLayout($post) { $meta = get_post_meta( $post->ID, 'attire_post_meta', true ); $sl = isset($meta['sidebar_layout']) ? $meta['sidebar_layout'] : 'default'; $imageDir = '/images/layouts/'; $imguri = get_template_directory_uri() . $imageDir; ?>
: