Php Wordpress主题错误通知:未定义索引:已激活
当我的页面在wordpress中加载时,我得到以下错误。我怎样才能防止这种情况Php Wordpress主题错误通知:未定义索引:已激活,php,wordpress,function,Php,Wordpress,Function,当我的页面在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/funct
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($\u GET['activated']='true'|$\u 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)代码>添加定义('WP_DEBUG',false)代码>
有趣的是,我今天也遇到了同样的问题,第一个选择对我有效:)希望它能帮助我。。。干杯