PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3
Jetpack – WP Security, Backup, Speed, & Growth v16.3
16.3 16.3-beta 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 All 508 releases
← All changes | jetpack_vendor/automattic/jetpack-blaze/src/class-dashboard-config-data.php +46 -6 13.3.3 → 16.3 View file →
@@ -16,9 +16,35 @@
16 16 /**
17 17 * Class Dashboard_Config_Data
18 18 */
19 19 class Dashboard_Config_Data {
20 +
20 21 /**
22 + * Blaze dashboard admin page. Default is admin.php.
23 + *
24 + * @var string
25 + */
26 + private $admin_page;
27 +
28 + /**
29 + * Blaze dashboard menu slug. Default is 'advertising'.
30 + *
31 + * @var string
32 + */
33 + private $menu_slug;
34 +
35 + /**
36 + * Dashboard config constructor.
37 + *
38 + * @param string $admin_page Dashboard admin page. Default is admin.php.
39 + * @param string $menu_slug Dashboard menu slug. Default is 'advertising'.
40 + */
41 + public function __construct( $admin_page = 'admin.php', $menu_slug = 'advertising' ) {
42 + $this->admin_page = $admin_page;
43 + $this->menu_slug = $menu_slug;
44 + }
45 +
46 + /**
21 47 * Set configData to window.configData.
22 48 *
23 49 * @param array $config_data The config data.
24 50 */
@@ -23,9 +49,10 @@
23 49 * @param array $config_data The config data.
24 50 */
25 51 public function get_js_config_data( $config_data = null ) {
26 52 return 'window.configData = ' . wp_json_encode(
27 - $config_data === null ? $this->get_data() : $config_data
53 + $config_data === null ? $this->get_data() : $config_data,
54 + JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP
28 55 ) . ';';
29 56 }
30 57
31 58 /**
@@ -37,9 +64,9 @@
37 64 $empty_object = json_decode( '{}' );
38 65
39 66 $user = $this->get_connected_user_identity();
40 67
41 - return array(
68 + $data = array(
42 69 'admin_page_base' => $this->get_admin_path(),
43 70 'api_root' => esc_url_raw( rest_url() ),
44 71 'blog_id' => $blog_id,
45 72 'enable_all_sections' => false,
@@ -52,9 +79,11 @@
52 79 'nonce' => wp_create_nonce( 'wp_rest' ),
53 80 'site_name' => \get_bloginfo( 'name' ),
54 81 'sections' => array(),
55 82 // Features are inlined in Calypso Blaze app (wp-calypso/apps/blaze-dashboard)
56 - 'features' => array(),
83 + 'features' => array(
84 + 'is_running_in_jetpack_site' => ! $host->is_wpcom_simple(),
85 + ),
57 86 'initial_state' => array(
58 87 'currentUser' => array(
59 88 'id' => $user['ID'],
60 89 'user' => $user,
@@ -66,9 +95,9 @@
66 95 'items' => array(
67 96 "$blog_id" => array(
68 97 'ID' => $blog_id,
69 98 'URL' => site_url(),
70 - 'jetpack' => true,
99 + 'jetpack' => ! $host->is_wpcom_simple(),
71 100 'visible' => true,
72 101 'capabilities' => $empty_object,
73 102 'products' => array(),
74 103 'plan' => $empty_object, // we need this empty object, otherwise the front end would crash on insight page.
@@ -75,8 +104,9 @@
75 104 'options' => array(
76 105 'admin_url' => admin_url(),
77 106 'gmt_offset' => $this->get_gmt_offset(),
78 107 'is_wpcom_atomic' => $host->is_woa_site(),
108 + 'is_wpcom_simple' => $host->is_wpcom_simple(),
79 109 'jetpack_version' => Constants::get_constant( 'JETPACK__VERSION' ),
80 110 ),
81 111 ),
82 112 ),
@@ -83,8 +113,17 @@
83 113 'features' => array( "$blog_id" => array( 'data' => $this->get_plan_features() ) ),
84 114 ),
85 115 ),
86 116 );
117 +
118 + /**
119 + * Filter to allow modification of the Blaze dashboard config data.
120 + *
121 + * @param bool $data Blaze dashboard config data.
122 + *
123 + * @since 0.21.0
124 + */
125 + return apply_filters( 'jetpack_blaze_dashboard_config_data', $data );
87 126 }
88 127
89 128 /**
90 129 * Gets the WordPress.com user's identity, if connected.
@@ -123,11 +162,12 @@
123 162 /**
124 163 * Page base for the Calypso admin page.
125 164 */
126 165 protected function get_admin_path() {
127 - // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
128 166 if ( ! isset( $_SERVER['PHP_SELF'] ) || ! isset( $_SERVER['QUERY_STRING'] ) ) {
129 - $parsed = wp_parse_url( admin_url( 'tools.php?page=advertising' ) );
167 + $admin_path = $this->admin_page . '?page=' . $this->menu_slug;
168 + $parsed = wp_parse_url( admin_url( $admin_path ) );
169 +
130 170 return $parsed['path'] . '?' . $parsed['query'];
131 171 }
132 172 // We do this because page.js requires the exactly page base to be set otherwise it will not work properly.
133 173 // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized