kalponikoronno

industry-toolkit.php

Oct 31st, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.29 KB | None | 0 0
  1. <?php
  2.  
  3. /*
  4. Plugin Name: Industry toolkit
  5. Plugin URI: https://aerody.xyz/
  6. Description: This plugin only used for industry theme.
  7. Version: 1.0
  8. Author: Automattic
  9. Author URI: https://automattic.com/wordpress-plugins/
  10. License: GPLv2 or later
  11. */
  12.  
  13. /*
  14. ==========================================================================
  15. include files
  16. ==========================================================================
  17. */
  18. function industry_toolkit_includes_files(){
  19.     wp_enqueue_style('industry-toolkit', plugins_url('/assets/css/industry-toolkit.css', __FILE__));
  20.     wp_enqueue_style('owl-carousel', plugins_url('/assets/css/owl.carousel.css', __FILE__));
  21.    
  22.    
  23.     wp_enqueue_script( 'owl-carousel', plugins_url('/assets/js/owl.carousel.min.js', __FILE__), array( 'jquery' ), '', true );
  24. }
  25. add_action('wp_enqueue_scripts', 'industry_toolkit_includes_files');
  26.  
  27. /*
  28. ==========================================================================
  29. custom post
  30. ==========================================================================
  31. */
  32.  
  33. function industry_theme_custom_post(){
  34.     register_post_type( 'industry-slide', array(
  35.             'labels' => array(
  36.                 'name' => __('Slides'),
  37.                 'singular_name' => __('Slide'),
  38.             ),
  39.             'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
  40.             'public' => false,
  41.             'show_ui' => true
  42.         )
  43.     );
  44.    
  45. }
  46. add_action('init', 'industry_theme_custom_post');
  47.  
  48.  
  49. /*
  50. ==========================================================================
  51. postlist shortcode
  52. ==========================================================================
  53. */
  54. function rrfonline_shortcode_query($atts, $content = null){
  55.  
  56.     extract(shortcode_atts(array(
  57.         'count' => 2,
  58.         'type' => 'page'
  59.     ), $atts));
  60.  
  61.     $args = array(
  62.         'post_type' => $type,
  63.         'posts_per_page' => $count
  64.     );
  65.  
  66.     $get_post = new WP_Query($args);
  67.  
  68.     $list = '<ul>';
  69.     while($get_post->have_posts()) : $get_post->the_post();
  70.  
  71.     $list .= '<li>'.get_the_title().'</li>';
  72.  
  73.     endwhile;
  74.     $list .= '</ul>';
  75.  
  76.     return $list;
  77. }
  78. add_shortcode( 'plist', 'rrfonline_shortcode_query' );
  79.  
  80.  
  81. /*
  82. ==========================================================================
  83. section title shortcode
  84. ==========================================================================
  85. */
  86. function industry_sectiontitle($atts, $content = null){
  87.    
  88.     extract(shortcode_atts(array(
  89.         'title' => '',
  90.         'subtitle' => '',
  91.         'description' => ''
  92.     ), $atts));
  93.    
  94.     $list = '<div class="industry-section-title text-center">';
  95.    
  96.     if(!empty($subtitle)){
  97.         $list .= '<h4>'.esc_html($subtitle).'</h4>';
  98.     }
  99.    
  100.     if(!empty($title)){
  101.         $list .= '<h2>'.esc_html($title).'</h2>';
  102.     }
  103.    
  104.     if(!empty($description)){
  105.         $list .= ''.wpautop( esc_html($description) ).'';
  106.     }
  107.    
  108.     $list .= '</div>';
  109.    
  110.     return $list;
  111.    
  112. }
  113. add_shortcode('industry_sectiontitle', 'industry_sectiontitle');
  114.  
  115. /*
  116. ==========================================================================
  117. service box shortcode
  118. ==========================================================================
  119. */
  120. function industry_service_box_shortcode($atts, $content = null){
  121.    
  122.     extract(shortcode_atts(array(
  123.         'icon_type' => 1,
  124.         'fa_icon' => 'fa fa-star',
  125.         'image_icon' => '',
  126.         'title' => '',
  127.         'description' => ''
  128.     ), $atts));
  129.    
  130.     $list = '<div class="industry-service-box text-center">';
  131.    
  132.     if($icon_type == 1){
  133.         $list .= '<div class="service_icon">
  134.            <i class="'.esc_attr($fa_icon).'"></i>
  135.        </div>';
  136.     }else{
  137.        
  138.         $service_image_icon_array = wp_get_attachment_image_src( $image_icon, 'thumbnail' );
  139.         $list .= '<div class="service_image_icon">
  140.            <img src="'.esc_url($service_image_icon_array[0]).'" alt="'.esc_html($title).'"/>
  141.        </div>';
  142.     }
  143.    
  144.     if(!empty($title)){
  145.         $list .= '<h2>'.esc_html($title).'</h2>';
  146.     }
  147.    
  148.     if(!empty($description)){
  149.         $list .= ''.wpautop( esc_html($description) ).'';
  150.     }
  151.    
  152.     $list .= '</div>';
  153.    
  154.     return $list;
  155. }
  156. add_shortcode("industry_servicebox", "industry_service_box_shortcode");
  157.  
  158. /*
  159. ==========================================================================
  160. slides shortcode
  161. ==========================================================================
  162. */
  163. function industry_slides_shortcode($atts, $content = null){
  164.    
  165.     extract(shortcode_atts(array(
  166.         'title' => '',
  167.         'count' => ''
  168.     ), $atts));
  169.    
  170.     $args = array(
  171.         'post_type' => 'industry-slide',
  172.         'posts_per_page' =>-1
  173.     );
  174.     $get_post = new WP_Query($args);
  175.    
  176.     $slide_random_number = rand(111111, 999999);
  177.    
  178.     $list = '
  179.    <script>
  180.        jQuery(window).load(function() {
  181.            jQuery("#industry-slides-'.$slide_random_number.'").owlCarousel({
  182.                items: 1,
  183.                loop: true,
  184.                dots: true,
  185.                nav: true,
  186.                autoplay: true,
  187.                navText: ["<i class=\'fa fa-angle-left\'></i>", "<i class=\'fa fa-angle-right\'></i>"]
  188.            });                  
  189.         });
  190.    </script>
  191.    
  192.    <div class="industry-slides owl-carousel" id="industry-slides-'.$slide_random_number.'">';
  193.  
  194.         while($get_post->have_posts()) : $get_post->the_post();
  195.             $post_id = get_the_ID();
  196.  
  197.             $list .= '
  198.                <div class="industry-single-slide" style="background-image:url('.get_the_post_thumbnail_url($post_id, 'full').')">
  199.                    <div class="industry-single-slide-inner">
  200.                        <div class="container">
  201.                            <div class="row">
  202.                                <div class="col-md-6">
  203.                                    <h2>'.get_the_title($post_id).'</h2>
  204.                                    '.wpautop(get_the_content($post_id)).'
  205.                                </div>
  206.                            </div>
  207.                        </div>
  208.                    </div>
  209.                </div>
  210.            ';
  211.         endwhile;
  212.         wp_reset_query()
  213.     $list .= '</div>';
  214.    
  215.     return $list;
  216. }
  217. add_shortcode("industry_slider", "industry_slides_shortcode");
Advertisement
Add Comment
Please, Sign In to add comment