I have created a plugin settings page in the WordPress dashboard menu. I want to include css file for that settings page. How can I do that? I am trying following in my plugin, but it does not include the css file on the plugins settings page:  function my_enqueue_styles() {     wp_enqueue_style( 'my_plugin', plugins_url('my_plugin/plugin.css') ); } add_action( 'wp_enqueue_scripts', 'my_enqueue_styles' );
46669
I have two simple functions that load stuff using  and , something like these:  function admin_custom_css() { wp_enqueue_style( 'stylesheet_name', 'stylesheet.css') };   function admin_custom_js  { wp_enqueue_script( 'javascript_file', 'script.js') };   ... and a few admin pages, created with  and   function my_menu() {    add_menu_page('Page 1', 'bar', 'something', 'else', 'foo');    add_submenu_page( 'theme_menu', 'Subpage 1', 'Subpage', 'something', 'else', 'foo');  } add_action('admin_menu', 'my_menu');    How do I load my two functions only on these pages?  Right now I'm using:  add_action('admin_init', 'admin_custom_css' );  add_action('admin_init', 'admin_custom_js' );     But it loads my files on every admin page, which is not nice at all.  Can I do this via one simple line in functions.php or have to enqueue them within my pages separately (I prefer the first option strongly, since I'd have to edit a lot of admin-page-creating-functions).  Thanks!
1670
I'm having an issue with my admin menu in WordPress. As you can see in the image below the formatting of the menu is out of order. This happens whenever I first land on one of the admin pages but if I refresh the page the menu looks fine. I tried disabling my plugins but none of them seem to be causing the issue.
56795
is there a way to hook / filter or add action that would be printed in the wp-config file? lets say i want to add some simple command like "empty the trash" aka  define('EMPTY_TRASH_DAYS', 1 );    This should be changes in the wp-config but i want it to go with theme..  Any way to do that?
14577
I am developing a WordPress theme for which I would like each comment's timestamp wrapped in in a &lt;span&gt; element for the sake of styling it with CSS rules. However,  as I use it in my theme's comments.php template does not seem to provide options to alter the HTML produced:  &lt;ol class="comment-list"&gt;     &lt;?php         wp_list_comments( array(             'style'       =&gt; 'ol',             'format'      =&gt; 'html5',             'short_ping'  =&gt; true,         ) );     ?&gt; &lt;/ol&gt;   which produces timestamps as such:  &lt;time datetime="2015-12-21T19:09:49+00:00"&gt; december 21st,  2015 on 19:09 &lt;/time&gt;   How can I alter the function's output to include a &lt;span&gt;element around each &lt;time&gt; element without altering core files?  I've tried looking at my theme's functions.php, as well as WordPress wp-includes/comment.php and wp-includes/comment-template.php. None of them deal with the actual tag structure of the comment timestamps generated by wp_list_comments(), so there was nothing there for me to play with.
7714
Different pages often need different set of scripts and styles for them.  I use functions.php and construction like this to load scripts and styles:  function load_assets() {    wp_enqueue_style( 'styles', get_template_directory_uri() . '/css/styles.css');    wp_enqueue_script('main-js', get_template_directory_uri() . '/js/main.js'); } add_action( 'wp_enqueue_scripts', 'load_assets' );   I know I can put some condition here like this:  is_page()   but is there a better way?  Suggestion:  Can wp_register_script() be used to target specific pages?
82760
How does filters and hooks actually work in WordPress?  I'm asking about something advanced. How is it implemented in PHP? E.g how does it collect all the hooks from the different plugins and "attach" them to the core hooks etc.
80675
Does anyone know how to include the admin bar in a page template where wp_head() and wp_footer() are not present? I'm developing a template other scripts and styles are just getting in the way. Rather than go through and dequeue all of the stuff I don't need, I've simple removed the two hooks altogether. All I want instead is the admin bar.  Thanks!
97826
I'm currently writing a plugin that requires the PayPal IPN, since the IPN is not inside the main plugin file, I have no way to use $wpdb. If you know a way to do this that will work with all WordPress installations it would really help me!  Thanks in advance!
124037
I plan to use the member plugin by Justin Tadlock  I wish to know if how could I, on the front side, auto switch to a theme according to a role status.. for example authors would have the site presented using theme 1 while editor would have the site presenter using theme 2  I would rather have 2 different theme rather than conditionals within one theme structure  Thank you in advance
3770
Is it possible to include one CSS file in another?
86724
I want to check for an appropriate template in the theme folder before falling back to the file in my plugin directory. Here’s my code:  add_filter('template_include', 'sermon_template_include'); function sermon_template_include($template) {     if(get_query_var('post_type') == 'wpfc_sermon') {         if ( is_archive() || is_search() ) :            if(file_exists(TEMPLATEDIR . '/archive-wpfc_sermon.php'))               return TEMPLATEDIR . '/archive-wpfc_sermon.php';            return dirname(__FILE__) . '/views/archive-wpfc_sermon.php';         else :            if(file_exists(TEMPLATEDIR . '/single-wpfc_sermon.php'))               return TEMPLATEDIR . '/single-wpfc_sermon.php';            return dirname(__FILE__) . '/views/single-wpfc_sermon.php';         endif;     }     return $template; }   Problem is, it doesn’t work! :-) It always picks the file in my plugin folder. Any idea what to do? I’ve tried alot of variations but I can’t seem to get anything to work! Thanks in advance! Jack  EDIT  I'm expecting the archive-wpfc_sermon.php to be returned from the theme folder if it exists. However, the file from my plugin always gets returned. Thanks for your help! This is from my Sermon Manager plugin available in the repository.
33199
I couldn't add defer tag in plugin javascripts. Google developer pagespeed test suggests me to add defer tag in contact form 7 javascripts.   This is how contact form 7 includes javascript in header.  add_action( 'wp_enqueue_scripts', 'wpcf7_enqueue_scripts' );  function wpcf7_enqueue_scripts() {     // jquery.form.js originally bundled with WordPress is out of date and deprecated     // so we need to deregister it and re-register the latest one     wp_deregister_script( 'jquery-form' );     wp_register_script( 'jquery-form', wpcf7_plugin_url( 'jquery.form.js' ),         array( 'jquery' ), '2.52', true );      $in_footer = true;     if ( 'header' === WPCF7_LOAD_JS )         $in_footer = false;      wp_enqueue_script( 'contact-form-7', wpcf7_plugin_url( 'scripts.js' ),         array( 'jquery', 'jquery-form' ), WPCF7_VERSION, $in_footer );      do_action( 'wpcf7_enqueue_scripts' ); }   Now how to add defer="defer" tag in the above code?
81936
The WordPress Codex points to an extremely simple way to change the URL of the wp-content directory, which is, adding this in wp-config.php:  define( 'WP_CONTENT_URL', 'http://example.com/wp-content');   And that does the job of serving most of the JavaScript and CSS files on my website from the different domain, except two.  http://mywebsite.com/wp-includes/js/comment-reply.js http://mywebsite.com/wp-includes/js/quicktags.js   The reason is very clear — these JavaScript files are served from within the wp-includes directory, which is not affected by the aforementioned rule.  So, is there a similar or simple method to have them served from example.com i.e. the domain of my choice? or is unregistering and enqueuing the scripts from a custom URL (done in functions.php) the only way?
4440
I'm creating a plugin and I want to get the list of all scripts and CSS used by other plugins.  This is my function:  function crunchify_print_scripts_styles() {         $result = [];     $result['scripts'] = [];     $result['styles'] = [];      // Print all loaded Scripts     global $wp_scripts;     foreach( $wp_scripts-&gt;queue as $script ) :        $result['scripts'][] =  $wp_scripts-&gt;registered[$script]-&gt;src . ";";     endforeach;      // Print all loaded Styles (CSS)     global $wp_styles;     foreach( $wp_styles-&gt;queue as $style ) :        $result['styles'][] =  $wp_styles-&gt;registered[$style]-&gt;src . ";";     endforeach;      return $result; } add_action( 'wp_enqueue_scripts', 'crunchify_print_scripts_styles');   I want to get the returned value inside a variable.  I tried this:  $toto = do_action( 'crunchify_print_scripts_styles' ); var_dump( $toto );   And this is my result:  NULL   If I write echo inside every foreach loop, I get the correct results, but how to store these values inside a variable?  [edit]  My code inside a pluginm which is not working too  /**  *  Get all scripts and styles from Wordpress  */ function print_scripts_styles() {      $result = [];     $result['scripts'] = [];     $result['styles'] = [];      // Print all loaded Scripts     global $wp_scripts;     foreach( $wp_scripts-&gt;queue as $script ) :         $result['scripts'][] =  $wp_scripts-&gt;registered[$script]-&gt;src . ";";     endforeach;      // Print all loaded Styles (CSS)     global $wp_styles;     foreach( $wp_styles-&gt;queue as $style ) :         $result['styles'][] =  $wp_styles-&gt;registered[$style]-&gt;src . ";";     endforeach;      return $result; }  add_action( 'wp_head', 'wp_rest_assets_init');  /**  * Init JSON REST API Assets routes.  *  * @since 1.0.0  */ function wp_rest_assets_init() {       $all_the_scripts_and_styles = print_scripts_styles();      if ( ! defined( 'JSON_API_VERSION' ) &amp;&amp;          ! in_array( 'json-rest-api/plugin.php', get_option( 'active_plugins' ) ) ) {              $class = new WP_REST_Assets();              $class::$scriptsAndStyles = $all_the_scripts_and_styles;              add_filter( 'rest_api_init', array( $class, 'register_routes' ) );     } else {         $class = new WP_JSON_Menus();         add_filter( 'json_endpoints', array( $class, 'register_routes' ) );     } }   add_action( 'init', 'wp_rest_assets_init' );
64957
I'm working on a theme that includes some functionality I've developed as separate plugins (as I'm hoping to release them independently).  I'd like to include these plugins as part of the theme core and I've noticed that some developers include plugins as files or subdirectories along with their theme, but over time that can ultimately lead to maintaining two versions of the same plugin - one for the plugin repository, one for the theme - but I'd like to avoid that, if possible.  What's the best practice for including plugins as part of a theme?
114215
I have my style.php file looking like this.  &lt;?php  header('Content-Type: text/css');?&gt; #div{     background:&lt;?php  echo get_option('bgcolor');?&gt;; }   This does not work, but when I do this it works.  &lt;?php  header('Content-Type: text/css');?&gt; #div{     background: &lt;?php  echo 'blue';?&gt;; }   What would be the problem?  This is the mainfile.php   &lt;?php       function test(){     global get_option('bgcolor');?&gt;          &lt;input type="text" id="bgcolor" name="post_popup_settings[bgcolor]" value="&lt;?php echo get_option('bgcolor');?&gt; " /&gt;     &lt;?php }     add_action('admin_head','test');   This is actually in the admin section.
8794
I observed the inside the wp_head function in the source links of every .css, .js files a ?ver=1 (or other number based on the file's/library version) is added. How can I overwrite them, to remove them?  This issue I think is causing problems on the cache manifest part.