Skip to content

Commit b43ba66

Browse files
committed
Fix replace_with_forwarded_url() for array content
array_walk_recursive() takes the input array by reference and returns a boolean value to indicate success. The function does not return the modified content.
1 parent 4e59345 commit b43ba66

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

includes/Forwarded_URLs.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,14 @@ public function replace_with_forwarded_url( $content ) {
167167
"//{$non_forwarded_host}" => "//{$forwarded_host}",
168168
);
169169

170-
$new = is_array( $content ) ? array_walk_recursive( $content, array( $this, 'replace_url' ) ) : str_replace( array_keys( $this->find_replace ), array_values( $this->find_replace ), $content );
170+
if ( is_array( $content ) ) {
171+
// array_walk_recursive() takes the input array by reference
172+
array_walk_recursive( $content, [ $this, 'replace_url' ] );
173+
} else {
174+
$content = str_replace( array_keys( $this->find_replace ), array_values( $this->find_replace ), $content );
175+
}
171176

172-
return $new;
177+
return $content;
173178
}
174179

175180

0 commit comments

Comments
 (0)