Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Jetpack_JSON_API_Maybe_Auto_Update_Endpoint | |
0.00% |
0 / 10 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| result | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
12 | |||
| get_update_results | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit( 0 ); |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Auto update endpoint class. |
| 9 | * |
| 10 | * POST /sites/%s/maybe_auto_update |
| 11 | * |
| 12 | * @phan-constructor-used-for-side-effects |
| 13 | */ |
| 14 | class Jetpack_JSON_API_Maybe_Auto_Update_Endpoint extends Jetpack_JSON_API_Endpoint { |
| 15 | |
| 16 | /** |
| 17 | * Needed capabilities. |
| 18 | * |
| 19 | * @var array |
| 20 | */ |
| 21 | protected $needed_capabilities = array( 'update_core', 'update_plugins', 'update_themes' ); |
| 22 | |
| 23 | /** |
| 24 | * Update results. |
| 25 | * |
| 26 | * @var array |
| 27 | */ |
| 28 | protected $update_results = array(); |
| 29 | |
| 30 | /** |
| 31 | * The result. |
| 32 | * |
| 33 | * @return array |
| 34 | */ |
| 35 | protected function result() { |
| 36 | add_action( 'automatic_updates_complete', array( $this, 'get_update_results' ), 100, 1 ); |
| 37 | |
| 38 | wp_maybe_auto_update(); |
| 39 | |
| 40 | $result = array(); |
| 41 | $result['log'] = $this->update_results; |
| 42 | |
| 43 | if ( empty( $result['log'] ) ) { |
| 44 | $possible_reasons_for_failure = Jetpack_Autoupdate::get_possible_failures(); |
| 45 | |
| 46 | if ( $possible_reasons_for_failure ) { |
| 47 | $result['log']['error'] = $possible_reasons_for_failure; |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | return $result; |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Get update results. |
| 56 | * |
| 57 | * @param array $results - the results. |
| 58 | */ |
| 59 | public function get_update_results( $results ) { |
| 60 | $this->update_results = $results; |
| 61 | } |
| 62 | } |