在类别编辑页面上向自定义字段框添加时间符号

时间:2011-03-07 作者:daveaspinall

我已经设法将所需的自定义字段添加到我的类别编辑页面(代码如下)。我想做的就是让textareas#Category\\u Extras\\u功能和#Category\\u Extras\\u应用程序上有一个tinymce编辑器?

    // Add custom fields to category edit pages
// the option name
define(\'Category_Extras\', \'Category_Extras_option\');

// your fields (the form)
add_filter(\'edit_category_form\', \'Category_Extras\');
function Category_Extras($tag) {
    $tag_extra_fields = get_option(Category_Extras);

    ?>

<table class="form-table">
        <tr class="form-field">
            <th scope="row" valign="top"><label for="Category_Extras_Features">Category Features</label></th>
            <td><textarea style="width: 97%;" cols="50" rows="5" name="Category_Extras_Features" id="Category_Extras_Features"><?php  echo $tag_extra_fields[$tag->term_id][\'Category_Extras_Features\']; ?></textarea>

            <p class="description">This isn\'t applicable to all categories but allows additional information to be displayed on a category page.</p></td>
        </tr>
        <tr class="form-field">
            <th scope="row" valign="top"><label for="Category_Extras_Applications">Category Applications</label></th>
            <td><textarea style="width: 97%;" cols="50" rows="5" name="Category_Extras_Applications" id="Category_Extras_Applications"><?php  echo $tag_extra_fields[$tag->term_id][\'Category_Extras_Applications\']; ?></textarea>
            <p class="description">This isn\'t applicable to all categories but allows additional information to be displayed on a category page.</p></td>
        </tr>
</table>



    <?php
}


// when the form gets submitted, and the category gets updated (in your case the option will get updated with the values of your custom fields above
add_filter(\'edited_terms\', \'update_Category_Extras\');
function update_Category_Extras($term_id) {
  if($_POST[\'taxonomy\'] == \'category\'):
    $tag_extra_fields = get_option(Category_Extras);
    $tag_extra_fields[$term_id][\'Category_Extras_Features\'] = strip_tags($_POST[\'Category_Extras_Features\']);
    $tag_extra_fields[$term_id][\'Category_Extras_Applications\'] = strip_tags($_POST[\'Category_Extras_Applications\']);
    update_option(Category_Extras, $tag_extra_fields);
  endif;
}


// when a category is removed
add_filter(\'deleted_term_taxonomy\', \'remove_Category_Extras\');
function remove_Category_Extras($term_id) {
  if($_POST[\'taxonomy\'] == \'category\'):
    $tag_extra_fields = get_option(Category_Extras);
    unset($tag_extra_fields[$term_id]);
    update_option(Category_Extras, $tag_extra_fields);
  endif;
}
这有可能吗?如果有人知道怎么做?

干杯

戴夫

1 个回复
SO网友:Bainternet

遵循本教程TinyMCE in WordPress Plugins 你会到达那里的。

结束

相关推荐

如何在tinyMCE工具栏中添加自定义按钮?

我想在“添加新帖子”屏幕的tinyMCE工具栏上添加一个自定义按钮,单击该按钮后,将在新帖子中插入文本。我已尝试使用此代码(从http://tinymce.moxiecode.com/tryit/custom_toolbar_button.php):wp_admin_css(\'thickbox\'); wp_print_scripts(\'jquery-ui-core\'); wp_print_scripts(\'jquery-ui-tabs\'); wp_print_scrip