PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 13.3.3
Jetpack – WP Security, Backup, Speed, & Growth v13.3.3
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
jetpack / json-endpoints / jetpack / class.jetpack-json-api-get-option-backup-endpoint.php

class.jetpack-json-api-get-option-backup-endpoint.php in Jetpack – WP Security, Backup, Speed, & Growth 13.3.3, at json-endpoints/jetpack/class.jetpack-json-api-get-option-backup-endpoint.php

69 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
3 /**
4 * Get option backup endpoint.
5 *
6 * /sites/%s/options/backup -> $blog_id
7 */
8 class Jetpack_JSON_API_Get_Option_Backup_Endpoint extends Jetpack_JSON_API_Endpoint {
9 /**
10 * Needed capabilities.
11 *
12 * @var array
13 */
14 protected $needed_capabilities = array(); // This endpoint is only accessible using a site token
15
16 /**
17 * Option names.
18 *
19 * @var string
20 */
21 protected $option_names;
22
23 /**
24 * Validate input.
25 *
26 * @param object $object - unused.
27 *
28 * @return bool|WP_Error
29 */
30 public function validate_input( $object ) { // phpcs:ignore VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
31 $query_args = $this->query_args();
32
33 if ( empty( $query_args['name'] ) ) {
34 return new WP_Error( 'option_name_not_specified', __( 'You must specify an option name', 'jetpack' ), 400 );
35 }
36
37 if ( is_array( $query_args['name'] ) ) {
38 $this->option_names = $query_args['name'];
39 } else {
40 $this->option_names = array( $query_args['name'] );
41 }
42
43 return true;
44 }
45
46 /**
47 * The result.
48 */
49 protected function result() {
50 // Disable Sync as this is a read-only operation and triggered by sync activity.
51 \Automattic\Jetpack\Sync\Actions::mark_sync_read_only();
52
53 $options = array_map( array( $this, 'get_option_row' ), $this->option_names );
54 return array( 'options' => $options );
55 }
56
57 /**
58 * Get options row.
59 *
60 * @param string $name - name of the row.
61 *
62 * @return object|null Database query result or null on failure.
63 */
64 private function get_option_row( $name ) {
65 global $wpdb;
66 return $wpdb->get_row( $wpdb->prepare( "select * from `{$wpdb->options}` where option_name = %s", $name ) );
67 }
68 }
69