function thb_add_post_metabox() { $thb_posts = thb_theme()->getPostType('post'); $thb_metabox = $thb_posts->getMetabox('layout'); if (!$thb_metabox) { return; } if (thb_config('core/blog', 'enable_author_block') || thb_config('core/blog', 'disable_navigation_block')) { $thb_container = $thb_metabox->createContainer(__('Post details', 'thb_text_domain'), 'single_display_settings'); if (thb_config('core/blog', 'enable_author_block')) { $thb_field = new THB_CheckboxField('enable_author_block'); $thb_field->setLabel(__('Author section', 'thb_text_domain')); $thb_field->setHelp(__('Show a secondary section displaying the author\'s name, avatar and short bio.', 'thb_text_domain')); $thb_container->addField($thb_field); } if (thb_config('core/blog', 'disable_navigation_block')) { $thb_field = new THB_CheckboxField('disable_navigation_block'); $thb_field->setLabel(__('Hide navigation', 'thb_text_domain')); $thb_field->setHelp(__('Hide the navigation between posts secondary section.', 'thb_text_domain')); $thb_container->addField($thb_field); } } $thb_container = $thb_metabox->createContainer(__('Related posts', 'thb_text_domain'), 'related'); $thb_field = new THB_CheckboxField('post_related'); $thb_field->setLabel(__('Enable a related posts section', 'thb_text_domain')); $thb_field->setHelp(__('Checking this control automatically creates a "related posts" section at the bottom of the post page.', 'thb_text_domain')); $thb_field->setDynamicDefault('thb_default_post_related'); $thb_container->addField($thb_field); $thb_field = new THB_NumberField('post_related_number'); $thb_field->setLabel(__('Related posts to show', 'thb_text_domain')); $thb_field->setHelp(__('Choose how many related posts you want to display. Defaults to 3.', 'thb_text_domain')); $thb_field->setDynamicDefault('thb_default_post_related_number'); $thb_container->addField($thb_field); $thb_field = new THB_CheckboxField('post_related_thumb'); $thb_field->setLabel(__('Show thumbnails in related posts', 'thb_text_domain')); $thb_field->setHelp(__('Checking this control enables the display of thumbnails for related posts.', 'thb_text_domain')); $thb_field->setDynamicDefault('thb_default_post_related_thumb'); $thb_container->addField($thb_field); $thb_metabox->getContainers(); // thb_theme()->getPostType('post')->addMetabox( $thb_metabox ); }
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); } }
$thb_field->setLabel(__('Shop page sidebar', 'thb_text_domain')); $thb_field->setOptions(array(0 => __('No sidebar', 'thb_text_domain'))); $thb_field->setDynamicOptions('thb_get_sidebars_for_select'); $thb_container->addField($thb_field); $thb_field = new THB_SelectField('shop_sidebar_position'); $thb_field->setLabel(__('Shop page sidebar position', 'thb_text_domain')); $thb_field->setOptions(array('sidebar-left' => __('Left', 'thb_text_domain'), 'sidebar-right' => __('Right', 'thb_text_domain'))); $thb_container->addField($thb_field); $thb_field = new THB_NumberField('shop_products_per_page'); $thb_field->setLabel(__('Products to show', 'thb_text_domain')); $thb_field->setHelp(__('Choose how many products will be displayed on Shop page.', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_container = $thb_tab->createContainer(__('Product page options', 'thb_text_domain'), 'woocommerce_product_options'); $thb_field = new THB_NumberField('related_products_per_page'); $thb_field->setLabel(__('Related product to show', 'thb_text_domain')); $thb_field->setHelp(__('Choose how many related posts will be displayed on single product page.', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_SelectField('product_sidebar'); $thb_field->setLabel(__('Product page sidebar', 'thb_text_domain')); $thb_field->setOptions(array(0 => __('No sidebar', 'thb_text_domain'))); $thb_field->setDynamicOptions('thb_get_sidebars_for_select'); $thb_container->addField($thb_field); $thb_field = new THB_SelectField('product_sidebar_position'); $thb_field->setLabel(__('Product page sidebar position', 'thb_text_domain')); $thb_field->setOptions(array('sidebar-left' => __('Left', 'thb_text_domain'), 'sidebar-right' => __('Right', 'thb_text_domain'))); $thb_container->addField($thb_field); $thb_page->addTab($thb_tab); if (!function_exists('thb_shop_columns_layout')) { function thb_shop_columns_layout($classes) { if (is_woocommerce()) {
$thb_field->setLabel(__('Email address', 'thb_text_domain')); $thb_field->setHelp(__('Emails from the website\'s contact form will be sent to this address.', 'thb_text_domain')); $thb_container->addField($thb_field); if (thb_config('core/contact', 'map')) { $thb_container = $thb_tab->createContainer(__('Map', 'thb_text_domain'), 'contact_map_data'); $thb_field = new THB_TextField('contact_marker'); $thb_field->setLabel(__('Map marker text', 'thb_text_domain')); $thb_field->setHelp(__('Adding text to the map pin will make it pop up when clicking on it.', 'thb_text_domain')); $thb_container->addField($thb_field); $thb_field = new THB_TextField('contact_lat_long'); $thb_field->setLabel(__('Map latitude and longitude', 'thb_text_domain')); $thb_field->setHelp(sprintf(__('Insert the latitude and longitude for the Google Map (eg. 44.422, 8.937) in a contact page. Trouble? <a href="%s" target="_blank">Get them here</a>.', 'thb_text_domain'), 'http://itouchmap.com/latlong.html')); $thb_container->addField($thb_field); $thb_field = new THB_NumberField('contact_zoom'); $thb_field->setLabel(__('Map zoom', 'thb_text_domain')); $thb_field->setHelp(__('A reasonable value ranges from 6 to 16; if left blank, the default value will be 10.', 'thb_text_domain')); $thb_container->addField($thb_field); } } /** * Frontend helpers * ----------------------------------------------------------------------------- */ if (!function_exists('thb_contact_map')) { function thb_contact_map($params = array()) { $latlong = thb_get_option('contact_lat_long'); $zoom = thb_get_option("contact_zoom"); $marker = thb_get_option("contact_marker"); $map_config = array('height' => '500'); $map_config = thb_array_asum($map_config, $params);
/** * Portfolio single entries options */ function thb_portfolio_single_options() { if (thb_portfolio_framework_check()) { $thb_works = thb_theme()->getPostType('works'); $slide_field = new THB_SlideField(thb_portfolio_config('work_slides_key')); $slide_field->setLabel(__('Slide', 'thb-portfolio')); $slide_field = apply_filters('thb_work_slide', $slide_field); if (thb_is_admin_template('single-works.php') && thb_portfolio_config('single')) { $thb_metabox = thb_theme()->getPostType('works')->getMetabox('layout'); $thb_container = $thb_metabox->createContainer(__('Related works', 'thb-portfolio'), 'related_works'); $thb_field = new THB_CheckboxField('works_related'); $thb_field->setLabel(__('Enable a related works section', 'thb-portfolio')); $thb_field->setHelp(__('Selecting "Yes" automatically creates a "related works" section at the bottom of a Portfolio item page.', 'thb-portfolio')); $thb_field->setDynamicDefault('thb_default_works_related'); $thb_container->addField($thb_field); $thb_field = new THB_NumberField('works_related_number'); $thb_field->setLabel(__('Related works to show', 'thb-portfolio')); $thb_field->setHelp(__('Choose how many related works you want to display. Defaults to 3.', 'thb-portfolio')); $thb_field->setDynamicDefault('thb_default_works_related_number'); $thb_container->addField($thb_field); $thb_field = new THB_CheckboxField('works_related_thumb'); $thb_field->setLabel(__('Show thumbnails in related works', 'thb-portfolio')); $thb_field->setHelp(__('Choose to enable the display of thumbnails for related works.', 'thb-portfolio')); $thb_field->setDynamicDefault('thb_default_works_related_thumb'); $thb_container->addField($thb_field); } $thb_metabox = $thb_works->getMetabox('layout'); $thb_tab = $thb_metabox->createTab(__('Project data', 'thb-portfolio'), 'extra'); $thb_tab->setIcon('clipboard'); // $thb_metabox = new THB_Metabox( __('Project data', 'thb-portfolio'), 'extra' ); // $thb_metabox->setPriority('high'); if (thb_portfolio_config('work_external_url')) { $thb_container = $thb_tab->createContainer('', 'data_details'); $field = new THB_TextField('external_url'); $field->setLabel(__('External URL', 'thb-portfolio')); $field->setHelp(__('Insert here an external URL to link to in Portfolio pages directly.', 'thb-portfolio')); $thb_container->addField($field); } if ($work_details = thb_portfolio_config('work_details')) { if ($work_details == 'text') { $thb_container = $thb_tab->createContainer(__('Details', 'thb-portfolio'), 'details'); $field = new THB_TextareaField('prj_info'); $field->setHelp(__('Insert here your project details (Note: accepts basic HTML).', 'thb-portfolio')); $thb_container->addField($field); } elseif ($work_details == 'keyvalue') { $thb_container = $thb_tab->createDuplicableContainer(__('Details', 'thb-portfolio'), 'details'); $thb_container->setIntroText(__('Click on the "Add" button to start inserting a series of key/value pairs details.', 'thb-portfolio')); $thb_container->addControl(__('Add', 'thb-portfolio'), ''); $thb_container->setSortable(); $thb_upload = new THB_KeyValueField('prj_info'); $thb_upload->setLabel(__('Detail', 'thb-portfolio')); $thb_container->setField($thb_upload); } } if (thb_portfolio_config('work_slides')) { if ($work_slides_config = thb_portfolio_config('work_slides_config')) { if (is_callable($work_slides_config)) { $thb_tab->addContainer(call_user_func($work_slides_config)); } } $thb_container = new THB_MetaboxDuplicableFieldsContainer(__('Project images and videos', 'thb-portfolio'), 'slides_container'); $thb_container->setSortable(); $thb_container->addControl(__('Add images', 'thb-portfolio'), 'add_image', '', array('action' => 'thb_add_multiple_slides', 'title' => __('Add images', 'thb-portfolio'))); $thb_container->addControl(__('Add video', 'thb-portfolio'), 'add_video', '', array('action' => 'thb_add_video_slide', 'title' => __('Add video', 'thb-portfolio'))); $thb_container->setField($slide_field); $thb_tab->addContainer($thb_container); // $thb_works->addMetabox($thb_metabox); } } }
function thb_portfolio_single_options() { $thb_metabox = thb_theme()->getPostType('works')->getMetabox('layout'); // $thb_container = $thb_metabox->getContainer( 'layout_container' ); $thb_container = $thb_metabox->createContainer(__('Related works', 'thb_text_domain'), 'related_works'); $thb_field = new THB_CheckboxField('works_related'); $thb_field->setLabel(__('Enable a related works section', 'thb_text_domain')); $thb_field->setHelp(__('Selecting "Yes" automatically creates a "related works" section at the bottom of a Portfolio item page.', 'thb_text_domain')); $thb_field->setDynamicDefault('thb_default_works_related'); $thb_container->addField($thb_field); $thb_field = new THB_NumberField('works_related_number'); $thb_field->setLabel(__('Related works to show', 'thb_text_domain')); $thb_field->setHelp(__('Choose how many related works you want to display. Defaults to 3.', 'thb_text_domain')); $thb_field->setDynamicDefault('thb_default_works_related_number'); $thb_container->addField($thb_field); $thb_field = new THB_CheckboxField('works_related_thumb'); $thb_field->setLabel(__('Show thumbnails in related works', 'thb_text_domain')); $thb_field->setHelp(__('Choose to enable the display of thumbnails for related works.', 'thb_text_domain')); $thb_field->setDynamicDefault('thb_default_works_related_thumb'); $thb_container->addField($thb_field); }
function thb_create_slideshows_posttype_config_container($label = '', $slug = 'slideshow_config_container') { /** * Base configuration fields container. */ $thb_container = new THB_MetaboxFieldsContainer('', $slug); $field = new THB_NumberField('delay'); $field->setLabel(__('Delay', 'thb_text_domain')); $field->setHelp(__('Expressed in seconds.', 'thb_text_domain')); $field->setPlaceholder(__('E.g. 5', 'thb_text_domain')); $thb_container->addField($field); $field = new THB_NumberField('transition_speed'); $field->setLabel(__('Transition speed', 'thb_text_domain')); $field->setHelp(__('Expressed in seconds.', 'thb_text_domain')); $field->setPlaceholder(__('E.g. 1', 'thb_text_domain')); $field->setMin('0'); $field->setStep('0.05'); $thb_container->addField($field); $thb_field = new THB_SelectField('slideshow_type'); $thb_field->setLabel(__('Type', 'thb_text_domain')); $thb_field->setDynamicOptions('thb_slideshows_types'); $thb_field->setInvisibleIfEmpty(true); $thb_container->addField($thb_field); return $thb_container; }