| [ Index ] |
PHP Cross Reference of PageLines Framework |
[Summary view] [Print] [Text view]
1 <?php 2 /* 3 Section: Features 4 Author: PageLines 5 Author URI: http://www.pagelines.com 6 Description: Creates a feature slider and custom post type 7 Class Name: PageLinesFeatures 8 Workswith: templates, main, header, morefoot 9 Cloning: true 10 Edition: pro 11 Tax: feature-sets 12 */ 13 14 /** 15 * Features Section 16 * 17 * @package PageLines Framework 18 * @author PageLines 19 */ 20 class PageLinesFeatures extends PageLinesSection { 21 22 var $taxID = 'feature-sets'; 23 var $ptID = 'feature'; 24 25 /** 26 * PHP that always loads no matter if section is added or not. 27 */ 28 function section_persistent(){ 29 $this->post_type_setup(); 30 31 $this->post_meta_setup(); 32 33 $options = array( 34 'posts_feature_control' => array( 35 'default' => false, 36 'version' => 'pro', 37 'type' => 'check', 38 'inputlabel'=> __( 'Enable Feature Metapanel on Posts?', 'pagelines' ), 39 'title' => __( 'Feature Section - Enable Post-As-Feature Control Metapanel', 'pagelines' ), 40 'shortexp' => __( 'Shows as metapanel for controlling the appearance of posts inside the feature slider.', 'pagelines' ), 41 'exp' => __( 'If you are using the feature slider in posts or post category mode, you may want to control the appearance of the posts inside the feature. Enable this option to show the posts metapanel.', 'pagelines' ) 42 ), 43 ); 44 45 pl_global_option( array( 'menu' => 'advanced', 'options' => $options, 'location' => 'top' ) ); 46 47 } 48 49 /** 50 * Load js 51 */ 52 function section_styles(){ 53 wp_enqueue_script( 'cycle', $this->base_url . '/script.cycle.js', array( 'jquery'), '2.9994', true); 54 } 55 56 /** 57 * 58 * @TODO document 59 * 60 */ 61 function section_head( $clone_id ) { 62 63 global $pagelines_ID; 64 65 $oset = array( 'post_id' => $pagelines_ID, 'clone_id' => $clone_id ); 66 67 $f = $this->post_set[ $clone_id ] = $this->pagelines_features_set( $clone_id ); 68 69 $feffect = ( ploption( 'feffect', $oset ) ) ? ploption( 'feffect', $oset ) : 'fade'; 70 $timeout = ( ploption( 'timeout', $oset ) ) ? ploption( 'timeout', $oset ) : 0; 71 $speed = ( ploption( 'fspeed', $oset ) ) ? ploption( 'fspeed', $oset ) : 1500; 72 $fsync = ( ploption( 'fremovesync', $oset ) ) ? 0 : 1; 73 $autostop = ( has_filter( 'pagelines_feature_autostop' ) ) ? ', autostop: 1, autostopCount: ' . apply_filters( 'pagelines_feature_autostop', 0) : ''; 74 $playpause = ( ploption('feature_playpause', $oset ) ) ? true : false; 75 $fmode = ploption( 'feature_nav_type', $oset ); 76 77 $clone_class = sprintf( 'fclone%s', $clone_id ); 78 79 $selector = sprintf( '#cycle.%s', $clone_class ); 80 $fnav_selector = sprintf( '#featurenav.%s', 'fclone'.$clone_id ); 81 $playpause_selector = sprintf( '.playpause.%s', 'fclone'.$clone_id ); 82 83 $args = sprintf( "slideResize: 0, fit: 1, fx: '%s', sync: %d, timeout: %d, speed: %d, cleartype: true, cleartypeNoBg: true, pager: '%s' %s", $feffect, $fsync, $timeout, $speed, $fnav_selector, $autostop ); 84 85 $this->_feature_css( $clone_id, $oset ); 86 87 $wrap_class = '.'.$clone_class."_wrap"; 88 89 ?> 90 91 <script type="text/javascript"> 92 /* <![CDATA[ */ jQuery(document).ready(function () { 93 94 jQuery('#feature-area').css('overflow', 'hidden'); 95 96 97 98 <?php if( ! ploption( 'feature_height_mode', $oset ) || ploption( 'feature_height_mode', $oset ) == 'aspect' ) : 99 100 printf( '$aspect%s = %s;', $clone_id,( ploption( 'feature_aspect', $oset ) && is_numeric( ploption( 'feature_aspect', $oset ) ) ) ? ploption( 'feature_aspect', $oset ) : 2.5 ); 101 102 printf( '$width_area%s = "%s #feature-area";', $clone_id, $wrap_class ); 103 104 printf( '$height_selectors%s = "%s";', $clone_id, $this->selectors( '', $wrap_class.' ' ) ); 105 ?> 106 jQuery(window).load(function() { 107 108 $the_width<?php echo $clone_id;?> = jQuery($width_area<?php echo $clone_id;?>).width(); 109 110 $new_height<?php echo $clone_id;?> = $the_width<?php echo $clone_id;?> / $aspect<?php echo $clone_id;?>; 111 jQuery($height_selectors<?php echo $clone_id;?>).height($new_height<?php echo $clone_id;?>); 112 113 }); 114 115 jQuery(window).resize(function() { 116 $response_width<?php echo $clone_id;?> = jQuery($width_area<?php echo $clone_id;?>).width(); 117 $new_height<?php echo $clone_id;?> = $response_width<?php echo $clone_id;?> / $aspect<?php echo $clone_id;?>; 118 jQuery($height_selectors<?php echo $clone_id;?>).height($new_height<?php echo $clone_id;?>); 119 120 }); 121 <?php 122 123 endif; 124 125 ?> 126 jQuery(window).load(function() { 127 <?php 128 //Feature Cycle Setup 129 printf( "jQuery('%s').cycle({ %s });", $selector, $args ); 130 131 $this->_js_feature_loop( $fmode, $f, $clone_class ); 132 133 if( $playpause ): 134 ?> 135 136 var cSel = '<?php echo $selector;?>'; 137 var ppSel = '<?php echo $playpause_selector;?>'; 138 139 jQuery(ppSel).click(function() { 140 if (jQuery(ppSel).hasClass('pause')) { 141 jQuery(cSel).cycle('pause'); jQuery(ppSel).removeClass('pause').addClass('resume'); 142 } else { 143 jQuery(ppSel).removeClass('resume').addClass('pause'); jQuery(cSel).cycle('resume', true); 144 } 145 }); 146 <?php endif;?> 147 148 }); 149 }); 150 151 /* ]]> */ </script> 152 153 <?php } 154 155 156 /** 157 * 158 * @TODO document 159 * 160 */ 161 function _feature_css( $clone_id, $oset){ 162 163 $height = ( ploption( 'feature_stage_height', $oset ) ) ? ploption( 'feature_stage_height', $oset ).'px' : '380px'; 164 165 $selectors = $this->selectors( $clone_id ); 166 $css = sprintf( '%s{height:%s;}', $selectors, $height ); 167 inline_css_markup( 'feature-css', $css ); 168 } 169 170 function selectors( $clone_id, $prepend = ''){ 171 172 $base = array( 173 '.fset_height', 174 '#feature_slider .text-bottom .fmedia .fmedia-pad', 175 '#feature_slider .text-bottom .feature-pad', 176 '#feature_slider .text-none .fmedia .fmedia-pad' 177 ); 178 179 $selectors = array(); 180 181 foreach($base as $sel){ 182 if( isset( $clone_id ) && $clone_id != 1 && $clone_id != '' ) 183 $selectors[] = sprintf('%s.clone_%s %s', $prepend, $clone_id, $sel); 184 else 185 $selectors[] = $prepend.$sel; 186 } 187 188 return join( ',', $selectors ); 189 } 190 191 /** 192 * 193 * @TODO document 194 * 195 */ 196 function _js_feature_loop( $fmode, $fposts = array(), $clone_class ){ 197 198 $count = 1; 199 $link_js = ''; 200 $cat_css = ''; 201 foreach( $fposts as $fid => $f ){ 202 $oset = array( 'post_id' => $f->ID ); 203 $feature_name = ( ploption( 'feature-name', $oset ) ) ? ploption( 'feature-name', $oset ) : $f->post_title; 204 205 $feature_thumb = ploption( 'feature-thumb', $oset ); 206 207 if ( ! $feature_thumb ) 208 $feature_thumb = ploption( 'feature-background-image', $oset ); 209 210 if ( ( ploption( 'feature_source', $this->oset ) == 'posts' || ploption( 'feature_source', $this->oset ) == 'posts_all' ) ) { 211 212 if ( plmeta( 'feature-thumb', $oset ) ) 213 $feature_thumb = plmeta( 'feature-thumb', $oset ); 214 elseif( plmeta( 'feature-background-image', $oset ) ) 215 $feature_thumb = plmeta( 'feature-background-image', $oset ); 216 elseif( has_post_thumbnail( $f->ID ) ) { 217 $feature_thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $f->ID ) ); 218 $feature_thumb = $feature_thumb[0]; 219 } else { 220 $feature_thumb = apply_filters( 'pagelines-feature-cat-default-thumb', $this->base_url . '/images/fthumb3.png', $f ); 221 } 222 } 223 224 if ( ! $feature_thumb ) 225 $feature_thumb = $this->base_url . '/images/fthumb3.png' ; 226 227 if( $fmode == 'names' || $fmode == 'thumbs' ){ 228 //echo "\n".' // '.$fmode.'!!!'."\n"; 229 if( $fmode == 'names' ) 230 $replace_value = esc_js( $feature_name ); 231 232 elseif ( $fmode == 'thumbs' ) 233 $replace_value = sprintf( "<span class='nav_thumb' style='background-image: url(%s);'><span class='nav_overlay'> </span></span>", $feature_thumb ); 234 235 $replace_js = sprintf( 'jQuery(this).html("%s");', $replace_value ); 236 } else 237 $replace_js = ''; 238 239 $link_title = sprintf( 'jQuery(this).attr("title", "%s");', esc_js( $feature_name ) ); 240 241 $link_js .= sprintf( 'if(jQuery(this).html() == "%s") { %s %s }', $count, $link_title, $replace_js ); 242 243 $count++; 244 } 245 printf( 'jQuery("div#featurenav.%s").children("a").each(function() { %s });', $clone_class, $link_js ); 246 } 247 248 249 /** 250 * 251 * @TODO document 252 * 253 */ 254 function section_template( $clone_id ) { 255 256 // $this->set set in pagelines_feature_set, better way to do this? 257 $this->draw_features( $this->post_set[ $clone_id ], $this->set, $clone_id ); 258 } 259 260 261 /** 262 * 263 * @TODO document 264 * 265 */ 266 function pagelines_features_set( $clone_id ){ 267 268 if( ploption( 'feature_set', $this->oset ) ) 269 $this->set = ploption( 'feature_set', $this->oset ); 270 elseif ( ploption( 'feature_default_tax', $this->oset ) ) 271 $this->set = ploption( 'feature_default_tax', $this->oset ); 272 else 273 $this->set = null; 274 275 $limit = ploption( 'feature_items', $this->oset ); 276 277 $order = ploption( 'feature_order', $this->oset ); 278 279 $orderby = ploption( 'feature_orderby', $this->oset ); 280 281 $source = ( ploption( 'feature_source', $this->oset ) == 'posts' || ploption( 'feature_source', $this->oset ) == 'posts_all') ? ploption( 'feature_source', $this->oset ) : 'customtype'; 282 283 $category = ( $source == 'posts' ) ? ploption( 'feature_category', $this->oset ) : ''; 284 $f = $this->load_pagelines_features( array( 'set' => $this->set, 'limit' => $limit, 'orderby' => $orderby, 'order' => $order, 'source' => $source, 'category' => $category ) ); 285 286 return $f; 287 } 288 289 290 /** 291 * 292 * @TODO document 293 * 294 */ 295 function load_pagelines_features( $args ) { 296 $defaults = array( 297 298 'query' => array(), 299 'set' => null, 300 'limit' => null, 301 'order' => 'DESC', 302 'orderby' => 'ID', 303 'source' => null, 304 'category' => null 305 ); 306 307 $args = wp_parse_args( $args, $defaults ); 308 extract( $args, EXTR_SKIP ); 309 310 $query['no_found_rows'] = 1; 311 $query['showposts'] = 5; 312 $query['orderby'] = $orderby; 313 314 $query['order'] = $order; 315 316 if($source == 'posts' || $source == 'posts_all' ){ 317 318 $query['post_type'] = 'post'; 319 320 if( $category ) 321 $query['cat'] = $category; 322 } else { 323 $query['post_type'] = $this->ptID; 324 325 if( isset( $set ) ) 326 $query[ $this->taxID ] = $set; 327 } 328 329 if( isset( $limit ) ) 330 $query['showposts'] = $limit; 331 elseif( $source == 'posts' || $source == 'posts_all' ) 332 $query['showposts'] = get_option( 'posts_per_page' ); 333 334 $q = new WP_Query( $query ); 335 if( is_array( $q->posts ) ) 336 return array_slice( $q->posts, 0, $query['showposts'] ); 337 else 338 return array(); 339 } 340 341 342 /** 343 * 344 * @TODO document 345 * 346 */ 347 function draw_features($f, $class, $clone_id = null) { 348 349 // Setup 350 global $post; 351 global $pagelines_ID; 352 global $pagelines_layout; 353 $current_page_post = $post; 354 355 if( empty( $f ) ){ 356 echo setup_section_notify( $this, __( "No Feature posts matched this page's criteria", 'pagelines' ) ); 357 return; 358 } 359 360 // Options 361 $feature_source = ploption( 'feature_source', $this->oset ); 362 $timeout = ploption( 'timeout', $this->oset ); 363 $playpause = ploption( 'feature_playpause', $this->oset ); 364 $feature_nav_type = ploption( 'feature_nav_type', $this->oset ); 365 366 // Refine 367 $no_nav = ( isset( $f ) && count( $f ) == 1 ) ? ' nonav' : ''; 368 $footer_nav_class = $class. ' '. $feature_nav_type . $no_nav; 369 $cycle_selector = "fclone" . $clone_id; 370 ?> 371 <div id="feature_slider" class="<?php echo $cycle_selector.'_wrap '. $class;?> fix"> 372 <div id="feature-area" class="fset_height"> 373 <div id="cycle" class="<?php echo $cycle_selector;?>"> 374 <?php 375 376 foreach( $f as $post ) : 377 378 // Setup For Std WP functions 379 setup_postdata( $post ); 380 381 $oset = array( 'post_id' => $post->ID ); 382 383 $target = apply_filters( 'pagelines_features_target', '', $post ); 384 385 $feature_style = ( ploption( 'feature-style', $oset ) ) ? ploption( 'feature-style', $oset ) : 'text-left'; 386 387 $feature_style = apply_filters( 'pagelines-feature-style', $feature_style ); 388 389 $flink_text = ( ploption( 'feature-link-text', $oset) ) ? __( ploption('feature-link-text', $oset ) ) : __( 'More', 'pagelines' ); 390 391 if ( $feature_source == 'posts' || $feature_source == 'posts_all' ) { 392 393 $feature_background_image = ''; 394 395 if( plmeta( 'feature-background-image', $oset ) ) 396 $feature_background_image = plmeta( 'feature-background-image', $oset ); 397 elseif ( has_post_thumbnail( $post->ID ) ) { 398 $feature_background_image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); 399 $feature_background_image = $feature_background_image[0]; 400 } else { 401 402 $feature_background_image = apply_filters( 'pagelines-feature-cat-default-image', $this->base_url.'/images/feature1.jpg', $post ); 403 404 } 405 406 $background_class = 'bg_cover'; 407 408 } else { 409 410 $feature_background_image = ploption( 'feature-background-image', $oset); 411 412 $background_class = 'bg_cover'; 413 414 } 415 416 417 $feature_design = ( ploption( 'feature-design', $oset ) ) ? ploption( 'feature-design', $oset ) : ''; 418 419 if ( $feature_source == 'posts' || $feature_source == 'posts_all' ) 420 setup_postdata( $post ); 421 422 423 if( plmeta( 'feature-link-url', $oset ) ) 424 $action = plmeta( 'feature-link-url', $oset ); 425 elseif( ploption( 'feature-link-url', $oset ) ) 426 $action = ploption( 'feature-link-url', $oset ); 427 elseif($feature_source == 'posts' || $feature_source == 'posts_all') 428 $action = get_permalink(); 429 else 430 $action = ''; 431 432 $fcontent_class = ( ploption( 'fcontent-bg', $oset ) ) ? ploption( 'feature-bg', $oset ) : ''; 433 434 $media_image = ploption( 'feature-media-image', $oset ); 435 436 $feature_media = ploption( 'feature-media', $oset ); 437 $feature_media_full = ploption( 'feature-media-full', $oset ); 438 439 $feature_wrap_markup = ( $feature_style == 'text-none' && $action ) ? 'a' : 'div'; 440 441 $feature_wrap_link = ( $feature_style == 'text-none' && $action ) ? sprintf( 'href="%s"', $action ) : ''; 442 443 $more_link = ( $feature_style != 'text-none' && $action ) ? sprintf( ' <a %s class="plmore" href="%s" >%s</a>', $target, $action, $flink_text ) : ''; 444 445 $background_css = ( $feature_background_image ) ? sprintf('style="background-image: url(\'%s\');"', $feature_background_image ) : ''; 446 447 printf( '<div id="%s" class="fcontainer %s %s fix" >', 'feature_'.$post->ID, $feature_style, $feature_design ); 448 449 printf( '<%s class="feature-wrap fset_height %s" %s %s >', $feature_wrap_markup, $background_class, $feature_wrap_link, $background_css ); 450 451 if( $feature_wrap_markup != 'a' ) : 452 453 if($feature_media && $feature_media_full): 454 echo $feature_media; 455 else: 456 457 ?> 458 459 <div class="feature-pad fset_height fix"> 460 <div class="fcontent scale_text fset_height <?php echo $fcontent_class;?>"> 461 <div class="fcontent-pad fix"> 462 <?php 463 464 465 pagelines_register_hook( 'pagelines_feature_text_top', $this->id ); // Hook 466 467 $link = ( $feature_source == 'posts' || $feature_source == 'posts_all' ) ? sprintf( '<a %s href="%s">%s</a>', $target, $action, $post->post_title ) : $post->post_title; 468 469 $title = sprintf( '<div class="fheading"> <h2 class="ftitle">%s</h2> </div>', $link ); 470 471 $content = ( $feature_source == 'posts' || $feature_source == 'posts_all' ) ? apply_filters( 'pagelines_feature_output', custom_trim_excerpt( get_the_excerpt(), '30' ) ) : do_shortcode( get_the_content() ); 472 473 printf( 474 '%s<div class="ftext"><div class="fexcerpt">%s%s%s</div></div>', 475 $title, 476 $content, 477 $more_link, 478 pledit( $post->ID ) 479 ); 480 481 pagelines_register_hook( 'pagelines_fcontent_after', $this->id ); // Hook ?> 482 </div> 483 </div> 484 485 <div class="fmedia fset_height" style=""> 486 <div class="fmedia-pad"> 487 <?php 488 489 pagelines_register_hook( 'pagelines_feature_media_top', $this->id ); // Hook 490 491 if( $media_image ) 492 printf( '<div class="media-frame"><img src="%s" /></div>', $media_image ); 493 494 elseif( $feature_media ) 495 echo do_shortcode( $feature_media ); 496 ?> 497 </div> 498 </div> 499 <?php pagelines_register_hook( 'pagelines_feature_after', $this->id ); // Hook ?> 500 <div class="clear"></div> 501 </div> 502 503 <?php 504 endif; 505 endif; 506 507 printf( '</%s>', $feature_wrap_markup ); 508 echo '</div>'; 509 endforeach; 510 511 $post = $current_page_post; 512 ?> 513 </div> 514 </div> 515 <?php 516 517 pagelines_register_hook( 'pagelines_feature_nav_before', $this->id ); // Hook 518 519 $playpause = ( $timeout != 0 && $playpause) ? sprintf( '<span class="playpause pause %s"><span> </span></span>', $cycle_selector ) : ''; 520 521 $nav = sprintf( '<div id="featurenav" class="%s subtext fix"></div>', $cycle_selector ); 522 523 printf( '<div id="feature-footer" class="%s fix"><div class="feature-footer-pad">%s%s<div class="clear"></div></div></div>', $footer_nav_class, $playpause, $nav ); 524 ?> 525 </div> 526 <div class="clear"></div> 527 <?php 528 } 529 530 /** 531 * 532 * @TODO document 533 * 534 */ 535 function post_meta_setup(){ 536 537 $pt_tab_options = array( 538 'feature_styling' => array( 539 'type' => 'multi_option', 540 'title' => __('Feature Design Style', 'pagelines'), 541 'shortexp' => __('The basic styling of the feature', 'pagelines'), 542 'selectvalues' => array( 543 'feature-style' => array( 544 'type' => 'select', 545 'inputlabel' => __( 'Feature Text Position', 'pagelines' ), 546 'selectvalues' => array( 547 'text-left' => array( 'name' => __( 'Text On Left', 'pagelines' ) ), 548 'text-right' => array( 'name' => __( 'Text On Right', 'pagelines' ) ), 549 'text-bottom' => array( 'name' => __( 'Text On Bottom', 'pagelines' ) ), 550 'text-none' => array( 'name' => __( 'Full Width Background Image - No Text - Links Entire BG', 'pagelines' ) ) 551 ), 552 ), 553 'feature-design' => array( 554 'type' => 'select', 555 'inputlabel' => __( 'Feature Design Style', 'pagelines' ), 556 'selectvalues' => array( 557 'fstyle-darkbg-overlay' => array( 'name' => __( 'White Text - Dark Feature Background - Transparent Text Overlay (Default)', 'pagelines' ) ), 558 'fstyle-lightbg' => array( 'name' => __( 'Black Text - Light Feature Background with Border - No Overlay', 'pagelines' ) ), 559 'fstyle-darkbg' => array( 'name' => __( 'White Text - Dark Feature Background - No Overlay', 'pagelines' ) ), 560 'fstyle-nobg' => array( 'name' => __( 'Black Text - No Feature Background - No Overlay', 'pagelines' ) ), 561 ), 562 ), 563 ), 564 ), 565 'feature_media_stuff' => array( 566 'type' => 'multi_option', 567 'title' => __('Feature Media', 'pagelines'), 568 'shortexp' => __('The media that the feature will use', 'pagelines'), 569 'selectvalues' => array( 570 'feature-background-image' => array( 571 'inputlabel' => __( 'Full Size - Feature Background Image', 'pagelines' ), 572 'type' => 'image_upload' 573 ), 574 575 'feature-media-image' => array( 576 'version' => 'pro', 577 'type' => 'image_upload', 578 'inputlabel' => __( 'Media Area - Image (optional)', 'pagelines' ), 579 ), 580 'feature-media' => array( 581 'version' => 'pro', 582 'type' => 'textarea', 583 'inputlabel' => __( 'Feature HTML (video embeds etc, In Media Area)', 'pagelines' ), 584 ), 585 'feature-media-full' => array( 586 'version' => 'pro', 587 'type' => 'check', 588 'inputlabel' => __( 'Make Feature HTML Full Width', 'pagelines' ), 589 ), 590 'feature-thumb' => array( 591 'inputlabel' => __( 'Thumb Navigation - Upload Feature Thumbnail (50px by 30px)', 'pagelines' ), 592 'type' => 'image_upload' 593 ), 594 'feature-name' => array( 595 'default' => '', 596 'inputlabel' => __( 'Names Navigation - Enter Text', 'pagelines' ), 597 'type' => 'text' 598 ), 599 ), 600 ), 601 602 603 'feature-link-url' => array( 604 'shortexp' => __( 'Adding a URL here will add a link to your feature slide', 'pagelines' ), 605 'title' => __( 'Feature Link URL', 'pagelines' ), 606 'label' => __( 'Enter Feature Link URL', 'pagelines' ), 607 'type' => 'text', 608 'exp' => __( 'Adds a More link to your text. If you have Full Width Background Image mode selected, the entire slide will be linked.', 'pagelines' ) 609 ), 610 'feature-link-text' => array( 611 'default' => 'More', 612 'shortexp' => __( 'Enter the text you would like in your feature link', 'pagelines' ), 613 'title' => __( 'Link Text', 'pagelines' ), 614 'label' => __( 'Enter Feature Link Text', 'pagelines' ), 615 'type' => 'text', 616 'size' => 'small' 617 ), 618 619 620 ); 621 622 $posts_mode = ( ploption('posts_feature_control') ) ? true : false; 623 624 // Add options for correct post type. 625 $post_types = ( $posts_mode ) ? array( $this->ptID, 'post' ) : array( $this->ptID ); 626 627 $pt_panel = array( 628 'id' => 'feature-metapanel', 629 'name' => __( 'Feature Setup Options', 'pagelines' ), 630 'posttype' => $post_types, 631 'hide_tabs' => true 632 ); 633 634 $pt_panel = new PageLinesMetaPanel( $pt_panel ); 635 636 637 $pt_tab = array( 638 'id' => 'feature-type-metatab', 639 'name' => __( 'Feature Setup Options', 'pagelines' ), 640 'icon' => $this->icon, 641 ); 642 643 $pt_panel->register_tab( $pt_tab, $pt_tab_options ); 644 645 } 646 647 648 /** 649 * 650 * @TODO document 651 * 652 */ 653 function post_type_setup(){ 654 655 $args = array( 656 'label' => __( 'Features', 'pagelines' ), 657 'singular_label' => __( 'Feature', 'pagelines' ), 658 'description' => __( 'For setting slides on the feature page template', 'pagelines' ), 659 'taxonomies' => array( $this->taxID ), 660 'menu_icon' => $this->icon 661 ); 662 $taxonomies = array( 663 $this->taxID => array( 664 'label' => __( 'Feature Sets', 'pagelines' ), 665 'singular_label' => __( 'Feature Set', 'pagelines' ), 666 ) 667 ); 668 $columns = array( 669 'cb' => "<input type=\"checkbox\" />", 670 'title' => __( 'Title', 'pagelines' ), 671 "feature-description" => __( 'Text', 'pagelines' ), 672 "feature-media" => __( 'Media', 'pagelines' ), 673 $this->taxID => __( 'Feature Sets', 'pagelines' ) 674 ); 675 676 677 $this->post_type = new PageLinesPostType( $this->ptID, $args, $taxonomies, $columns, array( &$this, 'column_display' ) ); 678 679 $this->post_type->set_default_posts( 'update_default_posts', $this ); 680 681 } 682 683 684 /** 685 * 686 * @TODO document 687 * 688 */ 689 function section_optionator( $settings ){ 690 $settings = wp_parse_args( $settings, $this->optionator_default ); 691 692 $page_metatab_array = array( 693 'feature_setup' => array( 694 'type' => 'multi_option', 695 'title' => __('Feature Section Setup', 'pagelines'), 696 'shortexp' => __('Basic section setup for features', 'pagelines'), 697 698 'docslink' => 'http://www.pagelines.com/docs/feature-slider', 699 'vidtitle' => __( 'View Feature Documentation', 'pagelines' ), 700 'selectvalues' => array( 701 702 'feature_set' => array( 703 'version' => 'pro', 704 'default' => 'default-features', 705 'type' => 'select_taxonomy', 706 'taxonomy_id' => $this->taxID, 707 'inputlabel' => __( 'Select Feature Set', 'pagelines' ), 708 ), 709 'feature_nav_type' => array( 710 'default' => 'thumbs', 711 'version' => 'pro', 712 'type' => 'select', 713 'selectvalues' => array( 714 'nonav' => array( 'name' => __( 'No Navigation', 'pagelines' ) ), 715 'dots' => array( 'name' => __( 'Squares or Dots', 'pagelines' ) ), 716 'names' => array( 'name' => __( 'Feature Names', 'pagelines' ) ), 717 'thumbs' => array( 'name' => __( 'Feature Thumbs (50px by 30px)', 'pagelines' ) ), 718 'numbers' => array( 'name' => __( 'Numbers', 'pagelines' ) ), 719 ), 720 'inputlabel' => __( 'Feature Navigation Mode', 'pagelines' ), 721 ), 722 'feature_items' => array( 723 'version' => 'pro', 724 'default' => 5, 725 'type' => 'text_small', 726 'inputlabel' => __( 'Max number of features to show', 'pagelines' ), 727 ), 728 729 ), 730 ), 731 'feature_handling' => array( 732 'type' => 'multi_option', 733 'title' => __('Feature Section Height and Responsive Control', 'pagelines'), 734 'shortexp' => __('Dimensions and Responsive Handling', 'pagelines'), 735 'selectvalues' => array( 736 737 'feature_height_mode' => array( 738 'default' => 'aspect', 739 'version' => 'pro', 740 'type' => 'select', 741 'selectvalues' => array( 742 'static' => array('name' => __( 'Static Height (Height is always the same)', 'pagelines' ) ), 743 'aspect' => array('name' => __( 'Aspect Height (Height based on width)', 'pagelines' ) ), 744 ), 745 'inputlabel' => __( 'Select Height Mode (The way feature height is managed)', 'pagelines' ) 746 ), 747 'feature_stage_height' => array( 748 'default' => '380', 749 'version' => 'pro', 750 'type' => 'text_small', 751 'inputlabel' => __( 'Static Mode - Height (In Pixels)', 'pagelines' ), 752 ), 753 'feature_aspect' => array( 754 'default' => '1.77', 755 'version' => 'pro', 756 'type' => 'text_small', 757 'inputlabel' => __( 'Aspect Mode - Ratio (Width/Height - 16:9 would be 1.777)', 'pagelines' ), 758 ), 759 ), 760 ), 761 'feature_transitions' => array( 762 'type' => 'multi_option', 763 'title' => __('Feature Transitions and Effects', 'pagelines'), 764 'shortexp' => __('Options for managing feature transitions', 'pagelines'), 765 'selectvalues' => array( 766 'feffect' => array( 767 'default' => 'fade', 768 'version' => 'pro', 769 'type' => 'select_same', 770 'selectvalues' => array('blindX', 'blindY', 'blindZ', 'cover', 'curtainX', 'curtainY', 'fade', 'fadeZoom', 'growX', 'growY', 'none', 'scrollUp', 'scrollDown', 'scrollLeft', 'scrollRight', 'scrollHorz', 'scrollVert','shuffle','slideX','slideY','toss','turnUp','turnDown','turnLeft','turnRight','uncover','wipe','zoom'), 771 'inputlabel'=> __( 'Select Transition Effect', 'pagelines' ), 772 ), 773 'timeout' => array( 774 'default' => '0', 775 'version' => 'pro', 776 'type' => 'text_small', 777 'inputlabel'=> __( 'Timeout (ms - 0 means manual transition, 5000 = 5 seconds)', 'pagelines' ), 778 ), 779 'fspeed' => array( 780 'default' => 1500, 781 'version' => 'pro', 782 'type' => 'text_small', 783 'inputlabel'=> __( 'Transition Speed (ms - e.g. 1500 = 1.5 seconds)', 'pagelines' ), 784 ), 785 786 'feature_playpause' => array( 787 'default' => false, 788 'version' => 'pro', 789 'type' => 'check', 790 'inputlabel'=> __( 'Show play pause button? (Auto Scrolling Only)', 'pagelines' ), 791 ), 792 ), 793 ), 794 'feature_source' => array( 795 'type' => 'multi_option', 796 'title' => __('Feature Source and Order (Advanced)', 'pagelines'), 797 'shortexp' => __('Advanced options for feature sources and their order. Important: Enable feature panel under settings > advanced for use with posts.', 'pagelines'), 798 'selectvalues' => array( 799 'feature_source' => array( 800 'default' => 'featureposts', 801 'version' => 'pro', 802 'type' => 'select', 803 'selectvalues' => array( 804 'featureposts' => array('name' => __( 'Feature Posts (custom post type)', 'pagelines' ) ), 805 'posts' => array('name' => __( 'Use Post Category', 'pagelines' ) ), 806 'posts_all' => array('name' => __( 'Use all Posts', 'pagelines' ) ), 807 ), 808 'inputlabel' => __( 'Select Feature Post Source (Optional - Defaults to Custom Post Type)', 'pagelines' ), 809 ), 810 'feature_category' => array( 811 'default' => 1, 812 'version' => 'pro', 813 'type' => 'select', 814 'selectvalues' => $this->get_cats(), 815 'inputlabel' => __( 'Select Post Category (Post category source only)', 'pagelines' ), 816 ), 817 818 'feature_orderby' => array( 819 'default' => 'ID', 820 'version' => 'pro', 821 'type' => 'select', 822 'selectvalues' => array( 823 'ID' => array('name' => __( 'Post ID (default)', 'pagelines' ) ), 824 'title' => array('name' => __( 'Title', 'pagelines' ) ), 825 'date' => array('name' => __( 'Date', 'pagelines' ) ), 826 'modified' => array('name' => __( 'Last Modified', 'pagelines' ) ), 827 'rand' => array('name' => __( 'Random', 'pagelines' ) ), 828 ), 829 'inputlabel' => __( 'Select sort method (If not using Post Type Order plugin)', 'pagelines' ), 830 ), 831 832 'feature_order' => array( 833 'default' => 'DESC', 834 'version' => 'pro', 835 'type' => 'select', 836 'selectvalues' => array( 837 'DESC' => array('name' => __( 'Descending', 'pagelines' ) ), 838 'ASC' => array('name' => __( 'Ascending', 'pagelines' ) ), 839 ), 840 'inputlabel' => __( 'Select sort order (If not using Post Type Order plugin)', 'pagelines' ), 841 ), 842 ), 843 ), 844 845 846 847 848 ); 849 850 $metatab_settings = array( 851 'id' => 'feature_meta', 852 'name' => __( 'Features', 'pagelines' ), 853 'icon' => $this->icon, 854 'clone_id' => $settings['clone_id'], 855 'active' => $settings['active'] 856 ); 857 858 register_metatab( $metatab_settings, $page_metatab_array ); 859 860 } 861 862 863 /** 864 * 865 * @TODO document 866 * 867 */ 868 function update_default_posts(){ 869 870 $posts = array_reverse( $this->default_posts() ); 871 872 foreach( $posts as $p ){ 873 // Create post object 874 $default = array(); 875 $default['post_title'] = $p['title']; 876 $default['post_content'] = $p['text']; 877 $default['post_type'] = $this->ptID; 878 $default['post_status'] = 'publish'; 879 880 if ( defined( 'ICL_LANGUAGE_CODE' ) ) 881 $default_post['icl_post_language'] = ICL_LANGUAGE_CODE; 882 883 $newPostID = wp_insert_post( $default ); 884 885 update_post_meta( $newPostID, 'feature-thumb', $p['thumb'] ); 886 update_post_meta( $newPostID, 'feature-link-url', $p['link'] ); 887 update_post_meta( $newPostID, 'feature-style', $p['style'] ); 888 update_post_meta( $newPostID, 'feature-media', $p['media'] ); 889 update_post_meta( $newPostID, 'feature-background-image', $p['background'] ); 890 update_post_meta( $newPostID, 'feature-design', $p['fcontent-design'] ); 891 wp_set_object_terms( $newPostID, 'default-features', $this->taxID ); 892 } 893 } 894 895 896 /** 897 * 898 * @TODO document 899 * 900 */ 901 function default_posts( ){ 902 903 $posts = array( 904 '1' => array( 905 'title' => 'PageLines', 906 'text' => 'Welcome to PageLines Framework!', 907 'media' => '', 908 'style' => 'text-none', 909 'link' => '#fake_link', 910 'background' => $this->base_url.'/images/feature1.jpg', 911 'name' => 'Intro', 912 'fcontent-design' => '', 913 'thumb' => $this->base_url.'/images/fthumb1.png' 914 ), 915 '2' => array( 916 'title' => 'Drag & Drop Design', 917 'text' => 'Welcome to a professional WordPress framework by PageLines. Designed for you in San Francisco, California.', 918 'media' => '', 919 'style' => 'text-none', 920 'link' => '#fake_link', 921 'background' => $this->base_url.'/images/feature2.jpg', 922 'name' => 'Design', 923 'fcontent-design' => '', 924 'thumb' => $this->base_url.'/images/fthumb2.png' 925 ), 926 '3' => array( 927 'title' => 'The PageLines Store', 928 'text' => 'Buy and sell drag and drop sections, plugins and themes. The first ever "app-store" for web design.', 929 'media' => '', 930 'style' => 'text-none', 931 'link' => '#fake_link', 932 'background' => $this->base_url.'/images/feature3.jpg', 933 'name' => 'Design', 934 'fcontent-design' => '', 935 'thumb' => $this->base_url.'/images/fthumb3.png' 936 ), 937 '4' => array( 938 'title' => 'Page-by-Page Options', 939 'text' => 'Want to do something totally unique? PageLines offers options for almost everything in an intuitive and easy to use format.', 940 'media' => '', 941 'style' => 'text-none', 942 'link' => '#fake_link', 943 'background' => $this->base_url.'/images/feature4.jpg', 944 'name' => 'Design', 945 'fcontent-design' => '', 946 'thumb' => $this->base_url.'/images/fthumb4.png' 947 ), 948 '5' => array( 949 'title' => 'Design Control', 950 'text' => 'Use advanced typography and color control to fine tune your design with point and click simplicity.', 951 'media' => '', 952 'style' => 'text-none', 953 'link' => '#fake_link', 954 'background' => $this->base_url.'/images/feature5.jpg', 955 'name' => 'Design', 956 'fcontent-design' => '', 957 'thumb' => $this->base_url.'/images/fthumb5.png' 958 ) 959 ); 960 961 return apply_filters('pagelines_default_features', array_reverse($posts)); 962 } 963 964 965 /** 966 * 967 * @TODO document 968 * 969 */ 970 function get_cats() { 971 972 $cats = get_categories(); 973 foreach( $cats as $cat ) 974 $categories[ $cat->cat_ID ] = array( 'name' => $cat->name ); 975 976 return ( isset( $categories) ) ? $categories : array(); 977 } 978 979 980 /** 981 * 982 * @TODO document 983 * 984 */ 985 function column_display( $column ){ 986 987 global $post; 988 989 switch ( $column ){ 990 case "feature-description": 991 the_excerpt(); 992 break; 993 case "feature-media": 994 if( m_pagelines( 'feature-media', $post->ID ) ) 995 em_pagelines( 'feature-media', $post->ID ); 996 elseif( m_pagelines( 'feature-media-image', $post->ID ) ) 997 echo '<img src="'.m_pagelines('feature-media', $post->ID).'" style="max-width: 200px; max-height: 200px" />'; 998 elseif(m_pagelines('feature-background-image', $post->ID)) 999 echo '<img src="'.m_pagelines('feature-background-image', $post->ID).'" style="max-width: 200px; max-height: 200px" />'; 1000 1001 break; 1002 case $this->taxID: 1003 echo get_the_term_list( $post->ID, $this->taxID, '', ', ','' ); 1004 break; 1005 } 1006 } 1007 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu May 23 23:52:43 2013 | Cross-referenced by PHPXref 0.7.1 |