PluginProbe ʕ •ᴥ•ʔ
Spider Elements – Premium Elementor Widgets & Addons Library / 1.7.0
Spider Elements – Premium Elementor Widgets & Addons Library v1.7.0
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 6 months ago Frontend 6 months ago freemius 6 months ago filters.php 6 months ago functions.php 6 months ago
filters.php
169 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 // Verify nonce for security
34 if ( ! isset( $_POST['spel_elements_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['spel_elements_nonce'] ) ), 'spel_elements_nonce' ) ) {
35 return;
36 }
37
38 if ( ! current_user_can( 'manage_options' ) ) {
39 return;
40 }
41
42 // Free Widgets
43 $free_widgets = [
44 'spel_accordion',
45 'docy_testimonial',
46 'docly_list_item',
47 'docy_team_carousel',
48 'docy_integrations',
49 'docy_video_popup',
50 'docy_blog_grid',
51 'spe_timeline_widget',
52 'spe_counter',
53 'spel_icon_box'
54 ];
55
56 // Pro Widgets
57 $pro_widgets = [
58 'spel_accordion_article',
59 'docy_box_hover',
60 'spel_business_hours',
61 'spe_feature_box',
62 'docy_flip_box',
63 'docly_hotspot',
64 'docy_image_hover',
65 'docy_image_slides',
66 'spel_marquee_slider',
67 'spe_skill_showcase_widget',
68 'spel_stacked_image'
69 ];
70
71 // Docy Widgets
72 $docy_widgets = [
73 'docly_cheatsheet',
74 'spel_videos_playlist',
75 'docy_tabs',
76 'docly_alerts_box',
77 ];
78
79 // Collect Free Widgets Values
80 $data = [];
81 foreach ( $free_widgets as $widget ) {
82 $data[ $widget ] = isset( $_POST[ $widget ] ) ? sanitize_text_field( $_POST[ $widget ] ) : '';
83 }
84
85 // Collect Pro Widgets Values
86 foreach ( $pro_widgets as $widget ) {
87 $data[ $widget ] = isset( $_POST[ $widget ] ) ? sanitize_text_field( $_POST[ $widget ] ) : '';
88 }
89
90 // Collect Docy Widgets Values
91 foreach ( $docy_widgets as $widget ) {
92 $data[ $widget ] = isset( $_POST[ $widget ] ) ? sanitize_text_field( $_POST[ $widget ] ) : '';
93 }
94
95 // Global Switcher
96 $data['element_global_switcher'] = isset( $_POST['element_global_switcher'] ) ? sanitize_text_field( $_POST['element_global_switcher'] ) : '';
97
98 // Save the data in the option table using update_option
99 update_option( 'spe_widget_settings', $data );
100
101 // If the user is not on a pro plan, reset pro-widgets
102 if ( ! spel_is_premium() ) {
103 foreach ( $pro_widgets as $widget ) {
104 $data[ $widget ] = 'off';
105 }
106 update_option( 'spe_widget_settings', $data );
107 }
108
109 // If the user is not on a pro-plan or Docy theme, reset pro-widgets
110 $is_premium_or_theme = spel_unlock_docy_theme();
111 if ( ! $is_premium_or_theme ) {
112 foreach ( $docy_widgets as $widget ) {
113 $data[ $widget ] = 'off';
114 }
115 update_option( 'spe_widget_settings', $data );
116 }
117 }
118
119 } );
120
121
122 // Dashboard Features Setting Save Data
123 add_action( 'admin_init', function () {
124
125 if ( isset( $_POST['features-submit'] ) ) {
126
127 // Verify nonce for security
128 if ( ! isset( $_POST['spel_features_nonce'] ) || ! wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['spel_features_nonce'] ) ), 'spel_features_nonce' ) ) {
129 return;
130 }
131
132 if ( ! current_user_can( 'manage_options' ) ) {
133 return;
134 }
135
136 // Pro Widgets
137 $pro_features = [
138 'spel_badge',
139 'spel_reveal_animation',
140 'spel_heading_highlighted',
141 'spel_feature_box',
142 'spel_smooth_animation',
143 ];
144
145 $data = get_option( 'spel_features_settings', [] );
146
147 // Collect Pro Features Values
148 foreach ( $pro_features as $feature ) {
149 $data[ $feature ] = isset( $_POST[ $feature ] ) ? sanitize_text_field( $_POST[ $feature ] ) : '';
150 }
151
152 // Global Switcher
153 $data['features_global_switcher'] = isset( $_POST['features_global_switcher'] ) ? sanitize_text_field( $_POST['features_global_switcher'] ) : '';
154
155 // Save the data in the option table using update_option
156 update_option( 'spel_features_settings', $data );
157
158 // If the user is not on a pro-plan or Jobi theme, reset pro-widgets
159 $theme = wp_get_theme();
160 $is_premium_or_theme = spel_is_premium() || in_array( $theme->get( 'Name' ), [ 'jobi', 'Jobi', 'jobi-child', 'Jobi Child' ] );
161 if ( ! $is_premium_or_theme ) {
162 foreach ( $pro_features as $feature ) {
163 $data[ $feature ] = 'off';
164 }
165 update_option( 'spel_features_settings', $data );
166 }
167 }
168
169 } );