• Resolved GalinaBublik

    (@galinabublik)


    I have proposition and petition.

    I added font-awecome.css to me theme.
    After some time added plugin and seen that plugin add font-awecome.css too.

    I think in WordPress need function that check list of registered style.

    In theme and/or in plugins developer can use some like this:

    if( !has_enqueue_style('font-awecome') ){
        wp_enqueue_style('font-awecome', get_template_directory_uri() . '/css/font-awesome.min.css');
    }
Viewing 4 replies - 1 through 4 (of 4 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    The handle is an arbitrary name, so you’d have to first ensure plugins and themes use consistently named handles. That isn’t practical.

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    especially when one spells the handle incorrectly ??

    Look into the scripts/styles and dependencies (in general) API, there are already functions for this.

    
    if ( !function_exists('has_enqueue_style') ) :
    function has_enqueue_style($handle) {
        return wp_style_is($handle, 'enqueued');
    }
    endif;

    For scripts, you should use wp_script_is. enqueued is an option that checks if the script is queued and you have other options which you can see in the switch cases here in the source https://developer.www.ads-software.com/reference/classes/wp_dependencies/query/#source

    It makes sense to use wp_deregister_style to unregister a stylesheet and register it again the way you want, but keep in mind that you need to hook into plugins_loaded or plugin hooks because plugins happen to be loaded after the theme.

    Thread Starter GalinaBublik

    (@galinabublik)

    Thank you, @samuel Elh, very match!

    • This reply was modified 7 years, 5 months ago by GalinaBublik.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Proposition and petition for new function’ is closed to new replies.