public static function register() { /* Make sure to register only once */ if (self::$__registered) { return; } self::$__registered = true; /* Get the post type settings */ $settings = wp_parse_args(self::post_type_args(), array('args' => array(), 'labels' => array(), 'metaboxes' => array(), 'taxonomies' => array())); extract($settings, EXTR_SKIP); /* Merge the labels into the args */ $args = array_merge($args, compact('labels')); /* Create the post type object */ $post_type_object = Youxi_Post_Type::get(self::post_type_name(), $args); /* Add the metaboxes */ foreach ($metaboxes as $metabox_id => $metabox) { $post_type_object->add_meta_box(new Youxi_Metabox($metabox_id, $metabox)); } /* Add the taxonomies */ foreach ($taxonomies as $tax_id => $taxonomy) { $post_type_object->add_taxonomy(new Youxi_Taxonomy($tax_id, $taxonomy)); } if (is_admin()) { /* Attach post type ordering page */ $ordering_page = new Youxi_Post_Order_Page(__('Order Portfolio', 'youxi'), __('Order Portfolio', 'youxi'), 'youxi-portfolio-order-page'); $post_type_object->add_submenu_page($ordering_page); } /* Register the post type */ $post_type_object->register(); }
/** * Initialize by constructing metaboxes based on supported post formats * * @since 1.0 */ public function init() { if ($post_formats_support = get_theme_support('post-formats')) { /* Get supported post formats */ if (!isset($post_formats_support[0]) || !is_array($post_formats_support[0])) { $post_formats_support = get_post_format_slugs(); } else { $post_formats_support = $post_formats_support[0]; } /* Prepare post format metaboxes */ $this->metaboxes = array(); foreach ($post_formats_support as $post_format) { if (is_callable("youxi_post_format_{$post_format}_metabox")) { $metabox_id = youxi_post_format_id($post_format); $metabox = call_user_func("youxi_post_format_{$post_format}_metabox"); $this->metaboxes[$post_format] = array_merge(array('id' => $metabox_id, 'html_classes' => array('youxi-metabox')), $metabox); } } /* Attach metabox on each supported post types */ foreach ((array) youxi_post_format_post_types() as $post_type) { /* Make sure it's an existing post type */ if (!post_type_exists($post_type)) { continue; } /* Get the post type wrapper object */ $post_type_object = Youxi_Post_Type::get($post_type); /* Add the metaboxes */ foreach ($this->metaboxes as $metabox) { $post_type_object->add_meta_box(new Youxi_Metabox($metabox['id'], $metabox)); } } /* Prepare on the 'add_meta_boxes' hook */ add_action('add_meta_boxes', array($this, 'prepare')); } }
function helium_add_edd_metabox() { $metaboxes = array(); /* Layout */ $metaboxes['layout'] = array('title' => esc_html__('Layout', 'helium'), 'fields' => array('show_title' => array('type' => 'switch', 'label' => esc_html__('Show Title', 'helium'), 'description' => esc_html__('Switch to show/hide the download title before the content.', 'helium'), 'std' => true))); /* Create the 'page' post type object */ $post_type_object = Youxi_Post_Type::get('download'); /* Add the metaboxes */ foreach ($metaboxes as $metabox_id => $metabox) { $post_type_object->add_meta_box(new Youxi_Metabox($metabox_id, $metabox)); } }
function helium_add_page_metabox() { $metaboxes = array(); /* Layout */ $metaboxes['layout'] = array('title' => esc_html__('Layout', 'helium'), 'fields' => array('page_layout' => array('type' => 'select', 'label' => esc_html__('Page Layout', 'helium'), 'description' => esc_html__('Specify the layout of the page (does not have any effect on custom page templates).', 'helium'), 'choices' => array('fullwidth' => esc_html__('Fullwidth', 'helium'), 'boxed' => esc_html__('Boxed', 'helium')), 'std' => 'boxed'), 'wrap_content' => array('type' => 'switch', 'label' => esc_html__('Wrap Content', 'helium'), 'description' => esc_html__('Switch to automatically wrap the post content inside a container. Switch off to use advanced row layouts.', 'helium'), 'std' => true))); /* Create the 'page' post type object */ $post_type_object = Youxi_Post_Type::get('page'); /* Add the metaboxes */ foreach ($metaboxes as $metabox_id => $metabox) { $post_type_object->add_meta_box(new Youxi_Metabox($metabox_id, $metabox)); } }
function helium_add_portfolio_metabox() { $metaboxes = array(); /* Portfolio Archive Page Template */ $metaboxes['portfolio_grid_settings'] = array('title' => esc_html__('Page Template: Portfolio', 'helium'), 'page_template' => 'archive-portfolio', 'fields' => array('use_defaults' => array('type' => 'switch', 'label' => esc_html__('Use Default Settings', 'helium'), 'description' => esc_html__('Switch to use the default portfolio grid settings.', 'helium'), 'std' => false), 'show_filter' => array('type' => 'switch', 'label' => esc_html__('Show Filter', 'helium'), 'description' => esc_html__('Switch to display the portfolio filter.', 'helium'), 'criteria' => 'use_defaults:is(0)', 'std' => true), 'pagination' => array('type' => 'select', 'label' => esc_html__('Pagination Type', 'helium'), 'description' => esc_html__('Specify the portfolio pagination type.', 'helium'), 'choices' => array('ajax' => esc_html__('AJAX', 'helium'), 'infinite' => esc_html__('Infinite', 'helium'), 'numbered' => esc_html__('Numbered', 'helium'), 'prev_next' => esc_html__('Prev/Next', 'helium'), 'show_all' => esc_html__('None (Show all)', 'helium')), 'criteria' => 'use_defaults:is(0)', 'std' => 'ajax'), 'ajax_button_text' => array('type' => 'text', 'label' => esc_html__('AJAX Button Text', 'helium'), 'description' => esc_html__('Specify the text to display on the AJAX load more button.', 'helium'), 'std' => 'Load More', 'criteria' => 'pagination:is(ajax),use_defaults:is(0)'), 'ajax_button_complete_text' => array('type' => 'text', 'label' => esc_html__('AJAX Button Complete Text', 'helium'), 'description' => esc_html__('Specify the text to display on the AJAX load more button when there are no more items to load.', 'helium'), 'std' => 'No More Items', 'criteria' => 'pagination:is(ajax),use_defaults:is(0)'), 'posts_per_page' => array('type' => 'uislider', 'label' => esc_html__('Posts Per Page', 'helium'), 'description' => esc_html__('Specify how many portfolio items to show per page.', 'helium'), 'widgetopts' => array('min' => 1, 'max' => 20, 'step' => 1), 'criteria' => 'use_defaults:is(0),pagination:not(show_all)', 'std' => 10), 'include' => array('type' => 'checkboxlist', 'label' => esc_html__('Included Categories', 'helium'), 'description' => esc_html__('Specify the portfolio categories to include (leave unchecked to include all).', 'helium'), 'choices' => get_terms(youxi_portfolio_tax_name(), array('fields' => 'id=>name', 'hide_empty' => false)), 'criteria' => 'use_defaults:is(0)'), 'behavior' => array('type' => 'select', 'label' => esc_html__('Behavior', 'helium'), 'description' => esc_html__('Specify the behavior when clicking the thumbnail image.', 'helium'), 'choices' => array('none' => esc_html__('None', 'helium'), 'lightbox' => esc_html__('Show Image in Lightbox', 'helium'), 'page' => esc_html__('Go to Detail Page', 'helium')), 'criteria' => 'use_defaults:is(0)'), 'orderby' => array('type' => 'select', 'label' => esc_html__('Order By', 'helium'), 'description' => esc_html__('Specify in what order the items should be displayed.', 'helium'), 'choices' => array('date' => esc_html__('Date', 'helium'), 'menu_order' => esc_html__('Menu Order', 'helium'), 'title' => esc_html__('Title', 'helium'), 'ID' => esc_html__('ID', 'helium')), 'criteria' => 'use_defaults:is(0)', 'std' => 'date'), 'order' => array('type' => 'select', 'label' => esc_html__('Order', 'helium'), 'description' => esc_html__('Specify how to order the items.', 'helium'), 'choices' => array('DESC' => esc_html__('Descending', 'helium'), 'ASC' => esc_html__('Ascending', 'helium')), 'criteria' => 'use_defaults:is(0),orderby:not(menu_order)', 'std' => 'DESC'), 'layout' => array('type' => 'select', 'label' => esc_html__('Layout', 'helium'), 'description' => esc_html__('Specify the portfolio layout.', 'helium'), 'choices' => array('classic' => esc_html__('Classic', 'helium'), 'masonry' => esc_html__('Masonry', 'helium'), 'justified' => esc_html__('Justified', 'helium')), 'criteria' => 'use_defaults:is(0)', 'std' => 'justified'), 'columns' => array('type' => 'uislider', 'label' => esc_html__('Columns', 'helium'), 'description' => esc_html__('Specify in how many columns the items should be displayed in the masonry/classic layout.', 'helium'), 'widgetopts' => array('min' => 3, 'max' => 5, 'step' => 1), 'std' => 4, 'criteria' => 'use_defaults:is(0),layout:not(justified)'))); $metaboxes['portfolio_slider_settings'] = array('title' => esc_html__('Page Template: Portfolio Slider', 'helium'), 'page_template' => 'page-templates/portfolio-slider', 'fields' => array('posts_per_page' => array('type' => 'uislider', 'label' => esc_html__('Number of Slides', 'helium'), 'description' => esc_html__('Specify how many portfolio items to show on the slider.', 'helium'), 'widgetopts' => array('min' => 1, 'max' => 10, 'step' => 1), 'std' => 5), 'orderby' => array('type' => 'select', 'label' => esc_html__('Order By', 'helium'), 'description' => esc_html__('Specify in what order the items should be displayed.', 'helium'), 'choices' => array('date' => esc_html__('Date', 'helium'), 'menu_order' => esc_html__('Menu Order', 'helium'), 'title' => esc_html__('Title', 'helium'), 'ID' => esc_html__('ID', 'helium'), 'rand' => esc_html__('Random', 'helium')), 'std' => 'date'), 'order' => array('type' => 'select', 'label' => esc_html__('Order', 'helium'), 'description' => esc_html__('Specify how to order the items.', 'helium'), 'choices' => array('DESC' => esc_html__('Descending', 'helium'), 'ASC' => esc_html__('Ascending', 'helium')), 'std' => 'DESC', 'criteria' => 'orderby:not(menu_order)'))); /* Create the 'page' post type object */ $post_type_object = Youxi_Post_Type::get('page'); /* Add the metaboxes */ foreach ($metaboxes as $metabox_id => $metabox) { $post_type_object->add_meta_box(new Youxi_Metabox($metabox_id, $metabox)); } }