PluginProbe ʕ •ᴥ•ʔ
Secure Custom Fields / 6.9.3
Secure Custom Fields v6.9.3
6.9.5 6.9.4 6.9.3 6.9.2 6.9.1 6.9.0 6.8.9 6.8.7 6.8.8 6.8.6 6.8.4 6.8.5 trunk 6.4.0-beta1 6.4.0-beta2 6.4.1 6.4.1-beta3 6.4.1-beta4 6.4.1-beta5 6.4.1-beta6 6.4.1-beta7 6.4.2 6.5.0 6.5.1 6.5.2 6.5.3 6.5.4 6.5.5 6.5.6 6.5.7 6.6.0 6.7.0 6.7.1 6.8.0 6.8.1 6.8.2 6.8.3
secure-custom-fields / includes / ajax / class-acf-ajax-upgrade.php
secure-custom-fields / includes / ajax Last commit date
class-acf-ajax-check-screen.php 2 months ago class-acf-ajax-local-json-diff.php 1 year ago class-acf-ajax-query-users.php 4 months ago class-acf-ajax-query.php 5 months ago class-acf-ajax-upgrade.php 2 months ago class-acf-ajax-user-setting.php 1 year ago class-acf-ajax.php 1 year ago index.php 1 year ago
class-acf-ajax-upgrade.php
75 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit; // Exit if accessed directly
5 }
6
7 if ( ! class_exists( 'ACF_Ajax_Upgrade' ) ) :
8
9 class ACF_Ajax_Upgrade extends ACF_Ajax {
10
11 /** @var string The AJAX action name */
12 var $action = 'acf/ajax/upgrade';
13
14 /**
15 * Returns the response data to sent back.
16 *
17 * @since ACF 5.7.2
18 *
19 * @param array $request The request args.
20 * @return boolean|WP_Error True if successful, or WP_Error on failure.
21 */
22 public function get_response( $request ) {
23 if ( ! current_user_can( acf_get_setting( 'capability' ) ) ) {
24 return new WP_Error( 'upgrade_error', __( 'Sorry, you do not have permission to do that.', 'secure-custom-fields' ) );
25 }
26
27 // Switch blog.
28 $switched = false;
29 if ( isset( $request['blog_id'] ) ) {
30 if ( ! is_super_admin() ) {
31 return new WP_Error( 'upgrade_error', __( 'Sorry, you do not have permission to do that.', 'secure-custom-fields' ) );
32 }
33
34 $blog_id = absint( $request['blog_id'] );
35 if ( ! $blog_id || ! get_site( $blog_id ) ) {
36 return new WP_Error( 'upgrade_error', __( 'Invalid site ID.', 'secure-custom-fields' ) );
37 }
38
39 switch_to_blog( $blog_id );
40 $switched = true;
41 }
42
43 // Bail early if no upgrade available.
44 if ( ! acf_has_upgrade() ) {
45 if ( $switched ) {
46 restore_current_blog();
47 }
48 return new WP_Error( 'upgrade_error', __( 'No updates available.', 'secure-custom-fields' ) );
49 }
50
51 // Listen for output.
52 ob_start();
53
54 // Run upgrades.
55 acf_upgrade_all();
56
57 // Store output.
58 $error = ob_get_clean();
59
60 if ( $switched ) {
61 restore_current_blog();
62 }
63
64 // Return error or success.
65 if ( $error ) {
66 return new WP_Error( 'upgrade_error', $error );
67 }
68
69 return true;
70 }
71 }
72
73 acf_new_instance( 'ACF_Ajax_Upgrade' );
74 endif; // class_exists check
75