Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 11 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Jetpack_JSON_API_Translations_Modify_Endpoint | |
0.00% |
0 / 9 |
|
0.00% |
0 / 2 |
30 | |
0.00% |
0 / 1 |
| default_action | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
12 | |||
| update | |
0.00% |
0 / 5 |
|
0.00% |
0 / 1 |
6 | |||
| 1 | <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName |
| 2 | |
| 3 | if ( ! defined( 'ABSPATH' ) ) { |
| 4 | exit( 0 ); |
| 5 | } |
| 6 | |
| 7 | /** |
| 8 | * Translations modify endpoint class. |
| 9 | * POST /sites/%s/translation |
| 10 | * POST /sites/%s/translations/update |
| 11 | * |
| 12 | * @phan-constructor-used-for-side-effects |
| 13 | */ |
| 14 | class Jetpack_JSON_API_Translations_Modify_Endpoint extends Jetpack_JSON_API_Translations_Endpoint { |
| 15 | |
| 16 | /** |
| 17 | * The action. |
| 18 | * |
| 19 | * @var string |
| 20 | */ |
| 21 | protected $action = 'default_action'; |
| 22 | |
| 23 | /** |
| 24 | * The new version. |
| 25 | * |
| 26 | * @var string |
| 27 | */ |
| 28 | protected $new_version; |
| 29 | |
| 30 | /** |
| 31 | * The log. |
| 32 | * |
| 33 | * @var array |
| 34 | */ |
| 35 | protected $log; |
| 36 | |
| 37 | /** |
| 38 | * Run the default action. |
| 39 | * |
| 40 | * @return true |
| 41 | */ |
| 42 | public function default_action() { |
| 43 | $args = $this->input(); |
| 44 | |
| 45 | if ( isset( $args['autoupdate'] ) && is_bool( $args['autoupdate'] ) ) { |
| 46 | Jetpack_Options::update_option( 'autoupdate_translations', $args['autoupdate'] ); |
| 47 | } |
| 48 | |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Update the translations. |
| 54 | */ |
| 55 | protected function update() { |
| 56 | include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php'; |
| 57 | |
| 58 | $upgrader = new Language_Pack_Upgrader( new Automatic_Upgrader_Skin() ); |
| 59 | $result = $upgrader->bulk_upgrade(); |
| 60 | |
| 61 | $this->log = $upgrader->skin->get_upgrade_messages(); |
| 62 | $this->success = ( ! is_wp_error( $result ) ) ? (bool) $result : false; |
| 63 | } |
| 64 | } |