0

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.

  • That is not the way to add stylesheets in WordPress. See: wordpress.stackexchange.com/q/113127/21376 (among numerous other questions). Second, do you know which line causes the error? Do you have debugging information? – s_ha_dum Jan 30 '14 at 19:24
  • I don't want to add it through the functions or within the template directory since the Theme is not mine and I want to be able to still get maintenance updates without messing up my css changes. – Michele Jan 30 '14 at 19:26
  • There is no error, it is simply a solid white page when it loads the /wp-admin – Michele Jan 30 '14 at 19:27
  • Never said to add the stlyesheet through the theme or 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. – s_ha_dum Jan 30 '14 at 19:34
  • Ok, there are a lot of errors coming up from other plugins... But this is the only line from the plugin I wrote [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 – Michele Jan 30 '14 at 19:40
0

The error "Cannot modify header information, headers already sent" often occurs when you have white space before the opening php tag, or after the closing php tag.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.