| @@ -117,12 +117,19 @@ | ||
| 117 | 117 | * Adds a wrapper div for Parse.ly preview functionality. |
| 118 | 118 | * |
| 119 | 119 | * @since 3.19.0 |
| 120 | 120 | * |
| 121 | - * @param string $content The post content. | |
| 122 | - * @return string The modified content with wrapper div if needed. | |
| 121 | + * @param mixed $content The post content. | |
| 122 | + * @return mixed The modified content with wrapper div if needed, or the | |
| 123 | + * unmodified content value in case of a non-string. | |
| 123 | 124 | */ |
| 124 | - public function add_parsely_preview_wrapper( string $content ): string { | |
| 125 | + public function add_parsely_preview_wrapper( $content ) { | |
| 126 | + if ( ! is_string( $content ) ) { | |
| 127 | + // $content should always be a string, but is filterable by `the_content`. | |
| 128 | + // If we get a non-string value, return it as is to avoid fatal errors. | |
| 129 | + return $content; | |
| 130 | + } | |
| 131 | + | |
| 125 | 132 | if ( ! isset( $_GET['parsely_preview'] ) || 'true' !== $_GET['parsely_preview'] ) { |
| 126 | 133 | return $content; |
| 127 | 134 | } |
| 128 | 135 | |
| @@ -175,10 +182,10 @@ | ||
| 175 | 182 | ); |
| 176 | 183 | |
| 177 | 184 | add_submenu_page( |
| 178 | 185 | 'parsely-dashboard-page', |
| 179 | - 'Parse.ly Traffic Boost', | |
| 180 | - 'Traffic Boost (beta)', | |
| 186 | + 'Parse.ly Engagement Boost', | |
| 187 | + 'Engagement Boost (beta)', | |
| 181 | 188 | $capability, // phpcs:ignore WordPress.WP.Capabilities.Undetermined |
| 182 | 189 | 'parsely-dashboard-page', |
| 183 | 190 | '__return_null' |
| 184 | 191 | ); |
| @@ -290,11 +297,23 @@ | ||
| 290 | 297 | array(), |
| 291 | 298 | $asset_info['version'] |
| 292 | 299 | ); |
| 293 | 300 | |
| 301 | + $inline_script_lines = array( | |
| 302 | + 'window.wpParselyDependencies = {};', | |
| 303 | + sprintf( | |
| 304 | + 'window.wpParselyDependencies.urlWpComponents = %s;', | |
| 305 | + wp_json_encode( includes_url( 'css/dist/components/style.css' ) ) | |
| 306 | + ), | |
| 307 | + sprintf( | |
| 308 | + 'window._parsely_traffic_boost_preview_nonce = %s;', | |
| 309 | + wp_json_encode( wp_create_nonce( 'parsely_preview' ) ) | |
| 310 | + ), | |
| 311 | + ); | |
| 312 | + | |
| 294 | 313 | wp_add_inline_script( |
| 295 | 314 | 'parsely-dashboard-page', |
| 296 | - 'window._parsely_traffic_boost_preview_nonce = ' . wp_json_encode( wp_create_nonce( 'parsely_preview' ) ) . ';', | |
| 315 | + join( "\n", $inline_script_lines ), | |
| 297 | 316 | 'before' |
| 298 | 317 | ); |
| 299 | 318 | |
| 300 | 319 | if ( $this->parsely->site_id_is_set() ) { |
| @@ -306,9 +325,9 @@ | ||
| 306 | 325 | } |
| 307 | 326 | } |
| 308 | 327 | |
| 309 | 328 | /** |
| 310 | - * Injects Content Helper permissions into the dashboard page. | |
| 329 | + * Injects Content Intelligence permissions into the dashboard page. | |
| 311 | 330 | * |
| 312 | 331 | * @since 3.19.0 |
| 313 | 332 | */ |
| 314 | 333 | protected function inject_content_helper_permissions(): void { |