Guest User

Untitled

a guest
Sep 15th, 2020
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.14 KB | None | 0 0
  1. <?php
  2. /**
  3. * this is the default block template
  4. * Class td_block_header_18
  5. */
  6. class td_block_template_18 extends td_block_template {
  7.  
  8.  
  9.  
  10. /**
  11. * renders the CSS for each block, each template may require a different css generated by the theme
  12. * @return string CSS the rendered css and <style> block
  13. */
  14. function get_css() {
  15.  
  16.  
  17. // $unique_block_class - the unique class that is on the block. use this to target the specific instance via css
  18. $unique_block_class = $this->get_unique_block_class();
  19.  
  20. // the css that will be compiled by the block, <style> - will be removed by the compiler
  21. $raw_css = "
  22. <style>
  23.  
  24. /* @header_color_a */
  25. .$unique_block_class .td-block-title > span,
  26. .$unique_block_class .td-block-title > a {
  27. background: #06d3d5 !important;
  28. background: -moz-linear-gradient(-68deg, @header_color_a 30%, @header_color_b 80%) !important;
  29. background: -webkit-linear-gradient(-68deg, @header_color_a 30%,@header_color_b 80%) !important;
  30. background: linear-gradient(156deg, @header_color_a 30%,@header_color_b 80%) !important;
  31. -webkit-background-clip: text !important;
  32. -webkit-text-fill-color: transparent;
  33. }
  34.  
  35.  
  36. /* @speech_bubble_color */
  37. .$unique_block_class .td-block-speech-bubble {
  38. background-color: @speech_bubble_color !important;
  39. }
  40. .$unique_block_class .td-block-speech-bubble:before {
  41. border-color: @speech_bubble_color transparent transparent transparent !important;
  42. }
  43.  
  44. /* @subtitle_text_color */
  45. .$unique_block_class .td-block-subtitle {
  46. color: @subtitle_text_color !important;
  47. }
  48.  
  49. /* @subtitle_border_color */
  50. .$unique_block_class .td-block-subtitle:before,
  51. .$unique_block_class .td-block-subtitle:after {
  52. background-color: @subtitle_border_color !important;
  53. }
  54.  
  55. /* @accent_text_color */
  56. .$unique_block_class .td_module_wrap:hover .entry-title a,
  57. .$unique_block_class .td_quote_on_blocks,
  58. .$unique_block_class .td-opacity-cat .td-post-category:hover,
  59. .$unique_block_class .td-opacity-read .td-read-more a:hover,
  60. .$unique_block_class .td-opacity-author .td-post-author-name a:hover,
  61. .$unique_block_class .td-instagram-user a,
  62. .$unique_block_class .td-pulldown-filter-item .td-cur-simple-item,
  63. .$unique_block_class .td-pulldown-filter-link:hover {
  64. color: @accent_text_color !important;
  65. }
  66.  
  67. .$unique_block_class .td-next-prev-wrap a:hover,
  68. .$unique_block_class .td-load-more-wrap a:hover {
  69. background-color: @accent_text_color !important;
  70. border-color: @accent_text_color !important;
  71. }
  72.  
  73. .$unique_block_class .td-read-more a,
  74. .$unique_block_class .td-weather-information:before,
  75. .$unique_block_class .td-weather-week:before,
  76. .$unique_block_class .td-exchange-header:before,
  77. .td-footer-wrapper .$unique_block_class .td-post-category,
  78. .$unique_block_class .td-post-category:hover {
  79. background-color: @accent_text_color !important;
  80. }
  81. </style>
  82. ";
  83.  
  84. $td_css_compiler = new td_css_compiler($raw_css);
  85. $td_css_compiler->load_setting_raw('header_color', $this->get_att('header_color'));
  86. $td_css_compiler->load_setting_raw('header_text_color', $this->get_att('header_text_color'));
  87. $td_css_compiler->load_setting_raw('header_color_a', $this->get_att('header_text_color_a'));
  88. $td_css_compiler->load_setting_raw('header_color_b', $this->get_att('header_text_color_b'));
  89.  
  90. //color one is empty
  91. if (empty($td_css_compiler->settings['header_color_a']) && !empty($td_css_compiler->settings['header_color_b'])) {
  92. $td_css_compiler->load_setting_raw('header_color_a', '#06d3d5');
  93. }
  94. //color two is empty
  95. if (!empty($td_css_compiler->settings['header_color_a']) && empty($td_css_compiler->settings['header_color_b'])) {
  96. $td_css_compiler->load_setting_raw('header_color_b', '#2a81cb');
  97. }
  98.  
  99. $td_css_compiler->load_setting_raw('speech_bubble_color', $this->get_att('speech_bubble_color'));
  100. $td_css_compiler->load_setting_raw('subtitle_text_color', $this->get_att('subtitle_text_color'));
  101. $td_css_compiler->load_setting_raw('subtitle_border_color', $this->get_att('subtitle_border_color'));
  102. $td_css_compiler->load_setting_raw('accent_text_color', $this->get_att('accent_text_color'));
  103.  
  104. $compiled_style = $td_css_compiler->compile_css();
  105.  
  106.  
  107. return $compiled_style;
  108. }
  109.  
  110.  
  111. /**
  112. * renders the block title
  113. * @return string HTML
  114. */
  115. function get_block_title() {
  116.  
  117. $custom_title = $this->get_att('custom_title');
  118. $custom_url = $this->get_att('custom_url');
  119. $title_tag = 'h4';
  120.  
  121. // title_tag used only on Title shortcode
  122. $block_title_tag = $this->get_att('title_tag');
  123. if(!empty($block_title_tag)) {
  124. $title_tag = $block_title_tag ;
  125. }
  126.  
  127. if (empty($custom_title)) {
  128. $td_pull_down_items = $this->get_td_pull_down_items();
  129. if (empty($td_pull_down_items)) {
  130. //no title selected and we don't have pulldown items
  131. return '';
  132. }
  133. // we don't have a title selected BUT we have pull down items! we cannot render pulldown items without a block title
  134. $custom_title = 'Block title';
  135. }
  136.  
  137. // speech bubble text
  138. $speech_bubble = '';
  139. $speech_bubble_text = $this->get_att('speech_bubble_text');
  140. if (!empty($speech_bubble_text)) {
  141. $speech_bubble = '<span class="td-block-speech-bubble">' . esc_html($speech_bubble_text) . '</span>';
  142. }
  143.  
  144. // subtitle text
  145. $subtitle = '';
  146. $subtitle_text = $this->get_att('subtitle_text');
  147. if (!empty($subtitle_text)) {
  148. $subtitle = '<div class="td-block-subtitle">' . esc_html($subtitle_text) . '</div>';
  149. }
  150.  
  151. // there is a custom title
  152. $buffy = '';
  153. $buffy .= '<' . $title_tag . ' class="block-title td-block-title">';
  154. if (!empty($custom_url)) {
  155. $buffy .= '<a href="' . esc_url($custom_url) . '">' . esc_html($custom_title) . '' . $speech_bubble . '</span></a>';
  156. } else {
  157. $buffy .= '<span>' . esc_html($custom_title) . '' . $speech_bubble . '</span>';
  158. }
  159. $buffy .= $subtitle;
  160. $buffy .= '</' . $title_tag . '>';
  161. return $buffy;
  162. }
  163.  
  164.  
  165. /**
  166. * renders the filter of the block
  167. * @return string
  168. */
  169. function get_pull_down_filter() {
  170. $buffy = '';
  171.  
  172. $td_pull_down_items = $this->get_td_pull_down_items();
  173.  
  174. if (empty($td_pull_down_items)) {
  175. return '';
  176. }
  177.  
  178. $buffy .= '<div class="td-wrapper-pulldown-filter">';
  179. $buffy .= '<div class="td-pulldown-filter-display-option">';
  180.  
  181.  
  182. //show the default display value
  183. $buffy .= '<div id="td-pulldown-' . $this->get_block_uid() . '-val"><span>';
  184. $buffy .= $td_pull_down_items[0]['name'] . ' </span><i class="td-icon-down"></i>';
  185. $buffy .= '</div>';
  186.  
  187. //builde the dropdown
  188. $buffy .= '<ul class="td-pulldown-filter-list">';
  189. foreach ($td_pull_down_items as $item) {
  190. $buffy .= '<li class="td-pulldown-filter-item"><a class="td-pulldown-filter-link" id="' . td_global::td_generate_unique_id() . '" data-td_filter_value="' . $item['id'] . '" data-td_block_id="' . $this->get_block_uid() . '" href="#">' . $item['name'] . '</a></li>';
  191. }
  192. $buffy .= '</ul>';
  193.  
  194. $buffy .= '</div>'; // /.td-pulldown-filter-display-option
  195. $buffy .= '</div>';
  196.  
  197. return $buffy;
  198. }
  199. }
Advertisement
Add Comment
Please, Sign In to add comment