【问题标题】:Notice: Undefined index: type // Wordpress Theme注意:未定义索引:类型 // Wordpress 主题
【发布时间】:2013-05-11 17:46:58
【问题描述】:

我已经花了几个小时使用我的 wordpress 主题。它与 WP 版本 3.4/3.51 不兼容。当 DEBUG 设置为 TRUE / 可用时: 出现许多通知。至于现在我已经完成了所有的通知,只剩下一个。我找不到任何解决方案。我希望有一个人可以帮助我。 我只有基本的 PHP 知识。

注意:未定义的索引:输入

<?php foreach ($options as $value) { 
switch ( $value['type'] ){
case "section": $i++;  ?>   

这就是通知的用途:switch ( $value['type'] ){


这是页面的一部分。它是我的主题的主题选项页面。

    <form method="post" enctype="multipart/form-data" >         
    <div class="info top-info"> 
     <div class="settingsaved">
        <?php
// Form results if ( isset( $_REQUEST['saved'] ) ) echo '<div id="message" class="updated2 fade"><p><strong>Settings Saved</strong></p></div>';
if ( isset( $_REQUEST['reset'] ) ) echo '<div id="message" class="updated2 fade"><p><strong>Settings Reset</strong></p></div>';
?></div>        
<div style="float: right;"><input type="submit" name="save" class="button-primary  save-options" value="Save Changes"></div><div style="clear: both;"></div></div><div id="content" class="clearfix"><div id="options_tabs" class="ui-tabs">
<ul class="options_tabs ui-tabs-nav">
<?php foreach ($options as $value) { 
switch ( $value['type'] ){case "section": $i++;                 
?><li class="ui-state-default ui-corner-top">
<a href="#option_<?php echo $value['id']; ?>">
<?php if ($value['icon']){ ?>
<img src="<?php echo $theme_directory ?>mm/files/images/icons/<?php echo $value['icon'] ?>"/>   
<?php } ?>
div style=" display: inline-block; margin-left: 6px; margin-top: -1px;position: absolute;"><?php echo $value['name']; ?></div><span></span></a></li>
<?php break;
}}?>
</ul><?php foreach ($options as $value) {
switch ( $value['type'] ) {
// --> open the option section
case "open": ?><?php break;// --> create a subheadline
case "subhead": ?>
<div class="mmtheme-sub-header"> <h2> <?php echo $value['name']; ?>  
<div style="float: right;"><a href="#" class="info-icon">Description</a><div class="description"><div class="inner"><?php echo htmlspecialchars_decode( $value['desc'] ); ?></div></div></div> </h2></div>
<?php break;    
// --> close the option section
case "subhead2": ?>

Here is code for mm.php

LINK TO FULL PHP FILE (mm-includes.php)

期待得到解决方案,提前致谢!


&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&

感谢 tJerry!你解决了我的问题!

我还剩一个通知,现在出现 - 下面是通知和源。如果我把它从我的眼睛上拿下来就好了,有人吗?

这是主题选项中的通知。

注意:使用未定义的常量 update_notifier - 在第 17 行的 \wp-content \themes\bardot\includes\update_notifier.php 中假设为“update_notifier”

*第 17 行 *

    add_dashboard_page( $theme_data['Name'] . 'Theme Updates ', '&nbsp;<span class="update-plugins 

count-2"><span class="update-count">New Theme Update</span></span>', 'administrator','m3-

updates', update_notifier);

【问题讨论】:

  • print_r($options) 的输出是什么?
  • 我讨厌在没有启用WP_DEBUG 的情况下编写代码的开发人员...

标签: wordpress undefined


【解决方案1】:

如果您在switch 语句之前插入它,您的通知 将消失,因为如果未设置该值,则将跳过开关块。

if(!isset($value['type']))
    continue;

【讨论】:

  • 1000ś 谢谢!这很好用。我有另一个通知弹出,我将它发布在另一个“评论”中
  • 这是主题选项中的通知。 注意:使用未定义的常量 update_notifier - 在 \wp-content \themes\bardot\includes\update_notifier.php 中假设为“update_notifier”第 17 行
  • **第 17 行 ** add_dashboard_page( $theme_data['Name'] . '主题更新 ', ' 新主题更新', 'administrator', 'm3- updates', update_notifier);
  • 我相信你可以在update_notifier周围加上单引号
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2015-12-01
  • 2013-11-27
  • 2015-06-02
  • 2021-09-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多