templates
2 years ago
Accordion.php
2 years ago
Alerts_Box.php
2 years ago
Animated_Heading.php
2 years ago
Before_after.php
2 years ago
Blog_Grid.php
2 years ago
Buttons.php
2 years ago
Cheat_sheet.php
2 years ago
Counter.php
2 years ago
Fullscreen_Slider.php
2 years ago
Icon_box.php
2 years ago
Instagram.php
2 years ago
Integrations.php
2 years ago
List_Item.php
2 years ago
Marquee_Slides.php
2 years ago
Pricing_Table_Switcher.php
2 years ago
Pricing_Table_Tabs.php
2 years ago
Skill_Showcase.php
2 years ago
Tabs.php
2 years ago
Team_Carousel.php
2 years ago
Testimonial.php
2 years ago
Timeline.php
2 years ago
Video_Playlist.php
2 years ago
Video_Popup.php
2 years ago
Cheat_sheet.php
432 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Use namespace to avoid conflict |
| 4 | */ |
| 5 | |
| 6 | namespace SPEL\Widgets; |
| 7 | |
| 8 | use Elementor\Repeater; |
| 9 | use Elementor\Widget_Base; |
| 10 | use Elementor\Controls_Manager; |
| 11 | use Elementor\Group_Control_Typography; |
| 12 | |
| 13 | // Exit if accessed directly |
| 14 | if (!defined('ABSPATH')) { |
| 15 | exit; |
| 16 | } |
| 17 | |
| 18 | |
| 19 | /** |
| 20 | * Class Alerts_box |
| 21 | * @package spider\Widgets |
| 22 | * @since 1.0.0 |
| 23 | */ |
| 24 | class Cheat_sheet extends Widget_Base |
| 25 | { |
| 26 | |
| 27 | public function get_name () |
| 28 | { |
| 29 | return 'docly_cheatsheet'; // ID of the widget (Don't change this name) |
| 30 | } |
| 31 | |
| 32 | public function get_title () |
| 33 | { |
| 34 | return esc_html__('Cheat Sheet', 'spider-elements'); |
| 35 | } |
| 36 | |
| 37 | public function get_icon () |
| 38 | { |
| 39 | return 'eicon-apps spel-icon'; |
| 40 | } |
| 41 | |
| 42 | public function get_keywords () |
| 43 | { |
| 44 | return [ 'spider', 'spider elements', 'toggle' ]; |
| 45 | } |
| 46 | |
| 47 | public function get_categories () |
| 48 | { |
| 49 | return [ 'spider-elements' ]; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Name: get_style_depends() |
| 54 | * Desc: Register the required CSS dependencies for the frontend. |
| 55 | */ |
| 56 | public function get_style_depends () |
| 57 | { |
| 58 | return [ 'spel-main' ]; |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * Name: get_script_depends() |
| 63 | * Desc: Register the required JS dependencies for the frontend. |
| 64 | */ |
| 65 | public function get_script_depends () |
| 66 | { |
| 67 | return [ 'spel-el-widgets', 'spel-script' ]; |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * Name: register_controls() |
| 72 | * Desc: Register controls for these widgets |
| 73 | * Params: no params |
| 74 | * Return: @void |
| 75 | * Since: @1.0.0 |
| 76 | * Package: @spider-elements |
| 77 | * Author: spider-themes |
| 78 | */ |
| 79 | protected function register_controls () |
| 80 | { |
| 81 | $this->elementor_content_control(); |
| 82 | $this->elementor_style_control(); |
| 83 | } |
| 84 | |
| 85 | /** |
| 86 | * Name: elementor_content_control() |
| 87 | * Desc: Register the Content Tab output on the Elementor editor. |
| 88 | * Params: no params |
| 89 | * Return: @void |
| 90 | * Since: @1.0.0 |
| 91 | * Package: @spider-elements |
| 92 | * Author: spider-themes |
| 93 | */ |
| 94 | public function elementor_content_control () |
| 95 | { |
| 96 | |
| 97 | //======================== Cheat Sheet Section =========================// |
| 98 | $this->start_controls_section( |
| 99 | 'cheat_sheet_sec', [ |
| 100 | 'label' => esc_html__('Cheat Sheet', 'spider-elements'), |
| 101 | ] |
| 102 | ); |
| 103 | |
| 104 | $this->add_control( |
| 105 | 'cheat_sheet_title', [ |
| 106 | 'label' => esc_html__('Title', 'spider-elements'), |
| 107 | 'type' => Controls_Manager::TEXT, |
| 108 | 'label_block' => true, |
| 109 | 'default' => esc_html__('Auxiliary', 'spider-elements'), |
| 110 | ] |
| 111 | ); |
| 112 | |
| 113 | $repeater = new Repeater(); |
| 114 | $repeater->add_control( |
| 115 | 'cs_number', [ |
| 116 | 'label' => __('Serial Number', 'spider-elements'), |
| 117 | 'type' => Controls_Manager::TEXT, |
| 118 | 'default' => '#1', |
| 119 | ] |
| 120 | ); |
| 121 | |
| 122 | $repeater->add_control( |
| 123 | 'cs_title', [ |
| 124 | 'label' => __('Top Text', 'spider-elements'), |
| 125 | 'type' => Controls_Manager::TEXT, |
| 126 | 'default' => esc_html__('be', 'spider-elements'), |
| 127 | ] |
| 128 | ); |
| 129 | |
| 130 | $repeater->add_control( |
| 131 | 'cs_content', [ |
| 132 | 'label' => __('Content', 'spider-elements'), |
| 133 | 'type' => Controls_Manager::TEXT, |
| 134 | 'default' => esc_html__('Sein', 'spider-elements'), |
| 135 | ] |
| 136 | ); |
| 137 | |
| 138 | $this->add_control( |
| 139 | 'cheat_sheet_contents', [ |
| 140 | 'label' => __('Cheat Sheet List', 'spider-elements'), |
| 141 | 'type' => Controls_Manager::REPEATER, |
| 142 | 'fields' => $repeater->get_controls(), |
| 143 | 'title_field' => '{{{ cs_title }}}', |
| 144 | 'default' => [ |
| 145 | [ |
| 146 | 'cs_number' => esc_html__('#1', 'spider-elements'), |
| 147 | 'cs_title' => esc_html__('be', 'spider-elements'), |
| 148 | 'cs_content' => esc_html__('sein', 'spider-elements'), |
| 149 | ], |
| 150 | [ |
| 151 | 'cs_number' => esc_html__('#2', 'spider-elements'), |
| 152 | 'cs_title' => esc_html__('have', 'spider-elements'), |
| 153 | 'cs_content' => esc_html__('haben', 'spider-elements'), |
| 154 | ], |
| 155 | [ |
| 156 | 'cs_number' => esc_html__('#3', 'spider-elements'), |
| 157 | 'cs_title' => esc_html__('become', 'spider-elements'), |
| 158 | 'cs_content' => esc_html__('werden', 'spider-elements'), |
| 159 | ], |
| 160 | [ |
| 161 | 'cs_number' => esc_html__('#4', 'spider-elements'), |
| 162 | 'cs_title' => esc_html__('can', 'spider-elements'), |
| 163 | 'cs_content' => esc_html__('konnen', 'spider-elements'), |
| 164 | ], |
| 165 | ], |
| 166 | 'prevent_empty' => false |
| 167 | ] |
| 168 | ); |
| 169 | |
| 170 | $this->add_control( |
| 171 | 'collapse_state', [ |
| 172 | 'label' => esc_html__('Extended Collapse', 'spider-elements'), |
| 173 | 'type' => Controls_Manager::SWITCHER, |
| 174 | 'label_on' => esc_html__('Yes', 'spider-elements'), |
| 175 | 'label_off' => esc_html__('No', 'spider-elements'), |
| 176 | 'return_value' => 'yes', |
| 177 | 'default' => 'yes', |
| 178 | 'separator' => 'before' |
| 179 | ] |
| 180 | ); |
| 181 | |
| 182 | $this->end_controls_section(); // End Cheat Sheet Section |
| 183 | |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Name: elementor_style_control() |
| 188 | * Desc: Register the Style Tab output on the Elementor editor. |
| 189 | * Params: no params |
| 190 | * Return: @void |
| 191 | * Since: @1.0.0 |
| 192 | * Package: @spider-elements |
| 193 | * Author: spider-themes |
| 194 | */ |
| 195 | public function elementor_style_control () |
| 196 | { |
| 197 | |
| 198 | //======================== Style Title =========================// |
| 199 | $this->start_controls_section( |
| 200 | 'cheat_sheet_title_style', [ |
| 201 | 'label' => esc_html__('Title', 'spider-elements'), |
| 202 | 'tab' => Controls_Manager::TAB_STYLE, |
| 203 | ] |
| 204 | ); |
| 205 | |
| 206 | $this->add_control( |
| 207 | 'cheat_sheet_title_color', [ |
| 208 | 'label' => esc_html__('Text Color', 'spider-elements'), |
| 209 | 'type' => Controls_Manager::COLOR, |
| 210 | 'separator' => 'before', |
| 211 | 'selectors' => [ |
| 212 | '{{WRAPPER}} .cheatsheet_accordian .card .card-header button' => 'color: {{VALUE}};', |
| 213 | ], |
| 214 | ] |
| 215 | ); |
| 216 | |
| 217 | $this->add_group_control( |
| 218 | Group_Control_Typography::get_type(), [ |
| 219 | 'name' => 'cheat_sheet_title_typo', |
| 220 | 'selector' => '{{WRAPPER}} .cheatsheet_accordian .card .card-header button', |
| 221 | ] |
| 222 | ); |
| 223 | |
| 224 | $this->end_controls_section(); // End Style Title |
| 225 | |
| 226 | |
| 227 | //================================ Cheat Sheet Item ================================// |
| 228 | $this->start_controls_section( |
| 229 | 'style_cs_item', [ |
| 230 | 'label' => esc_html__('Cheat Sheet Item', 'spider-elements'), |
| 231 | 'tab' => Controls_Manager::TAB_STYLE, |
| 232 | ] |
| 233 | ); |
| 234 | |
| 235 | //=== Number Options |
| 236 | $this->add_control( |
| 237 | 'cs_num_options', [ |
| 238 | 'label' => esc_html__('Number Options', 'spider-elements'), |
| 239 | 'type' => Controls_Manager::HEADING, |
| 240 | 'separator' => 'before', |
| 241 | ] |
| 242 | ); |
| 243 | |
| 244 | $this->add_control( |
| 245 | 'cs_item_num_color', [ |
| 246 | 'label' => esc_html__('Text Color', 'spider-elements'), |
| 247 | 'type' => Controls_Manager::COLOR, |
| 248 | 'separator' => 'before', |
| 249 | 'selectors' => [ |
| 250 | '{{WRAPPER}} .cheatsheet_item .cheatsheet_num' => 'color: {{VALUE}};', |
| 251 | ], |
| 252 | ] |
| 253 | ); |
| 254 | |
| 255 | $this->add_group_control( |
| 256 | Group_Control_Typography::get_type(), [ |
| 257 | 'name' => 'cs_item_num_typo', |
| 258 | 'selector' => '{{WRAPPER}} .cheatsheet_item .cheatsheet_num', |
| 259 | ] |
| 260 | ); // End Number Options |
| 261 | |
| 262 | |
| 263 | //=== Top Text Options |
| 264 | $this->add_control( |
| 265 | 'cs_top_text_options', [ |
| 266 | 'label' => esc_html__('Top Text Options', 'spider-elements'), |
| 267 | 'type' => Controls_Manager::HEADING, |
| 268 | 'separator' => 'before', |
| 269 | ] |
| 270 | ); |
| 271 | |
| 272 | $this->add_control( |
| 273 | 'cs_item_top_color', [ |
| 274 | 'label' => esc_html__('Text Color', 'spider-elements'), |
| 275 | 'type' => Controls_Manager::COLOR, |
| 276 | 'selectors' => [ |
| 277 | '{{WRAPPER}} .cheatsheet_item p' => 'color: {{VALUE}};', |
| 278 | ], |
| 279 | ] |
| 280 | ); |
| 281 | |
| 282 | $this->add_group_control( |
| 283 | Group_Control_Typography::get_type(), [ |
| 284 | 'name' => 'cs_item_top_typo', |
| 285 | 'selector' => '{{WRAPPER}} .cheatsheet_item p', |
| 286 | ] |
| 287 | ); // End Top Text Options |
| 288 | |
| 289 | |
| 290 | //=== Bottom Text Options |
| 291 | $this->add_control( |
| 292 | 'cs_bottom_text_options', [ |
| 293 | 'label' => esc_html__('Bottom Text Options', 'spider-elements'), |
| 294 | 'type' => Controls_Manager::HEADING, |
| 295 | 'separator' => 'before', |
| 296 | ] |
| 297 | ); |
| 298 | |
| 299 | $this->add_control( |
| 300 | 'cs_item_bottom_color', [ |
| 301 | 'label' => esc_html__('Text Color', 'spider-elements'), |
| 302 | 'type' => Controls_Manager::COLOR, |
| 303 | 'selectors' => [ |
| 304 | '{{WRAPPER}} .cheatsheet_item h5' => 'color: {{VALUE}};', |
| 305 | ], |
| 306 | ] |
| 307 | ); |
| 308 | |
| 309 | $this->add_group_control( |
| 310 | Group_Control_Typography::get_type(), [ |
| 311 | 'name' => 'cs_item_bottom_typo', |
| 312 | 'selector' => '{{WRAPPER}} .cheatsheet_item h5', |
| 313 | ] |
| 314 | ); // End Bottom Text Options |
| 315 | |
| 316 | $this->end_controls_section(); // End Cheat Sheet Item |
| 317 | |
| 318 | |
| 319 | //========================= Item Box Background ==========================// |
| 320 | $this->start_controls_section( |
| 321 | 'sec_bg_style', [ |
| 322 | 'label' => esc_html__('Background Box Item', 'spider-elements'), |
| 323 | 'tab' => Controls_Manager::TAB_STYLE, |
| 324 | ] |
| 325 | ); |
| 326 | |
| 327 | $this->add_responsive_control( |
| 328 | 'item_box_margin', [ |
| 329 | 'label' => esc_html__('Margin', 'spider-elements'), |
| 330 | 'type' => Controls_Manager::DIMENSIONS, |
| 331 | 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 332 | 'selectors' => [ |
| 333 | '{{WRAPPER}} .cheatsheet_item' => 'margin: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 334 | ], |
| 335 | ] |
| 336 | ); |
| 337 | |
| 338 | $this->add_responsive_control( |
| 339 | 'item_box_padding', [ |
| 340 | 'label' => esc_html__('Padding', 'spider-elements'), |
| 341 | 'type' => Controls_Manager::DIMENSIONS, |
| 342 | 'size_units' => [ 'px', '%', 'em', 'rem', 'custom' ], |
| 343 | 'selectors' => [ |
| 344 | '{{WRAPPER}} .cheatsheet_item' => 'padding: {{TOP}}{{UNIT}} {{RIGHT}}{{UNIT}} {{BOTTOM}}{{UNIT}} {{LEFT}}{{UNIT}};', |
| 345 | ], |
| 346 | ] |
| 347 | ); |
| 348 | |
| 349 | $this->add_control( |
| 350 | 'item_box_bg_color', [ |
| 351 | 'label' => esc_html__('Background Color', 'spider-elements'), |
| 352 | 'type' => Controls_Manager::COLOR, |
| 353 | 'separator' => 'before', |
| 354 | 'selectors' => [ |
| 355 | '{{WRAPPER}} .cheatsheet_item' => 'background-color: {{VALUE}};', |
| 356 | ], |
| 357 | ] |
| 358 | ); |
| 359 | |
| 360 | $this->end_controls_section(); // End Item Box Background |
| 361 | |
| 362 | } |
| 363 | |
| 364 | |
| 365 | /** |
| 366 | * Name: elementor_render() |
| 367 | * Desc: Render the widget output on the frontend. |
| 368 | * Params: no params |
| 369 | * Return: @void |
| 370 | * Since: @1.0.0 |
| 371 | * Package: @spider-elements |
| 372 | * Author: spider-themes |
| 373 | */ |
| 374 | protected function render () |
| 375 | { |
| 376 | $settings = $this->get_settings_for_display(); |
| 377 | extract($settings); // extract all settings array to variables converted to name of key |
| 378 | $id = $this->get_ID(); |
| 379 | $cheat_sheet_title = !empty($settings[ 'cheat_sheet_title' ]) ? $settings[ 'cheat_sheet_title' ] : ''; |
| 380 | $is_collapsed_class = $settings[ 'collapse_state' ] == 'yes' ? '' : 'active'; |
| 381 | $is_show = $settings[ 'collapse_state' ] == 'yes' ? 'show' : ''; |
| 382 | |
| 383 | ?> |
| 384 | <div class="cheatsheet_info"> |
| 385 | <div class="accordion cheatsheet_accordian"> |
| 386 | <div id="cheat-<?php echo esc_attr($id) ?>" class="card"> |
| 387 | <div class="card-header" id="headingAtlas-<?php echo esc_attr($id) ?>"> |
| 388 | <?php if ($cheat_sheet_title) : ?> |
| 389 | <h2 class="mb-0"> |
| 390 | <button class="btn btn-link <?php echo esc_attr($is_collapsed_class) ?>" type="button"> |
| 391 | <?php echo esc_html($cheat_sheet_title) ?> |
| 392 | <span class="pluse">[+]</span><span class="minus">[-]</span> |
| 393 | </button> |
| 394 | </h2> |
| 395 | <?php endif ?> |
| 396 | </div> |
| 397 | <div id="collapseAtlas-<?php echo esc_attr($id) ?>" |
| 398 | class="collapse <?php echo esc_attr($is_show) ?>" |
| 399 | aria-labelledby="headingAtlas-<?php echo esc_attr($id) ?>"> |
| 400 | <div class="ezd-grid ezd-grid-cols-12"> |
| 401 | <?php |
| 402 | if (is_array($cheat_sheet_contents)) { |
| 403 | foreach ( $cheat_sheet_contents as $item ) { |
| 404 | ?> |
| 405 | <div class="ezd-lg-col-3"> |
| 406 | <div class="cheatsheet_item shadow-sm"> |
| 407 | <?php |
| 408 | if (!empty($item[ 'cs_number' ])) { |
| 409 | echo '<div class="cheatsheet_num">' . esc_html($item[ 'cs_number' ]) . '</div>'; |
| 410 | } |
| 411 | if (!empty($item[ 'cs_title' ])) { |
| 412 | echo '<p>' . esc_html($item[ 'cs_title' ]) . '</p>'; |
| 413 | } |
| 414 | if (!empty($item[ 'cs_content' ])) { |
| 415 | echo '<h5>' . esc_html($item[ 'cs_content' ]) . '</h5>'; |
| 416 | } |
| 417 | ?> |
| 418 | </div> |
| 419 | </div> |
| 420 | <?php |
| 421 | } |
| 422 | } |
| 423 | ?> |
| 424 | </div> |
| 425 | </div> |
| 426 | </div> |
| 427 | |
| 428 | </div> |
| 429 | </div> |
| 430 | <?php |
| 431 | } |
| 432 | } |