PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 2.17.1
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v2.17.1
4.8.1 trunk 1.0 1.1 1.12.1 1.2.3 1.2.4 1.2.5 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.5.1 1.6.6 1.6.6.1 1.6.6.2 1.6.6.3 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.9.0 1.9.1 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.8.1 1.9.9 1.9.9.1 1.9.9.2 1.9.9.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.10 2.11 2.11.1 2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.13 2.14 2.14.1 2.15 2.15.1 2.16 2.16.1 2.17 2.17.1 2.18 2.18.1 2.18.2 2.18.3 2.19 2.19.1 2.19.2 2.19.3 2.2 2.2.1 2.3 2.3.1 2.3.10 2.3.2 2.3.3 2.3.4 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.1.1 2.4.1.2 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1 4.1.1 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 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.7.5 4.7.6 4.7.7
custom-facebook-feed / admin / addon-functions.php
custom-facebook-feed / admin Last commit date
PluginSilentUpgrader.php 5 years ago PluginSilentUpgraderSkin.php 6 years ago addon-functions.php 6 years ago class-cff-about.php 6 years ago class-cff-new-user.php 5 years ago class-cff-notifications.php 5 years ago class-cff-tracking.php 5 years ago class-install-skin.php 6 years ago
addon-functions.php
176 lines
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 /**
5 * Deactivate addon.
6 *
7 * @since 1.0.0
8 */
9 function cff_deactivate_addon() {
10
11 // Run a security check.
12 check_ajax_referer( 'cff-admin', 'nonce' );
13 $cap = current_user_can( 'manage_custom_facebook_feed_options' ) ? 'manage_custom_facebook_feed_options' : 'manage_options';
14 $cap = apply_filters( 'cff_settings_pages_capability', $cap );
15 // Check for permissions.
16 if ( ! current_user_can( $cap ) ) {
17 wp_send_json_error();
18 }
19
20 $type = 'addon';
21 if ( ! empty( $_POST['type'] ) ) {
22 $type = sanitize_key( $_POST['type'] );
23 }
24
25 if ( isset( $_POST['plugin'] ) ) {
26 deactivate_plugins( $_POST['plugin'] );
27
28 if ( 'plugin' === $type ) {
29 wp_send_json_success( esc_html__( 'Plugin deactivated.', 'custom-facebook-feed' ) );
30 } else {
31 wp_send_json_success( esc_html__( 'Addon deactivated.', 'custom-facebook-feed' ) );
32 }
33 }
34
35 wp_send_json_error( esc_html__( 'Could not deactivate the addon. Please deactivate from the Plugins page.', 'custom-facebook-feed' ) );
36 }
37 add_action( 'wp_ajax_cff_deactivate_addon', 'cff_deactivate_addon' );
38
39 /**
40 * Activate addon.
41 *
42 * @since 1.0.0
43 */
44 function cff_activate_addon() {
45
46 // Run a security check.
47 check_ajax_referer( 'cff-admin', 'nonce' );
48
49 // Check for permissions.
50 if ( ! current_user_can( 'manage_options' ) ) {
51 wp_send_json_error();
52 }
53
54 if ( isset( $_POST['plugin'] ) ) {
55
56 $type = 'addon';
57 if ( ! empty( $_POST['type'] ) ) {
58 $type = sanitize_key( $_POST['type'] );
59 }
60
61 $activate = activate_plugins( $_POST['plugin'] );
62
63 if ( ! is_wp_error( $activate ) ) {
64 if ( 'plugin' === $type ) {
65 wp_send_json_success( esc_html__( 'Plugin activated.', 'custom-facebook-feed' ) );
66 } else {
67 wp_send_json_success( esc_html__( 'Addon activated.', 'custom-facebook-feed' ) );
68 }
69 }
70 }
71
72 wp_send_json_error( esc_html__( 'Could not activate addon. Please activate from the Plugins page.', 'custom-facebook-feed' ) );
73 }
74 add_action( 'wp_ajax_cff_activate_addon', 'cff_activate_addon' );
75
76 /**
77 * Install addon.
78 *
79 * @since 1.0.0
80 */
81 function cff_install_addon() {
82
83 // Run a security check.
84 check_ajax_referer( 'cff-admin', 'nonce' );
85
86 // Check for permissions.
87 if ( ! current_user_can( 'manage_options' ) ) {
88 wp_send_json_error();
89 }
90
91 $error = esc_html__( 'Could not install addon. Please download from smashballoon.com and install manually.', 'custom-facebook-feed' );
92
93 if ( empty( $_POST['plugin'] ) ) {
94 wp_send_json_error( $error );
95 }
96
97 // Set the current screen to avoid undefined notices.
98 set_current_screen( 'cff-about' );
99
100 // Prepare variables.
101 $url = esc_url_raw(
102 add_query_arg(
103 array(
104 'page' => 'cff-about',
105 ),
106 admin_url( 'admin.php' )
107 )
108 );
109
110 $creds = request_filesystem_credentials( $url, '', false, false, null );
111
112 // Check for file system permissions.
113 if ( false === $creds ) {
114 wp_send_json_error( $error );
115 }
116
117 if ( ! WP_Filesystem( $creds ) ) {
118 wp_send_json_error( $error );
119 }
120
121 /*
122 * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
123 */
124
125 require_once CFF_PLUGIN_DIR . 'admin/class-install-skin.php';
126
127 // Do not allow WordPress to search/download translations, as this will break JS output.
128 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
129
130 // Create the plugin upgrader with our custom skin.
131 $installer = new CFF\Helpers\PluginSilentUpgrader( new CFF_Install_Skin() );
132
133 // Error check.
134 if ( ! method_exists( $installer, 'install' ) || empty( $_POST['plugin'] ) ) {
135 wp_send_json_error( $error );
136 }
137
138 $installer->install( $_POST['plugin'] ); // phpcs:ignore
139
140 // Flush the cache and return the newly installed plugin basename.
141 wp_cache_flush();
142
143 $plugin_basename = $installer->plugin_info();
144
145 if ( $plugin_basename ) {
146
147 $type = 'addon';
148 if ( ! empty( $_POST['type'] ) ) {
149 $type = sanitize_key( $_POST['type'] );
150 }
151
152 // Activate the plugin silently.
153 $activated = activate_plugin( $plugin_basename );
154
155 if ( ! is_wp_error( $activated ) ) {
156 wp_send_json_success(
157 array(
158 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed & activated.', 'custom-facebook-feed' ) : esc_html__( 'Addon installed & activated.', 'custom-facebook-feed' ),
159 'is_activated' => true,
160 'basename' => $plugin_basename,
161 )
162 );
163 } else {
164 wp_send_json_success(
165 array(
166 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed.', 'custom-facebook-feed' ) : esc_html__( 'Addon installed.', 'custom-facebook-feed' ),
167 'is_activated' => false,
168 'basename' => $plugin_basename,
169 )
170 );
171 }
172 }
173
174 wp_send_json_error( $error );
175 }
176 add_action( 'wp_ajax_cff_install_addon', 'cff_install_addon' );