PluginProbe
Jetpack VaultPress Backup / 1.0.1
Jetpack VaultPress Backup v1.0.1
3.0 3.1 3.2 3.3 3.4 3.5 3.6 3.7.1 3.8 3.9 trunk 0.2.0 1.0.0 1.0.1 1.1.0 1.2.0 1.3.0 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.5 1.6 1.7 All 37 releases
jetpack-backup / src / php / class-initial-state.php

class-initial-state.php in Jetpack VaultPress Backup 1.0.1, at src/php/class-initial-state.php

47 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The React initial state.
4 *
5 * @package automattic/jetpack-backup-plugin
6 */
7
8 use Automattic\Jetpack\Status;
9
10 /**
11 * The React initial state.
12 */
13 class Initial_State {
14 /**
15 * Get the initial state data.
16 *
17 * @return array
18 */
19 private function get_data() {
20 return array(
21 'API' => array(
22 'WP_API_root' => esc_url_raw( rest_url() ),
23 'WP_API_nonce' => wp_create_nonce( 'wp_rest' ),
24 'registrationNonce' => wp_create_nonce( 'jetpack-registration-nonce' ),
25 ),
26 'jetpackStatus' => array(
27 'calypsoSlug' => ( new Status() )->get_site_suffix(),
28 ),
29 'assets' => array(
30 'buildUrl' => plugins_url( 'build/', JETPACK_BACKUP_PLUGIN_ROOT_FILE ),
31 ),
32 );
33 }
34
35 /**
36 * Render the initial state into a JavaScript variable.
37 *
38 * @return string
39 */
40 public function render() {
41 add_action( 'jetpack_use_iframe_authorization_flow', '__return_true' );
42
43 return 'var JPBACKUP_INITIAL_STATE=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( $this->get_data() ) ) . '"));';
44 }
45
46 }
47