PluginProbe
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation / trunk
WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation vtrunk
1.4.48 1.4.47 1.4.46 1.4.45 1.4.44 1.4.43 1.4.42 1.4.41 1.4.40 1.4.39 1.4.38 1.4.37 1.4.36 1.1.2 1.2.0 1.2.1 1.2.2 1.3.0 1.3.1 1.4.0 1.4.1 1.4.10 1.4.11 1.4.12 1.4.13 All 64 releases
optin / includes / class-wpxpo-plugins.php

class-wpxpo-plugins.php in WowOptin: Next-Gen Popup Maker – Create Stunning Popups and Optins for Lead Generation trunk, at includes/class-wpxpo-plugins.php

59 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore
2
3 namespace OPTN\Includes;
4
5 defined( 'ABSPATH' ) || exit;
6
7 /**
8 * Class WpxpoPlugins
9 */
10 class WpxpoPlugins {
11
12
13 /**
14 * Constructor. Hooks into various WordPress actions.
15 */
16 public function __construct() {
17 // Our Plugin Activation Hooks.
18 add_action( 'wp_ajax_optn_install_plugin', array( $this, 'install_plugin_callback' ) );
19 }
20
21 /**
22 * Handles plugin installation and activation via AJAX.
23 *
24 * @return void
25 */
26 public function install_plugin_callback() {
27
28 $nonce = isset( $_POST['wpnonce'] ) ? sanitize_key( wp_unslash( $_POST['wpnonce'] ) ) : '';
29
30 if ( ! isset( $nonce ) ) {
31 wp_send_json_error( esc_html__( 'Nonce is missing.', 'optin' ) );
32 }
33
34 if ( wp_verify_nonce( $nonce, 'optin-nonce' ) === false ) {
35 wp_send_json_error( esc_html__( 'Invalid nonce.', 'optin' ) );
36 }
37
38 if ( ! current_user_can( 'install_plugins' ) ) {
39 wp_send_json_error( esc_html__( 'Insufficient permissions.', 'optin' ) );
40 }
41
42 $plugin = isset( $_POST['plugin'] ) ? sanitize_text_field( wp_unslash( $_POST['plugin'] ) ) : '';
43
44 if ( empty( $plugin ) ) {
45 wp_send_json_error( array( 'message' => 'No plugin specified' ) );
46 }
47
48 $res = array( 'message' => 'false' );
49
50 if ( $plugin ) {
51 $res = Xpo::install_and_active_plugin( $plugin );
52 }
53
54 wp_send_json_success( array( 'message' => $res ) );
55
56 die();
57 }
58 }
59