dashboard.php
3 weeks ago
modules.php
4 months ago
usersettings.php
3 weeks ago
widgets.php
3 weeks ago
widgets.php
88 lines
| 1 | <?php |
| 2 | $widgets_all = \ElementsKit_Lite\Config\Widget_List::instance()->get_list(); |
| 3 | $widgets_active = \ElementsKit_Lite\Config\Widget_List::instance()->get_list( 'active' ); |
| 4 | $widgets_categorized = array(); |
| 5 | foreach ( $widgets_all as $key => $row ) { |
| 6 | $widgets_categorized[ ( $row['widget-category'] ?? 'general' ) ][ $key ] = $row; |
| 7 | } |
| 8 | |
| 9 | // Reorder categories start |
| 10 | $widget_order = [ |
| 11 | 'general', |
| 12 | 'advanced', |
| 13 | 'creative', |
| 14 | 'special-features', |
| 15 | 'woocommerce', |
| 16 | 'header-footer', |
| 17 | 'marketing', |
| 18 | 'post', |
| 19 | 'form', |
| 20 | 'social-media-feeds', |
| 21 | 'review-testimonials', |
| 22 | 'meeting', |
| 23 | ]; |
| 24 | |
| 25 | $reordered_widgets = []; |
| 26 | |
| 27 | // Step 1: Reorder according to $widget_order |
| 28 | foreach ($widget_order as $category_key) { |
| 29 | if (isset($widgets_categorized[$category_key])) { |
| 30 | $reordered_widgets[$category_key] = $widgets_categorized[$category_key]; |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | $remaining = array_diff_key($widgets_categorized, $reordered_widgets); |
| 35 | $widgets_categorized = $reordered_widgets + $remaining; |
| 36 | // Reorder categories end |
| 37 | |
| 38 | // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- Checking current page type. The page only can access admin. So nonce verification is not required. |
| 39 | $onboard_step = isset( $_GET['ekit-onboard-steps'] ) ? sanitize_key( wp_unslash( $_GET['ekit-onboard-steps'] ) ) : ''; |
| 40 | $widget_css_class = 'loaded' === $onboard_step ? 'ekit-admin-widgets-container' : 'ekit-admin-widget-list'; |
| 41 | ?> |
| 42 | <!-- this blank input is for empty form submission --> |
| 43 | <input checked="checked" type="checkbox" value="_null" style="display:none" name="widget_list[]" > |
| 44 | |
| 45 | <div class="ekit-admin-fields-container <?php echo esc_attr( $widget_css_class ) ?>"> |
| 46 | <span class="ekit-admin-fields-container-description"><?php esc_html_e( 'You can disable the elements you are not using on your site. That will disable all associated assets of those widgets to improve your site loading speed.', 'elementskit-lite' ); ?></span> |
| 47 | |
| 48 | <div class="ekit-admin-fields-container-fieldset"> |
| 49 | <?php foreach ( $widgets_categorized as $widget_category => $widgets ) : ?> |
| 50 | <h2 class="ekit-widget-group-title"> |
| 51 | <?php |
| 52 | if($widget_category === 'social-media-feeds') { |
| 53 | echo esc_html__('Social Media Feeds', 'elementskit-lite'); |
| 54 | } else { |
| 55 | $widgets_category= str_replace( '-', ' & ', $widget_category ); |
| 56 | echo sprintf( |
| 57 | esc_html__('%1$s', 'elementskit-lite'), |
| 58 | ucwords($widgets_category) |
| 59 | ); |
| 60 | } |
| 61 | ?> |
| 62 | </h2> |
| 63 | <div class="attr-row"> |
| 64 | <?php foreach ( $widgets as $widget => $widget_config ) : ?> |
| 65 | <div class="attr-col-md-6 attr-col-lg-3" <?php echo ( $widget_config['package'] != 'pro-disabled' ? '' : 'data-attr-toggle="modal" data-target="#elementskit_go_pro_modal"' ); ?>> |
| 66 | <?php |
| 67 | $this->utils->input( |
| 68 | array( |
| 69 | 'type' => 'switch', |
| 70 | 'name' => 'widget_list[]', |
| 71 | 'label' => esc_html( $widget_config['title'] ), |
| 72 | 'value' => $widget, |
| 73 | 'attr' => ( $widget_config['package'] != 'pro-disabled' ? array() : array( 'disabled' => 'disabled' ) ), |
| 74 | 'class' => 'ekit-content-type-' . esc_attr( $widget_config['package'] ), |
| 75 | 'options' => array( |
| 76 | 'checked' => ( isset( $widgets_active[ $widget ] ) ? true : false ), |
| 77 | ), |
| 78 | ) |
| 79 | ); |
| 80 | ?> |
| 81 | </div> |
| 82 | <?php endforeach; ?> |
| 83 | </div> |
| 84 | <?php endforeach; ?> |
| 85 | </div> |
| 86 | </div> |
| 87 | |
| 88 |