How to enqueue a theme style-sheet to my admin settings page?

The admin_enqueue_scripts hook has a $hook_suffix parameter for the current admin page. This parameter will return something like toplevel_page_yourpagename where the toplevel_page will be your page level and yourpagename is what you find on the ?page=yourpagename url. Use that to check if the current page is your plugin’s settings page and then load the scripts. … Read more

get_stylesheet_uri returns wrong path

I don’t think you want get_stylesheet_uri, which will return the complete stylesheet URL including style.css. You want get_stylesheet_directory_uri, which will give you the path up to the child/parent theme stylesheet directory but not the trailing style.css, and which is the function used by the Roots theme per the code you posted. wp_enqueue_style(‘fsc’, get_stylesheet_directory_uri().’/abcdefg.css’, false, null); … Read more

is_page() function doesnt working

The init hook is too early — WordPress hasn’t yet identified the queried object (post, category, etc.); hence the is_page() doesn’t work there: add_action(‘init’, ‘register_script’); So for conditional tags/functions like is_page(), is_single(), etc. to work (i.e. return the proper result), you should use wp or a later hook: add_action(‘wp’, ‘whatever_function’); But for registering/enqueueing scripts and … Read more

Why are my styles being applied to the admin area?

Why are my styles being applied to the admin area? Assuming that is all of the code, it is because you are enqueueing the styles globally. You need to hook that to wp_enqueue_scripts, which will only load on the front end. wp_register_style( ‘main-styles’, get_stylesheet_directory_uri() . ‘/css/styles.css’, false, ‘1.0.0’, ‘all’); function enqueue_script_front_wpse_84975() { wp_enqueue_style(‘main-styles’); } add_action(‘wp_enqueue_scripts’, … Read more

Using multiple versions of jQuery while still calling it like WP likes

I found that it was better for me to use the latest jQuery version (which WordPress loads by default) and to treat the incompatibility issue by modifying the JS plugin files that were incompatible with the latest jQuery version. Note: The reason I chose this solution is because in most cases, JS plugin incompatibility with … Read more

Can’t make wp_enqueue work

Edit: I meant to refer to wp_dequeue_style() You have to dequeque (unregister) the scripts or styles that you wish to replace before replacing them or the new parameters won’t be accepted. Use wp_dequeue_style(). Also, as it says in the description for wp_dequeue_script(), hook it with a late priority (100), so that it is after the … Read more

Dequeue theme stylesheets but keep widget styling on custom page template

You would have to enqueue them at the same time you dequeue all the other items, assuming your widgets have separate stylesheets. You can’t selectively enqueue sub-portions of a stylesheet, and there is no method of identifying which stylesheets contain the widgets. Depending on the theme the widgets may not be in their own stylesheet, … Read more