| @@ -27,12 +27,18 @@ | ||
| 27 | 27 | if ( ! function_exists( 'get_plugin_updates' ) ) { |
| 28 | 28 | require_once ABSPATH . 'wp-admin/includes/update.php'; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - $response = []; | |
| 32 | - $plugins = get_plugins(); | |
| 33 | - $updates = get_plugin_updates(); | |
| 31 | + // Update the update cache if requested. | |
| 32 | + if ( isset( $args['force'] ) && $args['force'] === 'true' ) { | |
| 33 | + wp_update_plugins(); | |
| 34 | + } | |
| 34 | 35 | |
| 36 | + $response = []; | |
| 37 | + $plugins = get_plugins(); | |
| 38 | + $updates = get_plugin_updates(); | |
| 39 | + $auto_updates = get_site_option( 'auto_update_plugins', [] ); | |
| 40 | + | |
| 35 | 41 | foreach ( $plugins as $file => $details ) { |
| 36 | 42 | $plugin_status = $this->get_status( $file ); |
| 37 | 43 | $update = $this->get_update( $file, $updates ); |
| 38 | 44 | |
| @@ -52,8 +58,9 @@ | ||
| 52 | 58 | 'status' => $plugin_status, |
| 53 | 59 | 'textdomain' => $details['TextDomain'], |
| 54 | 60 | 'description' => $details['Description'], |
| 55 | 61 | 'php' => $details['RequiresPHP'], |
| 62 | + 'auto_update' => in_array( $file, $auto_updates, true ), | |
| 56 | 63 | ]; |
| 57 | 64 | } |
| 58 | 65 | |
| 59 | 66 | wp_send_json( $response ); |