插件中断WordPress登录

时间:2014-01-30 作者:Michele

此插件有两个问题,请帮助。。。

1我的插件正在破坏我的/wp管理,我得到的只是一个白色屏幕,而不是转发到登录屏幕,登录屏幕在启用时也会被破坏。其余现场工程。

2我的插件的另一个问题是,我无法让它回显该目录中的文件。这些样式中有两个文件。css和new。css。我以前使用过这种方法来显示文件夹中的文件,但我无法在这里使用它。

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

 ?>
根据下面评论中的讨论,我将函数改为现在:

 /*
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\');
这可以工作,但不能解决白屏问题/wp admin仍然没有在页面或页面源上呈现任何内容。另请注意,根据新函数,问题#2现在无关紧要,稍后我将重新讨论。目前,我的重点是让登录屏幕正常工作。

1 个回复
最合适的回答,由SO网友:helgatheviking 整理而成

“无法修改标头信息,标头已发送”错误通常发生在打开php标记之前或关闭php标记之后有空格时。

结束

相关推荐

$wpdb in php 5.5

我正在帮助一位朋友更新他们的网站,并将其移动到新的服务器上。他们的旧服务器运行php 5.3.6-13,新站点运行php 5.5。有一个使用$wpdb的自定义插件,允许用户编辑写入数据库中自定义表的一些信息,特别是:$query = \"UPDATE wp_building_plan SET sale_price = \'$sale_price\', available = \'$available\', broker_name = \'$broker_name\', broker_email = \'$