PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 1.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v1.4.0
2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 All 61 releases
subscription / includes / Ajax.php

Ajax.php in Subscriptions for WooCommerce with Stripe Recurring Payments 1.4.0, at includes/Ajax.php

87 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SpringDevs\Subscription;
4
5 /**
6 * The Ajax class
7 */
8 class Ajax {
9
10
11 /**
12 * Initialize the class
13 */
14 public function __construct() {
15 add_action( 'wp_ajax_install_woocommerce_plugin', array( $this, 'install_woocommerce_plugin' ) );
16 add_action( 'wp_ajax_activate_woocommerce_plugin', array( $this, 'activate_woocommerce_plugin' ) );
17 }
18
19 /**
20 * Install the WooCommerce Plugin.
21 */
22 public function install_woocommerce_plugin() {
23 include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
24 include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
25 include_once ABSPATH . 'wp-admin/includes/file.php';
26 include_once ABSPATH . 'wp-admin/includes/misc.php';
27
28 if ( ! class_exists( 'Plugin_Upgrader' ) ) {
29 include ABSPATH . 'wp-admin/includes/class-plugin-upgrader.php';
30 }
31 if ( ! class_exists( 'Plugin_Installer_Skin' ) ) {
32 include ABSPATH . 'wp-admin/includes/class-plugin-installer-skin.php';
33 }
34
35 $plugin = 'woocommerce';
36
37 $api = plugins_api(
38 'plugin_information',
39 array(
40 'slug' => $plugin,
41 'fields' => array(
42 'short_description' => false,
43 'sections' => false,
44 'requires' => false,
45 'rating' => false,
46 'ratings' => false,
47 'downloaded' => false,
48 'last_updated' => false,
49 'added' => false,
50 'tags' => false,
51 'compatibility' => false,
52 'homepage' => false,
53 'donate_link' => false,
54 ),
55 )
56 );
57
58 if ( is_wp_error( $api ) ) {
59 wp_die( $api );
60 }
61
62 $title = sprintf( __( 'Installing Plugin: %s', 'sdevs_subscrpt' ), $api->name . ' ' . $api->version );
63 $nonce = 'install-plugin_' . $plugin;
64 $url = 'update.php?action=install-plugin&plugin=' . urlencode( $plugin );
65
66 $upgrader = new \Plugin_Upgrader( new \Plugin_Installer_Skin( compact( 'title', 'url', 'nonce', 'plugin', 'api' ) ) );
67 $upgrader->install( $api->download_link );
68 wp_send_json(
69 array(
70 'msg' => 'Installed successfully !!',
71 )
72 );
73 }
74
75 /**
76 * Active WooComerce Plugin.
77 */
78 public function activate_woocommerce_plugin() {
79 activate_plugin( 'woocommerce/woocommerce.php' );
80 wp_send_json(
81 array(
82 'msg' => 'Activated successfully !!',
83 )
84 );
85 }
86 }
87