Wordpress插件开发 - 我做错了什么

时间:2013-03-14 15:28:55

标签: wordpress-plugin

我做错了什么......这似乎不起作用......我不断收到以下错误

警告:无法修改标头信息 - 已经发送的标头(/ home / puretige / public_html / wp-content / plugins / Pure Tiger / puretiger.php:13中的输出)/ home / puretige / public_html / wp-在第568行包含/ option.php

警告:无法修改标头信息 - 已经发送的标头(/ home / puretige / public_html / wp-content / plugins / Pure Tiger / puretiger.php:13中的输出)/ home / puretige / public_html / wp-在第569行包含/ option.php

插件在激活期间生成了2个意外输出字符。如果您发现“已发送标头”消息,联合供稿问题或其他问题,请尝试停用或删除此插件。

请注意我对此很新....

<?php
/*
Plugin Name: Pure Tiger Hosting
Plugin URI: http://www.puretigerhosting.com/wordpressplugin
Description: Themes, Plugins and Support from within your admin panel.
Version: 1.00
Author: Pure Tiger Hosting
Author URI: http://www.puretigerhosting.com
License: GPL2
*/
?>

<?php

add_action('admin_menu','register_custom_menu_page');

add_action('admin_menu','register_my_custom_submenu_page');

add_action('admin_menu','register_my_custom_submenu_page2');

add_action('admin_menu','register_my_custom_submenu_page3');



Function register_custom_menu_page() {

    add_menu_page('Pure Tiger', 'Pure Tiger','pure-tiger','add_users','','', 6);
}


/*-----------------------------Sub Pages--------------------------------------------*/


function register_my_custom_submenu_page() {
    add_submenu_page( 'pure-tiger','Themes','Themes','PTthemes','','','my_custom_submenu_page_themes');
}

function register_my_custom_submenu_page2() {
    add_submenu_page( 'pure-tiger','Plugins','Plugins','PTPlugins','','','my_custom_submenu_page_plugins');
}

function register_my_custom_submenu_page3() {
    add_submenu_page( 'pure-tiger','Ask a Question','Ask a Question','question','','','my_custom_submenu_page_question');
}


/*-----------------------------Themes--------------------------------------------*/

function my_custom_submenu_page_themes() {
    echo '<h3>Pure Tiger Themes</h3>';
}


/*-----------------------------Plugins--------------------------------------------*/

function my_custom_submenu_page_plugins() {
    echo '<h3>Pure Tiger Plugins</h3>';
}


/*-----------------------------Support--------------------------------------------*/

function my_custom_submenu_page_question() {
    echo '<h3>Pure Tiger Support</h3>';
}

?>

3 个答案:

答案 0 :(得分:0)

尝试在插件声明之前删除open close php标记。

/*
Plugin Name: Pure Tiger Hosting
Plugin URI: http://www.puretigerhosting.com/wordpressplugin
Description: Themes, Plugins and Support from within your admin panel.
Version: 1.00
Author: Pure Tiger Hosting
Author URI: http://www.puretigerhosting.com
License: GPL2
*/



<?php

add_action('admin_menu','register_custom_menu_page');
//remaining code to follow....

答案 1 :(得分:0)

在版权声明后删除关闭?>并打开<?php标记。 2个换行符阻止wordpress发送标题。

<?php
/*
Plugin Name: Pure Tiger Hosting
Plugin URI: http://www.puretigerhosting.com/wordpressplugin
Description: Themes, Plugins and Support from within your admin panel.
Version: 1.00
Author: Pure Tiger Hosting
Author URI: http://www.puretigerhosting.com
License: GPL2
*/

add_action('admin_menu','register_custom_menu_page');

add_action('admin_menu','register_my_custom_submenu_page');

答案 2 :(得分:-1)

检查此插件是否尝试编写cookie。

如果是这种情况,则必须在任何html代码处理之前启动插件。 所以你必须在<!doctype ... >

之前在index.php的顶部启动插件

关于cookie的一些阅读:http://php.net/manual/en/features.cookies.php