← All changes
|
jetpack_vendor/automattic/jetpack-backup/src/class-initial-state.php
+18
-4
12.3.2
→
16.3-a.5
View file →
| @@ -4,12 +4,27 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package automattic/jetpack-backup-plugin |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -namespace Automattic\Jetpack\Backup; | |
| 8 | +// After changing this file, consider increasing the version number ("VXXX") in all the files using this namespace, in | |
| 9 | +// order to ensure that the specific version of this file always get loaded. Otherwise, Jetpack autoloader might decide | |
| 10 | +// to load an older/newer version of the class (if, for example, both the standalone and bundled versions of the plugin | |
| 11 | +// are installed, or in some other cases). | |
| 12 | +namespace Automattic\Jetpack\Backup\V0005; | |
| 9 | 13 | |
| 10 | 14 | use Automattic\Jetpack\Connection\Plugin_Storage as Connection_Plugin_Storage; |
| 11 | 15 | use Automattic\Jetpack\Status; |
| 16 | +use Jetpack_Options; | |
| 17 | +use function add_action; | |
| 18 | +use function admin_url; | |
| 19 | +use function esc_url; | |
| 20 | +use function esc_url_raw; | |
| 21 | +use function get_bloginfo; | |
| 22 | +use function get_site_url; | |
| 23 | +use function plugins_url; | |
| 24 | +use function rest_url; | |
| 25 | +use function wp_create_nonce; | |
| 26 | +use function wp_json_encode; | |
| 12 | 27 | |
| 13 | 28 | /** |
| 14 | 29 | * The React initial state. |
| 15 | 30 | */ |
| @@ -30,9 +45,9 @@ | ||
| 30 | 45 | 'calypsoSlug' => ( new Status() )->get_site_suffix(), |
| 31 | 46 | ), |
| 32 | 47 | 'connectedPlugins' => Connection_Plugin_Storage::get_all(), |
| 33 | 48 | 'siteData' => array( |
| 34 | - 'id' => \Jetpack_Options::get_option( 'id' ), | |
| 49 | + 'id' => Jetpack_Options::get_option( 'id' ), | |
| 35 | 50 | 'title' => get_bloginfo( 'name' ) ? get_bloginfo( 'name' ) : get_site_url(), |
| 36 | 51 | 'adminUrl' => esc_url( admin_url() ), |
| 37 | 52 | ), |
| 38 | 53 | 'assets' => array( |
| @@ -48,8 +63,7 @@ | ||
| 48 | 63 | */ |
| 49 | 64 | public function render() { |
| 50 | 65 | add_action( 'jetpack_use_iframe_authorization_flow', '__return_true' ); |
| 51 | 66 | |
| 52 | - return 'var JPBACKUP_INITIAL_STATE=JSON.parse(decodeURIComponent("' . rawurlencode( wp_json_encode( $this->get_data() ) ) . '"));'; | |
| 67 | + return 'var JPBACKUP_INITIAL_STATE=' . wp_json_encode( $this->get_data(), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ) . ';'; | |
| 53 | 68 | } |
| 54 | - | |
| 55 | 69 | } |