Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Section: team_boxes
- Author: PageLines
- Author URI: http://www.pagelines.com
- Description: Creates team_boxes and team_box layouts
- Class Name: PageLinesteam_boxes
- Workswith: templates, main, header, morefoot
- Cloning: true
- */
- /**
- * team_boxes Section
- *
- * @package PageLines Framework
- * @author PageLines
- */
- class PageLinesteam_boxes extends PageLinesSection {
- var $taxID = 'team_box-sets';
- var $ptID = 'team_boxes';
- /**
- * PHP that always loads no matter if section is added or not.
- */
- function section_persistent(){
- $this->post_type_setup();
- $this->post_meta_setup();
- }
- /**
- *
- * @TODO document
- *
- */
- function post_type_setup(){
- $args = array(
- 'label' => __('team_boxes', 'pagelines'),
- 'singular_label' => __('team_box', 'pagelines'),
- 'description' => __( 'For creating team_boxes in team_box type layouts.', 'pagelines'),
- 'menu_icon' => $this->icon
- );
- $taxonomies = array(
- $this->taxID => array(
- 'label' => __('team_box Sets', 'pagelines'),
- 'singular_label' => __('team_box Set', 'pagelines'),
- )
- );
- $columns = array(
- 'cb' => "<input type=\"checkbox\" />",
- 'title' => 'Title',
- 'teamdescription' => 'Text',
- 'teammedia' => 'Media',
- $this->taxID => 'team_box Sets'
- );
- $this->post_type = new PageLinesPostType( $this->ptID, $args, $taxonomies, $columns, array(&$this, 'column_display'));
- $this->post_type->set_default_posts( 'pagelines_default_team_boxes', $this); // Default
- }
- /**
- *
- * @TODO document
- *
- */
- function post_meta_setup(){
- $type_meta_array = array(
- 'team_box_setup' => array(
- 'type' => 'multi_option',
- 'title' => __('Individual team_box Options', 'pagelines'),
- 'shortexp' => __('Basic setup options for handling of this team_box', 'pagelines'),
- 'selectvalues' => array(
- 'the_team_box_icon' => array(
- 'type' => 'image_upload',
- 'inputlabel' => __( 'team_box Image', 'pagelines'),
- ),
- 'the_team_box_icon_link' => array(
- 'type' => 'text',
- 'inputlabel' => __( 'team_box Link (Optional)', 'pagelines'),
- ),
- 'the_team_box_icon_target' => array(
- 'type' => 'check',
- 'inputlabel' => __( 'Open link in New Window?', 'pagelines'),
- ),
- 'team_box_class' => array(
- 'default' => '',
- 'type' => 'text',
- 'size' => 'small',
- 'inputlabel' => __( 'team_boxes Custom Class', 'pagelines'),
- ),
- 'team_box_more_text' => array(
- 'default' => '',
- 'type' => 'text',
- 'size' => 'small',
- 'inputlabel' => __( 'More Link Text (Shows if link and text is set)', 'pagelines'),
- ),
- ),
- ),
- );
- $post_types = array($this->id);
- $type_metapanel_settings = array(
- 'id' => 'team_boxes-metapanel',
- 'name' => THEMENAME.' team_box Options',
- 'posttype' => $post_types,
- );
- global $team_boxes_meta_panel;
- $team_boxes_meta_panel = new PageLinesMetaPanel( $type_metapanel_settings );
- $type_metatab_settings = array(
- 'id' => 'team_boxes-type-metatab',
- 'name' => 'team_box Setup Options',
- 'icon' => $this->icon,
- );
- $team_boxes_meta_panel->register_tab( $type_metatab_settings, $type_meta_array );
- }
- /**
- *
- * @TODO document
- *
- */
- function section_optionator( $settings ){
- $settings = wp_parse_args($settings, $this->optionator_default);
- $tab = array(
- 'team_box_setup' => array(
- 'type' => 'multi_option',
- 'title' => __('team_box Setup Options', 'pagelines'),
- 'shortexp' => __('Basic setup options for handling of team_boxes.', 'pagelines'),
- 'selectvalues' => array(
- 'team_box_set' => array(
- 'default' => 'default-team_boxes',
- 'type' => 'select_taxonomy',
- 'taxonomy_id' => $this->taxID,
- 'inputlabel' => __( 'team_box Set To Show', 'pagelines'),
- ),
- 'team_box_col_number' => array(
- 'type' => 'count_select',
- 'default' => '3',
- 'count_number' => '5',
- 'count_start' => '1',
- 'inputlabel' => __( "team_boxes Per Row", 'pagelines'),
- ),
- 'team_box_items' => array(
- 'default' => '6',
- 'type' => 'text_small',
- 'size' => 'small',
- 'inputlabel' => __( 'Maximum team_boxes To Show', 'pagelines'),
- ),
- ),
- ),
- 'team_box_image_formatting' => array(
- 'type' => 'multi_option',
- 'title' => __('team_box Image Options', 'pagelines'),
- 'shortexp' => __('Options for formatting team_box images.', 'pagelines'),
- 'exp' => __('', 'pagelines'),
- 'selectvalues' => array(
- 'team_box_thumb_type' => array(
- 'type' => 'select',
- 'default' => 'inline_thumbs',
- 'selectvalues' => array(
- 'inline_thumbs' => array('name' => __( 'Image At Left', 'pagelines') ),
- 'top_thumbs' => array('name' => __( 'Image On Top', 'pagelines') ),
- 'only_thumbs' => array('name' => __( "Only The Image, No Text", 'pagelines') )
- ),
- 'inputlabel' => __( 'team_box Thumb Style (optional - defaults to "At Left")', 'pagelines'),
- ),
- 'team_box_thumb_size' => array(
- 'default' => '64',
- 'type' => 'text_small',
- 'size' => 'small',
- 'inputlabel' => __( 'Enter the max image size in pixels (optional)', 'pagelines'),
- ),
- 'team_box_thumb_frame' => array(
- 'default' => '64',
- 'type' => 'check',
- 'size' => 'small',
- 'inputlabel' => __( 'Add A Frame To Images', 'pagelines'),
- ),
- ),
- ),
- 'team_box_ordering' => array(
- 'type' => 'multi_option',
- 'title' => __('team_box Ordering Options', 'pagelines'),
- 'shortexp' => __('Optionally control the ordering of the team_boxes', 'pagelines'),
- 'exp' => __('The easiest way to order team_boxes is using a post type order plugin for WordPress. However, if you would like to do it algorithmically, we have provided these options for you.', 'pagelines'),
- 'selectvalues' => array(
- 'team_box_orderby' => array(
- 'type' => 'select',
- 'default' => 'ID',
- 'inputlabel' => 'Order team_boxes By (If Not With Post Type Order Plugin)',
- 'selectvalues' => array(
- 'ID' => array('name' => __( 'Post ID (default)', 'pagelines') ),
- 'title' => array('name' => __( 'Title', 'pagelines') ),
- 'date' => array('name' => __( 'Date', 'pagelines') ),
- 'modified' => array('name' => __( 'Last Modified', 'pagelines') ),
- 'rand' => array('name' => __( 'Random', 'pagelines') ),
- )
- ),
- 'team_box_order' => array(
- 'default' => 'DESC',
- 'type' => 'select',
- 'selectvalues' => array(
- 'DESC' => array('name' => __( 'Descending', 'pagelines') ),
- 'ASC' => array('name' => __( 'Ascending', 'pagelines') ),
- ),
- 'inputlabel'=> __( 'Select sort order', 'pagelines'),
- ),
- ),
- ),
- 'team_box_more_text' => array(
- 'default' => '',
- 'type' => 'text',
- 'size' => 'small',
- 'inputlabel' => __( 'More Link Text', 'pagelines'),
- 'title' => __( 'More Link Text', 'pagelines'),
- 'shortexp' => __( 'Enter text for "more" links on linked team_box elements for this page.', 'pagelines'),
- 'exp' => __( 'If this option is blank (and not set in defaults), no more text will show.<br/><br/> This option can be overridden in individual team_box settings.', 'pagelines')
- ),
- 'team_box_class' => array(
- 'default' => '',
- 'type' => 'text',
- 'size' => 'small',
- 'inputlabel' => __( 'Add custom css class to these team_boxes', 'pagelines'),
- 'title' => __( 'Custom CSS class', 'pagelines'),
- 'shortexp' => __( 'Add a custom CSS class to this set of team_boxes.', 'pagelines'),
- ),
- );
- $tab_settings = array(
- 'id' => 'fteam_boxes_meta',
- 'name' => 'team_boxes',
- 'icon' => $this->icon,
- 'clone_id' => $settings['clone_id'],
- 'active' => $settings['active']
- );
- register_metatab($tab_settings, $tab);
- }
- /**
- * Section template.
- */
- function section_template( $clone_id = null ) {
- // Options
- $per_row = ( ploption( 'team_box_col_number', $this->oset) ) ? ploption( 'team_box_col_number', $this->oset) : 3;
- $team_box_set = ( ploption( 'team_box_set', $this->oset ) ) ? ploption( 'team_box_set', $this->oset ) : null;
- $team_box_limit = ploption( 'team_box_items', $this->oset );
- $this->thumb_type = ( ploption( 'team_box_thumb_type', $this->oset) ) ? ploption( 'team_box_thumb_type', $this->oset) : 'inline_thumbs';
- $this->thumb_size = ploption('team_box_thumb_size', $this->oset);
- $this->framed = ploption('team_box_thumb_frame', $this->oset);
- $class = ( ploption( 'team_box_class', $this->oset ) ) ? ploption( 'team_box_class', $this->oset ) : null;
- // Actions
- // Set up the query for this page
- $orderby = ( ploption('team_box_orderby', $this->oset) ) ? ploption('team_box_orderby', $this->oset) : 'ID';
- $order = ( ploption('team_box_order', $this->oset) ) ? ploption('team_box_order', $this->oset) : 'DESC';
- $params = array( 'orderby' => $orderby, 'order' => $order, 'post_type' => $this->ptID );
- $params[ 'showposts' ] = ( ploption('team_box_items', $this->oset) ) ? ploption('team_box_items', $this->oset) : $per_row;
- $params[ $this->taxID ] = ( ploption( 'team_box_set', $this->oset ) ) ? ploption( 'team_box_set', $this->oset ) : null;
- $params[ 'no_found_rows' ] = 1;
- $q = new WP_Query( $params );
- if(empty($q->posts)){
- echo setup_section_notify( $this, 'Add team_box Posts To Activate.', admin_url('edit.php?post_type='.$this->ptID), 'Add Posts' );
- return;
- }
- // Grid Args
- $args = array( 'per_row' => $per_row, 'callback' => array(&$this, 'draw_team_boxes'), 'class' => $class );
- // Call the Grid
- printf('<div class="fteam_boxes fix">%s</div>', grid( $q, $args ));
- }
- /**
- *
- * @TODO document
- *
- */
- function draw_team_boxes($p, $args){
- setup_postdata($p);
- $oset = array('post_id' => $p->ID);
- $team_box_link = plmeta('the_team_box_icon_link', $oset);
- $team_box_icon = plmeta('the_team_box_icon', $oset);
- $team_box_target = (plmeta('the_team_box_icon_target', $oset)) ? 'target="_blank"' : '';
- $class = ( plmeta( 'team_box_class', $oset ) ) ? plmeta( 'team_box_class', $oset ) : null;
- $cat = get_the_terms($p->ID, 'team_box-sets');
- $terms = array();
- $testimonials = false;
- foreach($cat as $set){
- array_push($terms, $set->slug);
- if($set->slug == 'testimonials'){
- $testimonials = true;
- }
- }
- $terms = implode(' ', $terms);
- $image = ($team_box_icon) ? self::_get_team_box_image( $p, $team_box_icon, $team_box_link, $this->thumb_size, $team_box_target) : '';
- $title_text = ($team_box_link) ? sprintf('<a href="%s">%s</a>', $team_box_link, $p->post_title ) : $p->post_title;
- $thumb = '';
- if($testimonials){
- $thumb = '<span>'.get_the_post_thumbnail($p->ID, 'testimonial', array('title'=>'')).'</span>';
- }
- $title = do_shortcode(sprintf('<div class="fteam_boxtitle">%s<h3>%s</h3></div>', $thumb, $title_text));
- if(plmeta('team_box_more_text', $oset)){
- $more_text = plmeta('team_box_more_text', $oset);
- } elseif(ploption('team_box_more_text', $this->oset)){
- $more_text = ploption('team_box_more_text', $this->oset);
- }else
- $more_text = false;
- $more_link = ($team_box_link && $more_text) ? sprintf('<span class="fteam_boxmore-wrap"><a class="fteam_boxmore" href="%s" %s>%s</a></span>', $team_box_link, $team_box_target, $more_text) : '';
- $more_link = apply_filters('team_box_more_link', $more_link);
- $content = sprintf('<div class="fteam_boxtext">%s %s %s</div>', do_shortcode(apply_filters('the_content',$p->post_content)), pledit( $p->ID ), $more_link);
- $info = ($this->thumb_type != 'only_thumbs') ? sprintf('<div class="fteam_boxinfo fix bd">%s%s</div>', $title, $content) : '';
- //echo print_r($terms);
- return sprintf(
- '<div id="%s" class="fteam_box %s %s"><div class="media team_box-media %s"><div class="blocks team_box-media-pad">%s%s</div></div></div>',
- 'fteam_box_'.$p->ID,
- $class,
- $terms,
- $this->thumb_type,
- $image,
- $info
- );
- }
- /**
- *
- * @TODO document
- *
- */
- function _get_team_box_image( $bpost, $team_box_icon, $team_box_link = false, $team_box_thumb_size = false, $team_box_target){
- global $pagelines_ID;
- $frame = ($this->framed) ? 'pl-imageframe' : '';
- if($this->thumb_type == 'inline_thumbs'){
- $max_width = ($team_box_thumb_size) ? $team_box_thumb_size : 65;
- $image_style = 'max-width: 100%';
- $wrapper_style = sprintf('width: 22%%; max-width:%dpx', $max_width);
- $wrapper_class = sprintf('fteam_boxgraphic img %s', $frame);
- } else {
- $max_width = ($team_box_thumb_size) ? $team_box_thumb_size.'px' : '100%';
- $image_style = 'max-width: 100%';
- $wrapper_style = sprintf('max-width:%s', $max_width);
- $wrapper_class = sprintf('fteam_boxgraphic %s', $frame);
- }
- // Make the image's tag with url
- $image_tag = sprintf('<img src="%s" alt="%s" style="%s" />', $team_box_icon, esc_html($bpost->post_title), $image_style);
- // If link for team_box is set, add it
- $image_output = ( $team_box_link ) ? sprintf('<a href="%s" title="%s" %s>%s</a>', $team_box_link, esc_html($bpost->post_title), $team_box_target, $image_tag ) : $image_tag;
- $wrapper = sprintf('<div class="%s" style="%s">%s</div>', $wrapper_class, $wrapper_style, $image_output );
- // Filter output
- return apply_filters('pl_team_box_image', $wrapper, $bpost->ID);
- }
- /**
- *
- * @TODO document
- *
- */
- function pagelines_default_team_boxes($post_type){
- $d = array_reverse( $this->get_default_fteam_boxes() );
- foreach($d as $dp){
- // Create post object
- $default_post = array();
- $default_post['post_title'] = $dp['title'];
- $default_post['post_content'] = $dp['text'];
- $default_post['post_type'] = $post_type;
- $default_post['post_status'] = 'publish';
- if ( defined( 'ICL_LANGUAGE_CODE' ) )
- $default_post['icl_post_language'] = ICL_LANGUAGE_CODE;
- $newPostID = wp_insert_post( $default_post );
- if(isset($dp['media']))
- update_post_meta($newPostID, 'the_team_box_icon', $dp['media']);
- wp_set_object_terms($newPostID, 'default-team_boxes', $this->taxID );
- // Add other default sets, if applicable.
- if(isset($dp['set']))
- wp_set_object_terms($newPostID, $dp['set'], $this->taxID, true);
- }
- }
- /**
- *
- * @TODO document
- *
- */
- function get_default_fteam_boxes(){
- $default_team_boxes[] = array(
- 'title' => 'Drag <span class="spamp">&</span> Drop',
- 'text' => 'PageLines is a drag & drop framework that allows you to completely customize your website with drag & drop.',
- 'media' => $this->base_url.'/images/fteam_box3.png'
- );
- $default_team_boxes[] = array(
- 'title' => 'Responsive <span class="spamp">&</span> Mobile',
- 'text' => "Built from the ground up to look great on mobile devices. PageLines utilizes an advanced responsive framework.",
- 'media' => $this->base_url.'/images/fteam_box2.png'
- );
- $default_team_boxes[] = array(
- 'title' => 'Tons of Addons',
- 'text' => "Load up your own sections, themes and plugins using PageLines' one of a kind extension marketplace.",
- 'media' => $this->base_url.'/images/fteam_box1.png'
- );
- return apply_filters('pagelines_default_team_boxes', $default_team_boxes);
- }
- /**
- *
- * @TODO document
- *
- */
- function column_display($column){
- global $post;
- switch ($column){
- case 'teamdescription':
- the_excerpt();
- break;
- case 'teammedia':
- echo get_the_post_thumbnail($post->ID, 'testimonial', array('title'=>''));
- break;
- case $this->taxID:
- echo get_the_term_list($post->ID, 'team_box-sets', '', ', ','');
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement