2013-02-15 59 views
0

當我的頁面加載到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');} 

回答

0

出現此錯誤是因爲您的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);

有趣的是,我今天有同樣的問題,第一個選項爲我工作:)希望它有幫助...乾杯!