Advertisement
asif90

service-shortcode.php

Nov 23rd, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. function stock_service_box_shortcode ($atts, $content = null){
  5.  
  6. extract( shortcode_atts( array(
  7. 'title' => '',
  8. 'desc' => '',
  9. 'type' => 1,
  10. 'link_to_page' => '',
  11. 'external_link' => '',
  12. 'link_text' => 'See more',
  13. 'icon_type' => 1,
  14. 'upload_icon' => '',
  15. 'choose_icon' => '',
  16. 'box_background' => '',
  17. ), $atts) );
  18.  
  19. if($type == 1){
  20. $link_source = get_page_link( $link_to_page );
  21. }else{
  22. $link_source = $external_link;
  23. }
  24.  
  25. $box_bg_array = wp_get_attachment_image_src( $box_background, 'medium' );
  26.  
  27. $stock_service_box_markup = '
  28. <div class="stock-service-box">
  29. <div style="background-image: url('.$box_bg_array[0].')" class="stock-service-icon">
  30. <div class="stock-service-table">
  31. <div class="stock-service-tablecell">';
  32.  
  33. if($icon_type == 1){
  34. $service_icon_array = wp_get_attachment_image_src( $upload_icon, 'thumbnail' );
  35. $stock_service_box_markup .= '<img src="'.$service_icon_array[0].'" alt="">';
  36. }else{
  37. $stock_service_box_markup .='<i class="'.$choose_icon.'"></i>';
  38. }
  39.  
  40.  
  41. $stock_service_box_markup .= '
  42. </div>
  43. </div>
  44. </div>
  45.  
  46. <div class="stock-service-content">
  47. <h3>'.$title.'</h3>
  48. '.wpautop($desc).'
  49. <a href="'.$link_source.'" class="service-btn" >'.$link_text.'</a>
  50. </div>
  51. </div>
  52.  
  53. ';
  54. $stock_service_box_markup .= '';
  55.  
  56. return $stock_service_box_markup ;
  57.  
  58. }
  59.  
  60. add_shortcode( 'stock_service_box', 'stock_service_box_shortcode' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement