Guest User

Untitled

a guest
Oct 18th, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.13 KB | None | 0 0
  1. <?php
  2. /**
  3. * this is the default block template
  4. * Class td_block_header_1
  5. */
  6. class td_block_template_1 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. // $unique_block_class - the unique class that is on the block. use this to target the specific instance via css
  17. $unique_block_class = $this->get_unique_block_class();
  18.  
  19. // the css that will be compiled by the block, <style> - will be removed by the compiler
  20. $raw_css = "
  21. <style>
  22.  
  23. /* @header_color */
  24. .$unique_block_class .td_module_wrap:hover .entry-title a,
  25. .$unique_block_class .td-load-more-wrap a:hover,
  26. .$unique_block_class .td_quote_on_blocks,
  27. .$unique_block_class .td-wrapper-pulldown-filter .td-pulldown-filter-display-option:hover,
  28. .$unique_block_class .td-wrapper-pulldown-filter a.td-pulldown-filter-link:hover,
  29. .$unique_block_class .td-instagram-user a {
  30. color: @header_color;
  31. }
  32.  
  33. .$unique_block_class .td-next-prev-wrap a:hover i {
  34. background-color: @header_color;
  35. border-color: @header_color;
  36. }
  37.  
  38. .$unique_block_class .td_module_wrap .td-post-category:hover,
  39. .$unique_block_class .td-trending-now-title,
  40. .$unique_block_class .td-weather-information:before,
  41. .$unique_block_class .td-weather-week:before,
  42. .$unique_block_class .td-exchange-header:before,
  43. .$unique_block_class .block-title > a:after,
  44. .$unique_block_class .block-title > span:after {
  45. background-color: @header_color;
  46. }
  47.  
  48. /* @header_text_color */
  49. .$unique_block_class .td-trending-now-title,
  50. .$unique_block_class .block-title span,
  51. .$unique_block_class .block-title a {
  52. color: @header_text_color;
  53. }
  54.  
  55. </style>
  56. ";
  57.  
  58. $td_css_compiler = new td_css_compiler($raw_css);
  59. $td_css_compiler->load_setting_raw('header_color', $this->get_att('header_color'));
  60. $td_css_compiler->load_setting_raw('header_text_color', $this->get_att('header_text_color'));
  61.  
  62. $compiled_style = $td_css_compiler->compile_css();
  63.  
  64.  
  65. return $compiled_style;
  66. }
  67.  
  68.  
  69. /**
  70. * renders the block title
  71. * @return string HTML
  72. */
  73. function get_block_title() {
  74.  
  75.  
  76. $custom_title = $this->get_att('custom_title');
  77. $custom_url = $this->get_att('custom_url');
  78. $title_tag = 'h4';
  79.  
  80. // title_tag used only on Title shortcode
  81. $block_title_tag = $this->get_att('title_tag');
  82. if(!empty($block_title_tag)) {
  83. $title_tag = $block_title_tag ;
  84. }
  85.  
  86. if (empty($custom_title)) {
  87. if ($this->get_td_pull_down_items() === false) {
  88. //no title selected and we don't have pulldown items
  89. return '';
  90. }
  91. // we don't have a title selected BUT we have pull down items! we cannot render pulldown items without a block title
  92. $custom_title = 'Block title';
  93. }
  94.  
  95.  
  96.  
  97. // there is a custom title
  98. $buffy = '';
  99. $buffy .= '<' . $title_tag . ' class="block-title">';
  100. if (!empty($custom_url)) {
  101. $buffy .= '<a href="' . esc_url($custom_url) . '" class="td-pulldown-size">' . esc_html($custom_title) . '</a>';
  102. } else {
  103. $buffy .= '<span class="td-pulldown-size">' . esc_html($custom_title) . '</span>';
  104. }
  105. $buffy .= '</' . $title_tag . '>';
  106. return $buffy;
  107. }
  108.  
  109.  
  110. /**
  111. * renders the filter of the block
  112. * @return string
  113. */
  114. function get_pull_down_filter() {
  115. $buffy = '';
  116.  
  117. $td_pull_down_items = $this->get_td_pull_down_items();
  118.  
  119. if ($td_pull_down_items === false) {
  120. return '';
  121. }
  122.  
  123. $buffy .= '<div class="td-wrapper-pulldown-filter">';
  124. $buffy .= '<div class="td-pulldown-filter-display-option">';
  125.  
  126.  
  127. //show the default display value
  128. $buffy .= '<div id="td-pulldown-' . $this->get_block_uid() . '-val"><span>';
  129. $buffy .= $td_pull_down_items[0]['name'] . ' </span><i class="td-icon-menu-down"></i>';
  130. $buffy .= '</div>';
  131.  
  132. //builde the dropdown
  133. $buffy .= '<ul class="td-pulldown-filter-list">';
  134. foreach ($td_pull_down_items as $item) {
  135. $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>';
  136. }
  137. $buffy .= '</ul>';
  138.  
  139. $buffy .= '</div>'; // /.td-pulldown-filter-display-option
  140. $buffy .= '</div>';
  141.  
  142. return $buffy;
  143. }
  144. }
Advertisement
Add Comment
Please, Sign In to add comment