Skip to content

Instantly share code, notes, and snippets.

@strangerstudios
Created May 30, 2015 13:39
Show Gist options
  • Save strangerstudios/ddab9431d21372a8703c to your computer and use it in GitHub Desktop.
Save strangerstudios/ddab9431d21372a8703c to your computer and use it in GitHub Desktop.
Look for a stylesheet in a WP child theme or theme before loading a default plugin stylesheet.
//figure out which css to load
if(file_exists(get_stylesheet_directory() . "/pluginname/frontend.css"))
$css_url = get_stylesheet_directory_uri() . "/pluginname/frontend.css";
elseif(file_exists(get_template_directory() . "/pluginname/frontend.css"))
$css_url = get_template_directory_uri() . "/pluginname/frontend.css";
else
$css_url = plugins_url('css/frontend.css',dirname(__FILE__) );
//load it
wp_enqueue_style('pluginname-frontend', $css_url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment