[wp-trac] [WordPress Trac] #54994: Action Hook admin_enqueue_scripts and wp_enqueue_scripts
WordPress Trac
noreply at wordpress.org
Sun Jan 30 08:58:54 UTC 2022
#54994: Action Hook admin_enqueue_scripts and wp_enqueue_scripts
--------------------------------+-----------------------------
Reporter: smusman98 | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: External Libraries | Version: 5.9
Severity: normal | Keywords:
Focuses: multisite |
--------------------------------+-----------------------------
Hey,
I'm a developer, I wanted to know if it's a bug, or am I doing it wrong
way?
When using admin_enqueue_scripts (both methods static in the same class, I
can not use it this way [ ( new self() ), 'admin_enqueue_scripts' ], It
will throw errors).
{{{#!php
<?php
public static function load_front_scripts()
{
$_this = self::wp_enqueue_scripts();
add_action( 'wp_enqueue_scripts', 'self::wp_enqueue_scripts' );
}
public static function wp_enqueue_scripts()
{
}
}}}
On the other side when using wp_enqueue_scripts same scenario, I'm strict
to use it this way, can not use it that way ('self::wp_enqueue_scripts'),
It will throw error,
{{{#!php
<?php
public static function load_admin_scripts()
{
add_action( 'admin_enqueue_scripts', [ ( new self() ),
'admin_enqueue_scripts' ] );
}
public static function admin_enqueue_scripts()
{
wp_enqueue_script( 'cpbwc-admin', CPBWC_PLUGIN_URL .
'/assets/js/admin.min.js', array( 'jquery' ), 1.0, true );
wp_enqueue_style( 'cpbwc-admin', CPBWC_PLUGIN_URL .
'/assets/css/admin.min.css', '', 1.0 );
wp_enqueue_media();
}
}}}
Conclusion:
On both action hooks callbacks I'm strict to use it the way I'm using,
Unable to call call-backs same way.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/54994>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list