Advertisement
Guest User

Pagelines Section Issue

a guest
Sep 9th, 2012
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 16.43 KB | None | 0 0
  1. <?php
  2. /*
  3.     Section: team_boxes
  4.     Author: PageLines
  5.     Author URI: http://www.pagelines.com
  6.     Description: Creates team_boxes and team_box layouts
  7.     Class Name: PageLinesteam_boxes
  8.     Workswith: templates, main, header, morefoot
  9.     Cloning: true
  10. */
  11.  
  12. /**
  13.  * team_boxes Section
  14.  *
  15.  * @package PageLines Framework
  16.  * @author PageLines
  17.  */
  18. class PageLinesteam_boxes extends PageLinesSection {
  19.  
  20.     var $taxID = 'team_box-sets';
  21.     var $ptID = 'team_boxes';
  22.  
  23.     /**
  24.     * PHP that always loads no matter if section is added or not.
  25.     */
  26.     function section_persistent(){
  27.        
  28.         $this->post_type_setup();
  29.        
  30.         $this->post_meta_setup();
  31.        
  32.     }
  33.    
  34.  
  35.     /**
  36.     *
  37.     * @TODO document
  38.     *
  39.     */
  40.     function post_type_setup(){
  41.             $args = array(
  42.                     'label'             => __('team_boxes', 'pagelines'),  
  43.                     'singular_label'    => __('team_box', 'pagelines'),
  44.                     'description'       => __( 'For creating team_boxes in team_box type layouts.', 'pagelines'),
  45.                     'menu_icon'         => $this->icon
  46.                 );
  47.             $taxonomies = array(
  48.                 $this->taxID => array( 
  49.                         'label' => __('team_box Sets', 'pagelines'),
  50.                         'singular_label' => __('team_box Set', 'pagelines'),
  51.                     )
  52.             );
  53.             $columns = array(
  54.                 'cb'            => "<input type=\"checkbox\" />",
  55.                 'title'         => 'Title',
  56.                 'teamdescription'   => 'Text',
  57.                 'teammedia'         => 'Media',
  58.                 $this->taxID    => 'team_box Sets'
  59.             );
  60.        
  61.             $this->post_type = new PageLinesPostType( $this->ptID, $args, $taxonomies, $columns, array(&$this, 'column_display'));
  62.        
  63.             $this->post_type->set_default_posts( 'pagelines_default_team_boxes', $this); // Default
  64.     }
  65.  
  66.  
  67.     /**
  68.     *
  69.     * @TODO document
  70.     *
  71.     */
  72.     function post_meta_setup(){
  73.        
  74.             $type_meta_array = array(
  75.                
  76.                 'team_box_setup' => array(
  77.                     'type'      => 'multi_option',
  78.                     'title'     => __('Individual team_box Options', 'pagelines'),
  79.                     'shortexp'  => __('Basic setup options for handling of this team_box', 'pagelines'),
  80.                     'selectvalues'  => array(
  81.                        
  82.                         'the_team_box_icon'         => array(
  83.                                 'type'      => 'image_upload',                 
  84.                                 'inputlabel'    => __( 'team_box Image', 'pagelines'),
  85.                             ),
  86.                         'the_team_box_icon_link'        => array(
  87.                                 'type' => 'text',                  
  88.                                 'inputlabel' => __( 'team_box Link (Optional)', 'pagelines'),
  89.                             ),
  90.                         'the_team_box_icon_target'      => array(
  91.                                 'type' => 'check',                 
  92.                                 'inputlabel' => __( 'Open link in New Window?', 'pagelines'),
  93.                             ),
  94.                         'team_box_class' => array(
  95.                             'default'       => '',
  96.                             'type'          => 'text',
  97.                             'size'          => 'small',
  98.                             'inputlabel'    => __( 'team_boxes Custom Class', 'pagelines'),
  99.                         ),
  100.                         'team_box_more_text' => array(
  101.                             'default'       => '',
  102.                             'type'          => 'text',
  103.                             'size'          => 'small',
  104.                             'inputlabel'    => __( 'More Link Text (Shows if link and text is set)', 'pagelines'),
  105.                         ),
  106.                     ),
  107.                 ),
  108.            
  109.             );
  110.  
  111.             $post_types = array($this->id);
  112.            
  113.             $type_metapanel_settings = array(
  114.                     'id'        => 'team_boxes-metapanel',
  115.                     'name'      => THEMENAME.' team_box Options',
  116.                     'posttype'  => $post_types,
  117.                 );
  118.            
  119.             global $team_boxes_meta_panel;
  120.            
  121.             $team_boxes_meta_panel =  new PageLinesMetaPanel( $type_metapanel_settings );
  122.            
  123.             $type_metatab_settings = array(
  124.                 'id'        => 'team_boxes-type-metatab',
  125.                 'name'      => 'team_box Setup Options',
  126.                 'icon'      => $this->icon,
  127.             );
  128.  
  129.             $team_boxes_meta_panel->register_tab( $type_metatab_settings, $type_meta_array );
  130.        
  131.     }
  132.  
  133.  
  134.     /**
  135.     *
  136.     * @TODO document
  137.     *
  138.     */
  139.     function section_optionator( $settings ){
  140.        
  141.         $settings = wp_parse_args($settings, $this->optionator_default);
  142.        
  143.             $tab = array(
  144.                 'team_box_setup' => array(
  145.                     'type'      => 'multi_option',
  146.                     'title'     => __('team_box Setup Options', 'pagelines'),
  147.                     'shortexp'  => __('Basic setup options for handling of team_boxes.', 'pagelines'),
  148.                     'selectvalues'  => array(
  149.                        
  150.                         'team_box_set' => array(
  151.                             'default'       => 'default-team_boxes',
  152.                             'type'          => 'select_taxonomy',
  153.                             'taxonomy_id'   => $this->taxID,               
  154.                             'inputlabel'    => __( 'team_box Set To Show', 'pagelines'),
  155.                         ),
  156.                         'team_box_col_number' => array(
  157.                             'type'          => 'count_select',
  158.                             'default'       => '3',
  159.                             'count_number'  => '5',
  160.                             'count_start'   => '1',
  161.                             'inputlabel'        => __( "team_boxes Per Row", 'pagelines'),
  162.                         ),
  163.                         'team_box_items' => array(
  164.                             'default'       => '6',
  165.                             'type'          => 'text_small',
  166.                             'size'          => 'small',
  167.                             'inputlabel'    => __( 'Maximum team_boxes To Show', 'pagelines'),
  168.                         ),
  169.                     ),
  170.                 ),
  171.                    
  172.                     'team_box_image_formatting' => array(
  173.                         'type'      => 'multi_option',
  174.                         'title'     => __('team_box Image Options', 'pagelines'),
  175.                         'shortexp'  => __('Options for formatting team_box images.', 'pagelines'),
  176.                         'exp'       => __('', 'pagelines'),
  177.                         'selectvalues'  => array(
  178.                            
  179.                             'team_box_thumb_type' => array(
  180.                                 'type'      => 'select',
  181.                                 'default'   => 'inline_thumbs',
  182.                                 'selectvalues'  => array(
  183.                                         'inline_thumbs' => array('name' => __( 'Image At Left', 'pagelines') ),
  184.                                         'top_thumbs'    => array('name' => __( 'Image On Top', 'pagelines') ),
  185.                                         'only_thumbs'   => array('name' => __( "Only The Image, No Text", 'pagelines') )
  186.                                     ),
  187.                                 'inputlabel' => __( 'team_box Thumb Style (optional - defaults to "At Left")', 'pagelines'),               
  188.  
  189.                             ),
  190.                             'team_box_thumb_size' => array(
  191.                                 'default'       => '64',
  192.                                 'type'          => 'text_small',
  193.                                 'size'          => 'small',
  194.                                 'inputlabel'        => __( 'Enter the max image size in pixels (optional)', 'pagelines'),
  195.                             ),
  196.                             'team_box_thumb_frame' => array(
  197.                                 'default'       => '64',
  198.                                 'type'          => 'check',
  199.                                 'size'          => 'small',
  200.                                 'inputlabel'        => __( 'Add A Frame To Images', 'pagelines'),
  201.                             ),
  202.                         ),
  203.                     ),
  204.                    
  205.                    
  206.                     'team_box_ordering' => array(
  207.                         'type'      => 'multi_option',
  208.                         'title'     => __('team_box Ordering Options', 'pagelines'),
  209.                         'shortexp'  => __('Optionally control the ordering of the team_boxes', 'pagelines'),
  210.                         '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'),
  211.                         'selectvalues'  => array(
  212.                            
  213.                             'team_box_orderby' => array(
  214.                                 'type'          => 'select',
  215.                                 'default'       => 'ID',
  216.                                 'inputlabel'    => 'Order team_boxes By (If Not With Post Type Order Plugin)',
  217.                                 'selectvalues' => array(
  218.                                     'ID'        => array('name' => __( 'Post ID (default)', 'pagelines') ),
  219.                                     'title'     => array('name' => __( 'Title', 'pagelines') ),
  220.                                     'date'      => array('name' => __( 'Date', 'pagelines') ),
  221.                                     'modified'  => array('name' => __( 'Last Modified', 'pagelines') ),
  222.                                     'rand'      => array('name' => __( 'Random', 'pagelines') ),                           
  223.                                 )
  224.                             ),
  225.                             'team_box_order' => array(
  226.                                     'default' => 'DESC',
  227.                                     'type' => 'select',
  228.                                     'selectvalues' => array(
  229.                                         'DESC'      => array('name' => __( 'Descending', 'pagelines') ),
  230.                                         'ASC'       => array('name' => __( 'Ascending', 'pagelines') ),
  231.                                     ),
  232.                                     'inputlabel'=> __( 'Select sort order', 'pagelines'),
  233.                             ),
  234.                         ),
  235.                     ),
  236.                    
  237.                     'team_box_more_text' => array(
  238.                         'default'       => '',
  239.                         'type'          => 'text',
  240.                         'size'          => 'small',
  241.                         'inputlabel'    => __( 'More Link Text', 'pagelines'),
  242.                         'title'         => __( 'More Link Text', 'pagelines'),
  243.                         'shortexp'      => __( 'Enter text for "more" links on linked team_box elements for this page.', 'pagelines'),
  244.                         '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')
  245.                     ),
  246.                     'team_box_class' => array(
  247.                         'default'       => '',
  248.                         'type'          => 'text',
  249.                         'size'          => 'small',
  250.                         'inputlabel'    => __( 'Add custom css class to these team_boxes', 'pagelines'),
  251.                         'title'         => __( 'Custom CSS class', 'pagelines'),
  252.                         'shortexp'      => __( 'Add a custom CSS class to this set of team_boxes.', 'pagelines'),
  253.                     ),
  254.             );
  255.        
  256.             $tab_settings = array(
  257.                     'id'        => 'fteam_boxes_meta',
  258.                     'name'      => 'team_boxes',
  259.                     'icon'      => $this->icon,
  260.                     'clone_id'  => $settings['clone_id'],
  261.                     'active'    => $settings['active']
  262.                 );
  263.  
  264.             register_metatab($tab_settings, $tab);
  265.     }
  266.  
  267.     /**
  268.     * Section template.
  269.     */
  270.    function section_template( $clone_id = null ) {    
  271.        
  272.         // Options
  273.             $per_row = ( ploption( 'team_box_col_number', $this->oset) ) ? ploption( 'team_box_col_number', $this->oset) : 3;
  274.             $team_box_set = ( ploption( 'team_box_set', $this->oset ) ) ? ploption( 'team_box_set', $this->oset ) : null;
  275.             $team_box_limit = ploption( 'team_box_items', $this->oset );
  276.             $this->thumb_type = ( ploption( 'team_box_thumb_type', $this->oset) ) ? ploption( 'team_box_thumb_type', $this->oset) : 'inline_thumbs';   
  277.             $this->thumb_size = ploption('team_box_thumb_size', $this->oset);
  278.             $this->framed = ploption('team_box_thumb_frame', $this->oset);
  279.            
  280.            
  281.             $class = ( ploption( 'team_box_class', $this->oset ) ) ? ploption( 'team_box_class', $this->oset ) : null;
  282.            
  283.         // Actions 
  284.             // Set up the query for this page
  285.                 $orderby = ( ploption('team_box_orderby', $this->oset) ) ? ploption('team_box_orderby', $this->oset) : 'ID';
  286.                 $order = ( ploption('team_box_order', $this->oset) ) ? ploption('team_box_order', $this->oset) : 'DESC';
  287.                 $params = array( 'orderby'  => $orderby, 'order' => $order, 'post_type' => $this->ptID );
  288.                 $params[ 'showposts' ] = ( ploption('team_box_items', $this->oset) ) ? ploption('team_box_items', $this->oset) : $per_row;
  289.                 $params[ $this->taxID ] = ( ploption( 'team_box_set', $this->oset ) ) ? ploption( 'team_box_set', $this->oset ) : null;
  290.                 $params[ 'no_found_rows' ] = 1;
  291.  
  292.                 $q = new WP_Query( $params );
  293.                
  294.                 if(empty($q->posts)){
  295.                     echo setup_section_notify( $this, 'Add team_box Posts To Activate.', admin_url('edit.php?post_type='.$this->ptID), 'Add Posts' );
  296.                     return;
  297.                 }
  298.            
  299.             // Grid Args
  300.                 $args = array( 'per_row' => $per_row, 'callback' => array(&$this, 'draw_team_boxes'), 'class' => $class );
  301.  
  302.             // Call the Grid
  303.                 printf('<div class="fteam_boxes fix">%s</div>', grid( $q, $args ));
  304.        
  305.     }
  306.  
  307.  
  308.     /**
  309.     *
  310.     * @TODO document
  311.     *
  312.     */
  313.     function draw_team_boxes($p, $args){
  314.  
  315.         setup_postdata($p);
  316.        
  317.         $oset = array('post_id' => $p->ID);
  318.         $team_box_link = plmeta('the_team_box_icon_link', $oset);
  319.         $team_box_icon = plmeta('the_team_box_icon', $oset);
  320.         $team_box_target = (plmeta('the_team_box_icon_target', $oset)) ? 'target="_blank"' : '';
  321.        
  322.         $class = ( plmeta( 'team_box_class', $oset ) ) ? plmeta( 'team_box_class', $oset ) : null;
  323.         $cat = get_the_terms($p->ID, 'team_box-sets');
  324.         $terms = array();
  325.         $testimonials = false;
  326.         foreach($cat as $set){
  327.             array_push($terms, $set->slug);
  328.             if($set->slug == 'testimonials'){
  329.                 $testimonials = true;  
  330.             }
  331.         }
  332.         $terms = implode(' ', $terms);
  333.         $image = ($team_box_icon) ? self::_get_team_box_image( $p, $team_box_icon, $team_box_link, $this->thumb_size, $team_box_target) : '';
  334.    
  335.         $title_text = ($team_box_link) ? sprintf('<a href="%s">%s</a>', $team_box_link, $p->post_title ) : $p->post_title;
  336.         $thumb = '';
  337.         if($testimonials){
  338.             $thumb = '<span>'.get_the_post_thumbnail($p->ID, 'testimonial', array('title'=>'')).'</span>'; 
  339.         }
  340.         $title = do_shortcode(sprintf('<div class="fteam_boxtitle">%s<h3>%s</h3></div>', $thumb, $title_text));
  341.  
  342.         if(plmeta('team_box_more_text', $oset)){
  343.             $more_text = plmeta('team_box_more_text', $oset);
  344.         } elseif(ploption('team_box_more_text', $this->oset)){
  345.             $more_text = ploption('team_box_more_text', $this->oset);
  346.         }else
  347.             $more_text = false;
  348.        
  349.         $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) : '';
  350.        
  351.         $more_link = apply_filters('team_box_more_link', $more_link);
  352.        
  353.         $content = sprintf('<div class="fteam_boxtext">%s %s %s</div>', do_shortcode(apply_filters('the_content',$p->post_content)), pledit( $p->ID ), $more_link);
  354.            
  355.         $info = ($this->thumb_type != 'only_thumbs') ? sprintf('<div class="fteam_boxinfo fix bd">%s%s</div>', $title, $content) : '';             
  356.                 //echo print_r($terms);
  357.         return sprintf(
  358.             '<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>',
  359.             'fteam_box_'.$p->ID,
  360.             $class,
  361.             $terms,
  362.             $this->thumb_type,
  363.             $image,
  364.             $info
  365.         );
  366.    
  367.     }
  368.  
  369.    
  370.  
  371.     /**
  372.     *
  373.     * @TODO document
  374.     *
  375.     */
  376.     function _get_team_box_image( $bpost, $team_box_icon, $team_box_link = false, $team_box_thumb_size = false, $team_box_target){
  377.             global $pagelines_ID;
  378.            
  379.             $frame = ($this->framed) ? 'pl-imageframe' : '';
  380.            
  381.             if($this->thumb_type == 'inline_thumbs'){
  382.                 $max_width = ($team_box_thumb_size) ? $team_box_thumb_size : 65;
  383.                 $image_style = 'max-width: 100%';
  384.                 $wrapper_style = sprintf('width: 22%%; max-width:%dpx', $max_width);
  385.                 $wrapper_class = sprintf('fteam_boxgraphic img %s', $frame);
  386.             } else {
  387.                 $max_width = ($team_box_thumb_size) ? $team_box_thumb_size.'px' : '100%';
  388.                 $image_style = 'max-width: 100%';
  389.                 $wrapper_style = sprintf('max-width:%s', $max_width);
  390.                 $wrapper_class = sprintf('fteam_boxgraphic %s', $frame);
  391.             }
  392.            
  393.             // Make the image's tag with url
  394.             $image_tag = sprintf('<img src="%s" alt="%s" style="%s" />', $team_box_icon, esc_html($bpost->post_title), $image_style);
  395.            
  396.             // If link for team_box is set, add it
  397.             $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;
  398.            
  399.             $wrapper = sprintf('<div class="%s" style="%s">%s</div>', $wrapper_class, $wrapper_style, $image_output );
  400.            
  401.             // Filter output
  402.             return apply_filters('pl_team_box_image', $wrapper, $bpost->ID);
  403.     }
  404.  
  405.    
  406.  
  407.         /**
  408.         *
  409.         * @TODO document
  410.         *
  411.         */
  412.         function pagelines_default_team_boxes($post_type){
  413.  
  414.             $d = array_reverse( $this->get_default_fteam_boxes() );
  415.  
  416.             foreach($d as $dp){
  417.                 // Create post object
  418.                 $default_post = array();
  419.                 $default_post['post_title'] = $dp['title'];
  420.                 $default_post['post_content'] = $dp['text'];
  421.                 $default_post['post_type'] = $post_type;
  422.                 $default_post['post_status'] = 'publish';
  423.                 if ( defined( 'ICL_LANGUAGE_CODE' ) )
  424.                     $default_post['icl_post_language'] = ICL_LANGUAGE_CODE;
  425.                 $newPostID = wp_insert_post( $default_post );
  426.  
  427.                 if(isset($dp['media']))
  428.                     update_post_meta($newPostID, 'the_team_box_icon', $dp['media']);
  429.  
  430.                 wp_set_object_terms($newPostID, 'default-team_boxes', $this->taxID );
  431.  
  432.                 // Add other default sets, if applicable.
  433.                 if(isset($dp['set']))
  434.                     wp_set_object_terms($newPostID, $dp['set'], $this->taxID, true);
  435.  
  436.             }
  437.         }
  438.  
  439.  
  440.         /**
  441.         *
  442.         * @TODO document
  443.         *
  444.         */
  445.         function get_default_fteam_boxes(){
  446.             $default_team_boxes[] = array(
  447.                                     'title' => 'Drag <span class="spamp">&amp;</span> Drop',
  448.                                     'text'  => 'PageLines is a drag &amp; drop framework that allows you to completely customize your website with drag &amp; drop.',
  449.                                     'media' => $this->base_url.'/images/fteam_box3.png'
  450.                                 );
  451.  
  452.             $default_team_boxes[] = array(
  453.                                     'title' => 'Responsive <span class="spamp">&amp;</span> Mobile',
  454.                                     'text'  => "Built from the ground up to look great on mobile devices. PageLines utilizes an advanced responsive framework.",
  455.                                     'media' => $this->base_url.'/images/fteam_box2.png'
  456.                                 );
  457.  
  458.             $default_team_boxes[] = array(
  459.                                     'title' => 'Tons of Addons',
  460.                                     'text'  => "Load up your own sections, themes and plugins using PageLines' one of a kind extension marketplace.",
  461.                                     'media' => $this->base_url.'/images/fteam_box1.png'
  462.                                 );
  463.  
  464.             return apply_filters('pagelines_default_team_boxes', $default_team_boxes);
  465.         }
  466.    
  467.  
  468.     /**
  469.     *
  470.     * @TODO document
  471.     *
  472.     */
  473.     function column_display($column){
  474.         global $post;
  475.  
  476.         switch ($column){
  477.             case 'teamdescription':
  478.                 the_excerpt();
  479.                 break;
  480.             case 'teammedia':
  481.                     echo get_the_post_thumbnail($post->ID, 'testimonial', array('title'=>'')); 
  482.                 break;
  483.             case $this->taxID:
  484.                 echo get_the_term_list($post->ID, 'team_box-sets', '', ', ','');
  485.                 break;
  486.         }
  487.     }
  488. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement