PluginProbe ʕ •ᴥ•ʔ
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents / 4.2.8
EmbedPress – PDF Embedder, 3D PDF FlipBook, Google Reviews, YouTube Videos, Upload & Embed PDF documents v4.2.8
4.6.0 4.5.6 4.5.5 4.5.4 4.5.3 4.5.2 trunk 1.0.0 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.7.0 1.7.1 1.7.2 1.7.3 1.7.4 1.7.5 2.0.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.3.0 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.6.0 2.6.1 2.6.2 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.7.6 2.7.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.6.5 3.6.6 3.6.7 3.6.8 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.8.1 3.8.2 3.8.3 3.8.4 3.8.5 3.9.0 3.9.1 3.9.10 3.9.11 3.9.12 3.9.13 3.9.14 3.9.15 3.9.16 3.9.17 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9 4.0.0 4.0.1 4.0.10 4.0.11 4.0.12 4.0.13 4.0.14 4.0.2 4.0.3 4.0.4 4.0.5 4.0.6 4.0.7 4.0.8 4.0.9 4.1.0 4.1.1 4.1.10 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2.0 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.4.0 4.4.1 4.4.10 4.4.11 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.4.9 4.5.0 4.5.1
embedpress / EmbedPress / Ends / Back / Settings / EmbedpressSettings.php
embedpress / EmbedPress / Ends / Back / Settings Last commit date
assets 1 year ago templates 1 year ago EmbedpressSettings.php 1 year ago
EmbedpressSettings.php
410 lines
1 <?php
2 namespace EmbedPress\Ends\Back\Settings;
3
4 use EmbedPress\Includes\Classes\Helper;
5
6 class EmbedpressSettings {
7 var $page_slug = '';
8 /**
9 * @var int|string
10 */
11 protected $file_version;
12
13 public function __construct($page_slug = 'embedpress') {
14 $this->page_slug = $page_slug;
15 $this->file_version = defined( 'WP_DEBUG') && WP_DEBUG ? time() : EMBEDPRESS_VERSION;
16 add_action('admin_enqueue_scripts', [$this, 'handle_scripts_and_styles']);
17 add_action('admin_menu', [$this, 'register_menu']);
18 add_action( 'init', [$this, 'save_settings']);
19
20 // ajax
21 add_action( 'wp_ajax_embedpress_elements_action', [$this, 'update_elements_list']);
22 add_action( 'wp_ajax_embedpress_settings_action', [$this, 'save_settings']);
23
24 $g_settings = get_option( EMBEDPRESS_PLG_NAME, [] );
25
26 if(!isset($g_settings['turn_off_rating_help'])){
27 $g_settings['turn_off_rating_help'] = true;
28 update_option(EMBEDPRESS_PLG_NAME, $g_settings);
29 }
30
31
32 // Migration
33 $option = 'embedpress_elements_updated'; // to update initially for backward compatibility
34 if ( !get_option( $option, false) ) {
35 $elements_initial_states = [
36 'gutenberg' => [
37 'google-docs-block' => 'google-docs-block',
38 'document' => 'document',
39 'embedpress' => 'embedpress',
40 'embedpress-pdf' => 'embedpress-pdf',
41 'google-sheets-block' => 'google-sheets-block',
42 'google-slides-block' => 'google-slides-block',
43 'youtube-block' => 'youtube-block',
44 'google-forms-block' => 'google-forms-block',
45 'google-drawings-block' => 'google-drawings-block',
46 'google-maps-block' => 'google-maps-block',
47 'twitch-block' => 'twitch-block',
48 'wistia-block' => 'wistia-block',
49 'vimeo-block' => 'vimeo-block',
50 ],
51 'elementor' => [
52 'embedpress-document' => 'embedpress-document',
53 'embedpress' => 'embedpress',
54 'embedpress-pdf' => 'embedpress-pdf',
55 ]
56 ];
57
58 $settings = get_option( EMBEDPRESS_PLG_NAME, [] );
59 $yt = get_option( EMBEDPRESS_PLG_NAME.':youtube' );
60 if ( empty( $settings) && empty( $yt) ) {
61 $settings['need_first_time_redirect'] = true;
62 }
63 if ( !isset( $settings['enablePluginInAdmin']) ) {
64 $settings['enablePluginInAdmin'] = 1;
65 }
66 if ( !isset( $settings['enablePluginInFront']) ) {
67 $settings['enablePluginInFront'] = 1;
68 }
69
70 update_option( EMBEDPRESS_PLG_NAME.":elements", $elements_initial_states);
71 update_option( EMBEDPRESS_PLG_NAME, $settings);
72 update_option( $option, true);
73 }
74 $migration_v_320 = 'embedpress_v_320_migration';
75 if ( !get_option( $migration_v_320, false) ) {
76 $elements = (array) get_option( EMBEDPRESS_PLG_NAME.":elements", []);
77 $elements['gutenberg']['embedpress-pdf'] = 'embedpress-pdf';
78 $elements['elementor']['embedpress-pdf'] = 'embedpress-pdf';
79 update_option( EMBEDPRESS_PLG_NAME.":elements", $elements);
80 update_option( $migration_v_320, true);
81 }
82
83 $migration_v_330 = 'embedpress_v_330_migration';
84 if ( !get_option( $migration_v_330, false) ) {
85 $elements = (array) get_option( EMBEDPRESS_PLG_NAME.":elements", []);
86 $elements['gutenberg']['embedpress-calendar'] = 'embedpress-calendar';
87 $elements['elementor']['embedpress-calendar'] = 'embedpress-calendar';
88 update_option( EMBEDPRESS_PLG_NAME.":elements", $elements);
89 update_option( $migration_v_330, true);
90 }
91
92 add_action( 'admin_init', [$this, 'embedpress_maybe_redirect_to_settings'] );
93
94
95
96
97 }
98 function embedpress_maybe_redirect_to_settings() {
99 $settings = get_option( EMBEDPRESS_PLG_NAME, [] );
100 if ( isset( $settings['need_first_time_redirect']) && $settings['need_first_time_redirect'] ) {
101 if ( get_option( 'embedpress_activation_redirect_done' ) || wp_doing_ajax() ) {
102 return;
103 }
104
105
106 update_option( 'embedpress_activation_redirect_done', true );
107 $settings['need_first_time_redirect'] = false;
108 update_option( EMBEDPRESS_PLG_NAME, $settings);
109
110 if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
111 return;
112 }
113
114 wp_safe_redirect( admin_url('admin.php?page='.$this->page_slug) );
115 exit;
116 }
117
118 }
119 public function update_elements_list() {
120
121 if (!current_user_can('manage_options')) {
122 wp_send_json_error(array('message' => 'You do not have sufficient permissions to access this functionality.'));
123 return;
124 }
125
126 if ( !empty($_POST['_wpnonce'] && wp_verify_nonce( $_POST['_wpnonce'], 'embedpress_elements_action')) ) {
127 $option = EMBEDPRESS_PLG_NAME.":elements";
128 $elements = (array) get_option( $option, []);
129 $settings = (array) get_option( EMBEDPRESS_PLG_NAME, []);
130
131 $type = !empty( $_POST['element_type']) ? sanitize_text_field( $_POST['element_type']) : '';
132 $name = !empty( $_POST['element_name']) ? sanitize_text_field( $_POST['element_name']) : '';
133 $checked = !empty( $_POST['checked']) ? $_POST['checked'] : false;
134 if ( 'false' != $checked ) {
135 $elements[$type][$name] = $name;
136 if ( $type === 'classic' ) {
137 $settings[$name] = 1;
138 }
139 }else{
140 if( isset( $elements[$type]) && isset( $elements[$type][$name])){
141 unset( $elements[$type][$name]);
142 }
143 if ( $type === 'classic' ) {
144 $settings[$name] = 0;
145 }
146 }
147 update_option( EMBEDPRESS_PLG_NAME, $settings);
148 update_option( $option, $elements);
149 wp_send_json_success();
150 }
151 wp_send_json_error();
152 }
153
154 public function register_menu() {
155 add_menu_page( __('EmbedPress Settings', 'embedpress'), 'EmbedPress', 'manage_options', $this->page_slug,
156 [ $this, 'render_settings_page' ], EMBEDPRESS_URL_ASSETS.'images/menu-icon.svg', 64 );
157
158 }
159
160 public function handle_scripts_and_styles() {
161 if ( !empty( $_REQUEST['page']) && $this->page_slug === $_REQUEST['page'] ) {
162 $this->enqueue_styles();
163 $this->enqueue_scripts();
164 }
165 }
166
167 public function enqueue_scripts() {
168 if ( !did_action( 'wp_enqueue_media') ) {
169 wp_enqueue_media();
170 }
171 wp_register_script( 'ep-settings-script', EMBEDPRESS_SETTINGS_ASSETS_URL.'js/settings.js', ['jquery', 'wp-color-picker' ], $this->file_version, true );
172 wp_enqueue_script( 'ep-settings', EMBEDPRESS_URL_ASSETS . 'js/settings.js', ['jquery', 'wp-color-picker' ], $this->file_version, true );
173 wp_localize_script( 'ep-settings-script', 'embedpressObj', array(
174 'nonce' => wp_create_nonce('embedpress_elements_action'),
175 ) );
176
177 wp_enqueue_script( 'ep-settings-script');
178 }
179
180 public function enqueue_styles() {
181 wp_enqueue_style( 'ep-settings-style', EMBEDPRESS_SETTINGS_ASSETS_URL.'css/style.css', null, $this->file_version );
182 wp_enqueue_style( 'ep-settings-icon-style', EMBEDPRESS_SETTINGS_ASSETS_URL.'css/icon/style.css', null, $this->file_version );
183 wp_enqueue_style( 'wp-color-picker' );
184
185 }
186
187 public function render_settings_page( ) {
188 global $template, $page_slug, $nonce_field, $ep_page, $gen_menu_template_names, $brand_menu_template_names, $pro_active, $coming_soon, $success_message, $error_message, $platform_menu_template_names;
189
190 $page_slug = $this->page_slug; // make this available for included template
191 $template = !empty( $_GET['page_type'] ) ? sanitize_file_name( $_GET['page_type']) : 'general';
192
193 $nonce_field = wp_nonce_field('ep_settings_nonce', 'ep_settings_nonce', true, false);
194 $ep_page = admin_url('admin.php?page='.$this->page_slug);
195 $gen_menu_template_names = apply_filters('ep_general_menu_tmpl_names', ['general', 'shortcode',]);
196 $platform_menu_template_names = apply_filters('ep_platform_menu_tmpl_names', [ 'youtube', 'vimeo', 'wistia', 'twitch','dailymotion', 'soundcloud' ,'spotify','google-calendar','opensea']);
197 $brand_menu_template_names = apply_filters('ep_brand_menu_templates', ['custom-logo', 'branding',]);
198 $pro_active = apply_filters('embedpress/is_allow_rander', false);
199 $coming_soon = "<span class='ep-coming-soon'>". esc_html__( '(Coming soon)', 'embedpress'). "</span>";
200 $success_message = esc_html__( "Settings Updated", "embedpress" );
201 $error_message = esc_html__( "Ops! Something went wrong.", "embedpress" );
202 include_once EMBEDPRESS_SETTINGS_PATH . 'templates/main-template.php';
203 }
204
205 public function save_settings() {
206 // needs to check for ajax and return response accordingly.
207 if ( !empty( $_POST['ep_settings_nonce']) && wp_verify_nonce( $_POST['ep_settings_nonce'], 'ep_settings_nonce') ) {
208 $submit_type = !empty( $_POST['submit'] ) ? $_POST['submit'] : '';
209 $save_handler_method = "save_{$submit_type}_settings";
210 do_action( "before_{$save_handler_method}");
211 do_action( "before_embedpress_settings_save");
212 if ( method_exists( $this, $save_handler_method ) ) {
213 $this->$save_handler_method();
214 }
215 do_action( "after_embedpress_settings_save");
216 $return_url = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : admin_url();
217 $return_url = add_query_arg( 'success', 1, $return_url );
218 if ( wp_doing_ajax() ) {
219 wp_send_json_success();
220 }
221 wp_safe_redirect( $return_url);
222 exit();
223 }
224 }
225
226 public function save_general_settings() {
227 $settings = (array) get_option( EMBEDPRESS_PLG_NAME, []);
228 $settings ['enableEmbedResizeWidth'] = isset( $_POST['enableEmbedResizeWidth']) ? intval( $_POST['enableEmbedResizeWidth']) : 600;
229 $settings ['enableEmbedResizeHeight'] = isset( $_POST['enableEmbedResizeHeight']) ? intval( $_POST['enableEmbedResizeHeight']) : 550;
230 $settings ['pdf_custom_color_settings'] = isset( $_POST['pdf_custom_color_settings']) ? intval( $_POST['pdf_custom_color_settings']) : 0;
231 $settings ['turn_off_rating_help'] = isset( $_POST['turn_off_rating_help']) ? intval( $_POST['turn_off_rating_help']) : 0;
232
233 $settings ['custom_color'] = isset( $_POST['custom_color']) ? $_POST['custom_color'] : '#333333';
234
235 // Pro will handle g_loading_animation settings and other
236 $settings = apply_filters( 'ep_general_settings_before_save', $settings, $_POST);
237
238 update_option( EMBEDPRESS_PLG_NAME, $settings);
239 do_action( 'ep_general_settings_after_save', $settings, $_POST);
240 }
241
242 public function save_youtube_settings() {
243 $option_name = EMBEDPRESS_PLG_NAME.':youtube';
244 $settings = get_option( $option_name, []);
245 $settings['api_key'] = isset( $_POST['api_key']) ? sanitize_text_field( $_POST['api_key']) : 0;
246 $settings['pagesize'] = isset( $_POST['pagesize']) ? sanitize_text_field( $_POST['pagesize']) : 0;
247 $settings['start_time'] = isset( $_POST['start_time']) ? sanitize_text_field( $_POST['start_time']) : 0;
248 $settings['end_time'] = isset( $_POST['end_time']) ? sanitize_text_field( $_POST['end_time']) : 0;
249 $settings['autoplay'] = isset( $_POST['autoplay']) ? sanitize_text_field( $_POST['autoplay']) : '';
250 $settings['controls'] = isset( $_POST['controls']) ? sanitize_text_field( $_POST['controls']) : '';
251 $settings['fs'] = isset( $_POST['fs']) ? sanitize_text_field( $_POST['fs']) : '';
252 $settings['iv_load_policy'] = isset( $_POST['iv_load_policy']) ? sanitize_text_field( $_POST['iv_load_policy']) : 1;
253 $settings['color'] = isset( $_POST['color']) ? sanitize_text_field( $_POST['color']) : 'red';
254 $settings['rel'] = isset( $_POST['rel']) ? sanitize_text_field( $_POST['rel']) : 1;
255 $settings['license_key'] = 1; // backward compatibility
256
257 // Pro will handle g_loading_animation settings and other
258 $settings = apply_filters( 'ep_youtube_settings_before_save', $settings);
259 update_option( $option_name, $settings);
260 do_action( 'ep_youtube_settings_after_save', $settings);
261
262 }
263
264 public function save_wistia_settings() {
265 $option_name = EMBEDPRESS_PLG_NAME.':wistia';
266 $settings = get_option( $option_name, []);
267 $settings['start_time'] = isset( $_POST['start_time']) ? sanitize_text_field( $_POST['start_time']) : 0;
268 $settings['autoplay'] = isset( $_POST['autoplay']) ? sanitize_text_field( $_POST['autoplay']) : '';
269 $settings['display_fullscreen_button'] = isset( $_POST['display_fullscreen_button']) ? sanitize_text_field( $_POST['display_fullscreen_button']) : '';
270 $settings['small_play_button'] = isset( $_POST['small_play_button']) ? sanitize_text_field( $_POST['small_play_button']) : '';
271 $settings['player_color'] = isset( $_POST['player_color']) ? sanitize_text_field( $_POST['player_color']) : '';
272 $settings['plugin_resumable'] = isset( $_POST['plugin_resumable']) ? sanitize_text_field( $_POST['plugin_resumable']) : '';
273 $settings['plugin_focus'] = isset( $_POST['plugin_focus']) ? sanitize_text_field( $_POST['plugin_focus']) : '';
274 $settings['plugin_rewind'] = isset( $_POST['plugin_rewind']) ? sanitize_text_field( $_POST['plugin_rewind']) : '';
275 $settings['display_playbar'] = isset( $_POST['display_playbar']) ? sanitize_text_field( $_POST['display_playbar']) : 1;
276 $settings['plugin_rewind_time'] = isset( $_POST['plugin_rewind_time']) ? sanitize_text_field( $_POST['plugin_rewind_time']) : 10;
277 $settings['license_key'] = 1; // backward compatibility
278 // Pro will handle g_loading_animation settings and other
279 $settings = apply_filters( 'ep_wistia_settings_before_save', $settings);
280 update_option( $option_name, $settings);
281 do_action( 'ep_wistia_settings_after_save', $settings);
282 }
283
284 public function save_vimeo_settings() {
285 $option_name = EMBEDPRESS_PLG_NAME.':vimeo';
286 $settings = get_option( $option_name, []);
287 $settings['start_time'] = isset( $_POST['start_time']) ? sanitize_text_field( $_POST['start_time']) : 0;
288 $settings['autoplay'] = isset( $_POST['autoplay']) ? sanitize_text_field( $_POST['autoplay']) : '';
289 $settings['color'] = isset( $_POST['color']) ? sanitize_text_field( $_POST['color']) : '#00adef';
290 $settings['display_title'] = isset( $_POST['display_title']) ? sanitize_text_field( $_POST['display_title']) : 1;
291 $settings['display_author'] = isset( $_POST['display_author']) ? sanitize_text_field( $_POST['display_author']) : 1;
292 $settings['display_avatar'] = isset( $_POST['display_avatar']) ? sanitize_text_field( $_POST['display_avatar']) : 1;
293 $settings['license_key'] = 1; // backward compatibility
294 // Pro will handle g_loading_animation settings and other
295 $settings = apply_filters( 'ep_vimeo_settings_before_save', $settings);
296 update_option( $option_name, $settings);
297 do_action( 'ep_vimeo_settings_after_save', $settings);
298 }
299
300 public function save_twitch_settings() {
301 $option_name = EMBEDPRESS_PLG_NAME.':twitch';
302 $settings = get_option( $option_name, []);
303 $settings['embedpress_pro_twitch_autoplay'] = isset( $_POST['autoplay']) ? sanitize_text_field( $_POST['autoplay']) : 'no';
304 $settings['embedpress_pro_fs'] = isset( $_POST['fs']) ? sanitize_text_field( $_POST['fs']) : 'yes';
305 $settings['start_time'] = isset( $_POST['start_time']) ? sanitize_text_field( $_POST['start_time']) : 0;
306 $settings['embedpress_pro_twitch_theme'] = isset( $_POST['theme']) ? sanitize_text_field( $_POST['theme']) : 'dark';
307 $settings['embedpress_pro_twitch_mute'] = isset( $_POST['mute']) ? sanitize_text_field( $_POST['mute']) : 'yes';
308 $settings['license_key'] = 1; // backward compatibility
309 // Pro will handle g_loading_animation settings and other
310 $settings = apply_filters( 'ep_twitch_settings_before_save', $settings);
311 update_option( $option_name, $settings);
312 do_action( 'ep_twitch_settings_after_save', $settings);
313 }
314
315 public function save_spotify_settings() {
316 $option_name = EMBEDPRESS_PLG_NAME.':spotify';
317 $settings = get_option( $option_name, []);
318 $settings['theme'] = isset( $_POST['spotify_theme']) ? sanitize_text_field( $_POST['spotify_theme']) : '1';
319 $settings['license_key'] = 1; // backward compatibility
320
321 $settings = apply_filters( 'ep_spotify_settings_before_save', $settings);
322 update_option( $option_name, $settings);
323 do_action( 'ep_spotify_settings_after_save', $settings);
324 return $settings;
325 }
326
327 public function save_custom_logo_settings() {
328 do_action( 'before_embedpress_branding_save');
329 $settings = (array) get_option( EMBEDPRESS_PLG_NAME, []);
330 $settings['embedpress_document_powered_by'] = isset( $_POST['embedpress_document_powered_by']) ? sanitize_text_field( $_POST['embedpress_document_powered_by']) : 'no';
331 update_option( EMBEDPRESS_PLG_NAME, $settings);
332 do_action( 'after_embedpress_branding_save');
333
334 }
335
336 public function save_dailymotion_settings() {
337 $option_name = EMBEDPRESS_PLG_NAME.':dailymotion';
338 $settings = get_option( $option_name, []);
339 $settings['start_time'] = isset( $_POST['start_time']) ? sanitize_text_field( $_POST['start_time']) : 0;
340 $settings['visual'] = isset( $_POST['visual']) ? sanitize_text_field( $_POST['visual']) : '';
341 $settings['autoplay'] = isset( $_POST['autoplay']) ? sanitize_text_field( $_POST['autoplay']) : '';
342 $settings['play_on_mobile'] = isset( $_POST['play_on_mobile']) ? sanitize_text_field( $_POST['play_on_mobile']) : '';
343 $settings['color'] = isset( $_POST['color']) ? sanitize_text_field( $_POST['color']) : '#dd3333';
344 $settings['controls'] = isset( $_POST['controls']) ? sanitize_text_field( $_POST['controls']) : '';
345 $settings['video_info'] = isset( $_POST['video_info']) ? sanitize_text_field( $_POST['video_info']) : '';
346 $settings['mute'] = isset( $_POST['mute']) ? sanitize_text_field( $_POST['mute']) : '';
347 // Pro will handle g_loading_animation settings and other
348 $settings = apply_filters( 'ep_dailymotion_settings_before_save', $settings);
349 update_option( $option_name, $settings);
350 do_action( 'ep_dailymotion_settings_after_save', $settings);
351 }
352
353 public function save_soundcloud_settings() {
354 $option_name = EMBEDPRESS_PLG_NAME.':soundcloud';
355 $settings = get_option( $option_name, []);
356 $settings['visual'] = isset( $_POST['visual']) ? sanitize_text_field( $_POST['visual']) : '';
357 $settings['autoplay'] = isset( $_POST['autoplay']) ? sanitize_text_field( $_POST['autoplay']) : '';
358 $settings['play_on_mobile'] = isset( $_POST['play_on_mobile']) ? sanitize_text_field( $_POST['play_on_mobile']) : '';
359 $settings['share_button'] = isset( $_POST['share_button']) ? sanitize_text_field( $_POST['share_button']) : '';
360 $settings['comments'] = isset( $_POST['comments']) ? sanitize_text_field( $_POST['comments']) : '';
361 $settings['color'] = isset( $_POST['color']) ? sanitize_text_field( $_POST['color']) : '';
362 $settings['artwork'] = isset( $_POST['artwork']) ? sanitize_text_field( $_POST['artwork']) : '';
363 $settings['play_count'] = isset( $_POST['play_count']) ? sanitize_text_field( $_POST['play_count']) : '';
364 $settings['username'] = isset( $_POST['username']) ? sanitize_text_field( $_POST['username']) : '';
365
366 $settings['license_key'] = 1; // backward compatibility
367 // Pro will handle g_loading_animation settings and other
368 $settings = apply_filters( 'ep_soundcloud_settings_before_save', $settings);
369 update_option( $option_name, $settings);
370 do_action( 'ep_soundcloud_settings_after_save', $settings);
371 }
372
373 public function save_gcalendar_settings() {
374 $client_secret = !empty( $_POST['epgc_client_secret']) ? json_decode( wp_unslash( trim( $_POST['epgc_client_secret'])), true) : [];
375 $epgc_cache_time = !empty( $_POST['epgc_cache_time'] ) ? absint( $_POST['epgc_cache_time']) : 0;
376 $epgc_selected_calendar_ids = !empty( $_POST['epgc_selected_calendar_ids'] ) ? array_map( 'sanitize_text_field', $_POST['epgc_selected_calendar_ids']) : [];
377
378
379 $pretty_client_secret = '';
380 if ( !empty( $client_secret) ) {
381 $pretty_client_secret = $this->get_pretty_json_string( $client_secret);
382 }
383
384 update_option( 'epgc_client_secret', $pretty_client_secret);
385 update_option( 'epgc_cache_time', $epgc_cache_time);
386 update_option( 'epgc_selected_calendar_ids', $epgc_selected_calendar_ids);
387
388 }
389
390 public function save_opensea_settings() {
391 $option_name = EMBEDPRESS_PLG_NAME.':opensea';
392 $settings = get_option( $option_name, []);
393 $settings['api_key'] = isset( $_POST['api_key']) ? sanitize_text_field( $_POST['api_key']) : 0;
394 $settings['limit'] = isset( $_POST['limit']) ? sanitize_text_field( $_POST['limit']) : 0;
395 $settings['orderby'] = isset( $_POST['orderby']) ? sanitize_text_field( $_POST['orderby']) : 0;
396
397 $settings['license_key'] = 1; // backward compatibility
398
399 // Pro will handle g_loading_animation settings and other
400 $settings = apply_filters( 'ep_opensea_settings_before_save', $settings);
401 update_option( $option_name, $settings);
402 do_action( 'ep_opensea_settings_after_save', $settings);
403 }
404
405
406 function get_pretty_json_string($array) {
407 return str_replace(" ", " ", json_encode($array, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
408 }
409 }
410