Thursday 30 January 2014

Plugin Breaking Wordpress Login

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');

?>
 
 
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. 

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More