问题描述

在使用 metaboxes /自定义字段时,我似乎间接地通过我的 wp_postmeta 间接创建了许多这些_CleCloseme meta_keys 。

看到这里:

到目前为止,还没有出现任何问题,而且自定义的字段工作正常,但是我本来只在本地测试网站上发布了两个或更多的帖子,如果稍后会导致问题,我不想将其实现到我的现场网站在路上。任何人都知道该怎么做,是否正常?

这是我的 metaboxes 的代码。

<?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)

最佳解决方案

简短版本:

_encloseme 在发布时被添加到帖子中。不久之后,wp-cron 进程将被安排处理该职位以寻找机箱。

换句话说,它会在以后清理它们。完全不用担心。

完全解释:

“Enclosures” 是一个帖子中的链接,如音频或视频文件。 WordPress 根据正在链接的文件的 MIME 类型找到这些,然后保存额外的元数据。这些元数据用于 RSS 订阅源,以创建特殊的标签来将这些文件连接到帖子。

这就是播客的工作原理。如果您在一个帖子中放置了一个链接到 MP3,那么将为该链接创建一个机箱,并且该 Feed 将具有机箱,并且像 iTunes 这样的播客读者可以使用该功能直接从 RSS 下载 MP3 饲料。

_encloseme 只是特殊的元数据,表示该邮箱尚未被机箱进程处理。当您创建或更新已发布的帖子时,将获取 auto-added,以便该文章将由机箱创建者处理。

参考文献

注:本文内容整合自 Google/Baidu/Bing 辅助翻译的英文资料结果。如果您对结果不满意,可以加入我们改善翻译效果:薇晓朵技术论坛。