Skip to content

Commit 663ed32

Browse files
authored
Merge pull request #3389 from Parsely/fix/the-content-filter-typing
2 parents 5f26c1b + 35dcfed commit 663ed32

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

phpstan.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ parameters:
1313
- vendor/php-stubs/wordpress-stubs/wordpress-stubs.php
1414
- vendor/php-stubs/wordpress-tests-stubs/wordpress-tests-stubs.php
1515
type_coverage:
16-
return_type: 87.7
16+
return_type: 87.6
1717
param_type: 79.1
1818
property_type: 0 # We can't use property types until PHP 7.4 becomes the plugin's minimum version.
1919
print_suggestions: false

src/UI/class-dashboard-page.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,17 @@ public function handle_preview_template(): void {
118118
*
119119
* @since 3.19.0
120120
*
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.
123124
*/
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+
125132
if ( ! isset( $_GET['parsely_preview'] ) || 'true' !== $_GET['parsely_preview'] ) {
126133
return $content;
127134
}

0 commit comments

Comments
 (0)