Two issues with this plugin, please help...
1 My plugin is breaking my /wp-admin to where all I get is a white screen instead of forwarding to the login screen, which is also broken when this is enabled. The rest of the site works.
2 Another problem with my plugin is that I can't get it to echo back the files in that directory. There are two files in there styles.css and new.css. I've used this method to display files in a folder before but I can't get it to work here.
<?php
/*
Plugin Name: Call Custom CSS
Description: Call custom CSS files to your theme while still being to recieve theme development updates
Version: 1.1.0
Author: Michele Narup
Author URI: http://michelenarup.com
*/
function addcss(){
$directory = get_site_url() . "/wp-content/css/";
$stylesheets = glob($directory . "*.css");
wp_enqueue_style('styles' , get_site_url(). '/wp-content/css/style.css');
//echo $directory;
foreach($stylesheets as $stylesheet)
{
echo "<link rel='stylesheet'";
echo $stylesheet;
echo "type='text/css' media='all' />";
}
}
add_action('wp_head', 'addcss');
?>
As per a discussion in the comments below I changed the function to now read:
/*
Plugin Name: Call Custom CSS
Description: Call custom CSS files to your theme while still being to receive theme development updates
Version: 1.1.0
Author: Michele Narup
Author URI: http://michelenarup.com
*/
function load_my_style () {
wp_register_style('customstyle', get_site_url() . '/wp-content/css/style.css');
wp_enqueue_style('customstyle');
}
add_action('wp_enqueue_scripts', 'load_my_style');
This works but does not fix the white screen problem. /wp-admin is still not rendering anything at all on the page or page source. Also note, problem #2 is now irrelevant based on the new function, I will revisit that later. For now I'm focusing on getting the login screen to work.
functions.php
. Plugins can add stylesheets through the same, and appropriate, mechanisms. A white screen usually indicates an error whether you see the error or not. Follow my debugging link.[30-Jan-2014 19:38:10] PHP Warning: Cannot modify header information - headers already sent by (output started at /____/____/public_html/____/wp-content/plugins/call-css/call-css.php:26) in /____/____/public_html/____/wp-includes/pluggable.php on line 896