Advertisement
Sharmin2304

Untitled

Sep 21st, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.39 KB | None | 0 0
  1. <?php
  2.  
  3. add_shortcode( 'imgra_service', 'imgra_service_function' );
  4. function imgra_service_function( $atts ) {
  5.      $result = shortcode_atts( array(
  6.         'service_type' => '',
  7.         'view_post'   => ''
  8.  
  9.  
  10.     ), $atts ) ;
  11.      extract($result);
  12.  
  13. ob_start();
  14.  
  15. ?>
  16.  <?php if ($service_type == 'one'): ?>
  17.  
  18. <!-- Practise Part Start -->
  19.     <section class="practise-part">
  20.         <div class="container">
  21.             <div class="row">
  22.                 <?php
  23.  
  24.                 $service = new WP_Query(array(
  25.                     'post_type'         => 'service',
  26.                     'posts_per_page'    => $view_post
  27.                 )); ?>
  28.                 <!-- Single Practice -->
  29.                 <?php while($service->have_posts()): $service->the_post();
  30.                     $service_meta = get_post_meta(get_the_ID(), 'imgra_service_meta_options', true);
  31.                     $service_icon = isset($service_meta['service_icon']) ? $service_meta['service_icon'] : array();
  32.                 ?>
  33.                 <div class="col-sm-6 col-lg-4">
  34.                     <div class="practise-item">
  35.                        
  36.                         <div class="icon-box"><i class="<?php echo esc_attr($service_icon); ?>"></i></div>
  37.                         <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  38.                             </h2>
  39.                         <p><?php echo wp_trim_words(get_the_content(), 15); ?></p>
  40.                     </div>
  41.                 </div>
  42.                
  43.                 <?php endwhile; ?>
  44.             </div>
  45.         </div>
  46.     </section>
  47.     <!-- Practise Part End -->
  48.       <?php endif ?>
  49.  
  50.     <?php if ($service_type == 'two'): ?>
  51.             <!-- Service Part Start -->
  52.      <section class="practise-3-part pad-bot-50">
  53.         <div class="container">
  54.      
  55.                 <div class="row">
  56.                     <?php $service = new WP_Query(array(
  57.                     'post_type'         => 'service',
  58.                     'posts_per_page'    => $view_post
  59.                 )); ?>
  60.                 <!-- Single Practice -->
  61.                 <?php while($service->have_posts()): $service->the_post();
  62.                 ?>
  63.                 <?php  
  64.                 $service_meta = get_post_meta(get_the_ID(), 'imgra_service_meta_options', true);
  65.                 $service_icon = isset($service_meta['service_icon']) ? $service_meta['service_icon'] : array();
  66.                 $service_read_icon = isset($service_meta['service_readmore_icon']) ? $service_meta['service_readmore_icon'] : array();
  67.                 ?>
  68.                     <div class="col-lg-4 col-sm-6">
  69.                         <div class="practise-3-item">
  70.                             <div class="icon-box"><i class="<?php echo esc_attr($service_icon); ?>"></i></div>
  71.                             <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
  72.                             <?php var_dump($service_type); ?></h5>
  73.                             <p><?php echo wp_trim_words(get_the_content(), 15); ?></p>
  74.                             <a href="<?php the_permalink(); ?>">→</a>
  75.                         </div>
  76.                     </div>
  77.          
  78.                <?php endwhile; ?>
  79.                 </div>
  80.      
  81.         </div>
  82.     </section>
  83.     <!-- Service Part End -->
  84.  
  85.     <?php endif ?>
  86.  
  87.  <?php if ($service_type == 'three'): ?>
  88.  
  89.             <!-- Prictise area Part start -->
  90.         <section class="practise-4-part">
  91.             <div class="container">
  92.                 <div class="row">
  93.                     <?php $service = new WP_Query(array(
  94.                     'post_type'         => 'service',
  95.                     'posts_per_page'    => $view_post
  96.                 )); ?>
  97.                 <?php while($service->have_posts()): $service->the_post();?>
  98.               <!-- Single team -->
  99.                     <div class="col-sm-6 col-lg-4">
  100.                         <div class="sin-practice-4">
  101.                             <?php the_post_thumbnail(); ?>
  102.                             <span>1</span>
  103.                             <div class="pra-four-inner">
  104.                              <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
  105.                              <p><?php echo wp_trim_words(get_the_content(), 25); ?></p>
  106.                            
  107.                         </div>
  108.                     </div>
  109.                 </div>
  110.  
  111.             <?php endwhile; ?>
  112.     </div>
  113.     </div>
  114.     </section>
  115. <!-- Prictise area Part End -->
  116. <?php endif ?>
  117.  
  118. <?php if ( $service_type == 'four' ): ?>
  119.  
  120.         <!-- Prictise area Part start -->
  121.     <section class="practise-4-part pad-bot-30">
  122.         <div class="container">
  123.             <div class="row">
  124.                 <?php $service = new WP_Query(array(
  125.                     'post_type'         => 'service',
  126.                     'posts_per_page'    => $view_post
  127.                 )); ?>
  128.                 <?php
  129.  
  130.                 while($service->have_posts()): $service->the_post();
  131.  
  132.                 $service_meta = get_post_meta(get_the_ID(), 'imgra_service_meta_options', true);
  133.                 $service_btn_txt = isset($service_meta['service_button_text']) ? $service_meta['service_button_text'] : array();?>
  134.                 <!-- Single team -->
  135.                 <div class="col-sm-6 col-lg-4">
  136.                     <div class="sin-practice-4">
  137.                         <?php the_post_thumbnail(); ?>
  138.                         <div class="pra-four-inner">
  139.                          <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
  140.                          <p><?php echo wp_trim_words(get_the_content(), 25); ?></p>
  141.                          <div class="read-more4">
  142.                             <a href="<?php the_permalink(); ?>" class="line-style"><?php echo esc_html($service_btn_txt); ?></a>
  143.                         </div>
  144.  
  145.                     </div>
  146.                 </div>
  147.             </div>
  148.  
  149.  
  150.     <?php endwhile; ?>
  151.  
  152. </div>
  153. </div>
  154. </section>
  155. <!-- Prictise area Part End -->
  156.    
  157. <?php endif ?>
  158.  
  159. <?php if ($service_type == 'five'): ?>
  160.     <!-- Practise Part Start -->
  161.     <section class="practise-4-part pad-bot-30">
  162.         <div class="container">
  163.             <div class="row">
  164.                 <?php $service = new WP_Query(array(
  165.                     'post_type'         => 'service',
  166.                     'posts_per_page'    => $view_post
  167.                 )); ?>
  168.                 <?php
  169.  
  170.                 while($service->have_posts()): $service->the_post();
  171.  
  172.                 $service_meta = get_post_meta(get_the_ID(), 'imgra_service_meta_options', true);
  173.                 $service_btn_txt = isset($service_meta['service_button_text']) ? $service_meta['service_button_text'] : array();?>
  174.                 <!-- Single team -->
  175.                 <div class="col-sm-6 col-lg-4">
  176.                     <div class="sin-practice-4">
  177.                         <?php the_post_thumbnail(); ?>
  178.                         <div class="pra-four-inner">
  179.                          <h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
  180.                          <p><?php echo wp_trim_words(get_the_content(), 25); ?></p>
  181.                          <div class="read-more4">
  182.                             <a href="<?php the_permalink(); ?>" class="line-style"><?php echo esc_html($service_btn_txt); ?></a>
  183.                         </div>
  184.  
  185.                     </div>
  186.                 </div>
  187.             </div>
  188.  
  189.  
  190.     <?php endwhile; ?>
  191.  
  192. </div>
  193. </div>
  194. </section>
  195.     <!-- Practise Part End -->
  196. <?php endif ?>
  197.  
  198.  
  199.  
  200. <?php
  201. return ob_get_clean();
  202. }
  203.  
  204. add_action( 'vc_before_init', 'imgra_service_el' );
  205. function imgra_service_el() {
  206.     vc_map( array(
  207.         "name" => esc_html( "Imgra Service", "imgra" ),
  208.         "base" => "imgra_service",
  209.         "category" => esc_html( "Imgra Helper", "imgra"),
  210.         "params" => array(
  211.             array(
  212.                 'type'          => 'textfield',
  213.                 'heading'       =>  esc_html( 'Enter Service Post No', 'imgra' ),
  214.                 'param_name'    => 'view_post',
  215.  
  216.                     ),
  217.  
  218.             array(
  219.                 'type'          => 'dropdown',
  220.                 'heading'       =>  esc_html( 'Select Service Type', 'imgra' ),
  221.                 'param_name'    => 'service_type',
  222.                 'value'         => array(
  223.                     'Service Four'  => 'one',
  224.                     'Service One'   => 'two',
  225.                     'Service Two'   => 'three',
  226.                     'Service Three' => 'four',
  227.                     'Service Five'  => 'five'
  228.                     ),
  229.  
  230.  
  231.  
  232.             ),
  233.            
  234.         )
  235.     )
  236. );
  237.  
  238. }
  239.  
  240.  
  241.  ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement