cheat-sheet-1.php
77 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; // Exit if accessed directly. |
| 4 | } |
| 5 | |
| 6 | /// Example settings array (usually these come from Elementor or database) |
| 7 | $settings = $this->get_settings_for_display(); // Assuming you are in Elementor's widget class |
| 8 | $id = $this->get_ID(); |
| 9 | |
| 10 | // Ensure default 'collapse_state' is set to 'yes' for expanded (show) by default |
| 11 | $is_collapsed_class = $settings['collapse_state'] === 'yes' ? 'collapsed' : 'active'; |
| 12 | $is_show = $settings['collapse_state'] === 'yes' ? 'show' : ''; // Show by default |
| 13 | |
| 14 | $cheat_sheet_title = ! empty( $settings['cheat_sheet_title'] ) ? $settings['cheat_sheet_title'] : 'Default Title'; // Example cheat sheet title |
| 15 | $cheat_sheet_contents = ! empty( $settings['cheat_sheet_contents'] ) ? $settings['cheat_sheet_contents'] : []; // Array of cheat sheet contents |
| 16 | $column_grid = $settings['column_grid'] ?? 3; |
| 17 | |
| 18 | ?> |
| 19 | <div class="cheatsheet_info"> |
| 20 | <div class="accordion cheatsheet_accordion"> |
| 21 | <div id="cheat-<?php echo esc_attr( $id ) ?>" class="card"> |
| 22 | <?php |
| 23 | if ( 'yes' === $settings['enable_cheat_sheet_title'] ) { ?> |
| 24 | <div class="card-header" id="headingAtlas-<?php echo esc_attr( $id ) ?>"> |
| 25 | <?php |
| 26 | if ( $cheat_sheet_title ) { ?> |
| 27 | <h2 class="mb-0"> |
| 28 | <button class="btn btn-link <?php echo esc_attr( $is_collapsed_class ) ?>" type="button"> |
| 29 | <?php echo esc_html( $cheat_sheet_title ) ?> |
| 30 | <span class="pluse">[+]</span><span class="minus">[-]</span> |
| 31 | </button> |
| 32 | </h2> |
| 33 | <?php |
| 34 | } |
| 35 | ?> |
| 36 | </div> |
| 37 | <?php |
| 38 | } |
| 39 | ?> |
| 40 | <div id="collapseAtlas-<?php echo esc_attr( $id ) ?>" |
| 41 | class="collapse <?php echo esc_attr( $is_show ) ?>" |
| 42 | aria-labelledby="headingAtlas-<?php echo esc_attr( $id ) ?>"> |
| 43 | <div class="ezd-grid ezd-grid-cols-12 sheet_items_gap"> |
| 44 | <?php |
| 45 | if ( is_array( $cheat_sheet_contents ) ) { |
| 46 | // Loop through the cheat sheet contents and auto-generate serial numbers |
| 47 | foreach ( $cheat_sheet_contents as $index => $item ) { |
| 48 | ?> |
| 49 | <div class="ezd-lg-col-<?php echo esc_attr( $column_grid ); ?>"> |
| 50 | <div class="cheatsheet_item"> |
| 51 | <?php |
| 52 | // Auto-generate serial number using $index + 1 |
| 53 | echo '<div class="cheatsheet_num">' . esc_html( '#' . ( $index + 1 ) ) . '</div>'; |
| 54 | |
| 55 | // Display the title if available |
| 56 | if ( ! empty( $item['cs_title'] ) ) { |
| 57 | echo '<p>' . esc_html( $item['cs_title'] ) . '</p>'; |
| 58 | } |
| 59 | |
| 60 | // Display the content if available |
| 61 | if ( ! empty( $item['cs_content'] ) ) { |
| 62 | echo '<h5>' . esc_html( $item['cs_content'] ) . '</h5>'; |
| 63 | } |
| 64 | ?> |
| 65 | </div> |
| 66 | </div> |
| 67 | <?php |
| 68 | } |
| 69 | } |
| 70 | ?> |
| 71 | </div> |
| 72 | </div> |
| 73 | </div> |
| 74 | </div> |
| 75 | </div> |
| 76 | <?php |
| 77 |