Admin
1 year ago
Frontend
1 year ago
freemius
1 year ago
filters.php
1 year ago
functions.php
1 year ago
filters.php
139 lines
| 1 | <?php |
| 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | exit; // Exit if accessed directly |
| 4 | } |
| 5 | |
| 6 | add_image_size( 'spel_270x152', 270, 152, true ); // Video Playlist Thumb |
| 7 | add_image_size( 'spel_120x70', 120, 70, true ); // Fullscreen slider Thumb 01 |
| 8 | |
| 9 | /** |
| 10 | * Constants for widget badge |
| 11 | */ |
| 12 | add_action('after_setup_theme', function(){ |
| 13 | |
| 14 | if ( ! defined( 'SPEL_TEXT_BADGE' ) ) { |
| 15 | define('SPEL_TEXT_BADGE', |
| 16 | '<span class="spe-text-badge-control">' . esc_html__( 'SPIDER', 'spider-elements' ) . '</span>' |
| 17 | ); |
| 18 | } |
| 19 | |
| 20 | if ( ! defined( 'SPEL_PRO_BADGE' ) ) { |
| 21 | define('SPEL_PRO_BADGE', |
| 22 | '<span class="spel-pro-badge-control">' . esc_html__( 'PRO', 'spider-elements' ) . '</span>' |
| 23 | ); |
| 24 | } |
| 25 | |
| 26 | }, 20); |
| 27 | |
| 28 | add_action( 'admin_init', function () { |
| 29 | |
| 30 | // Retrieve the field values from the form |
| 31 | if ( isset( $_POST['elements-submit'] ) ) { |
| 32 | |
| 33 | // Free Widgets |
| 34 | $free_widgets = [ |
| 35 | 'docy_tabs', |
| 36 | 'spel_videos_playlist', |
| 37 | 'docly_alerts_box', |
| 38 | 'spel_accordion', |
| 39 | 'docy_testimonial', |
| 40 | 'docly_list_item', |
| 41 | 'docly_cheatsheet', |
| 42 | 'docy_team_carousel', |
| 43 | 'docy_integrations', |
| 44 | 'spel_before_after', |
| 45 | 'docy_video_popup', |
| 46 | 'docy_blog_grid', |
| 47 | 'spe_timeline_widget', |
| 48 | 'spe_counter', |
| 49 | 'spel_icon_box' |
| 50 | ]; |
| 51 | |
| 52 | |
| 53 | // Pro Widgets |
| 54 | $pro_widgets = [ |
| 55 | 'spel_accordion_article', |
| 56 | 'docy_box_hover', |
| 57 | 'spel_business_hours', |
| 58 | 'spe_feature_box', |
| 59 | 'docy_flip_box', |
| 60 | 'docly_hotspot', |
| 61 | 'docy_image_hover', |
| 62 | 'docy_image_slides', |
| 63 | 'spel_marquee_slider', |
| 64 | 'spe_skill_showcase_widget', |
| 65 | 'spel_stacked_image' |
| 66 | ]; |
| 67 | |
| 68 | // Collect Free Widgets Values |
| 69 | $data = []; |
| 70 | foreach ($free_widgets as $widget) { |
| 71 | $data[$widget] = isset($_POST[$widget]) ? sanitize_text_field($_POST[$widget]) : ''; |
| 72 | } |
| 73 | |
| 74 | |
| 75 | // Collect Pro Widgets Values |
| 76 | foreach ($pro_widgets as $widget) { |
| 77 | $data[$widget] = isset($_POST[$widget]) ? sanitize_text_field($_POST[$widget]) : ''; |
| 78 | } |
| 79 | |
| 80 | // Global Switcher |
| 81 | $data['spe_global_switcher'] = isset($_POST['spe_global_switcher']) ? sanitize_text_field($_POST['spe_global_switcher']) : ''; |
| 82 | |
| 83 | // Save the data in the option table using update_option |
| 84 | update_option('spe_widget_settings', $data); |
| 85 | |
| 86 | // If the user is not on a pro plan, reset pro-widgets |
| 87 | if (!spel_is_premium()) { |
| 88 | foreach ($pro_widgets as $widget) { |
| 89 | $data[$widget] = 'off'; |
| 90 | } |
| 91 | update_option('spe_widget_settings', $data); |
| 92 | } |
| 93 | |
| 94 | } |
| 95 | |
| 96 | } ); |
| 97 | |
| 98 | |
| 99 | // Dashboard Features Setting Save Data |
| 100 | add_action( 'admin_init', function () { |
| 101 | |
| 102 | if ( isset( $_POST['features-submit'] ) ) { |
| 103 | |
| 104 | // Pro Widgets |
| 105 | $pro_features = [ |
| 106 | 'spel_badge', |
| 107 | 'spel_reveal_animation', |
| 108 | 'spel_heading_highlighted', |
| 109 | 'spel_feature_box', |
| 110 | 'spel_smooth_animation', |
| 111 | ]; |
| 112 | |
| 113 | |
| 114 | $data = get_option('spel_features_settings', []); |
| 115 | |
| 116 | // Collect Pro Features Values |
| 117 | foreach ($pro_features as $feature) { |
| 118 | $data[$feature] = isset($_POST[$feature]) ? sanitize_text_field($_POST[$feature]) : ''; |
| 119 | } |
| 120 | |
| 121 | // Global Switcher |
| 122 | $data['features_global_switcher'] = isset($_POST['features_global_switcher']) ? sanitize_text_field($_POST['features_global_switcher']) : ''; |
| 123 | |
| 124 | // Save the data in the option table using update_option |
| 125 | update_option('spel_features_settings', $data); |
| 126 | |
| 127 | // If the user is not on a pro-plan or Jobi theme, reset pro-widgets |
| 128 | $theme = wp_get_theme(); |
| 129 | $is_premium_or_theme = spel_is_premium() || in_array($theme->get('Name'), ['jobi', 'Jobi', 'jobi-child', 'Jobi Child']); |
| 130 | if (!$is_premium_or_theme) { |
| 131 | foreach ($pro_features as $feature) { |
| 132 | $data[$feature] = 'off'; |
| 133 | } |
| 134 | update_option('spel_features_settings', $data); |
| 135 | } |
| 136 | |
| 137 | } |
| 138 | |
| 139 | } ); |