Skip to content

Commit d90ce05

Browse files
authored
wpcomsh: Prevent PHP fatals when footer is nested in an output buffer (#45732)
1 parent d72e9f8 commit d90ce05

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fixed
3+
4+
Footer: Avoid PHP errors when nested in output buffering.

projects/plugins/wpcomsh/footer-credit/footer-credit-optimizations.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,23 @@ function wpcom_better_footer_links_buffer( $page ) {
1717
}
1818

1919
// Would like to only see footer content before wp_footer output.
20-
$output = preg_split( '/wpcom_wp_footer/i', $page, 2 );
20+
$output = explode( 'wpcom_wp_footer', $page, 2 );
2121

2222
// Run "better link" filters.
2323
$footer = wpcom_better_footer_links( $output[0] );
2424

2525
$remaining_content = $output[1] ?? '';
2626

2727
// Piece back together again.
28-
$page = implode( array( $footer, 'wpcom_wp_footer' . $remaining_content ) );
28+
$page = $footer . 'wpcom_wp_footer' . $remaining_content;
2929

3030
// If nothing to join, return empty string.
3131
if ( 'wpcom_wp_footer' === $page ) {
3232
return '';
3333
}
3434

3535
// Replace any dangling references of glue code.
36-
$page = preg_replace( '/wpcom_wp_footer/i', '', $page );
36+
$page = str_replace( 'wpcom_wp_footer', '', $page );
3737

3838
return $page;
3939
}

0 commit comments

Comments
 (0)