PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.6.5
Spider Elements – Premium Elementor Widgets & Addons Library v1.6.5
trunk 1.0.0 1.1.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.7.0 1.8.0 1.9.0
spider-elements / includes / filters.php
spider-elements / includes Last commit date
Admin 1 year ago Frontend 1 year ago freemius 1 year ago filters.php 1 year ago functions.php 1 year ago
filters.php
151 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
8 /**
9 * Constants for the widget badge
10 */
11 add_action( 'after_setup_theme', function () {
12
13 if ( ! defined( 'SPEL_TEXT_BADGE' ) ) {
14 define( 'SPEL_TEXT_BADGE',
15 '<span class="spe-text-badge-control">' . esc_html__( 'SPIDER', 'spider-elements' ) . '</span>'
16 );
17 }
18
19 if ( ! defined( 'SPEL_PRO_BADGE' ) ) {
20 define( 'SPEL_PRO_BADGE',
21 '<span class="spel-pro-badge-control">' . esc_html__( 'PRO', 'spider-elements' ) . '</span>'
22 );
23 }
24
25 }, 20 );
26
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 'spel_accordion',
36 'docy_testimonial',
37 'docly_list_item',
38 'docy_team_carousel',
39 'docy_integrations',
40 'docy_video_popup',
41 'docy_blog_grid',
42 'spe_timeline_widget',
43 'spe_counter',
44 'spel_icon_box'
45 ];
46
47 // Pro Widgets
48 $pro_widgets = [
49 'spel_accordion_article',
50 'docy_box_hover',
51 'spel_business_hours',
52 'spe_feature_box',
53 'docy_flip_box',
54 'docly_hotspot',
55 'docy_image_hover',
56 'docy_image_slides',
57 'spel_marquee_slider',
58 'spe_skill_showcase_widget',
59 'spel_stacked_image'
60 ];
61
62 // Docy Widgets
63 $docy_widgets = [
64 'docly_cheatsheet',
65 'spel_videos_playlist',
66 'docy_tabs',
67 'docly_alerts_box',
68 ];
69
70 // Collect Free Widgets Values
71 $data = [];
72 foreach ( $free_widgets as $widget ) {
73 $data[ $widget ] = isset( $_POST[ $widget ] ) ? sanitize_text_field( $_POST[ $widget ] ) : '';
74 }
75
76 // Collect Pro Widgets Values
77 foreach ( $pro_widgets as $widget ) {
78 $data[ $widget ] = isset( $_POST[ $widget ] ) ? sanitize_text_field( $_POST[ $widget ] ) : '';
79 }
80
81 // Collect Docy Widgets Values
82 foreach ( $docy_widgets as $widget ) {
83 $data[ $widget ] = isset( $_POST[ $widget ] ) ? sanitize_text_field( $_POST[ $widget ] ) : '';
84 }
85
86 // Global Switcher
87 $data['element_global_switcher'] = isset( $_POST['element_global_switcher'] ) ? sanitize_text_field( $_POST['element_global_switcher'] ) : '';
88
89 // Save the data in the option table using update_option
90 update_option( 'spe_widget_settings', $data );
91
92 // If the user is not on a pro plan, reset pro-widgets
93 if ( ! spel_is_premium() ) {
94 foreach ( $pro_widgets as $widget ) {
95 $data[ $widget ] = 'off';
96 }
97 update_option( 'spe_widget_settings', $data );
98 }
99
100 // If the user is not on a pro-plan or Docy theme, reset pro-widgets
101 $is_premium_or_theme = spel_unlock_docy_theme();
102 if ( ! $is_premium_or_theme ) {
103 foreach ( $docy_widgets as $widget ) {
104 $data[ $widget ] = 'off';
105 }
106 update_option( 'spe_widget_settings', $data );
107 }
108 }
109
110 } );
111
112
113 // Dashboard Features Setting Save Data
114 add_action( 'admin_init', function () {
115
116 if ( isset( $_POST['features-submit'] ) ) {
117
118 // Pro Widgets
119 $pro_features = [
120 'spel_badge',
121 'spel_reveal_animation',
122 'spel_heading_highlighted',
123 'spel_feature_box',
124 'spel_smooth_animation',
125 ];
126
127 $data = get_option( 'spel_features_settings', [] );
128
129 // Collect Pro Features Values
130 foreach ( $pro_features as $feature ) {
131 $data[ $feature ] = isset( $_POST[ $feature ] ) ? sanitize_text_field( $_POST[ $feature ] ) : '';
132 }
133
134 // Global Switcher
135 $data['features_global_switcher'] = isset( $_POST['features_global_switcher'] ) ? sanitize_text_field( $_POST['features_global_switcher'] ) : '';
136
137 // Save the data in the option table using update_option
138 update_option( 'spel_features_settings', $data );
139
140 // If the user is not on a pro-plan or Jobi theme, reset pro-widgets
141 $theme = wp_get_theme();
142 $is_premium_or_theme = spel_is_premium() || in_array( $theme->get( 'Name' ), [ 'jobi', 'Jobi', 'jobi-child', 'Jobi Child' ] );
143 if ( ! $is_premium_or_theme ) {
144 foreach ( $pro_features as $feature ) {
145 $data[ $feature ] = 'off';
146 }
147 update_option( 'spel_features_settings', $data );
148 }
149 }
150
151 } );