Advertisement
salmancreation

Factorian Toolkit

Apr 2nd, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 11.39 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. // file include
  25. require_once(Factorian_ACC_PATH . 'vc-addons/vc-blocks-load.php' );
  26. require_once(Factorian_ACC_PATH . 'theme-shortcodes/slides-shortcode.php' );
  27. require_once(Factorian_ACC_PATH . 'vc-addons/vc-slide.php' );
  28.  
  29.  
  30. function factorian_toolkit_file(){
  31.  
  32. wp_enqueue_style( 'owl-carousel', PLUGINS_URL('assets/css/owl.carousel.css', __FILE__));
  33. wp_enqueue_style( 'owl-transition', PLUGINS_URL('assets/css/owl.transitions.css', __FILE__));
  34. wp_enqueue_script( 'owl-carousel-js', PLUGINS_URL('assets/js/owl.carousel.min.js', __FILE__), array('jquery'), '1.3', true );
  35.  
  36.  
  37. }
  38. add_action('wp_enqueue_scripts','factorian_toolkit_file');
  39.  
  40.  
  41.  
  42.  
  43. // Progressbar shortcode
  44.  
  45. function factorian_progressbar_shortcode($atts){
  46.     extract( shortcode_atts( array(
  47.         'count' => '50',
  48.         'animate' => 'yes',
  49.         'color' => '#c22',
  50.  
  51.     ), $atts) );
  52.    
  53.    if($animate =='yes'){
  54.    $progressbar='<div class="progress">
  55.       <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.'%
  56.       </div>
  57.     </div>';
  58.     }
  59.     elseif($animate =='no'){
  60.         $progressbar='<div class="progress">
  61.       <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.'%
  62.       </div>
  63.     </div>';
  64.     }
  65.  
  66.     return $progressbar;
  67.  
  68. }
  69. add_shortcode('factorian_progressbar', 'factorian_progressbar_shortcode');  
  70.  
  71. // tooltip shortcode
  72.  
  73. function factorian_tooltip_shortcode($atts){
  74.     extract( shortcode_atts( array(
  75.         'placement' => 'left',
  76.         'text' => ''
  77.  
  78.     ), $atts) );
  79.  
  80.  
  81.     return '<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="'.$placement.'" title="Tooltip on '.$placement.'">'.$text.'</button>';
  82.  
  83. }
  84. add_shortcode('factorian_tooltip', 'factorian_tooltip_shortcode');  
  85.  
  86.  
  87.  
  88.  
  89. function factorian_post_list_shortcode($atts){
  90.     extract( shortcode_atts( array(
  91.         'count' => -1,
  92.     ), $atts) );
  93.      
  94.     $q = new WP_Query(
  95.         array(
  96.             'posts_per_page' => $count,
  97.             'post_type' => 'factorian-slider',
  98.             'orderby' => 'menu_order',
  99.             'order' => 'ASC'
  100.             )
  101.         );      
  102.          
  103.     $list ='
  104.    <ul class="custom_post_list">';
  105.     while($q->have_posts()) : $q->the_post();
  106.         $idd = get_the_ID();
  107.         $custom_field = get_post_meta($idd, 'custom_field', true);
  108.         $post_content = get_the_content();
  109.         $list .= '
  110.        <li class="single_post_item">
  111.            <h2>' .do_shortcode( get_the_title() ). '</h2>
  112.            '.wpautop( $post_content ).'
  113.            <p>'.$custom_field.'</p>
  114.        </li>
  115.        ';        
  116.     endwhile;
  117.     $list.= '</ul>';
  118.     wp_reset_query();
  119.     return $list;
  120. }
  121. add_shortcode('factorian_post_list', 'factorian_post_list_shortcode');  
  122.  
  123.  
  124. /* Factorian Theme VC Addons*/
  125.  
  126. function factorian_vc_addons(){
  127.  
  128.     vc_map( array(
  129.       "name" => __( "Slider Post List", "factorian-sctheme" ),
  130.       "base" => "factorian_post_list",
  131.       "icon" => "http://simpleicon.com/wp-content/uploads/list.png",
  132.       "category" => __( "Factorian", "factorian-sctheme"),
  133.       'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
  134.       'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
  135.       "params" => array(
  136.          array(
  137.             "type" => "textfield",
  138.             "heading" => __( "Post Count", "factorian-sctheme" ),
  139.             "param_name" => "count",
  140.             "value" => __( "2", "factorian-sctheme" ),
  141.             "description" => __( "Type How many posts.", "factorian-sctheme" )
  142.          )
  143.       )
  144.    ) );
  145.  
  146.     vc_map( array(
  147.       "name" => __( "Progressbar", "factorian-sctheme" ),
  148.       "base" => "factorian_progressbar",
  149.       "icon" => "http://mobiuslearning.com/site/wp-content/uploads/2015/02/Icon-ProgressBar-300x169.png",
  150.       "category" => __( "Factorian", "factorian-sctheme"),
  151.       'admin_enqueue_js' => array(get_template_directory_uri().'/vc_extend/bartag.js'),
  152.       'admin_enqueue_css' => array(get_template_directory_uri().'/vc_extend/bartag.css'),
  153.       "params" => array(
  154.          array(
  155.             "type" => "textfield",
  156.             "heading" => __( "Progressbar Value", "factorian-sctheme" ),
  157.             "param_name" => "count",
  158.             "value" => __( "50", "factorian-sctheme" ),
  159.             "description" => __( "Type The Value.", "factorian-sctheme" )
  160.          ),
  161.          array(
  162.             "type" => "colorpicker",
  163.             "heading" => __( "Progressbar Color", "factorian-sctheme" ),
  164.             "param_name" => "color",
  165.             "value" => __( "#c33", "factorian-sctheme" ),
  166.             "description" => __( "Select Your Color.", "factorian-sctheme" )
  167.          ),
  168.          array(
  169.             "type" => "dropdown",
  170.             "heading" => __( "Progressbar Animate", "factorian-sctheme" ),
  171.             "param_name" => "animate",
  172.             "value" => array(
  173.                 "Yes" => "yes",
  174.                 "NO" => "no"
  175.                 ),
  176.          ),
  177.       )
  178.    ) );
  179.  
  180.     // slider vc addon
  181.  
  182.  
  183. }
  184. add_action('vc_before_init','factorian_vc_addons');
  185.  
  186.  
  187. function factorian_toolkit_get_post_as_list( ) {
  188.  
  189.     $args = wp_parse_args( array(
  190.             'post_type'   => 'factorian-slider',   
  191.             'numberposts' => -1,
  192.         ) );
  193.  
  194.     $posts = get_posts($args);
  195.  
  196.  
  197.     $post_options = array(esc_html__('-- Select Slide --', 'factorian-toolkit')=>'');
  198.     if($posts) {
  199.         foreach ($posts as $post) {
  200.             $post_options[ $post->post_title ] = $post->ID;
  201.         }
  202.     }
  203.  
  204.     return $post_options;
  205.  
  206. }
  207.  
  208. // Slider shortcode
  209.  
  210. function factorian_slider_shortcode($atts){
  211.     extract( shortcode_atts( array(
  212.         'count' => 3,
  213.         'slide_id' => '',
  214.         'height' => '590',
  215.         'loop' => 'true',
  216.         'autoPlay' => 'true',
  217.         'autoPlayTimeOut' => 500,
  218.         'pagination' => '',
  219.         'navigation' => 'true',
  220.     ), $atts) );
  221.  
  222.         if ($count == 1) {
  223.             $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'factorian-slider', 'p' => $slide_id ));
  224.         } else {
  225.             $q = new WP_Query(array('posts_per_page' => $count, 'post_type' => 'factorian-slider'));  
  226.         }
  227.  
  228.         if ($count == 1) {
  229.             $factorian_slider ='';
  230.         } else {
  231.     $factorian_slider ='<script>
  232.          jQuery(window).load(function(){
  233.  
  234.           jQuery(".factorian_slider").owlCarousel({
  235.               items: 1,
  236.               mouseDrag: false,
  237.               slideSpeed : '.$autoPlayTimeOut.',
  238.               autoPlay : '.$autoPlay.',
  239.               loop:'.$loop.',
  240.               pagination:'.$pagination.',
  241.               navigation:'.$navigation.',
  242.               navigationText: ["<i class=\'fa fa-angle-left\'></i>","<i class=\'fa fa-angle-right\'></i>"]
  243.              
  244.           });
  245.         });
  246.         </script>';
  247.         }
  248.    
  249.     $factorian_slider .='
  250.    <div id="slide" class="factorian_slider">';
  251.     while($q->have_posts()) : $q->the_post();
  252.         $idd = get_the_ID();
  253.         if(get_post_meta($idd, 'factorian_slider_options', true)) {
  254.             $slide_meta = get_post_meta($idd, 'factorian_slider_options', true);
  255.         } else{
  256.             $slide_meta = array();
  257.         }
  258.  
  259.         if(array_key_exists('over_lay', $slide_meta)){
  260.             $over_lay = $slide_meta['over_lay'];
  261.         }else{
  262.             $over_lay = true;
  263.         }
  264.  
  265.         if(array_key_exists('over_lay_amout', $slide_meta)){
  266.             $over_lay_amout = $slide_meta['over_lay_amout'];
  267.         }else{
  268.             $over_lay_amout = .5;
  269.         }
  270.  
  271.         if(array_key_exists('overlay_color', $slide_meta)){
  272.             $overlay_color = $slide_meta['overlay_color'];
  273.         }else{
  274.             $overlay_color = '#000';
  275.         }
  276.  
  277.         $post_content = get_the_content();
  278.  
  279.     $factorian_slider .='
  280.     <div style="background-image:url('.get_the_post_thumbnail_url($idd, 'large' ).'); height:'.$height.'px;" class="single_slider">';
  281.        
  282.         if ($over_lay == true) {
  283.             $factorian_slider .='<div style="opacity:'.$over_lay_amout.';background-color:'.$overlay_color.'" class="slide_overlay"></div>';
  284.         }
  285.  
  286.         $factorian_slider .='<div class="slider_tabel">
  287.             <div class="slider_tabel_cell">
  288.                 <div class="container">
  289.                     <div class="row">
  290.                         <div class="col-md-6 col-md-offset-6">
  291.                             <h1>'.do_shortcode( get_the_title() ).'</h1>
  292.                             <h3>'.wpautop( $post_content ).'</h3>';
  293.  
  294.                             if(!empty($slide_meta['buttons'])) {
  295.                                 $factorian_slider .='<div class="slide_button">';
  296.                                 foreach ($slide_meta['buttons'] as $button) {
  297.                                     if ($button['button_link'] == 1) {
  298.                                         $btn_link = get_page_link($button['button_link_to_wp_page']);
  299.                                     } else{
  300.                                         $btn_link = $button['button_link_to_external_page'];
  301.                                     }
  302.  
  303.                                     $factorian_slider .='<a href="'.$btn_link.'" class="'.$button['button_type'].'_btn slide_btn_button">'.$button['button_text'].'</a>';
  304.                                 }
  305.                                 $factorian_slider .='</div>';
  306.                             }
  307.  
  308.     $factorian_slider .='</div>
  309.                     </div>
  310.                 </div>
  311.             </div>
  312.         </div>
  313.     </div>';
  314.  
  315.        
  316.     endwhile;
  317.     $factorian_slider.= '</div>';
  318.     wp_reset_query();
  319.  
  320.     return $factorian_slider;
  321.  
  322. }
  323. add_shortcode('factorian_slider', 'factorian_slider_shortcode');  
  324.  
  325.  
  326.  
  327. // Register Slider  Post Type
  328. function factorian_custom_post_resgister() {
  329.     $labels = array(
  330.         'name'                  => _x( 'Factorian Slider', 'Post type general name', 'factorian-sctheme' ),
  331.         'singular_name'         => _x( 'Factorian Slider', 'Post type singular name', 'factorian-sctheme' ),
  332.         'menu_name'             => _x( 'Factorian  Slider', 'Admin Menu text', 'factorian-sctheme' ),
  333.         'name_admin_bar'        => _x( 'Slider', 'Add New on Toolbar', 'factorian-sctheme' ),
  334.         'add_new'               => __( 'Add New Slider', 'factorian-sctheme' ),
  335.         'add_new_item'          => __( 'Add New Slider', 'factorian-sctheme' ),
  336.         'new_item'              => __( 'New Slider', 'factorian-sctheme' ),
  337.         'edit_item'             => __( 'Edit Slider', 'factorian-sctheme' ),
  338.         'view_item'             => __( 'View Slider', 'factorian-sctheme' ),
  339.         'all_items'             => __( 'All Slider', 'factorian-sctheme' ),
  340.         'search_items'          => __( 'Search Slider', 'factorian-sctheme' ),
  341.         'parent_item_colon'     => __( 'Parent Slider:', 'factorian-sctheme' ),
  342.         'not_found'             => __( 'No slider found.', 'factorian-sctheme' ),
  343.     );
  344.  
  345.     $args = array(
  346.         'labels'             => $labels,
  347.         'public'             => flase,
  348.         'show_ui'            => true,
  349.         'supports'           => array( 'title', 'editor', 'thumbnail'),
  350.         'menu_icon'          => 'dashicons-slides'
  351.     );
  352.  
  353.     register_post_type( 'factorian-slider', $args );
  354. }
  355.  
  356. add_action( 'init', 'factorian_custom_post_resgister' );
  357.  
  358.  
  359. wp_enqueue_style( 'factorian-shortcode', PLUGINS_URL('assets/css/shortcode.css', __FILE__));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement