function thb_sidebars_metabox($post_type = null) { $thb_theme = thb_theme(); // $thb_post_type = $thb_theme->getPostType($post_type); $thb_metabox = new THB_Metabox(__('Sidebar', 'thb_text_domain'), 'sidebar'); $thb_metabox->setPosition('side'); $thb_container = thb_sidebars_metabox_container($post_type); $thb_metabox->addContainer($thb_container); // $thb_post_type->addMetabox($thb_metabox); return $thb_metabox; }
function thb_seo_init($post_type) { $thb_metabox = new THB_Metabox(__('SEO', 'thb_text_domain'), 'seo'); $thb_metabox->setPosition('side'); $thb_container = $thb_metabox->createContainer('', 'seo_container'); $thb_field = new THB_TextareaField('seo_description'); $thb_field->setLabel(__('Description', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_TextareaField('seo_keywords'); $thb_field->setLabel(__('Keywords', 'thb_text_domain')); $thb_container->addField($thb_field); $post_type->addMetabox($thb_metabox); }
function thb_add_footerstripes_posttype_config_metabox() { $consumer_key = thb_get_option('twitter_consumer_key'); $consumer_secret = thb_get_option('twitter_consumer_secret'); $oauth_token = thb_get_option('twitter_oauth_token'); $oauth_token_secret = thb_get_option('twitter_oauth_token_secret'); $config_note = ''; if ($consumer_key == '' || $consumer_secret == '' || $oauth_token == '' || $oauth_token_secret == '') { $config_note = __('Make sure to fill the required Twitter API settings in the "Theme options > Social" tab.', 'thb_text_domain'); } $post_type = thb_theme()->getPostType('footerstripes'); $thb_metabox = new THB_Metabox(__('Footer contents', 'thb_text_domain'), 'footerstripes_config'); $thb_container = $thb_metabox->createContainer('', 'footerstripes_config_container'); $thb_field = new THB_SelectField('footerstripes_content_type'); $thb_field->setLabel(__('Content type', 'thb_text_domain')); $thb_field->setOptions(array('twitter' => __('Twitter', 'thb_text_domain'), 'call-to-action' => __('Call to action', 'thb_text_domain'), 'social' => __('Social', 'thb_text_domain'))); $thb_container->addField($thb_field); // Twitter $thb_container = $thb_metabox->createContainer(__('Twitter', 'thb_text_domain'), 'footerstripes_content_type_twitter'); $thb_container->setIntroText($config_note); $thb_field = new THB_TextField('footerstripes_twitter_username'); $thb_field->setLabel(__('Username', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_NumberField('footerstripes_twitter_num'); $thb_field->setLabel(__('Tweets #', 'thb_text_domain')); $thb_container->addField($thb_field); // Social $thb_container = $thb_metabox->createContainer(__('Social', 'thb_text_domain'), 'footerstripes_content_type_social'); $thb_field = new THB_TextField('footerstripes_social_services'); $thb_field->setLabel(__('Services', 'thb_text_domain')); $thb_field->setHelp(__('Comma separated, order matters', 'thb_text_domain') . '. ' . __('Possible values', 'thb_text_domain') . ': twitter, facebook, googleplus, flickr, youtube, vimeo, pinterest, dribbble, forrst.'); $thb_container->addField($thb_field); // Call to action $thb_container = $thb_metabox->createContainer(__('Call to action', 'thb_text_domain'), 'footerstripes_content_type_call-to-action'); $thb_field = new THB_TextField('footerstripes_call-to-action_big_text'); $thb_field->setLabel(__('Big text', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_TextareaField('footerstripes_call-to-action_small_text'); $thb_field->setLabel(__('Small text', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_TextField('footerstripes_call-to-action_btn_text'); $thb_field->setLabel(__('Button text', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_TextField('footerstripes_call-to-action_btn_url'); $thb_field->setLabel(__('Button URL', 'thb_text_domain')); $thb_container->addField($thb_field); $post_type->addMetabox($thb_metabox); }
function thb_add_portfolio_metabox() { $ajax = thb_config('core/portfolio', 'ajax'); $thb_metabox = new THB_Metabox(__('Portfolio items', 'thb_text_domain'), 'portfolio_loop'); $thb_metabox->setPriority('high'); $thb_container = $thb_metabox->createContainer('', 'portfolio_loop_container'); $thb_field = new THB_QueryFilterField('works_query'); $thb_field->setTaxonomies(thb_get_post_type_taxonomies('works')); if (thb_is_admin_template(thb_config('core/portfolio', 'pagination_disabled'))) { $thb_field->setHideNum(); } $thb_container->addField($thb_field); if (!empty($ajax)) { if (thb_is_admin_template($ajax)) { $thb_field = new THB_YesNoField('works_ajax_pagination'); $thb_field->setLabel(__('Use AJAX pagination', 'thb_text_domain')); $thb_field->setHelp(__('If the page template supports this feature (e.g. its items are filterable), enabling AJAX pagination won\'t refresh your page while filtering through Portfolio items.', 'thb_text_domain')); $thb_container->addField($thb_field); } } thb_theme()->getPostType('page')->addMetabox($thb_metabox); if (thb_check_template_config('core/portfolio', 'grid_templates')) { $thb_metabox = thb_theme()->getPostType('page')->getMetabox('layout'); $thb_container = $thb_metabox->getContainer('layout_container'); $thb_field = new THB_SelectField('portfolio_columns'); $thb_field->setLabel(thb_config('core/portfolio', 'grid_templates_columns_label')); $thb_field->setOptions(thb_config('core/portfolio', 'grid_templates_columns')); $thb_container->addField($thb_field); $grid_image_sizes = thb_config('core/portfolio', 'grid_image_sizes'); if (!empty($grid_image_sizes)) { $grid_size_options = array(); if (is_array(current($grid_image_sizes))) { $grid_size_options[] = __('Fixed', 'thb_text_domain'); $grid_size_options[] = __('Variable', 'thb_text_domain'); } else { $grid_size_options[$grid_image_sizes[0]] = __('Fixed', 'thb_text_domain'); $grid_size_options[$grid_image_sizes[1]] = __('Variable', 'thb_text_domain'); } $thb_field = new THB_SelectField('portfolio_grid_image_sizes'); $thb_field->setLabel(__('Thumbnails height', 'thb_text_domain')); $thb_field->setOptions($grid_size_options); $thb_container->addField($thb_field); } } }
function thb_photogallery_container() { $thb_theme = thb_theme(); $thb_photogallery_page_template = thb_config('core/photogallery', 'templates'); if (thb_is_admin_template($thb_photogallery_page_template)) { $thb_metabox = new THB_Metabox(__('Gallery', 'thb_text_domain'), 'slideshow'); $thb_container = $thb_metabox->createContainer(__('Configuration', 'thb_text_domain'), 'photogallery_masonry_details_container'); $thb_field = new THB_NumberField('slides_per_page'); $thb_field->setLabel(__('Pictures per page', 'thb_text_domain')); // $thb_field->setHelp( __('In case of AJAX loading, chose how many pictures to display.', 'thb_text_domain') ); $thb_field->setHelp(__('Choose how many pictures to load dinamically. Leaving this empty will show all the images available.', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_SelectField('portfolio_columns'); $thb_field->setLabel(thb_config('core/photogallery', 'grid_templates_columns_label')); $thb_field->setOptions(thb_config('core/photogallery', 'grid_templates_columns')); $thb_container->addField($thb_field); $image_sizes = thb_config('core/photogallery', 'image_sizes'); if (!empty($image_sizes)) { $slides_size_options = array(); if (is_array(current($image_sizes))) { $slides_size_options[] = __('Fixed', 'thb_text_domain'); $slides_size_options[] = __('Variable', 'thb_text_domain'); } else { $slides_size_options[$image_sizes[0]] = __('Fixed', 'thb_text_domain'); $slides_size_options[$image_sizes[1]] = __('Variable', 'thb_text_domain'); } $thb_field = new THB_SelectField('slides_size'); $thb_field->setLabel(__('Photos height', 'thb_text_domain')); $thb_field->setOptions($slides_size_options); $thb_container->addField($thb_field); } $thb_container = $thb_metabox->createDuplicableContainer(__('Photos', 'thb_text_domain'), 'photogallery_slides'); $thb_container->setSortable(); $thb_container->addControl(__('Add photo', 'thb_text_domain'), 'add_image', 'images.png', array('action' => 'thb_add_multiple_slides', 'title' => __('Add photos', 'thb_text_domain'))); $field = new THB_SlideField('photogallery_slide'); $field->setLabel(__('Slide', 'thb_text_domain')); $thb_container->setField($field); $thb_theme->getPostType('page')->addMetabox($thb_metabox); } }
function thb_works_slideshow_metabox() { $thb_theme = thb_theme(); $thb_works = $thb_theme->getPostType('works'); $thb_metabox = new THB_Metabox(__('Work images and videos', 'thb_text_domain'), 'portfolio_slides_config'); $thb_metabox->setPriority('high'); if (thb_config('core/portfolio', 'work_slides_config')) { $thb_metabox->addContainer(call_user_func(thb_config('core/portfolio', 'work_slides_config'))); } $thb_metabox->addContainer(thb_create_slideshows_slides_container('', array('slides_key' => thb_config('core/portfolio', 'work_slides_key')))); $thb_works->addMetabox($thb_metabox); }
function thb_add_home_page_slides_metabox() { $thb_metabox = new THB_Metabox(__('Slides', 'thb_text_domain'), 'slides'); $thb_container = $thb_metabox->createDuplicableContainer('', 'slides_container'); $thb_container->setSortable(); $thb_container->setIntroText(__("<strong>How to use</strong><br><br>Insert the post type ID in order to populate the slide with the post's featured image, excerpt, title and a button with a link to the single post page.<br>Alternatively, you can insert custom texts and button.<br><br>Please note that if you're using a post type ID, custom texts and background image will override the entry's content.", 'thb_text_domain')); $thb_container->addControl(__('Add', 'thb_text_domain'), ''); $thb_upload = new THB_HomePageSlideField('home_page_slide'); $thb_upload->setLabel(__('Home page slide', 'thb_text_domain')); $thb_container->setField($thb_upload); thb_theme()->getPostType('page')->addMetabox($thb_metabox, array('template-showcase.php')); }
function thb_single_layout_options() { $post_types = thb_theme()->getPostTypes(); foreach ($post_types as $pt) { if ($pt->isPublicContent() || $pt->getType() == 'post' || $pt->getType() == 'page') { $thb_metabox = new THB_Metabox(__('Layout', 'thb_text_domain'), 'layout'); $thb_metabox->setPriority('high'); $thb_metabox->addContainer(thb_layout_global_options_container()); $pt->addMetabox($thb_metabox); } } }
/** * Create a Slideshow metabox. * * @return THB_Metabox */ function thb_create_entry_slideshow_metabox() { $thb_metabox = new THB_Metabox(__('Slideshow', 'thb_text_domain'), 'page-slideshow'); $thb_container = $thb_metabox->createContainer('', 'config'); $field = new THB_TextField('slideshow'); $field->setHelp(__('Use <code>[thb_slideshow id="1"]</code> to include a slideshow.', 'thb_text_domain')); $thb_container->addField($field); return $thb_metabox; }
function thb_add_blog_filter_metabox() { $thb_metabox = new THB_Metabox(__('Blog items', 'thb_text_domain'), 'loop'); $thb_metabox->setPriority('high'); $thb_container = $thb_metabox->createContainer('', 'loop_container'); $thb_field = new THB_QueryFilterField('post_query'); $thb_field->setTaxonomies(thb_get_post_type_taxonomies('post')); $thb_container->addField($thb_field); thb_theme()->getPostType('post')->addMetaboxToPages($thb_metabox); }
/** * Add a custom metabox to the post type. * * @param THB_Metabox $metabox The custom metabox. * @param array $templates The admin templates that should display * the metabox. * @param int $index The insertion index. * @return void */ public function addMetabox($metabox, $templates = array(), $index = false) { $add = true; if (!empty($templates)) { $add = thb_is_admin_template($templates); } // if( empty($_POST) && is_admin() ) { // foreach( $conditions as $condition ) { // if( !$condition ) { // $add = false; // break; // } // } // } if ($add) { $metabox->setPostType($this->_type); $metabox = apply_filters('thb_' . $metabox->getSlug() . '_metabox', $metabox); if ($index === false) { $this->_metaboxes[] = $metabox; } else { $this->_metaboxes = thb_array_insert($this->_metaboxes, $metabox, $index); } } }
/** * Add the Flexslider configuration options to the Slideshow config metabox. * * @param THB_Metabox $thb_metabox The Slideshow configuration metabox. * @return THB_Metabox */ function thb_flexslider_config_container($thb_metabox) { $thb_container = thb_flexslider_config_create_container(); $thb_metabox->addContainer($thb_container); return $thb_metabox; }