nazim259

Untitled

Apr 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. ************************************************* short-code.php ********************************************************
  2.  
  3. <?php
  4.  
  5.  
  6. function fac_slide_shortcode($atts){
  7. extract( shortcode_atts( array(
  8. 'count' => 3,
  9. 'slider_id' => ' ',
  10. 'height' => '690',
  11. 'loop' => 'true',
  12. 'autoplay' => 'true',
  13. 'autoplayTimeout' => 5000,
  14. 'nav' => 'true',
  15. 'dots' => 'true',
  16. ), $atts) );
  17.  
  18.  
  19. if($count == 1){
  20. $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'slide' , 'p' => $slider_id));
  21. }else{
  22. $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'slide'));
  23. }
  24.  
  25.  
  26. if($count ==1){
  27. $list = '';
  28. }else{
  29.  
  30. $list = '
  31.  
  32. <script>
  33. jQuery(window).load(function(){
  34.  
  35. jQuery(".factorian-slides").owlCarousel({
  36.  
  37. items: 1,
  38. loop: '.$loop.',
  39. autoplay: '.$autoplay.',
  40. autoplayTimeout: '.$autoplayTimeout.',
  41. nav: '.$nav.',
  42. dots: '.$dots.',
  43. navText: ["<i class=\'fa fa-angle-left\'></i>", "<i class=\'fa fa-angle-right\'></i>"],
  44.  
  45. });
  46. });
  47. </script>';
  48. }
  49.  
  50.  
  51.  
  52. ****************************************************************** factorian-toolkit.php ******************************************
  53.  
  54. function fac_toolkit_get_slide_as_list(){
  55.  
  56. $args = wp_parse_args(array(
  57. 'post_type' => 'slide',
  58. 'numberposts' => -1,
  59. ));
  60.  
  61. $posts = get_posts($args);
  62. $post_options = array (esc_html__('-- Select slide --', 'mytheme')=>'');
  63. if($posts){
  64. foreach ($posts as $post) {
  65. $post_options[$post->post_title] = $post->ID;
  66. }
  67. }
  68. return $post_options;
  69. }
  70.  
  71. **************************************************** vc-slide.php *****************************************
  72.  
  73. array(
  74. "type" => "dropdown",
  75. "heading" => __( "Select Slide", "my-text-domain" ),
  76. "param_name" => "slider_id",
  77. "value" => fac_toolkit_get_slide_as_list(),
  78. "description" => __( "", "my-text-domain" ),
  79. 'dependency' => array(
  80. "element" => "count",
  81. "value" => array("1"),
  82. )
  83. ),
  84. array(
  85. "type" => "textfield",
  86. "heading" => __( "Slider Hight", "my-text-domain" ),
  87. "param_name" => "height",
  88. "std" => __( "690", "my-text-domain" ),
  89. "description" => __( "Type slider height in px. ", "my-text-domain" )
  90. ),
  91. array(
  92. "type" => "dropdown",
  93. "heading" => __( "Enable Loop?", "my-text-domain" ),
  94. "param_name" => "loop",
  95. "std" => __( "true", "my-text-domain" ),
  96. "value" => array(
  97. 'Yes' => 'true',
  98. 'No' => 'false',
  99. ),
  100. "description" => __( "", "my-text-domain" ),
  101. 'dependency' => array(
  102. "element" => "count",
  103. "value" => array( "2", "3", "4" , "5" , "6" , "7" , "8" , "9" , "10"),
  104. )
  105. ),
Add Comment
Please, Sign In to add comment