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', 'callback' => array($this, 'PageWidth'), 'position' => 'side', 'priority' => 'core', 'post_type' => 'page' ), 'attire-page-settings' => array( 'title' => 'Page Settings', 'callback' => array($this, 'PageSettings'), 'position' => 'normal', '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('page_layout_nonce', 'page_layout_nonce'); echo ''; } /** * @usage Page settings * * @param $post */ function PageSettings($post) { if (!is_array($this->metadata)) { $this->metadata = maybe_unserialize(get_post_meta($post->ID, 'attire_post_meta', true)); } $pagebg = isset($this->metadata['pagebg']) ? $this->metadata['pagebg'] : ''; $left_sidebar = isset($this->metadata['left_sidebar']) ? $this->metadata['left_sidebar'] : ''; $left_sidebar_width = isset($this->metadata['left_sidebar_width']) ? $this->metadata['left_sidebar_width'] : ''; $right_sidebar = isset($this->metadata['right_sidebar']) ? $this->metadata['right_sidebar'] : ''; $right_sidebar_width = isset($this->metadata['right_sidebar_width']) ? $this->metadata['right_sidebar_width'] : ''; $color = isset($this->metadata['cph_bg_color']) ? $this->metadata['cph_bg_color'] : ''; $text_color = isset($this->metadata['cph_text_color']) ? $this->metadata['cph_text_color'] : ''; $image = isset($this->metadata['cph_image']) ? $this->metadata['cph_image'] : ''; $desc = isset($this->metadata['cph_description']) ? $this->metadata['cph_description'] : ''; $active = isset($this->metadata['cph_active']) && (int)$this->metadata['cph_active'] === 1 ? 'checked' : ''; ?>
'cpb', 'name' => 'attire_post_meta[pagebg]', 'selected' => esc_attr($pagebg) )); ?>
Left Sidebar
'cpl', 'name' => 'attire_post_meta[left_sidebar]', 'selected' => esc_attr($left_sidebar) )); ?>
Right Sidebar
'cpl', 'name' => 'attire_post_meta[right_sidebar]', 'selected' => esc_attr($right_sidebar) )); ?>