/wp-content/plugins/elementskit-lite/widgets/business-hours/business-hours.php

https://gitlab.com/campus-academy/krowkaramel · PHP · 393 lines · 338 code · 52 blank · 3 comment · 5 complexity · bd270fc3dc3f9e091384aa4ecc348932 MD5 · raw file

  1. <?php
  2. namespace Elementor;
  3. use \Elementor\ElementsKit_Widget_Business_Hours_Handler as Handler;
  4. use \ElementsKit_Lite\Modules\Controls\Controls_Manager as ElementsKit_Controls_Manager;
  5. if ( ! defined( 'ABSPATH' ) ) exit;
  6. class ElementsKit_Widget_Business_Hours extends Widget_Base {
  7. use \ElementsKit_Lite\Widgets\Widget_Notice;
  8. public $base;
  9. public function get_name() {
  10. return Handler::get_name();
  11. }
  12. public function get_title() {
  13. return Handler::get_title();
  14. }
  15. public function get_icon() {
  16. return Handler::get_icon();
  17. }
  18. public function get_categories() {
  19. return Handler::get_categories();
  20. }
  21. public function get_help_url() {
  22. return '';
  23. }
  24. protected function register_controls() {
  25. $this->start_controls_section(
  26. 'ekit_btn_section_content',
  27. array(
  28. 'label' => esc_html__( 'Content', 'elementskit-lite' ),
  29. )
  30. );
  31. $repeater = new Repeater();
  32. $repeater->add_control(
  33. 'ekit_business_day',
  34. [
  35. 'label' => esc_html__( 'Day', 'elementskit-lite' ),
  36. 'type' => Controls_Manager::TEXT,
  37. 'default' => esc_html__( 'Saturday', 'elementskit-lite' ),
  38. ]
  39. );
  40. $repeater->add_control(
  41. 'ekit_business_time',
  42. [
  43. 'label' => esc_html__( 'Time', 'elementskit-lite' ),
  44. 'type' => Controls_Manager::TEXTAREA,
  45. 'default' => esc_html__( '9:00 AM - 6:00 PM', 'elementskit-lite' ),
  46. ]
  47. );
  48. $repeater->add_control(
  49. 'ekit_highlight_this_day',
  50. [
  51. 'label' => esc_html__( 'Hight Light this day', 'elementskit-lite' ),
  52. 'type' => Controls_Manager::SWITCHER,
  53. 'return_value' => 'yes',
  54. 'default' => 'no',
  55. 'separator' => 'before',
  56. ]
  57. );
  58. $repeater->add_responsive_control(
  59. 'ekit_single_business_day_color',
  60. [
  61. 'label' => esc_html__( 'Day Color', 'elementskit-lite' ),
  62. 'type' => Controls_Manager::COLOR,
  63. 'default' => '#fa2d2d',
  64. 'selectors' => [
  65. '{{WRAPPER}} .ekit-wid-con {{CURRENT_ITEM}}.ekit-closed-day.ekit-single-day .ekit-business-day' => 'color: {{VALUE}}',
  66. ],
  67. 'condition' => [
  68. 'ekit_highlight_this_day' => 'yes',
  69. ],
  70. 'separator' => 'before',
  71. ]
  72. );
  73. $repeater->add_responsive_control(
  74. 'ekit_single_business_time_color',
  75. [
  76. 'label' => esc_html__( 'Time Color', 'elementskit-lite' ),
  77. 'type' => Controls_Manager::COLOR,
  78. 'default' => '#fa2d2d',
  79. 'selectors' => [
  80. '{{WRAPPER}} .ekit-wid-con {{CURRENT_ITEM}}.ekit-closed-day.ekit-single-day .ekit-business-time' => 'color: {{VALUE}}',
  81. ],
  82. 'condition' => [
  83. 'ekit_highlight_this_day' => 'yes',
  84. ],
  85. 'separator' => 'before',
  86. ]
  87. );
  88. $repeater->add_responsive_control(
  89. 'ekit_single_business_background_color',
  90. [
  91. 'label' => esc_html__( 'Background Color', 'elementskit-lite' ),
  92. 'type' => Controls_Manager::COLOR,
  93. 'selectors' => [
  94. '{{WRAPPER}} .ekit-wid-con {{CURRENT_ITEM}}.ekit-closed-day' => 'background-color: {{VALUE}}',
  95. ],
  96. 'condition' => [
  97. 'ekit_highlight_this_day' => 'yes',
  98. ],
  99. 'separator' => 'before',
  100. ]
  101. );
  102. $this->add_control(
  103. 'ekit_business_openday_list',
  104. [
  105. 'type' => Controls_Manager::REPEATER,
  106. 'fields' => array_values( $repeater->get_controls() ),
  107. 'default' => [
  108. [
  109. 'ekit_business_day' => esc_html__( 'Sunday', 'elementskit-lite' ),
  110. 'ekit_business_time' => esc_html__( 'Close','elementskit-lite' ),
  111. 'ekit_highlight_this_day' => esc_html__( 'yes','elementskit-lite' ),
  112. ],
  113. [
  114. 'ekit_business_day' => esc_html__( 'Saturday', 'elementskit-lite' ),
  115. 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ),
  116. 'ekit_highlight_this_day' => esc_html__( 'yes','elementskit-lite' ),
  117. ],
  118. [
  119. 'ekit_business_day' => esc_html__( 'Monday', 'elementskit-lite' ),
  120. 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ),
  121. ],
  122. [
  123. 'ekit_business_day' => esc_html__( 'Tues Day', 'elementskit-lite' ),
  124. 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ),
  125. ],
  126. [
  127. 'ekit_business_day' => esc_html__( 'Wednesday', 'elementskit-lite' ),
  128. 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ),
  129. ],
  130. [
  131. 'ekit_business_day' => esc_html__( 'Thursday', 'elementskit-lite' ),
  132. 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ),
  133. ],
  134. [
  135. 'ekit_business_day' => esc_html__( 'Friday', 'elementskit-lite' ),
  136. 'ekit_business_time' => esc_html__( '10:00 AM to 7:00 PM','elementskit-lite' ),
  137. ]
  138. ],
  139. 'title_field' => '{{{ ekit_business_day }}}',
  140. ]
  141. );
  142. $this->end_controls_section();
  143. // Style Item section
  144. $this->start_controls_section(
  145. 'ekit_business_item_style_section',
  146. [
  147. 'label' => esc_html__( 'Item', 'elementskit-lite' ),
  148. 'tab' => Controls_Manager::TAB_STYLE,
  149. ]
  150. );
  151. $this->add_responsive_control(
  152. 'ekit_business_item_margin',
  153. [
  154. 'label' => esc_html__( 'Margin', 'elementskit-lite' ),
  155. 'type' => Controls_Manager::DIMENSIONS,
  156. 'size_units' => [ 'px', '%', 'em' ],
  157. 'selectors' => [
  158. '{{WRAPPER}} .ekit-wid-con .ekit-single-day' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  159. ],
  160. 'separator' =>'before',
  161. ]
  162. );
  163. $this->add_responsive_control(
  164. 'ekit_business_item_padding',
  165. [
  166. 'label' => esc_html__( 'Padding', 'elementskit-lite' ),
  167. 'type' => Controls_Manager::DIMENSIONS,
  168. 'size_units' => [ 'px', '%', 'em' ],
  169. 'selectors' => [
  170. '{{WRAPPER}} .ekit-wid-con .ekit-single-day' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  171. ],
  172. 'separator' =>'after',
  173. ]
  174. );
  175. $this->add_group_control(
  176. Group_Control_Background::get_type(),
  177. [
  178. 'name' => 'ekit_business_item_background',
  179. 'label' => esc_html__( 'Background', 'elementskit-lite' ),
  180. 'types' => [ 'classic', 'gradient' ],
  181. 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day',
  182. ]
  183. );
  184. $this->add_responsive_control(
  185. 'ekit_business_item_item_radius',
  186. [
  187. 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ),
  188. 'type' => Controls_Manager::DIMENSIONS,
  189. 'size_units' => [ 'px', '%', 'em' ],
  190. 'selectors' => [
  191. '{{WRAPPER}} .ekit-wid-con .ekit-single-day' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  192. ],
  193. ]
  194. );
  195. $this->add_group_control(
  196. Group_Control_Border::get_type(),
  197. [
  198. 'name' => 'ekit_business_item_border',
  199. 'label' => esc_html__( 'Border', 'elementskit-lite' ),
  200. 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day:not(:last-child)',
  201. ]
  202. );
  203. $this->end_controls_section();
  204. // Style Business day section
  205. $this->start_controls_section(
  206. 'ekit_business_day_style_section',
  207. [
  208. 'label' => esc_html__( 'Day', 'elementskit-lite' ),
  209. 'tab' => Controls_Manager::TAB_STYLE,
  210. ]
  211. );
  212. $this->add_responsive_control(
  213. 'ekit_business_day_color',
  214. [
  215. 'label' => esc_html__( 'Color', 'elementskit-lite' ),
  216. 'type' => Controls_Manager::COLOR,
  217. 'selectors' => [
  218. '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day' => 'color: {{VALUE}};',
  219. ],
  220. ]
  221. );
  222. $this->add_group_control(
  223. Group_Control_Typography::get_type(),
  224. [
  225. 'name' => 'ekit_business_day_typography',
  226. 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day',
  227. ]
  228. );
  229. $this->add_group_control(
  230. Group_Control_Background::get_type(),
  231. [
  232. 'name' => 'ekit_business_day_background',
  233. 'label' => esc_html__( 'Background', 'elementskit-lite' ),
  234. 'types' => [ 'classic', 'gradient' ],
  235. 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day',
  236. ]
  237. );
  238. $this->add_responsive_control(
  239. 'ekit_business_item_day_radius',
  240. [
  241. 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ),
  242. 'type' => Controls_Manager::DIMENSIONS,
  243. 'size_units' => [ 'px', '%', 'em' ],
  244. 'selectors' => [
  245. '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  246. ],
  247. ]
  248. );
  249. $this->add_responsive_control(
  250. 'ekit_business_item_day_padding',
  251. [
  252. 'label' => esc_html__( 'Padding', 'elementskit-lite' ),
  253. 'type' => Controls_Manager::DIMENSIONS,
  254. 'size_units' => [ 'px', '%', 'em' ],
  255. 'selectors' => [
  256. '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-day' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  257. ],
  258. ]
  259. );
  260. $this->end_controls_section();
  261. // Style Business Time section
  262. $this->start_controls_section(
  263. 'ekit_business_time_style_section',
  264. [
  265. 'label' => esc_html__( 'Time', 'elementskit-lite' ),
  266. 'tab' => Controls_Manager::TAB_STYLE,
  267. ]
  268. );
  269. $this->add_responsive_control(
  270. 'ekit_business_time_color',
  271. [
  272. 'label' => esc_html__( 'Color', 'elementskit-lite' ),
  273. 'type' => Controls_Manager::COLOR,
  274. 'selectors' => [
  275. '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time' => 'color: {{VALUE}};',
  276. ],
  277. ]
  278. );
  279. $this->add_group_control(
  280. Group_Control_Typography::get_type(),
  281. [
  282. 'name' => 'ekit_business_time_typography',
  283. 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time',
  284. ]
  285. );
  286. $this->add_group_control(
  287. Group_Control_Background::get_type(),
  288. [
  289. 'name' => 'ekit_business_time_background',
  290. 'label' => esc_html__( 'Background', 'elementskit-lite' ),
  291. 'types' => [ 'classic', 'gradient' ],
  292. 'selector' => '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time',
  293. ]
  294. );
  295. $this->add_responsive_control(
  296. 'ekit_business_item_time_radius',
  297. [
  298. 'label' => esc_html__( 'Border Radius', 'elementskit-lite' ),
  299. 'type' => Controls_Manager::DIMENSIONS,
  300. 'size_units' => [ 'px', '%', 'em' ],
  301. 'selectors' => [
  302. '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time' => 'border-radius: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  303. ],
  304. ]
  305. );
  306. $this->add_responsive_control(
  307. 'ekit_business_item_time_padding',
  308. [
  309. 'label' => esc_html__( 'Padding', 'elementskit-lite' ),
  310. 'type' => Controls_Manager::DIMENSIONS,
  311. 'size_units' => [ 'px', '%', 'em' ],
  312. 'selectors' => [
  313. '{{WRAPPER}} .ekit-wid-con .ekit-single-day .ekit-business-time' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};',
  314. ],
  315. ]
  316. );
  317. $this->end_controls_section();
  318. $this->insert_pro_message();
  319. }
  320. protected function render( ) {
  321. echo '<div class="ekit-wid-con" >';
  322. $this->render_raw();
  323. echo '</div>';
  324. }
  325. protected function render_raw( ) {
  326. $settings = $this->get_settings_for_display();
  327. ?>
  328. <div class="ekit-business-hours-inner">
  329. <?php foreach ($settings['ekit_business_openday_list'] as $item) : ?>
  330. <div class="ekit-single-day elementor-repeater-item-<?php echo esc_attr($item['_id']); ?> <?php if( $item['ekit_highlight_this_day'] == 'yes' ){ echo esc_attr( 'ekit-closed-day','elementskit-lite'); }?>">
  331. <?php if( !empty( $item['ekit_business_day'] ) ) : ?>
  332. <span class="ekit-business-day"><?php echo esc_html($item['ekit_business_day']); ?></span>
  333. <?php endif; if( !empty( $item['ekit_business_time'] ) ): ?>
  334. <span class="ekit-business-time"><?php echo esc_html($item['ekit_business_time']); ?></span>
  335. <?php endif; ?>
  336. </div>
  337. <?php endforeach; ?>
  338. </div>
  339. <?php
  340. }
  341. }