PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.1.5
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.1.5
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
assets 3 years ago builder 3 years ago templates 3 years ago views 3 years ago addon-functions.php 3 years ago admin-functions.php 3 years ago enqueu-script.php 3 years ago
addon-functions.php
209 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
14 // Check for permissions.
15 if ( ! current_user_can( 'deactivate_plugins' ) ) {
16 wp_send_json_error();
17 }
18
19 $type = 'addon';
20 if ( ! empty( $_POST['type'] ) ) {
21 $type = sanitize_key( wp_unslash( $_POST['type'] ) );
22 }
23
24 if ( isset( $_POST['plugin'] ) ) {
25 deactivate_plugins( wp_unslash( $_POST['plugin'] ) );
26
27 if ( 'plugin' === $type ) {
28 wp_send_json_success( esc_html__( 'Plugin deactivated.', 'custom-facebook-feed' ) );
29 } else {
30 wp_send_json_success( esc_html__( 'Addon deactivated.', 'custom-facebook-feed' ) );
31 }
32 }
33
34 wp_send_json_error( esc_html__( 'Could not deactivate the addon. Please deactivate from the Plugins page.', 'custom-facebook-feed' ) );
35 }
36 add_action( 'wp_ajax_cff_deactivate_addon', 'cff_deactivate_addon' );
37
38 /**
39 * Activate addon.
40 *
41 * @since 1.0.0
42 */
43 function cff_activate_addon() {
44
45 // Run a security check.
46 check_ajax_referer( 'cff-admin', 'nonce' );
47
48 // Check for permissions.
49 if ( ! current_user_can( 'activate_plugins' ) ) {
50 wp_send_json_error();
51 }
52
53 if ( isset( $_POST['plugin'] ) ) {
54
55 $type = 'addon';
56 if ( ! empty( $_POST['type'] ) ) {
57 $type = sanitize_key( wp_unslash( $_POST['type'] ) );
58 }
59
60 $activate = activate_plugins( $_POST['plugin'] );
61
62 if ( ! is_wp_error( $activate ) ) {
63 if ( 'plugin' === $type ) {
64 wp_send_json_success( esc_html__( 'Plugin activated.', 'custom-facebook-feed' ) );
65 } else {
66 wp_send_json_success( esc_html__( 'Addon activated.', 'custom-facebook-feed' ) );
67 }
68 }
69 }
70
71 wp_send_json_error( esc_html__( 'Could not activate addon. Please activate from the Plugins page.', 'custom-facebook-feed' ) );
72 }
73 add_action( 'wp_ajax_cff_activate_addon', 'cff_activate_addon' );
74
75 /**
76 * Install addon.
77 *
78 * @since 1.0.0
79 */
80 function cff_install_addon() {
81
82 // Run a security check.
83 check_ajax_referer( 'cff-admin', 'nonce' );
84
85 // Check for permissions.
86 if ( ! current_user_can( 'install_plugins' ) ) {
87 wp_send_json_error();
88 }
89
90 $error = esc_html__( 'Could not install addon. Please download from smashballoon.com and install manually.', 'custom-facebook-feed' );
91
92 if ( empty( $_POST['plugin'] ) ) {
93 wp_send_json_error( $error );
94 }
95
96 // Set the current screen to avoid undefined notices.
97 set_current_screen( 'cff-about' );
98
99 // Prepare variables.
100 $url = esc_url_raw(
101 add_query_arg(
102 array(
103 'page' => 'cff-about',
104 ),
105 admin_url( 'admin.php' )
106 )
107 );
108
109 $creds = request_filesystem_credentials( $url, '', false, false, null );
110
111 // Check for file system permissions.
112 if ( false === $creds ) {
113 wp_send_json_error( $error );
114 }
115
116 if ( ! WP_Filesystem( $creds ) ) {
117 wp_send_json_error( $error );
118 }
119
120 /*
121 * We do not need any extra credentials if we have gotten this far, so let's install the plugin.
122 */
123
124 #require_once CFF_PLUGIN_DIR . 'admin/class-install-skin.php';
125
126 // Do not allow WordPress to search/download translations, as this will break JS output.
127 remove_action( 'upgrader_process_complete', array( 'Language_Pack_Upgrader', 'async_upgrade' ), 20 );
128
129 // Create the plugin upgrader with our custom skin.
130 $installer = new CustomFacebookFeed\Helpers\PluginSilentUpgrader( new CustomFacebookFeed\Admin\CFF_Install_Skin() );
131
132 // Error check.
133 if ( ! method_exists( $installer, 'install' ) || empty( $_POST['plugin'] ) ) {
134 wp_send_json_error( $error );
135 }
136
137 $installer->install( $_POST['plugin'] ); // phpcs:ignore
138
139 // Flush the cache and return the newly installed plugin basename.
140 wp_cache_flush();
141
142 $plugin_basename = $installer->plugin_info();
143
144 if ( $plugin_basename ) {
145
146 $type = 'addon';
147 if ( ! empty( $_POST['type'] ) ) {
148 $type = sanitize_key( $_POST['type'] );
149 }
150
151 // Activate the plugin silently.
152 $activated = activate_plugin( $plugin_basename );
153
154 if ( ! is_wp_error( $activated ) ) {
155 wp_send_json_success(
156 array(
157 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed & activated.', 'custom-facebook-feed' ) : esc_html__( 'Addon installed & activated.', 'custom-facebook-feed' ),
158 'is_activated' => true,
159 'basename' => $plugin_basename,
160 )
161 );
162 } else {
163 wp_send_json_success(
164 array(
165 'msg' => 'plugin' === $type ? esc_html__( 'Plugin installed.', 'custom-facebook-feed' ) : esc_html__( 'Addon installed.', 'custom-facebook-feed' ),
166 'is_activated' => false,
167 'basename' => $plugin_basename,
168 )
169 );
170 }
171 }
172
173 wp_send_json_error( $error );
174 }
175
176
177 add_action( 'wp_ajax_cff_install_addon', 'cff_install_addon' );
178
179
180 /**
181 * Smash Balloon Encrypt or decrypt
182 *
183 * @param string @action
184 * @param string @string
185 *
186 * @return string $output
187 */
188 function sb_encrypt_decrypt( $action, $string ) {
189 $output = false;
190
191 $encrypt_method = "AES-256-CBC";
192 $secret_key = 'SMA$H.BA[[OON#23121';
193 $secret_iv = '1231394873342102221';
194
195 // hash
196 $key = hash( 'sha256', $secret_key );
197
198 // iv - encrypt method AES-256-CBC expects 16 bytes - else you will get a warning
199 $iv = substr( hash( 'sha256', $secret_iv ), 0, 16 );
200
201 if ( $action == 'encrypt' ) {
202 $output = openssl_encrypt( $string, $encrypt_method, $key, 0, $iv );
203 $output = base64_encode( $output );
204 } else if ( $action == 'decrypt' ) {
205 $output = openssl_decrypt( base64_decode( $string ), $encrypt_method, $key, 0, $iv );
206 }
207
208 return $output;
209 }