Opened 10 years ago
Closed 10 years ago
#32557 closed defect (bug) (fixed)
programming error found inside wp_print_scripts function (wp-includes/functions.wp-scripts.php)
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | 4.3 | Priority: | normal |
Severity: | normal | Version: | 4.2.2 |
Component: | Script Loader | Keywords: | |
Focuses: | Cc: |
Description (last modified by )
Dear Sir/Mdm,
I'd recently installed a slider plugin called Slider WD https://wordpress.org/plugins/slider-wd/ into my wordpress version 4.2.2, and i found a problem which i can't add image into my slider.
Once clicked "Add Image" button, it will show that Fatal error occured at wp-includes/functions.wp-scripts.php line 85, do_items is referred to a non-object.
I did further study about the script and i found that probably a programming error under wp_print_scripts function which caused this issue.
Below are the comparison of the same function under different version
version 4.2.2:
function wp_print_scripts( $handles = false ) { /** * Fires before scripts in the $handles queue are printed. * * @since 2.1.0 */ do_action( 'wp_print_scripts' ); if ( '' === $handles ) { // for wp_head $handles = false; } _wp_scripts_maybe_doing_it_wrong( __FUNCTION__ ); global $wp_scripts; if ( ! ( $wp_scripts instanceof WP_Scripts ) ) { if ( ! $handles ) { return array(); // No need to instantiate if nothing is there. } } return wp_scripts()->do_items( $handles ); }
Version 4.0.2:
function wp_print_scripts( $handles = false ) { /** * Fires before scripts in the $handles queue are printed. * * @since 2.1.0 */ do_action( 'wp_print_scripts' ); if ( '' === $handles ) // for wp_head $handles = false; global $wp_scripts; if ( ! is_a( $wp_scripts, 'WP_Scripts' ) ) { if ( ! did_action( 'init' ) ) _doing_it_wrong( __FUNCTION__, sprintf( __( 'Scripts and styles should not be registered or enqueued until the %1$s, %2$s, or %3$s hooks.' ), '<code>wp_enqueue_scripts</code>', '<code>admin_enqueue_scripts</code>', '<code>login_enqueue_scripts</code>' ), '3.3' ); if ( !$handles ) return array(); // No need to instantiate if nothing is there. else $wp_scripts = new WP_Scripts(); } return $wp_scripts->do_items( $handles ); }
under the condition if ( !$handles ), there's an else statement $wp_scripts = new WP_Scripts(); in version 4.0.2, however, version 4.2.2, this statement is missing.
Change History (12)
#1
in reply to:
↑ description
@
10 years ago
#4
@
10 years ago
- Milestone Awaiting Review deleted
- Resolution set to duplicate
- Status changed from new to closed
Duplicate of #32541.
#5
@
10 years ago
- Milestone set to 4.2.3
- Resolution duplicate deleted
- Status changed from closed to reopened
On second thought, doesn't seem like a duplicate. Reopening and moving to 4.2.3 for investigation.
Thank you for the report.
#8
@
10 years ago
- Resolution fixed deleted
- Status changed from closed to reopened
Reopened for 4.2.3
#10
@
10 years ago
wp_print_scripts()
and wp_print_styles()
are already using wp_scripts()
and wp_styles()
in the 4.2 branch.
@wonderboymusic, could you confirm if anything needs to be done here for 4.2.3?
Sorry, copied a wrong like for Slider WD, here's the correct one: https://wordpress.org/plugins/slider-wd/