問題描述

在使用 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 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。