PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.0.12
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.0.12
6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 5.2.2 5.3 All 153 releases
mainwp / class / class-mainwp-post-plugin-theme-handler.php

class-mainwp-post-plugin-theme-handler.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 6.0.12, at class/class-mainwp-post-plugin-theme-handler.php

1,021 lines 42.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Post Plugin Theme Handler.
4 *
5 * @package MainWP/Dashboard
6 */
7
8 namespace MainWP\Dashboard;
9
10 // Exit if accessed directly.
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 /**
16 * Class MainWP_Post_Plugin_Theme_Handler
17 *
18 * @package MainWP\Dashboard
19 *
20 * @uses \MainWP\Dashboard\MainWP_Post_Base_Handler
21 */
22 class MainWP_Post_Plugin_Theme_Handler extends MainWP_Post_Base_Handler { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
23 // phpcs:disable Generic.Metrics.CyclomaticComplexity -- complexity.
24 /**
25 * Protected static variable to hold the single instance of the class.
26 *
27 * @var mixed Default null
28 */
29 private static $instance = null;
30
31 /**
32 * Method instance()
33 *
34 * Create public static instance.
35 *
36 * @static
37 * @return MainWP_Post_Plugin_Theme_Handler
38 */
39 public static function instance() {
40 if ( null === static::$instance ) {
41 static::$instance = new self();
42 }
43 return static::$instance;
44 }
45
46 /**
47 * Init plugins/themes actions
48 */
49 public function init() {
50 // Page: ManageSites.
51 $this->add_action( 'mainwp_ext_prepareinstallplugintheme', array( &$this, 'mainwp_ext_prepareinstallplugintheme' ) );
52 $this->add_action( 'mainwp_ext_performinstallplugintheme', array( &$this, 'mainwp_ext_performinstallplugintheme' ) );
53
54 // Page: InstallPlugins/Themes.
55 $this->add_action( 'mainwp_preparebulkinstallplugintheme', array( &$this, 'mainwp_preparebulkinstallplugintheme' ) );
56 $this->add_action( 'mainwp_installbulkinstallplugintheme', array( &$this, 'mainwp_installbulkinstallplugintheme' ) );
57 $this->add_action( 'mainwp_preparebulkuploadplugintheme', array( &$this, 'mainwp_preparebulkuploadplugintheme' ) );
58 $this->add_action( 'mainwp_installbulkuploadplugintheme', array( &$this, 'mainwp_installbulkuploadplugintheme' ) );
59 $this->add_action( 'mainwp_cleanbulkuploadplugintheme', array( &$this, 'mainwp_cleanbulkuploadplugintheme' ) );
60 $this->add_action( 'mainwp_preparebulkinstallcheckplugin', array( &$this, 'hook_prepare_installcheck_plugin' ) );
61
62 // Widget: RightNow.
63 $this->add_action( 'mainwp_upgradewp', array( &$this, 'mainwp_upgradewp' ) );
64 $this->add_action( 'mainwp_upgradeplugintheme', array( &$this, 'mainwp_upgrade_plugintheme' ) );
65 $this->add_action( 'mainwp_ignoreplugintheme', array( &$this, 'mainwp_ignoreplugintheme' ) );
66 $this->add_action( 'mainwp_unignoreplugintheme', array( &$this, 'mainwp_unignoreplugintheme' ) );
67 $this->add_action( 'mainwp_ignorepluginsthemes', array( &$this, 'mainwp_ignorepluginsthemes' ) );
68 $this->add_action( 'mainwp_unignorepluginsthemes', array( &$this, 'mainwp_unignore_global_pluginsthemes' ) );
69 $this->add_action( 'mainwp_unignoreabandonedplugintheme', array( &$this, 'mainwp_unignoreabandonedplugintheme' ) );
70 $this->add_action( 'mainwp_unignoreabandonedpluginsthemes', array( &$this, 'mainwp_unignoreabandonedpluginsthemes' ) );
71 $this->add_action( 'mainwp_dismissoutdateplugintheme', array( &$this, 'mainwp_dismissoutdateplugintheme' ) );
72 $this->add_action( 'mainwp_dismissoutdatepluginsthemes', array( &$this, 'mainwp_dismissoutdatepluginsthemes' ) );
73 $this->add_action( 'mainwp_trust_plugin', array( &$this, 'mainwp_trust_plugin' ) );
74 $this->add_action( 'mainwp_trust_theme', array( &$this, 'mainwp_trust_theme' ) );
75 $this->add_action( 'mainwp_updates_ignore_upgrades', array( &$this, 'ajax_ignore_core_updates' ) );
76 $this->add_action( 'mainwp_updates_unignore_upgrades', array( &$this, 'ajax_unignore_core_updates' ) );
77 $this->add_action( 'mainwp_updates_unignore_global_upgrades', array( &$this, 'ajax_unignore_global_upgrades' ) );
78
79 // Page: Themes.
80 $this->add_action( 'mainwp_themes_search', array( &$this, 'mainwp_themes_search' ) );
81 $this->add_action( 'mainwp_themes_search_all', array( &$this, 'mainwp_themes_search_all' ) );
82 if ( \mainwp_current_user_can( 'dashboard', 'activate_themes' ) ) {
83 $this->add_action( 'mainwp_theme_activate', array( &$this, 'mainwp_theme_activate' ) );
84 }
85 if ( \mainwp_current_user_can( 'dashboard', 'delete_themes' ) ) {
86 $this->add_action( 'mainwp_theme_delete', array( &$this, 'mainwp_theme_delete' ) );
87 }
88 $this->add_action( 'mainwp_trusted_theme_notes_save', array( &$this, 'mainwp_trusted_theme_notes_save' ) );
89 if ( \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) {
90 $this->add_action( 'mainwp_theme_ignore_updates', array( &$this, 'mainwp_theme_ignore_updates' ) );
91 }
92
93 // Page: Plugins.
94 $this->add_action( 'mainwp_plugins_search', array( &$this, 'mainwp_plugins_search' ) );
95 $this->add_action( 'mainwp_plugins_search_all_active', array( &$this, 'mainwp_plugins_search_all_active' ) );
96
97 if ( \mainwp_current_user_can( 'dashboard', 'activate_deactivate_plugins' ) ) {
98 $this->add_action( 'mainwp_plugin_activate', array( &$this, 'mainwp_plugin_activate' ) );
99 $this->add_action( 'mainwp_plugin_deactivate', array( &$this, 'mainwp_plugin_deactivate' ) );
100 }
101 if ( \mainwp_current_user_can( 'dashboard', 'delete_plugins' ) ) {
102 $this->add_action( 'mainwp_plugin_delete', array( &$this, 'mainwp_plugin_delete' ) );
103 }
104
105 if ( \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) {
106 $this->add_action( 'mainwp_plugin_ignore_updates', array( &$this, 'mainwp_plugin_ignore_updates' ) );
107 }
108 $this->add_action( 'mainwp_trusted_plugin_notes_save', array( &$this, 'mainwp_trusted_plugin_notes_save' ) );
109
110 // Widget: Plugins.
111 $this->add_action( 'mainwp_widget_plugin_activate', array( &$this, 'mainwp_widget_plugin_activate' ) );
112 $this->add_action( 'mainwp_widget_plugin_deactivate', array( &$this, 'mainwp_widget_plugin_deactivate' ) );
113 $this->add_action( 'mainwp_widget_plugin_delete', array( &$this, 'mainwp_widget_plugin_delete' ) );
114
115 // Widget: Themes.
116 $this->add_action( 'mainwp_widget_theme_activate', array( &$this, 'mainwp_widget_theme_activate' ) );
117 $this->add_action( 'mainwp_widget_theme_delete', array( &$this, 'mainwp_widget_theme_delete' ) );
118 }
119
120 /**
121 * Method mainwp_themes_search()
122 *
123 * Search handler for Themes.
124 *
125 * @uses \MainWP\Dashboard\MainWP_Cache::init_session()
126 *
127 * @uses \MainWP\Dashboard\MainWP_Themes::render_table()
128 */
129 public function mainwp_themes_search() {
130 $this->secure_request( 'mainwp_themes_search' );
131 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
132 $keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : '';
133 $status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : '';
134 $groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : array();
135 $sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : array();
136 $clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : array();
137 $not_criteria = isset( $_POST['not_criteria'] ) && 'true' === $_POST['not_criteria'] ? true : false;
138 $not_fetchdata = isset( $_POST['not_fetchdata'] ) && ! empty( $_POST['not_fetchdata'] ) ? true : false;
139
140 // phpcs:enable
141 MainWP_Cache::init_session();
142 $result = MainWP_Themes::render_table( $keyword, $status, $groups, $sites, $not_criteria, $clients, $not_fetchdata );
143 wp_send_json( $result );
144 }
145
146 /**
147 * Method mainwp_theme_activate()
148 *
149 * Activate Theme,
150 * Page: Themes.
151 *
152 * @uses \MainWP\Dashboard\MainWP_Themes_Handler::activate_theme()
153 */
154 public function mainwp_theme_activate() {
155 $this->secure_request( 'mainwp_theme_activate' );
156 MainWP_Themes_Handler::activate_theme();
157 die();
158 }
159
160 /**
161 * Method mainwp_theme_delete()
162 *
163 * Delete Theme,
164 * Page: Themes.
165 *
166 * @uses \MainWP\Dashboard\MainWP_Themes_Handler::delete_themes()
167 */
168 public function mainwp_theme_delete() {
169 $this->secure_request( 'mainwp_theme_delete' );
170 MainWP_Themes_Handler::delete_themes();
171 die();
172 }
173
174 /**
175 * Method mainwp_theme_ignore_updates()
176 *
177 * Ignore theme updates,
178 * Page: Themes.
179 *
180 * @uses \MainWP\Dashboard\MainWP_Themes_Handler::ignore_updates()
181 */
182 public function mainwp_theme_ignore_updates() {
183 $this->secure_request( 'mainwp_theme_ignore_updates' );
184 MainWP_Themes_Handler::ignore_updates();
185 die();
186 }
187
188 /**
189 * Method mainwp_themes_search_all()
190 *
191 * Search ALL handler for,
192 * Page: Themes.
193 *
194 * @uses \MainWP\Dashboard\MainWP_Cache::init_session()
195 * @uses \MainWP\Dashboard\MainWP_Themes::render_all_themes_table()
196 */
197 public function mainwp_themes_search_all() {
198 $this->secure_request( 'mainwp_themes_search_all' );
199 MainWP_Cache::init_session();
200 MainWP_Themes::render_all_themes_table();
201 die();
202 }
203
204 /**
205 * Method mainwp_trusted_theme_notes_save()
206 *
207 * Save trusted theme notes,
208 * Page: Themes.
209 *
210 * @uses \MainWP\Dashboard\MainWP_Themes_Handler::save_trusted_theme_note()
211 */
212 public function mainwp_trusted_theme_notes_save() {
213 $this->secure_request( 'mainwp_trusted_theme_notes_save' );
214 $esc_note = MainWP_Themes_Handler::save_trusted_theme_note();
215 die(
216 wp_json_encode(
217 array(
218 'result' => 'SUCCESS',
219 'esc_note_content' => $esc_note,
220 )
221 )
222 );
223 }
224
225 /**
226 * Method mainwp_plugins_search()
227 *
228 * Search handler for Plugins.
229 *
230 * @uses \MainWP\Dashboard\MainWP_Cache::init_session()
231 * @uses \MainWP\Dashboard\MainWP_Plugins::render_table()
232 */
233 public function mainwp_plugins_search() {
234 $this->secure_request( 'mainwp_plugins_search' );
235 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
236 $keyword = isset( $_POST['keyword'] ) ? sanitize_text_field( wp_unslash( $_POST['keyword'] ) ) : '';
237 $status = isset( $_POST['status'] ) ? sanitize_text_field( wp_unslash( $_POST['status'] ) ) : '';
238 $groups = isset( $_POST['groups'] ) && is_array( $_POST['groups'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['groups'] ) ) : '';
239 $sites = isset( $_POST['sites'] ) && is_array( $_POST['sites'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['sites'] ) ) : '';
240 $clients = isset( $_POST['clients'] ) && is_array( $_POST['clients'] ) ? array_map( 'sanitize_text_field', wp_unslash( $_POST['clients'] ) ) : '';
241 $not_criteria = isset( $_POST['not_criteria'] ) && 'true' === $_POST['not_criteria'] ? true : false;
242 $not_fetchdata = isset( $_POST['not_fetchdata'] ) && ! empty( $_POST['not_fetchdata'] ) ? true : false;
243
244 // phpcs:enable
245 MainWP_Cache::init_session();
246 $result = MainWP_Plugins::render_table( $keyword, $status, $groups, $sites, $not_criteria, $clients, $not_fetchdata );
247 wp_send_json( $result );
248 }
249
250 /**
251 * Method mainwp_plugins_search_all_active()
252 *
253 * Search all Active handler for,
254 * Page: Plugins.
255 *
256 * @uses \MainWP\Dashboard\MainWP_Cache::init_session()
257 * @uses \MainWP\Dashboard\MainWP_Plugins::render_all_active_table()
258 */
259 public function mainwp_plugins_search_all_active() {
260 $this->secure_request( 'mainwp_plugins_search_all_active' );
261 MainWP_Cache::init_session();
262 MainWP_Plugins::render_all_active_table();
263 die();
264 }
265
266 /**
267 * Method mainwp_plugin_activate()
268 *
269 * Activate plugins,
270 * Page: Plugins.
271 *
272 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::activate_plugins()
273 */
274 public function mainwp_plugin_activate() {
275 $this->secure_request( 'mainwp_plugin_activate' );
276 MainWP_Plugins_Handler::activate_plugins();
277 die();
278 }
279
280 /**
281 * Method mainwp_plugin_deactivate()
282 *
283 * Deactivate plugins,
284 * Page: Plugins.
285 *
286 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::deactivate_plugins()
287 */
288 public function mainwp_plugin_deactivate() {
289 $this->secure_request( 'mainwp_plugin_deactivate' );
290 MainWP_Plugins_Handler::deactivate_plugins();
291 die();
292 }
293
294 /**
295 * Method mainwp_plugin_delete()
296 *
297 * Delete plugins,
298 * Page: Plugins.
299 *
300 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::delete_plugins()
301 */
302 public function mainwp_plugin_delete() {
303 $this->secure_request( 'mainwp_plugin_delete' );
304 MainWP_Plugins_Handler::delete_plugins();
305 die();
306 }
307
308 /**
309 * Method mainwp_plugin_ignore_updates()
310 *
311 * Ignore plugin updates,
312 * Page: Plugins.
313 *
314 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::ignore_updates()
315 */
316 public function mainwp_plugin_ignore_updates() {
317 $this->secure_request( 'mainwp_plugin_ignore_updates' );
318 MainWP_Plugins_Handler::ignore_updates();
319 die();
320 }
321
322 /**
323 * Method mainwp_trusted_plugin_notes_save()
324 *
325 * Save trusted plugin notes,
326 * Page: Plugins.
327 *
328 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::save_trusted_plugin_note()
329 */
330 public function mainwp_trusted_plugin_notes_save() {
331 $this->secure_request( 'mainwp_trusted_plugin_notes_save' );
332 $esc_note = MainWP_Plugins_Handler::save_trusted_plugin_note();
333 die(
334 wp_json_encode(
335 array(
336 'result' => 'SUCCESS',
337 'esc_note_content' => $esc_note,
338 )
339 )
340 );
341 }
342
343 /**
344 * Method mainwp_widget_plugin_activate()
345 *
346 * Activate plugin,
347 * Widget: Plugins.
348 *
349 * @uses \MainWP\Dashboard\MainWP_Widget_Plugins::activate_plugin()
350 */
351 public function mainwp_widget_plugin_activate() {
352 $this->secure_request( 'mainwp_widget_plugin_activate' );
353 MainWP_Widget_Plugins::activate_plugin();
354 }
355
356 /**
357 * Method mainwp_widget_plugin_deactivate()
358 *
359 * Deactivate plugin,
360 * Widget: Plugins.
361 *
362 * @uses \MainWP\Dashboard\MainWP_Widget_Plugins::deactivate_plugin()
363 */
364 public function mainwp_widget_plugin_deactivate() {
365 $this->secure_request( 'mainwp_widget_plugin_deactivate' );
366 MainWP_Widget_Plugins::deactivate_plugin();
367 }
368
369 /**
370 * Method mainwp_widget_plugin_delete()
371 *
372 * Delete plugin,
373 * Widget: Plugins.
374 *
375 * @uses \MainWP\Dashboard\MainWP_Widget_Plugins::delete_plugin()
376 */
377 public function mainwp_widget_plugin_delete() {
378 $this->secure_request( 'mainwp_widget_plugin_delete' );
379 MainWP_Widget_Plugins::delete_plugin();
380 }
381
382 /**
383 * Method mainwp_widget_theme_activate()
384 *
385 * Activate theme,
386 * Widget: Themes.
387 *
388 * @uses \MainWP\Dashboard\MainWP_Widget_Themes::activate_theme()
389 */
390 public function mainwp_widget_theme_activate() {
391 $this->secure_request( 'mainwp_widget_theme_activate' );
392 MainWP_Widget_Themes::activate_theme();
393 }
394
395 /**
396 * Method mainwp_widget_theme_delete()
397 *
398 * Delete theme,
399 * Widget: Themes.
400 *
401 * @uses \MainWP\Dashboard\MainWP_Widget_Themes::delete_theme()
402 */
403 public function mainwp_widget_theme_delete() {
404 $this->secure_request( 'mainwp_widget_theme_delete' );
405 MainWP_Widget_Themes::delete_theme();
406 }
407
408 /**
409 * Method mainwp_preparebulkinstallplugintheme()
410 *
411 * Prepair bulk installation of plugins & themes,
412 * Page: InstallPlugins/Themes.
413 *
414 * @uses \MainWP\Dashboard\MainWP_Install_Bulk::prepare_install()
415 */
416 public function mainwp_preparebulkinstallplugintheme() {
417 $this->secure_request( 'mainwp_preparebulkinstallplugintheme' );
418 MainWP_Install_Bulk::prepare_install();
419 }
420
421 /**
422 * Method mainwp_installbulkinstallplugintheme()
423 *
424 * Installation of plugins & themes,
425 * Page: InstallPlugins/Themes.
426 *
427 * @uses \MainWP\Dashboard\MainWP_Install_Bulk::perform_install()
428 */
429 public function mainwp_installbulkinstallplugintheme() {
430 $this->secure_request( 'mainwp_installbulkinstallplugintheme' );
431 MainWP_Install_Bulk::perform_install();
432 }
433
434 /**
435 * Method mainwp_preparebulkuploadplugintheme()
436 *
437 * Prepair bulk upload of plugins & themes,
438 * Page: InstallPlugins/Themes.
439 *
440 * @uses \MainWP\Dashboard\MainWP_Install_Bulk::prepare_upload()
441 */
442 public function mainwp_preparebulkuploadplugintheme() {
443 $this->secure_request( 'mainwp_preparebulkuploadplugintheme' );
444 MainWP_Install_Bulk::prepare_upload();
445 }
446
447 /**
448 * Method mainwp_installbulkuploadplugintheme()
449 *
450 * Bulk upload of plugins & themes,
451 * Page: InstallPlugins/Themes.
452 *
453 * @uses \MainWP\Dashboard\MainWP_Install_Bulk::perform_upload()
454 */
455 public function mainwp_installbulkuploadplugintheme() {
456 $this->secure_request( 'mainwp_installbulkuploadplugintheme' );
457 MainWP_Install_Bulk::perform_upload();
458 }
459
460 /**
461 * Method mainwp_cleanbulkuploadplugintheme()
462 *
463 * Clean upload of plugins & themes,
464 * Page: InstallPlugins/Themes.
465 *
466 * @uses \MainWP\Dashboard\MainWP_Install_Bulk::clean_upload()
467 */
468 public function mainwp_cleanbulkuploadplugintheme() {
469 $this->secure_request( 'mainwp_cleanbulkuploadplugintheme' );
470 MainWP_Install_Bulk::clean_upload();
471 }
472
473 /**
474 * Method mainwp_ext_prepareinstallplugintheme()
475 *
476 * Prepair Installation of plugins & themes,
477 * Page: ManageSites.
478 */
479 public function mainwp_ext_prepareinstallplugintheme() {
480 do_action( 'mainwp_prepareinstallplugintheme' );
481 }
482
483 /**
484 * Method mainwp_ext_performinstallplugintheme()
485 *
486 * Installation of plugins & themes,
487 * Page: ManageSites.
488 */
489 public function mainwp_ext_performinstallplugintheme() {
490 $this->secure_request( 'mainwp_ext_performinstallplugintheme' );
491 do_action( 'mainwp_performinstallplugintheme' );
492 }
493
494 /**
495 * Method hook_prepare_installcheck_plugin()
496 *
497 * Prepair bulk installation of plugins,
498 */
499 public function hook_prepare_installcheck_plugin() {
500 $this->secure_request( 'mainwp_preparebulkinstallcheckplugin' );
501 include_once ABSPATH . '/wp-admin/includes/plugin-install.php'; // NOSONAR - WP compatible.
502 $api = MainWP_System_Utility::get_plugin_theme_info(
503 'plugin',
504 array(
505 'slug' => isset( $_POST['slug'] ) ? sanitize_text_field( wp_unslash( $_POST['slug'] ) ) : '', // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
506 'fields' => array( 'sections' => false ),
507 )
508 ); // Save on a bit of bandwidth.
509 $url = $api->download_link;
510 $output = array();
511 $output['url'] = $url;
512 wp_send_json( $output );
513 }
514
515 /**
516 * Method mainwp_upgradewp()
517 *
518 * Update a specific WP core.
519 *
520 * @uses \MainWP\Dashboard\MainWP_Exception
521 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::upgrade_site()
522 */
523 public function mainwp_upgradewp() {
524 if ( ! \mainwp_current_user_can( 'dashboard', 'update_wordpress' ) ) {
525 die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update WordPress', 'mainwp' ), false ) ) ) );
526 }
527
528 $this->secure_request( 'mainwp_upgradewp' );
529
530 try {
531 $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : false; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
532 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::upgrade_site( $id ) ) ) ); // ok.
533 } catch ( MainWP_Exception $e ) {
534 die(
535 wp_json_encode(
536 array(
537 'error' => array(
538 'message' => $e->getMessage(),
539 'extra' => $e->get_message_extra(),
540 'errorCode' => $e->get_message_error_code(),
541 ),
542 )
543 )
544 );
545 }
546 }
547
548 /**
549 * Method mainwp_upgrade_plugintheme()
550 *
551 * Update plugin or theme.
552 *
553 * @uses \MainWP\Dashboard\MainWP_DB_Backup::backup_full_task_running()
554 * @uses \MainWP\Dashboard\MainWP_DB::get_website_by_id()
555 * @uses \MainWP\Dashboard\MainWP_Exception
556 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::get_plugin_theme_slugs()
557 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::upgrade_plugin_theme_translation()
558 */
559 public function mainwp_upgrade_plugintheme() { // phpcs:ignore -- NOSONAR -Current complexity is the only way to achieve desired results, pull request solutions appreciated.
560
561 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
562 if ( ! isset( $_POST['type'] ) ) {
563 die( wp_json_encode( array( 'error' => '<i class="red times icon"></i> ' . esc_html__( 'Plugin or theme not specified. Please reload the page and try again.', 'mainwp' ) ) ) );
564 }
565
566 if ( 'plugin' === $_POST['type'] && ! \mainwp_current_user_can( 'dashboard', 'update_plugins' ) ) {
567 die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update plugins', 'mainwp' ), false ) ) ) );
568 }
569
570 if ( 'theme' === $_POST['type'] && ! \mainwp_current_user_can( 'dashboard', 'update_themes' ) ) {
571 die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update themes', 'mainwp' ), false ) ) ) );
572 }
573
574 if ( 'translation' === $_POST['type'] && ! \mainwp_current_user_can( 'dashboard', 'update_translations' ) ) {
575 die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'update translations', 'mainwp' ), false ) ) ) );
576 }
577
578 $this->secure_request( 'mainwp_upgradeplugintheme' );
579
580 // support chunk update for manage sites page only.
581 $chunk_support = ! empty( $_POST['chunk_support'] ) ? true : false;
582 $max_update = 0;
583 $websiteId = null;
584 $slugs = '';
585
586 if ( isset( $_POST['websiteId'] ) ) {
587 $websiteId = intval( $_POST['websiteId'] );
588
589 if ( $chunk_support ) {
590 /**
591 * Filter: mainwp_update_plugintheme_max
592 *
593 * Filters the max number of plugins/themes to be updated in one run in order to improve performance.
594 *
595 * @param int $websiteId Child site ID.
596 *
597 * @since Unknown
598 */
599 $max_update = apply_filters( 'mainwp_update_plugintheme_max', false, $websiteId );
600 if ( empty( $max_update ) ) {
601 $chunk_support = false; // there is no hook so disable chunk update support.
602 }
603 }
604 if ( $chunk_support ) {
605 if ( isset( $_POST['chunk_slugs'] ) ) {
606 $slugs = wp_unslash( $_POST['chunk_slugs'] );
607 } else {
608 $slugs = MainWP_Updates_Handler::get_plugin_theme_slugs( $websiteId, sanitize_text_field( wp_unslash( $_POST['type'] ) ) );
609 }
610 } elseif ( isset( $_POST['slug'] ) ) {
611 $slugs = wp_unslash( $_POST['slug'] );
612 } else {
613 $slugs = MainWP_Updates_Handler::get_plugin_theme_slugs( $websiteId, sanitize_text_field( wp_unslash( $_POST['type'] ) ) );
614 }
615 }
616 // phpcs:enable
617
618 if ( MainWP_DB_Backup::instance()->backup_full_task_running( $websiteId ) ) {
619 die( wp_json_encode( array( 'error' => esc_html__( 'Backup process in progress on the child site. Please, try again later.', 'mainwp' ) ) ) );
620 }
621
622 $chunk_slugs = array();
623
624 if ( $chunk_support && $max_update ) {
625 $slugs = explode( ',', $slugs );
626 $chunk_slugs = array_slice( $slugs, $max_update );
627 $update_slugs = array_diff( $slugs, $chunk_slugs );
628 $slugs = implode( ',', $update_slugs );
629 }
630
631 if ( empty( $slugs ) && ! $chunk_support ) {
632 die( wp_json_encode( array( 'message' => esc_html__( 'Item slug could not be found. Update process could not be executed.', 'mainwp' ) ) ) );
633 }
634 $website = MainWP_DB::instance()->get_website_by_id( $websiteId );
635 try {
636 $info = array(
637 'result' => array(),
638 'result_error' => array(),
639 );
640
641 $result = MainWP_Updates_Handler::upgrade_plugin_theme_translation( $websiteId, sanitize_text_field( wp_unslash( $_POST['type'] ) ), $slugs ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
642
643 if ( is_array( $result ) ) {
644 if ( isset( $result['result'] ) ) {
645 $info['result'] = $result['result'];
646 }
647 if ( isset( $result['result_error'] ) ) {
648 $info['result_error'] = $result['result_error'];
649 }
650 }
651
652 if ( $chunk_support && ( ! empty( $chunk_slugs ) ) ) {
653 $info['chunk_slugs'] = implode( ',', $chunk_slugs );
654 }
655
656 if ( ! empty( $website ) ) {
657 $info['site_url'] = esc_url( $website->url );
658 }
659
660 // Get max the scope of the largest change.
661 $max_scope = apply_filters( 'mainwp_html_regression_largest_change_scope', $websiteId, false );
662 if ( ! empty( $max_scope ) && $max_scope !== $websiteId ) {
663 $info['result']['html_regression_max_scope'] = $max_scope;
664 }
665
666 wp_send_json( $info );
667 } catch ( MainWP_Exception $e ) {
668 die(
669 wp_json_encode(
670 array(
671 'error' => array(
672 'message' => $e->getMessage(),
673 'extra' => $e->get_message_extra(),
674 'errorCode' => $e->get_message_error_code(),
675 ),
676 )
677 )
678 );
679 }
680 }
681
682 /**
683 * Method mainwp_ignoreplugintheme()
684 *
685 * Ignores a plugin or a theme.
686 */
687 public function mainwp_ignoreplugintheme() {
688 $this->secure_request( 'mainwp_ignoreplugintheme' );
689
690 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
691 if ( ! isset( $_POST['id'] ) ) {
692 die( wp_json_encode( array( 'error' => esc_html__( 'Item ID not found. Please reload the page and try again.', 'mainwp' ) ) ) );
693 }
694 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
695 $slug = isset( $_POST['slug'] ) ? esc_html( wp_unslash( $_POST['slug'] ) ) : '';
696 $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0;
697 $name = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '';
698 $ver = isset( $_POST['ignore_ver'] ) ? sanitize_text_field( wp_unslash( $_POST['ignore_ver'] ) ) : '';
699 // phpcs:enable
700 wp_send_json( array( 'result' => MainWP_Updates_Handler::ignore_plugin_theme( $type, $slug, $name, $id, $ver ) ) );
701 }
702
703
704 /**
705 * Method mainwp_unignore_global_pluginsthemes()
706 *
707 * Unignore plugins or themes.
708 */
709 public function mainwp_unignore_global_pluginsthemes() {
710 $this->secure_request( 'mainwp_unignorepluginsthemes' );
711
712 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
713 if ( ! isset( $_POST['slug'] ) ) {
714 die( wp_json_encode( array( 'error' => esc_html__( 'Item slug not found. Please reload the page and try again.', 'mainwp' ) ) ) );
715 }
716 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
717 $slug = isset( $_POST['slug'] ) ? wp_unslash( $_POST['slug'] ) : '';
718 $ver = isset( $_POST['ignore_ver'] ) ? wp_unslash( $_POST['ignore_ver'] ) : '';
719 // phpcs:enable
720 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::unignore_global_plugins_themes( $type, $slug, $ver ) ) ) );
721 }
722
723 /**
724 * Method mainwp_unignoreabandonedplugintheme()
725 *
726 * Unignore abandoned plugin or theme.
727 *
728 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::ignore_plugin_theme()
729 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::unignore_abandoned_plugin_theme()
730 */
731 public function mainwp_unignoreabandonedplugintheme() {
732 $this->secure_request( 'mainwp_unignoreabandonedplugintheme' );
733
734 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
735 if ( ! isset( $_POST['id'] ) ) {
736 die( wp_json_encode( array( 'error' => esc_html__( 'Item ID not found. Please reload the page and try again.', 'mainwp' ) ) ) );
737 }
738
739 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
740 $slug = isset( $_POST['slug'] ) ? esc_html( wp_unslash( $_POST['slug'] ) ) : '';
741 $id = isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : 0; // string|int.
742 // phpcs:enable
743 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::unignore_abandoned_plugin_theme( $type, $slug, $id ) ) ) ); // ok.
744 }
745
746 /**
747 * Method mainwp_unignoreabandonedpluginthemes()
748 *
749 * Unignore abandoned plugins or themes.
750 *
751 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::unignore_abandoned_plugins_themes()
752 */
753 public function mainwp_unignoreabandonedpluginsthemes() {
754 $this->secure_request( 'mainwp_unignoreabandonedpluginsthemes' );
755
756 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
757 if ( ! isset( $_POST['slug'] ) ) {
758 die( wp_json_encode( array( 'error' => esc_html__( 'Item slug not found. Please reload the page and try again.', 'mainwp' ) ) ) );
759 }
760
761 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
762 $slug = isset( $_POST['slug'] ) ? esc_html( wp_unslash( $_POST['slug'] ) ) : '';
763 // phpcs:enable
764 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::unignore_abandoned_plugins_themes( $type, $slug ) ) ) );
765 }
766
767 /**
768 * Method mainwp_dismissoutdateplugintheme()
769 *
770 * Dismiss outdated plugin or theme.
771 *
772 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::dismiss_plugin_theme()
773 */
774 public function mainwp_dismissoutdateplugintheme() {
775 $this->secure_request( 'mainwp_dismissoutdateplugintheme' );
776
777 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
778 if ( ! isset( $_POST['id'] ) ) {
779 die( wp_json_encode( array( 'error' => esc_html__( 'Item ID not found. Please reload the page and try again.', 'mainwp' ) ) ) );
780 }
781 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
782 $slug = isset( $_POST['slug'] ) ? esc_html( wp_unslash( $_POST['slug'] ) ) : '';
783 $name = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '';
784 $id = isset( $_POST['id'] ) ? intval( $_POST['id'] ) : 0;
785 // phpcs:enable
786 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::dismiss_plugin_theme( $type, $slug, $name, $id ) ) ) );
787 }
788
789 /**
790 * Method mainwp_dismissoutdatepluginthemes()
791 *
792 * Dismiss outdated plugins or themes.
793 *
794 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::dismiss_plugins_themes()
795 */
796 public function mainwp_dismissoutdatepluginsthemes() {
797 $this->secure_request( 'mainwp_dismissoutdatepluginsthemes' );
798
799 if ( ! \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) {
800 die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) );
801 }
802
803 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
804 if ( ! isset( $_POST['slug'] ) ) {
805 die( wp_json_encode( array( 'error' => esc_html__( 'Item slug not found. Please reload the page and try again.', 'mainwp' ) ) ) );
806 }
807
808 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
809 $slug = isset( $_POST['slug'] ) ? esc_html( wp_unslash( $_POST['slug'] ) ) : '';
810 $name = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '';
811 // phpcs:enable
812
813 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::dismiss_plugins_themes( $type, $slug, $name ) ) ) );
814 }
815
816 /**
817 * Method mainwp_unignoreplugintheme()
818 *
819 * Unignore plugin or theme.
820 *
821 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::unignore_plugin_theme()
822 */
823 public function mainwp_unignoreplugintheme() {
824 $this->secure_request( 'mainwp_unignoreplugintheme' );
825
826 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
827 if ( ! isset( $_POST['id'] ) ) {
828 die( wp_json_encode( array( 'error' => esc_html__( 'Item ID not found. Please reload the page and try again.', 'mainwp' ) ) ) );
829 }
830 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
831 $slug = isset( $_POST['slug'] ) ? wp_unslash( $_POST['slug'] ) : '';
832 $id = isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : '';
833 $ver = isset( $_POST['ignore_ver'] ) ? sanitize_text_field( wp_unslash( $_POST['ignore_ver'] ) ) : '';
834
835 // phpcs:enable
836 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::unignore_plugin_theme( $type, $slug, $id, $ver ) ) ) );
837 }
838
839 /**
840 * Method mainwp_ignorepluginsthemes()
841 *
842 * Ignore plugins or themes.
843 *
844 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::ignore_plugins_themes()
845 */
846 public function mainwp_ignorepluginsthemes() {
847 $this->secure_request( 'mainwp_ignorepluginsthemes' );
848
849 if ( ! \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) {
850 die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) );
851 }
852
853 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
854 if ( ! isset( $_POST['slug'] ) ) {
855 die( wp_json_encode( array( 'error' => esc_html__( 'Item slug not found. Please reload the page and try again.', 'mainwp' ) ) ) );
856 }
857
858 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
859 $slug = isset( $_POST['slug'] ) ? esc_html( wp_unslash( $_POST['slug'] ) ) : '';
860 $name = isset( $_POST['name'] ) ? sanitize_text_field( wp_unslash( $_POST['name'] ) ) : '';
861 $ver = isset( $_POST['ignore_ver'] ) ? sanitize_text_field( wp_unslash( $_POST['ignore_ver'] ) ) : '';
862
863 // phpcs:enable
864 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::ignore_plugins_themes( $type, $slug, $name, $ver ) ) ) );
865 }
866
867 /**
868 * Method ajax_ignore_core_updates()
869 *
870 * Ignore plugins or themes.
871 *
872 * @uses \MainWP\Dashboard\MainWP_Updates_Handler::ignore_plugins_themes()
873 */
874 public function ajax_ignore_core_updates() { //phpcs:ignore -- NOSONAR complex function.
875
876 $this->secure_request( 'mainwp_updates_ignore_upgrades' );
877
878 if ( ! \mainwp_current_user_can( 'dashboard', 'ignore_unignore_updates' ) ) {
879 die( wp_json_encode( array( 'error' => \mainwp_do_not_have_permissions( esc_html__( 'ignore/unignore updates', 'mainwp' ) ) ) ) );
880 }
881
882 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
883 if ( empty( $_POST['slug'] ) ) {
884 die( wp_json_encode( array( 'error' => esc_html__( 'Item slug not found. Please reload the page and try again.', 'mainwp' ) ) ) );
885 }
886
887 $type = isset( $_POST['type'] ) ? sanitize_text_field( wp_unslash( $_POST['type'] ) ) : '';
888 $ignore = isset( $_POST['ignore'] ) ? sanitize_text_field( wp_unslash( $_POST['ignore'] ) ) : '';
889 $site_id = isset( $_POST['site_id'] ) ? intval( $_POST['site_id'] ) : 0;
890 $ver = isset( $_POST['ignore_ver'] ) ? sanitize_text_field( wp_unslash( $_POST['ignore_ver'] ) ) : '';
891
892 if ( 'wp' === $type ) {
893 if ( ( 'this_version' === $ignore || 'all_versions' === $ignore ) && $site_id ) {
894 $website = MainWP_DB::instance()->get_website_by_id( $site_id, false, array( 'ignored_wp_upgrades' ) );
895
896 if ( empty( $website ) ) {
897 wp_send_json( array( 'error' => esc_html__( 'Site ID invalid or site not found. Please try again.', 'mainwp' ) ) );
898 }
899
900 $ignored_upgrades = ! empty( $website->ignored_wp_upgrades ) ? json_decode( $website->ignored_wp_upgrades, true ) : array();
901
902 if ( ! is_array( $ignored_upgrades ) ) {
903 $ignored_upgrades = array();
904 }
905
906 $ignored_vers = is_array( $ignored_upgrades ) && isset( $ignored_upgrades['ignored_versions'] ) ? $ignored_upgrades['ignored_versions'] : array();
907 if ( ! is_array( $ignored_vers ) ) {
908 $ignored_vers = array();
909 }
910
911 if ( empty( $ver ) || 'all_versions' === $ver ) { // ignore all.
912 $ignored_vers = array( 'all_versions' );
913 } else {
914 $ver = urldecode( $ver );
915 if ( ! in_array( $ver, $ignored_vers ) ) {
916 $ignored_vers[] = $ver;
917 }
918 }
919
920 $ignored_upgrades['ignored_versions'] = $ignored_vers;
921
922 MainWP_DB::instance()->update_website_option(
923 $site_id,
924 'ignored_wp_upgrades',
925 wp_json_encode( $ignored_upgrades )
926 );
927
928 wp_send_json( array( 'success' => 1 ) );
929
930 } elseif ( 'this_version_global' === $ignore ) {
931
932 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
933 $decodedIgnoredCores = ! empty( $userExtension->ignored_wp_upgrades ) ? json_decode( $userExtension->ignored_wp_upgrades, true ) : array();
934
935 if ( ! is_array( $decodedIgnoredCores ) ) {
936 $decodedIgnoredCores = array();
937 }
938
939 $ignored_vers = isset( $decodedIgnoredCores['ignored_versions'] ) ? $decodedIgnoredCores['ignored_versions'] : array();
940
941 if ( ! is_array( $ignored_vers ) ) {
942 $ignored_vers = array();
943 }
944
945 $ver = urldecode( $ver );
946 if ( ! in_array( $ver, $ignored_vers ) ) {
947 $ignored_vers[] = $ver;
948 }
949
950 $decodedIgnoredCores['ignored_versions'] = $ignored_vers;
951
952 MainWP_DB_Common::instance()->update_user_extension(
953 array(
954 'userid' => null,
955 'ignored_wp_upgrades' => wp_json_encode( $decodedIgnoredCores ),
956 )
957 );
958 wp_send_json( array( 'success' => 1 ) );
959 }
960 }
961 wp_send_json( array( 'error' => esc_html__( 'Invalid types. Please try again.', 'mainwp' ) ) );
962 }
963
964 /**
965 * Method ajax_unignore_core_updates()
966 *
967 * Unignore plugin or theme.
968 */
969 public function ajax_unignore_core_updates() {
970 $this->secure_request( 'mainwp_updates_unignore_upgrades' );
971 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
972 $id = isset( $_POST['id'] ) ? sanitize_text_field( wp_unslash( $_POST['id'] ) ) : ''; // numberic id or _ALL_.
973 $ver = isset( $_POST['ignore_ver'] ) ? sanitize_text_field( wp_unslash( $_POST['ignore_ver'] ) ) : '';
974 // phpcs:enable
975 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::unignore_core_updates( $id, $ver ) ) ) );
976 }
977
978
979 /**
980 * Method ajax_unignore_global_upgrades()
981 *
982 * Unignore plugin or theme.
983 */
984 public function ajax_unignore_global_upgrades() {
985 $this->secure_request( 'mainwp_updates_unignore_global_upgrades' );
986 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
987 $slug = isset( $_POST['slug'] ) ? wp_unslash( $_POST['slug'] ) : '';
988 $ver = isset( $_POST['ignore_ver'] ) ? sanitize_text_field( wp_unslash( $_POST['ignore_ver'] ) ) : '';
989 // phpcs:enable
990 die( wp_json_encode( array( 'result' => MainWP_Updates_Handler::unignore_global_cores( $slug, $ver ) ) ) );
991 }
992
993
994 /**
995 * Method mainwp_trust_plugin()
996 *
997 * Trust plugin.
998 *
999 * @uses \MainWP\Dashboard\MainWP_Plugins_Handler::trust_post()
1000 * @uses \MainWP\Dashboard\MainWP_Themes_Handler::trust_post()
1001 */
1002 public function mainwp_trust_plugin() {
1003 $this->secure_request( 'mainwp_trust_plugin' );
1004
1005 MainWP_Plugins_Handler::trust_post();
1006 die( wp_json_encode( array( 'result' => true ) ) );
1007 }
1008
1009 /**
1010 * Method mainwp_trust_theme()
1011 *
1012 * Trust theme.
1013 */
1014 public function mainwp_trust_theme() {
1015 $this->secure_request( 'mainwp_trust_theme' );
1016
1017 MainWP_Themes_Handler::trust_post();
1018 die( wp_json_encode( array( 'result' => true ) ) );
1019 }
1020 }
1021