【问题标题】:Wordpress theme error Notice: Undefined index: activatedWordpress 主题错误通知:未定义索引:已激活
【发布时间】:2014-08-18 16:37:19
【问题描述】:

当我的页面在 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 wordpress function


    【解决方案1】:

    出现此错误是因为您的 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);

    有趣的是我今天遇到了同样的问题,第一个选项对我有用:) 希望它有帮助......干杯!

    【讨论】:

      猜你喜欢
      • 2013-09-11
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-10
      • 1970-01-01
      相关资源
      最近更新 更多