“_encloSeme”元密钥难题

时间:2011-06-23 作者:mmaximalist

在使用元数据库/自定义字段时,我似乎间接地创建了其中的许多字段_encloseme meta_keys 我的全身wp_postmeta.

此处可见:

到目前为止,还没有出现任何问题,自定义字段工作正常,但我只在本地测试站点上处理了2个左右的帖子,如果以后会导致问题,我不想将其应用到我的实时站点。有人知道该怎么办吗?正常吗?

这是我的元数据库的代码。

<?php

    //Add meta boxes to post types
    function plib_add_box() {
        global $meta_box;

        foreach($meta_box as $post_type => $value) {
            add_meta_box($value[\'id\'], $value[\'title\'], \'plib_format_box\', $post_type, $value[\'context\'], $value[\'priority\']);
        }
    }
    //Formatting
    function plib_format_box() {
      global $meta_box, $post;

      // verification
      echo \'<input type="hidden" name="plib_meta_box_nonce" value="\', wp_create_nonce(basename(__FILE__)), \'" />\';

      echo \'<table class="form-table">\';

      foreach ($meta_box[$post->post_type][\'fields\'] as $field) {
          // get current post meta data
          $meta = get_post_meta($post->ID, $field[\'id\'], true);

          echo \'<tr>\'.
                  \'<th style="width:20%"><label for="\'. $field[\'id\'] .\'">\'. $field[\'name\']. \'</label></th>\'.
                  \'<td>\';
          switch ($field[\'type\']) {
              case \'text\':
                  echo \'<input type="text" name="\'. $field[\'id\']. \'" id="\'. $field[\'id\'] .\'" value="\'. ($meta ? $meta : $field[\'default\']) . \'" size="30" style="width:97%" />\'. \'<br />\'. $field[\'desc\'];
                  break;
              case \'textarea\':
                  echo \'<textarea name="\'. $field[\'id\']. \'" id="\'. $field[\'id\']. \'" cols="60" rows="4" style="width:97%">\'. ($meta ? $meta : $field[\'default\']) . \'</textarea>\'. \'<br />\'. $field[\'desc\'];
                  break;
              case \'select\':
                  echo \'<select name="\'. $field[\'id\'] . \'" id="\'. $field[\'id\'] . \'">\';
                  foreach ($field[\'options\'] as $option) {
                      echo \'<option \'. ( $meta == $option ? \' selected="selected"\' : \'\' ) . \'>\'. $option . \'</option>\';
                  }
                  echo \'</select>\';
                  break;
              case \'radio\':
                  foreach ($field[\'options\'] as $option) {
                      echo \'<input type="radio" name="\' . $field[\'id\'] . \'" value="\' . $option[\'value\'] . \'"\' . ( $meta == $option[\'value\'] ? \' checked="checked"\' : \'\' ) . \' />\' . $option[\'name\'];
                  }
                  break;
              case \'checkbox\':
                  echo \'<input type="checkbox" name="\' . $field[\'id\'] . \'" id="\' . $field[\'id\'] . \'"\' . ( $meta ? \' checked="checked"\' : \'\' ) . \' />\';
                  break;
          }
          echo     \'<td>\'.\'</tr>\';
      }

      echo \'</table>\';

    }
    // Save data from meta box
    function plib_save_data($post_id) {
        global $meta_box,  $post;

        //Verify
        if (!wp_verify_nonce($_POST[\'plib_meta_box_nonce\'], basename(__FILE__))) {
            return $post_id;
        }

        //Check > autosave
        if (defined(\'DOING_AUTOSAVE\') && DOING_AUTOSAVE) {
            return $post_id;
        }

        //Check > permissions
        if (\'page\' == $_POST[\'post_type\']) {
            if (!current_user_can(\'edit_page\', $post_id)) {
                return $post_id;
            }
        } elseif (!current_user_can(\'edit_post\', $post_id)) {
            return $post_id;
        }

        foreach ($meta_box[$post->post_type][\'fields\'] as $field) {
            $old = get_post_meta($post_id, $field[\'id\'], true);
            $new = $_POST[$field[\'id\']];

            if ($new && $new != $old) {
                update_post_meta($post_id, $field[\'id\'], $new);
            } elseif (\'\' == $new && $old) {
                delete_post_meta($post_id, $field[\'id\'], $old);
            }
        }
    }

    add_action(\'save_post\', \'plib_save_data\');

    //We create an array called $meta_box and set the array key to the relevant post type
// If custom post type, change the \'post\' variable
    $meta_box[\'post\'] = array(

        //This is the id applied to the meta box
        \'id\' => \'venue_location\',  

        //This is the title that appears on the meta box container
        \'title\' => \'Venue/Location\',    

        //This defines the part of the page where the edit screen section should be shown
        \'context\' => \'normal\',    

        //This sets the priority within the context where the boxes should show
        \'priority\' => \'high\',

        //Here we define all the fields we want in the meta box
        \'fields\' => array(
            array(
                \'name\' => \'Venue\',
                \'desc\' => \'Venue Name\',
                \'id\' => \'venue_info\',
                \'type\' => \'text\',
                \'default\' => \'\'
            ),
            array(
                \'name\' => \'Location\',
                \'desc\' => \'Location of the Venue\',
                \'id\' => \'location_info\',
                \'type\' => \'text\',
                \'default\' => \'\'
            )
        )
    );
    add_action(\'admin_menu\', \'plib_add_box\');
?>
(以防万一,这里有一个指向上述代码的pastbin链接:http://pastebin.com/0QsqxtZW)

1 个回复
最合适的回答,由SO网友:Otto 整理而成

简短版本:

_encloseme在发布后添加到帖子中。wp cron进程应该在此后不久安排好,以处理post以查找机柜。

换句话说,它会在以后正常地清理它们。没什么好担心的。

详细说明:

“附件”是帖子中指向音频或视频文件的链接。WordPress根据链接文件的MIME类型查找这些文件,然后保存有关这些文件的额外元数据。此元数据用于RSS提要中,用于创建特殊标记以将这些文件连接到帖子。

例如,这就是播客的工作方式。如果你在帖子中放置了一个MP3链接,那么就会为该链接创建一个附件,feed将包含该附件,然后像iTunes这样的播客读者可以使用该附件直接从RSS提要下载MP3。

_encloseme只是一种特殊的元数据,表示该帖子尚未由enclosure进程处理。创建或更新已发布的帖子时,会自动添加该帖子,以便附件创建者处理该帖子。

结束

相关推荐