Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Industry toolkit
- Plugin URI: https://aerody.xyz/
- Description: This plugin only used for industry theme.
- Version: 1.0
- Author: Automattic
- Author URI: https://automattic.com/wordpress-plugins/
- License: GPLv2 or later
- */
- /*
- ==========================================================================
- include files
- ==========================================================================
- */
- function industry_toolkit_includes_files(){
- wp_enqueue_style('industry-toolkit', plugins_url('/assets/css/industry-toolkit.css', __FILE__));
- wp_enqueue_style('owl-carousel', plugins_url('/assets/css/owl.carousel.css', __FILE__));
- wp_enqueue_script( 'owl-carousel', plugins_url('/assets/js/owl.carousel.min.js', __FILE__), array( 'jquery' ), '', true );
- }
- add_action('wp_enqueue_scripts', 'industry_toolkit_includes_files');
- /*
- ==========================================================================
- custom post
- ==========================================================================
- */
- function industry_theme_custom_post(){
- register_post_type( 'industry-slide', array(
- 'labels' => array(
- 'name' => __('Slides'),
- 'singular_name' => __('Slide'),
- ),
- 'supports' => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
- 'public' => false,
- 'show_ui' => true
- )
- );
- }
- add_action('init', 'industry_theme_custom_post');
- /*
- ==========================================================================
- postlist shortcode
- ==========================================================================
- */
- function rrfonline_shortcode_query($atts, $content = null){
- extract(shortcode_atts(array(
- 'count' => 2,
- 'type' => 'page'
- ), $atts));
- $args = array(
- 'post_type' => $type,
- 'posts_per_page' => $count
- );
- $get_post = new WP_Query($args);
- $list = '<ul>';
- while($get_post->have_posts()) : $get_post->the_post();
- $list .= '<li>'.get_the_title().'</li>';
- endwhile;
- $list .= '</ul>';
- return $list;
- }
- add_shortcode( 'plist', 'rrfonline_shortcode_query' );
- /*
- ==========================================================================
- section title shortcode
- ==========================================================================
- */
- function industry_sectiontitle($atts, $content = null){
- extract(shortcode_atts(array(
- 'title' => '',
- 'subtitle' => '',
- 'description' => ''
- ), $atts));
- $list = '<div class="industry-section-title text-center">';
- if(!empty($subtitle)){
- $list .= '<h4>'.esc_html($subtitle).'</h4>';
- }
- if(!empty($title)){
- $list .= '<h2>'.esc_html($title).'</h2>';
- }
- if(!empty($description)){
- $list .= ''.wpautop( esc_html($description) ).'';
- }
- $list .= '</div>';
- return $list;
- }
- add_shortcode('industry_sectiontitle', 'industry_sectiontitle');
- /*
- ==========================================================================
- service box shortcode
- ==========================================================================
- */
- function industry_service_box_shortcode($atts, $content = null){
- extract(shortcode_atts(array(
- 'icon_type' => 1,
- 'fa_icon' => 'fa fa-star',
- 'image_icon' => '',
- 'title' => '',
- 'description' => ''
- ), $atts));
- $list = '<div class="industry-service-box text-center">';
- if($icon_type == 1){
- $list .= '<div class="service_icon">
- <i class="'.esc_attr($fa_icon).'"></i>
- </div>';
- }else{
- $service_image_icon_array = wp_get_attachment_image_src( $image_icon, 'thumbnail' );
- $list .= '<div class="service_image_icon">
- <img src="'.esc_url($service_image_icon_array[0]).'" alt="'.esc_html($title).'"/>
- </div>';
- }
- if(!empty($title)){
- $list .= '<h2>'.esc_html($title).'</h2>';
- }
- if(!empty($description)){
- $list .= ''.wpautop( esc_html($description) ).'';
- }
- $list .= '</div>';
- return $list;
- }
- add_shortcode("industry_servicebox", "industry_service_box_shortcode");
- /*
- ==========================================================================
- slides shortcode
- ==========================================================================
- */
- function industry_slides_shortcode($atts, $content = null){
- extract(shortcode_atts(array(
- 'title' => '',
- 'count' => ''
- ), $atts));
- $args = array(
- 'post_type' => 'industry-slide',
- 'posts_per_page' =>-1
- );
- $get_post = new WP_Query($args);
- $slide_random_number = rand(111111, 999999);
- $list = '
- <script>
- jQuery(window).load(function() {
- jQuery("#industry-slides-'.$slide_random_number.'").owlCarousel({
- items: 1,
- loop: true,
- dots: true,
- nav: true,
- autoplay: true,
- navText: ["<i class=\'fa fa-angle-left\'></i>", "<i class=\'fa fa-angle-right\'></i>"]
- });
- });
- </script>
- <div class="industry-slides owl-carousel" id="industry-slides-'.$slide_random_number.'">';
- while($get_post->have_posts()) : $get_post->the_post();
- $post_id = get_the_ID();
- $list .= '
- <div class="industry-single-slide" style="background-image:url('.get_the_post_thumbnail_url($post_id, 'full').')">
- <div class="industry-single-slide-inner">
- <div class="container">
- <div class="row">
- <div class="col-md-6">
- <h2>'.get_the_title($post_id).'</h2>
- '.wpautop(get_the_content($post_id)).'
- </div>
- </div>
- </div>
- </div>
- </div>
- ';
- endwhile;
- wp_reset_query()
- $list .= '</div>';
- return $list;
- }
- add_shortcode("industry_slider", "industry_slides_shortcode");
Advertisement
Add Comment
Please, Sign In to add comment