コード例 #1
0
ファイル: options.php プロジェクト: joasssko/schk
/**
 * 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);
        }
    }
}
コード例 #2
0
 /**
  * Create the duplicable fields container for image and video slides.
  *
  * @param string $label The fields container label.
  * @return THB_MetaboxDuplicableFieldsContainer
  */
 function thb_create_slideshows_slides_container($label = '', $config = array())
 {
     $config = thb_array_asum(array('slug' => 'slides_container', 'slides_key' => THB_SLIDES, 'captions' => true, 'images' => true, 'videos' => true), $config);
     extract($config);
     $thb_container = new THB_MetaboxDuplicableFieldsContainer($label, $slug);
     $thb_container->setSortable();
     if ($images) {
         $thb_container->addControl(__('Add images', 'thb_text_domain'), 'add_image', 'images.png', array('action' => 'thb_add_multiple_slides', 'title' => __('Add image slides', 'thb_text_domain')));
     }
     if ($videos) {
         $thb_container->addControl(__('Add video', 'thb_text_domain'), 'add_video', 'film.png');
     }
     $field = new THB_SlideField($slides_key);
     $field->setLabel(__('Slide', 'thb_text_domain'));
     if (!$captions) {
         $field->disableCaptions();
     }
     $thb_container->setField($field);
     return $thb_container;
 }