WordPress的主题错误注意:未定义的索引:激活
问题描述:
当我的页面加载到wordpress时,出现以下错误。我怎样才能防止这一点?WordPress的主题错误注意:未定义的索引:激活
Notice: Undefined index: activated in /home3/answ/public_html/wp-content/themes/tipztheme/functions.php on line 582
Notice: Undefined index: preview in /home3/answ/public_html/wp-content/themes/tipztheme/functions.php on line 582
这是导致错误的线508上的代码。 508线是if ($_GET['activated'] == 'true' || $_GET['preview'] == 1)
您的帮助非常感谢!
Plugin Name: DDThemes - Logo Options
Plugin URI: http://www.designdisease.com/
*/
//ADD OPTION PAGE
add_action('admin_menu', 'ddthemes_admin');
//UPON ACTIVATION OR PREVIEWED
if ($_GET['activated'] == 'true' || $_GET['preview'] == 1)
{
ddthemes_setup();
}
function ddthemes_admin()
{
/* PROCESS OPTION SAVING HERE */
if ('save' == $_REQUEST['action'])
{
if ($_REQUEST['savetype'] == 'header')
{
update_option('ddthemes_header', $_REQUEST['ddthemes_header']);
}
}
/* SHOW THEME CUSTOMIZE PAGE HERE */
add_theme_page(__('Logo Options'), __('Logo Options'), 'edit_themes', basename(__FILE__), 'ddthemes_headeropt_page');}
答
出现此错误是因为您的PHP错误报告设置。它出现在您的变量未正确设置时。说实话,这不是一个真正的大交易,这是很好的; =)为了解决它,你有两个选择:选项一是设置你的变量,然后添加一些虚拟值,例如:
if (!isset($_REQUEST['savetype']))
{
//If not set add some dummy value
$_REQUEST['savetype'] = "undefine";
}
if ($_REQUEST['savetype'] == 'header')
{
update_option('ddthemes_header', $_REQUEST['ddthemes_header']);
}
另一种解决方案是修改(抑制错误报告)在的php.ini并插入该行:
<?php error_reporting (E_ALL^E_NOTICE); ?>
然而另一种解决方案也是剿错误报告,但这个时间在你WP -config.php改为:define('WP_DEBUG', true);
add define('WP_DEBUG', false);
有趣的是,我今天有同样的问题,第一个选项为我工作:)希望它有帮助...干杯!