Created
May 4, 2019 19:34
-
-
Save salehahmadbabu/5990f3938a62a479408e0a08943cec2b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// vc slide addon | |
<?php | |
vc_map(array( | |
"name" => esc_html__("Opolis Slider","opolis"), | |
"base" => "opolis_slides", | |
"category" => esc_html__("Opolis","opolis"), | |
"params" => array( | |
array( | |
"type" => "textfield", | |
"heading" => esc_html__("Count","opolis"), | |
"param_name" => "count", | |
"value" => esc_html__("3","opolis"), | |
"description" => esc_html__("Select slides count. If you want unlimited slides, then type -1.","opolis") | |
), | |
array( | |
"type" => "textfield", | |
"heading" => esc_html__("Slider height","opolis"), | |
"param_name" => "height", | |
"std" => esc_html__("730","opolis"), | |
"description" => esc_html__("Type slider height in px, numbers only.","opolis") | |
), | |
array( | |
"type" => "dropdown", | |
"heading" => esc_html__("Enable loop?","opolis"), | |
"param_name" => "loop", | |
"std" => esc_html__("true","opolis"), | |
"value" => array( | |
esc_html__("Yes","opolis") => "true", | |
esc_html__("No","opolis") => "false" | |
), | |
"description" => esc_html__("","opolis"), | |
"dependency" => array( | |
"element" => "count", | |
"value" => array("2","3","4","5","6","7","8","9","10","11","12","13","14","15") | |
) | |
), | |
array( | |
"type" => "dropdown", | |
"heading" => esc_html__("Enable autoplay?","opolis"), | |
"param_name" => "autoplay", | |
"std" => esc_html__("true","opolis"), | |
"value" => array( | |
esc_html__("Yes","opolis") => "true", | |
esc_html__("No","opolis") => "false" | |
), | |
"description" => esc_html__("","opolis"), | |
"dependency" => array( | |
"element" => "count", | |
"value" => array("2","3","4","5","6","7","8","9","10","11","12","13","14","15") | |
) | |
), | |
array( | |
"type" => "dropdown", | |
"heading" => esc_html__("Slide time?","opolis"), | |
"param_name" => "autoplayTimeout", | |
"std" => esc_html__("5000","opolis"), | |
"value" => array( | |
esc_html__("1 Second","opolis") => "1000", | |
esc_html__("2 Seconds","opolis") => "2000", | |
esc_html__("3 Seconds","opolis") => "3000", | |
esc_html__("4 Seconds","opolis") => "4000", | |
esc_html__("5 Seconds","opolis") => "5000", | |
esc_html__("6 Seconds","opolis") => "6000", | |
esc_html__("7 Seconds","opolis") => "7000", | |
esc_html__("8 Seconds","opolis") => "8000", | |
esc_html__("9 Seconds","opolis") => "9000", | |
esc_html__("10 Seconds","opolis") => "10000", | |
esc_html__("11 Seconds","opolis") => "11000", | |
esc_html__("12 Seconds","opolis") => "12000", | |
esc_html__("13 Seconds","opolis") => "13000", | |
esc_html__("14 Seconds","opolis") => "14000", | |
esc_html__("15 Seconds","opolis") => "15000", | |
), | |
"description" => esc_html__("","opolis"), | |
"dependency" => array( | |
"element" => "count", | |
"value" => array("2","3","4","5","6","7","8","9","10","11","12","13","14","15") | |
) | |
), | |
array( | |
"type" => "dropdown", | |
"heading" => esc_html__("Enable navigation icon?","opolis"), | |
"param_name" => "nav", | |
"std" => esc_html__("true","opolis"), | |
"value" => array( | |
esc_html__("Yes","opolis") => "true", | |
esc_html__("No","opolis") => "false" | |
), | |
"description" => esc_html__("","opolis"), | |
"dependency" => array( | |
"element" => "count", | |
"value" => array("2","3","4","5","6","7","8","9","10","11","12","13","14","15") | |
) | |
), | |
array( | |
"type" => "dropdown", | |
"heading" => esc_html__("Enable dots?","opolis"), | |
"param_name" => "dots", | |
"std" => esc_html__("true","opolis"), | |
"value" => array( | |
esc_html__("Yes","opolis") => "true", | |
esc_html__("No","opolis") => "false" | |
), | |
"description" => esc_html__("","opolis"), | |
"dependency" => array( | |
"element" => "count", | |
"value" => array("2","3","4","5","6","7","8","9","10","11","12","13","14","15") | |
) | |
), | |
) | |
)); | |
//slide shortcode | |
<?php | |
function opolis_slides_shortcode($atts){ | |
extract( shortcode_atts( array( | |
'count' => 3, | |
'height' =>'', | |
'loop' =>'', | |
'autoplay' =>'', | |
'autoplayTimeout' =>'', | |
'nav' =>'', | |
'dots' =>'' | |
), $atts) ); | |
$q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'slide')); | |
$list = ' | |
<script> | |
jQuery(window).load(function(){ | |
jQuery(".opolis-slides").owlCarousel({ | |
items: 1, | |
loop: $loop, | |
nav: $nav, | |
autoplay: $autoplay, | |
autoplayTimeout: $autoplayTimeout, | |
dots: $dots, | |
nav: $nav | |
}); | |
}); | |
</script>'; | |
$list .='<div class="opolis-slides-wrapper">'; | |
$list .=' | |
<div class="opolis-slides">'; | |
while($q->have_posts()) : $q->the_post(); | |
$idd = get_the_ID(); | |
$slide_meta = (get_post_meta($idd, 'opolis_slide_options', true)) ? get_post_meta($idd, 'opolis_slide_options', true) : array(); | |
$post_content = get_the_content(); | |
$list .=' | |
<div class="single-slide-item"> | |
<div class="container"> | |
<div class="row"> | |
<div class="col-md-10 offset-md-1 text-center"> | |
<h2>'.get_the_title().'</h2> | |
'.$post_content.''; | |
if(!empty($slide_meta['buttons'])){ | |
$list .= '<div class="opolis-slide-btns">'; | |
foreach ($slide_meta['buttons'] as $button) { | |
$btn_link = ($button['link_type'] == 1) ? get_page_link($button['link_to_page']) : $button['link_to_external']; | |
$list .= '<a href="'.esc_url( $btn_link ).'" class="'.esc_attr( $button['type'] ).'-btn opolis-slide-btn">'.esc_html( $button['text'] ).'</a>'; | |
} | |
$list .= '</div>'; | |
} | |
$list .= ' | |
</div> | |
</div> | |
</div> | |
</div> | |
'; | |
endwhile; | |
$list.= '</div></div>'; | |
wp_reset_query(); | |
return $list; | |
} | |
add_shortcode('opolis_slides', 'opolis_slides_shortcode'); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment