Advertisement
webrur

Class 12

Apr 25th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
  2.  
  3. function factorian_slides_shortcode($atts){
  4. extract( shortcode_atts( array(
  5. 'count' => 3,
  6. 'loop' => 'true',
  7. 'slide_id' => '',
  8. 'slider_height' => '730',
  9. 'autoplay' => 'false',
  10. 'autoplayTimeout' => 5000,
  11. 'nav' => 'true',
  12. 'dots' => 'true',
  13. ), $atts) );
  14.  
  15. if ( $count == 1 ) {
  16. $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'slide', 'p' => $slider_id));
  17. } else {
  18. $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'slide'));
  19. }
  20.  
  21. if ( $count == 1 ) {
  22. $list = '';
  23. } else {
  24. $list = '
  25. <script>
  26. jQuery(window).load(function() {
  27. jQuery(".factorian-slides").owlCarousel({
  28. items: 1,
  29. loop: '.$loop.',
  30. autoplay : '.$autoplay.',
  31. autoplayTimeout : '.$autoplayTimeout.',
  32. nav : '.$nav.',
  33. dots : '.$dots.',
  34. navText : ["<i class=\'fa fa-angle-left\'></i>", "<i class=\'fa fa-angle-right\'></i>"]
  35. });
  36. });
  37. </script>';
  38. }
  39.  
  40.  
  41.  
  42.  
  43. $list .= '
  44. <div class="factorian-slides">';
  45. while($q->have_posts()) : $q->the_post();
  46. $idd = get_the_ID();
  47.  
  48. // Slide meta array exist
  49. if(get_post_meta($idd, 'factorian_slide_options', true)) {
  50. $slide_meta = get_post_meta($idd, 'factorian_slide_options', true);
  51. } else {
  52. $slide_meta = array();
  53. }
  54.  
  55. // Slide meta array exist
  56. if(array_key_exists('overlay', $slide_meta)) {
  57. $overlay = $slide_meta['overlay'];
  58. } else {
  59. $overlay = true;
  60. }
  61.  
  62. // Slide meta array exist
  63. if(array_key_exists('overlay_percentage', $slide_meta)) {
  64. $overlay_percentage = $slide_meta['overlay_percentage'];
  65. } else {
  66. $overlay_percentage = .7;
  67. }
  68.  
  69. // Slide meta array exist
  70. if(array_key_exists('overlay_color', $slide_meta)) {
  71. $overlay_color = $slide_meta['overlay_color'];
  72. } else {
  73. $overlay_color = '#020202';
  74. }
  75.  
  76.  
  77.  
  78. $post_content = get_the_content();
  79. $list .= '
  80. <div style="background-image: url('.get_the_post_thumbnail_url($idd, 'large').'); height:'.$slider_height.'px;" class="factorian-slide-item">';
  81.  
  82. if($overlay == true) {
  83. $list .='<div style="opacity:'.$overlay_percentage.'; background-color:'.$overlay_color.';" class="slide-overlay"></div>';
  84. }
  85.  
  86. $list .='
  87.  
  88. <div class="slide-content-table">
  89. <div class="slide-content-tablecell">
  90. <div class="container">
  91. <div class="row">
  92. <div class="col-md-6">
  93. <h2>'.get_the_title($idd).'</h2>
  94. '.wpautop($post_content).'';
  95.  
  96. if(!empty($slide_meta['buttons'])) {
  97. $list .='<div class="slide-buttons">';
  98. foreach($slide_meta['buttons'] as $button) {
  99. if($button['link_type'] == 1) {
  100. $btn_link = get_page_link($button['link_to_page']);
  101. } else {
  102. $btn_link = $button['link_to_external'];
  103. }
  104.  
  105. $list .='<a href="'.$btn_link.'" class="'.$button['type'].'-btn factorain-slide-btn">'.$button['text'].'</a>';
  106. }
  107. $list .='</div>';
  108. }
  109.  
  110. $list .='
  111.  
  112.  
  113. </div>
  114. </div>
  115. </div>
  116. </div>
  117. </div>
  118. </div>
  119. ';
  120. endwhile;
  121. $list .= '</div>';
  122. wp_reset_query();
  123. return $list;
  124. }
  125. add_shortcode('factorian_slides', 'factorian_slides_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement