Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IS: add conditional to use new method introduced in WP 6.3 #32454

Merged
merged 1 commit into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions projects/plugins/jetpack/changelog/update-infinite-scripts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: compat

Infinite Scroll: avoid PHP notices when using the latest version of WordPress, 6.3.
14 changes: 12 additions & 2 deletions projects/plugins/jetpack/modules/infinite-scroll/infinity.php
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,7 @@ function ( $script_name ) use ( $initial_scripts ) {

// If new scripts are needed, extract relevant data from $wp_scripts
if ( ! empty( $new_scripts ) ) {
global $wp_version;
$results['scripts'] = array();

foreach ( $new_scripts as $handle ) {
Expand All @@ -1173,13 +1174,22 @@ function ( $script_name ) use ( $initial_scripts ) {
continue;
}

// Remove conditional once WordPress 6.3 is the minimum required version.
if ( version_compare( $wp_version, '6.3', '>=' ) ) {
$before_handle = $wp_scripts->get_inline_script_data( $handle, 'before' );
$after_handle = $wp_scripts->get_inline_script_data( $handle, 'after' );
} else {
$before_handle = $wp_scripts->print_inline_script( $handle, 'before', false );
$after_handle = $wp_scripts->print_inline_script( $handle, 'after', false );
}

// Provide basic script data
$script_data = array(
'handle' => $handle,
'footer' => ( is_array( $wp_scripts->in_footer ) && in_array( $handle, $wp_scripts->in_footer, true ) ),
'extra_data' => $wp_scripts->print_extra_script( $handle, false ),
'before_handle' => $wp_scripts->print_inline_script( $handle, 'before', false ),
'after_handle' => $wp_scripts->print_inline_script( $handle, 'after', false ),
'before_handle' => $before_handle,
'after_handle' => $after_handle,
);

// Base source
Expand Down