Esempio n. 1
0
/**
 * Portfolio custom post type.
 *
 * ---
 *
 * The Happy Framework: WordPress Development Framework
 * Copyright 2012, Andrea Gandino & Simone Maranzana
 *
 * Licensed under The MIT License
 * Redistribuitions of files must retain the above copyright notice.
 *
 * @package THB Portfolio
 * @author The Happy Bit <*****@*****.**>
 * @copyright Copyright 2012, Andrea Gandino & Simone Maranzana
 * @link http://
 * @since The Happy Framework v 1.0
 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
function thb_portfolio_post_type()
{
    /**
     * The post type labels.
     *
     * @see http://codex.wordpress.org/Function_Reference/register_post_type
     */
    $thb_works_labels = array('name' => __('Portfolio', 'thb-portfolio'), 'singular_name' => __('Work', 'thb-portfolio'), 'add_new' => __('Add new', 'thb-portfolio'), 'add_new_item' => __('Add new Work', 'thb-portfolio'), 'edit' => __('Edit', 'thb-portfolio'), 'edit_item' => __('Edit Work', 'thb-portfolio'), 'new_item' => __('New Work', 'thb-portfolio'), 'view' => __('View Work', 'thb-portfolio'), 'view_item' => __('View Work', 'thb-portfolio'), 'search_items' => __('Search Works', 'thb-portfolio'), 'not_found' => __('No Works found', 'thb-portfolio'), 'not_found_in_trash' => __('No Works found in Trash', 'thb-portfolio'), 'parent' => __('Parent Work', 'thb-portfolio'));
    /**
     * The post type arguments.
     *
     * @see http://codex.wordpress.org/Function_Reference/register_post_type
     */
    if (thb_portfolio_framework_check()) {
        $options_slug = thb_get_option('works_url_slug');
    } else {
        $options_slug = apply_filters('thb_portfolio_slug', '');
    }
    $slug = !empty($options_slug) ? $options_slug : 'works';
    $thb_works_args = array('labels' => $thb_works_labels, 'public' => true, 'show_ui' => true, 'capability_type' => 'post', 'hierarchical' => false, 'rewrite' => array('slug' => $slug, 'with_front' => true), 'query_var' => true, 'show_in_nav_menus' => true, 'supports' => array('title', 'thumbnail', 'excerpt', 'editor', 'comments', 'custom-fields'));
    /**
     * Create the post type object.
     */
    register_post_type('works', $thb_works_args);
    if (thb_portfolio_framework_check()) {
        $thb_works = new THB_PostType('works', $thb_works_args);
    }
    /**
     * Create the post type taxonomy for Works categories.
     */
    $thb_portfolio_categories_args = array('hierarchical' => true, 'labels' => array('name' => __('Portfolio Categories', 'thb-portfolio'), 'singular_name' => __('Portfolio Category', 'thb-portfolio'), 'search_items' => __('Search Portfolio Categories', 'thb-portfolio'), 'all_items' => __('All Portfolio Categories', 'thb-portfolio'), 'parent_item' => __('Parent Portfolio Category', 'thb-portfolio'), 'parent_item_colon' => __('Parent Portfolio Category:', 'thb-portfolio'), 'edit_item' => __('Edit Portfolio Category', 'thb-portfolio'), 'update_item' => __('Update Portfolio Category', 'thb-portfolio'), 'add_new_item' => __('Add New Portfolio Category', 'thb-portfolio'), 'new_item_name' => __('New Portfolio Category Name', 'thb-portfolio'), 'menu_name' => __('Portfolio Category', 'thb-portfolio')), 'rewrite' => true, 'query_var' => true);
    register_taxonomy('portfolio_categories', 'works', $thb_portfolio_categories_args);
    if (thb_portfolio_framework_check()) {
        $thb_works_taxonomy = new THB_Taxonomy('portfolio_categories', $thb_portfolio_categories_args);
        $thb_works->addTaxonomy($thb_works_taxonomy);
    }
    /**
     * Add the post type to the theme instance.
     */
    if (thb_portfolio_framework_check()) {
        $thb_theme = thb_theme();
        $thb_theme->addPostType($thb_works);
    }
}
Esempio n. 2
0
/**
 * Body classes
 * -----------------------------------------------------------------------------
 */
function thb_portfolio_body_classes($classes)
{
    if (!thb_portfolio_framework_check()) {
        return;
    }
    $thb_portfolio_grid_templates = thb_portfolio_config('grid_templates');
    $grid_body_class = thb_config('backpack/layout', 'grid_body_class');
    if ($grid_body_class && thb_is_page_template($thb_portfolio_grid_templates)) {
        $classes[] = thb_get_grid_class_name(thb_get_grid_columns());
    }
    return $classes;
}
Esempio n. 3
0
/**
 * 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);
        }
    }
}
Esempio n. 4
0
/**
 * Sidebars
 * -----------------------------------------------------------------------------
 */
function thb_portfolio_sidebars()
{
    if (thb_portfolio_framework_check() && thb_portfolio_config('sidebars')) {
        $thb_theme = thb_theme();
        $thb_works = $thb_theme->getPostType('works');
        $thb_theme->addSidebar(__('Portfolio sidebar', 'thb-portfolio'), 'works-sidebar');
        $thb_works->setSidebar('works-sidebar');
    }
}