Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if ( ! defined( 'ABSPATH' ) ) { die; } // Cannot access pages directly.
- function factorian_slides_shortcode($atts){
- extract( shortcode_atts( array(
- 'count' => 3,
- 'loop' => 'true',
- 'slide_id' => '',
- 'slider_height' => '730',
- 'autoplay' => 'false',
- 'autoplayTimeout' => 5000,
- 'nav' => 'true',
- 'dots' => 'true',
- ), $atts) );
- if ( $count == 1 ) {
- $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'slide', 'p' => $slider_id));
- } else {
- $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'slide'));
- }
- if ( $count == 1 ) {
- $list = '';
- } else {
- $list = '
- <script>
- jQuery(window).load(function() {
- jQuery(".factorian-slides").owlCarousel({
- items: 1,
- loop: '.$loop.',
- autoplay : '.$autoplay.',
- autoplayTimeout : '.$autoplayTimeout.',
- nav : '.$nav.',
- dots : '.$dots.',
- navText : ["<i class=\'fa fa-angle-left\'></i>", "<i class=\'fa fa-angle-right\'></i>"]
- });
- });
- </script>';
- }
- $list .= '
- <div class="factorian-slides">';
- while($q->have_posts()) : $q->the_post();
- $idd = get_the_ID();
- // Slide meta array exist
- if(get_post_meta($idd, 'factorian_slide_options', true)) {
- $slide_meta = get_post_meta($idd, 'factorian_slide_options', true);
- } else {
- $slide_meta = array();
- }
- // Slide meta array exist
- if(array_key_exists('overlay', $slide_meta)) {
- $overlay = $slide_meta['overlay'];
- } else {
- $overlay = true;
- }
- // Slide meta array exist
- if(array_key_exists('overlay_percentage', $slide_meta)) {
- $overlay_percentage = $slide_meta['overlay_percentage'];
- } else {
- $overlay_percentage = .7;
- }
- // Slide meta array exist
- if(array_key_exists('overlay_color', $slide_meta)) {
- $overlay_color = $slide_meta['overlay_color'];
- } else {
- $overlay_color = '#020202';
- }
- $post_content = get_the_content();
- $list .= '
- <div style="background-image: url('.get_the_post_thumbnail_url($idd, 'large').'); height:'.$slider_height.'px;" class="factorian-slide-item">';
- if($overlay == true) {
- $list .='<div style="opacity:'.$overlay_percentage.'; background-color:'.$overlay_color.';" class="slide-overlay"></div>';
- }
- $list .='
- <div class="slide-content-table">
- <div class="slide-content-tablecell">
- <div class="container">
- <div class="row">
- <div class="col-md-6">
- <h2>'.get_the_title($idd).'</h2>
- '.wpautop($post_content).'';
- if(!empty($slide_meta['buttons'])) {
- $list .='<div class="slide-buttons">';
- foreach($slide_meta['buttons'] as $button) {
- if($button['link_type'] == 1) {
- $btn_link = get_page_link($button['link_to_page']);
- } else {
- $btn_link = $button['link_to_external'];
- }
- $list .='<a href="'.$btn_link.'" class="'.$button['type'].'-btn factorain-slide-btn">'.$button['text'].'</a>';
- }
- $list .='</div>';
- }
- $list .='
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- ';
- endwhile;
- $list .= '</div>';
- wp_reset_query();
- return $list;
- }
- add_shortcode('factorian_slides', 'factorian_slides_shortcode');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement