Advertisement
Uranbold

service.php

Mar 24th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. <?php
  2.  
  3. /* ================================================================================== */
  4. /* Service Shortcode
  5. /* ================================================================================== */
  6. if (!function_exists('shortcode_tw_service')) {
  7. function shortcode_tw_service($atts, $content) {
  8. $atts = shortcode_atts(array(
  9. 'size' => 'col-md-3',
  10. 'layout_size' => 'col-md-12',
  11. 'class' => '',
  12. 'element_padding' => '',
  13. 'element_color' => '',
  14. 'element_dark_light' => 'light',
  15. 'animation' => 'none',
  16. 'animation_delay' => '',
  17. // ----------------
  18. "service_style" => "top",
  19. "service_hover" => "none",
  20. "title_line" => "true",
  21. "rotate"=>"false",
  22. "thumb_type" => "fi",
  23. "service_thumb_width" => "20",
  24. "service_thumb" => "",
  25. "add_thumb" => "Upload",
  26. "service_title" => "Your Service Title",
  27. "more_text" => "Read More",
  28. "more_url" => "",
  29. "more_target" => "_blank",
  30. // Font icon
  31. "fi" => "",
  32. "fi_size" => "30",
  33. "fi_padding" => "20",
  34. "fi_color" => "#aaaaaa",
  35. "fi_bg_color" => "",
  36. "fi_border_color" => "#aaaaaa",
  37. "fi_rounded" => "6",
  38. "fi_rounded_size" => "3",
  39. "fi_box_shadow" => "false",
  40. "fi_rotate" => "false",
  41. "fi_icon" => "fa-glass",
  42. // Circle Chart
  43. "cc" => "",
  44. "cc_type" => "text",
  45. 'cc_line_cap' => 'butt',
  46. "cc_line_width" => "8",
  47. "cc_text" => "80%",
  48. "cc_percent" => "80",
  49. "cc_size" => "100",
  50. "cc_font_size" => "30",
  51. "cc_padding" => "0",
  52. "cc_color" => "#3B5998",
  53. "cc_track_color" => "#f9f9f9",
  54. "cc_icon" => "fa-star",
  55. ), $atts);
  56.  
  57. $class=$thumb=$styleDesc=$marginDesc='';
  58. $thumbType = isset($atts['thumb_type']) ? $atts['thumb_type'] : 'fi';
  59. $marginBox = $marginIcon = '';
  60. $iconHeight = ($thumbType === 'fi' ? ($atts['fi_size'] + $atts['fi_padding'] + $atts['fi_padding'] + ($atts['fi_rounded'] * 2)) : ($thumbType === 'image' ? intval($atts['service_thumb_width']) : intval($atts['cc_size'])));
  61. $iconHeightHalf = $iconHeight/2;
  62. $class = $atts['service_style'].'-service';
  63. if ($atts['service_style'] === 'left'){
  64. $styleDesc = 'desc_unstyle';
  65. $marginDesc = 'margin-left:' . ($thumbType === 'fi' ? ($iconHeight + 25) : ($thumbType === 'image' ? ($iconHeight + 25) : ($iconHeight + 15))) . 'px;';
  66. // $marginBox = 'margin-left:' . $iconHeightHalf . 'px;';
  67. // $marginIcon = 'margin-left:-' . $iconHeightHalf . 'px;';
  68. // if($atts['service_hover']==='style_2')
  69. // $marginIcon = 'margin-left:-' . $iconHeightHalf . 'px;margin-top:-' . $iconHeightHalf . 'px;';
  70. }
  71. elseif ($atts['service_style'] === 'right') {
  72. $styleDesc = 'desc_unstyle';
  73. $marginDesc = 'margin-right:' . ($thumbType === 'fi' ? ($iconHeightHalf + 25) : ($thumbType === 'image' ? ($iconHeightHalf + 30) : ($iconHeightHalf + 15))) . 'px;';
  74. } else {
  75. $marginBox = 'margin-top:' . $iconHeightHalf . 'px;';
  76. $marginIcon = 'margin-top:-' . $iconHeightHalf . 'px;';
  77. }
  78. if ($thumbType === 'image') {
  79. $thumb = isset($atts['service_thumb']) ? '<img title="' . esc_attr($atts['service_title']) . '" width="' . esc_attr($atts['service_thumb_width']) . '" src="' . esc_url($atts['service_thumb']) . '" alt="' . esc_attr($atts['service_title']) . '" />' : '';
  80. } elseif ($thumbType === 'fi') {
  81. $thumb = do_shortcode('[tw_fonticon size="waves-shortcode" fi_size="' . $atts['fi_size'] . '" fi_padding="' . $atts['fi_padding'] . '" fi_color="' . $atts['fi_color'] . '" fi_bg_color="' . $atts['fi_bg_color'] . '" fi_border_color="' . $atts['fi_border_color'] . '" fi_rounded="' . $atts['fi_rounded'] . '" fi_rounded_size="' . $atts['fi_rounded_size'] . '" fi_box_shadow="' . $atts['fi_box_shadow'] . '" fi_rotate="' . $atts['fi_rotate'] . '" fi_icon="' . $atts['fi_icon'] . '"]');
  82. } elseif ($thumbType === 'cc') {
  83. $thumb = do_shortcode('[tw_chart_circle size="waves-shortcode" cc_type="' . $atts['cc_type'] . '" cc_line_cap="' . $atts['cc_line_cap'] . '" cc_line_width="' . $atts['cc_line_width'] . '" cc_text="' . $atts['cc_text'] . '" cc_percent="' . $atts['cc_percent'] . '" cc_size="' . $atts['cc_size'] . '" cc_font_size="' . $atts['cc_font_size'] . '" cc_padding="' . $atts['cc_padding'] . '" cc_color="' . $atts['cc_color'] . '" cc_track_color="' . $atts['cc_track_color'] . '" cc_icon="' . $atts['cc_icon'] . '"]');
  84. }
  85. if (isMobile() && !tw_option('moblile_animation')) {
  86. $atts['item_animation'] = 'none';
  87. }
  88. if(!empty($atts['service_hover'])){
  89. $class.=' '.$atts['service_hover'];
  90. }
  91. if($atts['title_line']!=='true'){
  92. $class.=' no-titleline';
  93. }
  94.  
  95. $output = waves_item($atts, '', '', '');
  96. $output .= '<div class="tw-service-box ' . $class . '" style="'.$marginBox.'">';
  97. $output .= '<div class="tw-service-icon" style="' . $marginIcon . '">' . $thumb . '</div>';
  98. $output .= '<div class="tw-service-content ' . $styleDesc . '" style="' . $marginDesc . '">';
  99. if ($atts['service_title'] != ''){
  100. $output .= '<h3><a href="' . esc_url($atts['more_url']) . '" target="' . esc_attr($atts['more_target']) . '">' . esc_html($atts['service_title']) . '</a></h3>';
  101. }
  102. $output .= '<div class="service-title-sep"></div>';
  103. if ($content != ''){
  104. $output .= '<p>' . do_shortcode($content) . '</p>';
  105. }
  106. if (!empty($atts['more_url'])){
  107. $output .= '<div class="service-title-sep last"></div>';
  108. $output .= '<a class="more" href="' . esc_url($atts['more_url']) . '" target="' . esc_attr($atts['more_target']) . '">' . esc_html($atts['more_text']) . '</a>';
  109. }
  110. $output .= '</div>';
  111. $output .= "</div>";
  112. $output .= "</div>";
  113. return $output;
  114. }
  115. }
  116. add_shortcode('tw_service', 'shortcode_tw_service');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement