Advertisement
salmancreation

Factorian Slider not working - salman

Mar 31st, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.68 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Factorian Toolkit
  4. Plugin URI: http://salmancreation.com
  5. Author: Salman Ahmed
  6. Version: 1.0
  7. Description: Factorian WordPress Theme Plugin Toolkit . All Shortcodes & VC-Addons . Please Active This . Thank you
  8. */
  9.  
  10.  
  11. // don't load directly
  12. if ( ! defined( 'ABSPATH' ) ) {
  13.     exit;
  14. }
  15.  
  16.  
  17. // Define
  18. define('Factorian_ACC_URL', WP_PUGIN_URL .'/'. plugin_basename( dirname(__FILE__) ) . '/' );
  19. define('Factorian_ACC_PATH', plugin_dir_path( __FILE__ ));
  20.  
  21. // Shortcode widget support
  22. add_filter('widget_text','do_shortcode');
  23.  
  24. require_once(Factorian_ACC_PATH . 'vc-addons/vc-blocks-load.php' );
  25. require_once(Factorian_ACC_PATH . 'theme-shortcodes/slides-shortcode.php' );
  26.  
  27.  
  28.  
  29. function factorian_toolkit_file(){
  30.  
  31. wp_enqueue_style( 'owl-carousel', PLUGINS_URL('assets/css/owl.carousel.css', __FILE__));
  32. wp_enqueue_style( 'owl-transition', PLUGINS_URL('assets/css/owl.transitions.css', __FILE__));
  33. wp_enqueue_script( 'owl-carousel-js', PLUGINS_URL('assets/js/owl.carousel.min.js', __FILE__), array('jquery'), '1.3', true );
  34.  
  35.  
  36. }
  37. add_action('wp_enqueue_scripts','factorian_toolkit_file');
  38.  
  39.  
  40.  
  41.  
  42. // Progressbar shortcode
  43.  
  44. function factorian_progressbar_shortcode($atts){
  45.     extract( shortcode_atts( array(
  46.         'count' => '50',
  47.         'animate' => 'yes',
  48.         'color' => '#c22',
  49.  
  50.     ), $atts) );
  51.    
  52.    if($animate =='yes'){
  53.    $progressbar='<div class="progress">
  54.       <div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="'.$count.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$count.'%;background-color:'.$color.';">  '.$count.'%
  55.       </div>
  56.     </div>';
  57.     }
  58.     elseif($animate =='no'){
  59.         $progressbar='<div class="progress">
  60.       <div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="'.$count.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$count.'%;background-color:'.$color.';">  '.$count.'%
  61.       </div>
  62.     </div>';
  63.     }
  64.  
  65.     return $progressbar;
  66.  
  67. }
  68. add_shortcode('factorian_progressbar', 'factorian_progressbar_shortcode');  
  69.  
  70. // tooltip shortcode
  71.  
  72. function factorian_tooltip_shortcode($atts){
  73.     extract( shortcode_atts( array(
  74.         'placement' => 'left',
  75.         'text' => ''
  76.  
  77.     ), $atts) );
  78.  
  79.  
  80.     return '<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="'.$placement.'" title="Tooltip on '.$placement.'">'.$text.'</button>';
  81.  
  82. }
  83. add_shortcode('factorian_tooltip', 'factorian_tooltip_shortcode');  
  84.  
  85.  
  86.  
  87.  
  88. function factorian_post_list_shortcode($atts){
  89.     extract( shortcode_atts( array(
  90.         'count' => -1,
  91.     ), $atts) );
  92.      
  93.     $q = new WP_Query(
  94.         array(
  95.             'posts_per_page' => $count,
  96.             'post_type' => 'factorian-slider',
  97.             'orderby' => 'menu_order',
  98.             'order' => 'ASC'
  99.             )
  100.         );      
  101.          
  102.     $list = '<div class="custom_post_list">';
  103.     while($q->have_posts()) : $q->the_post();
  104.         $idd = get_the_ID();
  105.         $custom_field = get_post_meta($idd, 'custom_field', true);
  106.         $post_content = get_the_content();
  107.         $list .= '
  108.        <div style="background-image:url('.get_the_post_thumbnail_url($idd, 'large' ).')" class="single_post_item">
  109.            <h2>' .do_shortcode( get_the_title() ). '</h2>
  110.            '.wpautop( $post_content ).'
  111.            <p>'.$custom_field.'</p>
  112.        </div>
  113.        ';        
  114.     endwhile;
  115.     $list.= '</div>';
  116.     wp_reset_query();
  117.     return $list;
  118. }
  119. add_shortcode('factorian_post_list', 'factorian_post_list_shortcode');  
  120.  
  121.  
  122. /* Factorian Theme VC Addons*/
  123.  
  124. function factorian_vc_addons(){
  125.  
  126.     vc_map( array(
  127.       "name" => __( "Slider Post List", "factorian-sctheme" ),
  128.       "base" => "factorian_post_list",
  129.       "icon" => "https://en.share-gate.com/app/archive/media/Sharegate/Images/2013/header_IMGSlider_616161.jpg",
  130.       "category" => __( "Factorian", "factorian-sctheme"),
  131.       'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
  132.       'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
  133.       "params" => array(
  134.          array(
  135.             "type" => "textfield",
  136.             "heading" => __( "Post Count", "factorian-sctheme" ),
  137.             "param_name" => "count",
  138.             "value" => __( "2", "factorian-sctheme" ),
  139.             "description" => __( "Type How many posts.", "factorian-sctheme" )
  140.          )
  141.       )
  142.    ) );
  143.  
  144.     vc_map( array(
  145.       "name" => __( "Progressbar", "factorian-sctheme" ),
  146.       "base" => "factorian_progressbar",
  147.       "icon" => "http://mobiuslearning.com/site/wp-content/uploads/2015/02/Icon-ProgressBar-300x169.png",
  148.       "category" => __( "Factorian", "factorian-sctheme"),
  149.       'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
  150.       'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
  151.       "params" => array(
  152.          array(
  153.             "type" => "textfield",
  154.             "heading" => __( "Progressbar Value", "factorian-sctheme" ),
  155.             "param_name" => "count",
  156.             "value" => __( "50", "factorian-sctheme" ),
  157.             "description" => __( "Type The Value.", "factorian-sctheme" )
  158.          ),
  159.          array(
  160.             "type" => "colorpicker",
  161.             "heading" => __( "Progressbar Color", "factorian-sctheme" ),
  162.             "param_name" => "color",
  163.             "value" => __( "#c33", "factorian-sctheme" ),
  164.             "description" => __( "Select Your Color.", "factorian-sctheme" )
  165.          ),
  166.          array(
  167.             "type" => "dropdown",
  168.             "heading" => __( "Progressbar Animate", "factorian-sctheme" ),
  169.             "param_name" => "animate",
  170.             "value" => array(
  171.                 "Yes" => "yes",
  172.                 "NO" => "no"
  173.                 ),
  174.             "description" => __( "Select Your Color.", "factorian-sctheme" )
  175.          ),
  176.       )
  177.    ) );
  178.  
  179. }
  180. add_action('vc_before_init','factorian_vc_addons');
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195. // Slider shortcode
  196.  
  197. function factorian_slider_shortcode($atts){
  198.     extract( shortcode_atts( array(
  199.         'count' => '',
  200.     ), $atts) );
  201.  
  202.  
  203.     $q = new WP_Query(
  204.         array(
  205.             'posts_per_page' => $count,
  206.             'post_type' => 'factorian-slider'
  207.             )
  208.         );  
  209.  
  210.  
  211.     $factorian_slider ='<script>
  212.     jQuery(document).ready(function($){
  213.         $(".factorian_slider").owlCarousel({
  214.             items: 1,
  215.             loop: true,
  216.             autoplay: false,
  217.             nav: true,
  218.             dots: true,
  219.             navText: ["<i class=\'fa fa-agnle-left\'></i>","<i class=\'fa fa-agnle-right\'></i>"],
  220.  
  221.         });
  222.     });
  223.    </script> <div class="factorian_slider">';
  224.  
  225.  while($q->have_posts()) : $q->the_post();
  226.         $idd = get_the_ID();
  227.         $slide_meta = get_post_meta($idd, 'factorian_slider_options', true);
  228.         $post_content = get_the_content();
  229.  
  230.     $factorian_slider .='
  231.     <div style="background-image:url('.get_the_post_thumbnail_url($idd, 'large' ).')" class="single_slider">
  232.         <div class="slider_tabel">
  233.             <div class="slider_tabel_cell">
  234.                 <div class="container">
  235.                     <div class="row">
  236.                         <div class="col-md-6 col-md-offset-6">
  237.                             <h1>'.do_shortcode( get_the_title() ).'</h1>
  238.                             <h3>'.wpautop( $post_content ).'</h3>';
  239.  
  240.                             if(!empty($slide_meta['buttons'])) {
  241.                                 $factorian_slider.='<div class="slide_button">';
  242.                                 foreach ($slide_meta['buttons'] as $button) {
  243.                                     if ($button['button_link'] == 1) {
  244.                                         $btn_link = get_page_link($button['button_link_to_wp_page']);
  245.                                     } else{
  246.                                         $btn_link = $button['button_link_to_external_page'];
  247.                                     }
  248.  
  249.                                     $factorian_slider .='<a href="'.$btn_link.'" class="'.$button['button_type'].'_btn slide_btn_button"></a>';
  250.                                 }
  251.                                 $factorian_slider .='</div>';
  252.                             }
  253.  
  254.             $factorian_slider .='              
  255.                         </div>
  256.                     </div>
  257.                 </div>
  258.             </div>
  259.         </div>
  260.     </div>';
  261.  
  262.        
  263.     endwhile;
  264.     $factorian_slider.= '</div>';
  265.     wp_reset_query();
  266.  
  267.     return $factorian_slider;
  268.  
  269. }
  270. add_shortcode('factorian_slider', 'factorian_slider_shortcode');  
  271.  
  272.  
  273.  
  274. // Register Slider  Post Type
  275. function factorian_custom_post_resgister() {
  276.     $labels = array(
  277.         'name'                  => _x( 'Factorian Slider', 'Post type general name', 'factorian-sctheme' ),
  278.         'singular_name'         => _x( 'Factorian Slider', 'Post type singular name', 'factorian-sctheme' ),
  279.         'menu_name'             => _x( 'Factorian  Slider', 'Admin Menu text', 'factorian-sctheme' ),
  280.         'name_admin_bar'        => _x( 'Slider', 'Add New on Toolbar', 'factorian-sctheme' ),
  281.         'add_new'               => __( 'Add New Slider', 'factorian-sctheme' ),
  282.         'add_new_item'          => __( 'Add New Slider', 'factorian-sctheme' ),
  283.         'new_item'              => __( 'New Slider', 'factorian-sctheme' ),
  284.         'edit_item'             => __( 'Edit Slider', 'factorian-sctheme' ),
  285.         'view_item'             => __( 'View Slider', 'factorian-sctheme' ),
  286.         'all_items'             => __( 'All Slider', 'factorian-sctheme' ),
  287.         'search_items'          => __( 'Search Slider', 'factorian-sctheme' ),
  288.         'parent_item_colon'     => __( 'Parent Slider:', 'factorian-sctheme' ),
  289.         'not_found'             => __( 'No slider found.', 'factorian-sctheme' ),
  290.     );
  291.  
  292.     $args = array(
  293.         'labels'             => $labels,
  294.         'public'             => flase,
  295.         'show_ui'            => true,
  296.         'supports'           => array( 'title', 'editor', 'thumbnail'),
  297.         'menu_icon'          => 'dashicons-slides'
  298.     );
  299.  
  300.     register_post_type( 'factorian-slider', $args );
  301. }
  302.  
  303. add_action( 'init', 'factorian_custom_post_resgister' );
  304.  
  305.  
  306. wp_enqueue_style( 'factorian-shortcode', get_template_directory_uri() . '/assets/css/shortcode.css', array(), '1.0');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement