我可以通过我的Add_Filter回调内容附加插件吗?

时间:2011-02-15 作者:Scott B

我正在尝试将插件界面添加到类别编辑器中。我使用add\\u meta\\u box()过滤器轻松地将其附加到帖子和页面编辑器,但在类别编辑器上似乎没有add\\u meta\\u box挂钩。

因此,由于我已经在使用add\\u filter(“edit\\u category\\u form”,“my\\u category\\u editor\\u function”,1)向category edit屏幕添加了一些额外字段,我想知道是否可以从该函数中调用我的插件脚本?

示例:

add_filter(\'edit_category_form\', \'my_category_editor_function\', 1);
function my_category_editor_function($tag) {
    $tag_extra_fields = get_option(\'my_category_editor_function\');?>
    <!--This is where I would call my plugin interface-->
    <div style="float:right;top:0;right:0">
    <?php 
        /*
        load my widget here. May have to use some funky css to get it to float 
        to the right of the cat editor just like it does in the post editor
        */
    ?>
    </div>
    <!--This is my current fields added with the filter-->
    <table class="form-table">
    <tr class="form-field">
        <th scope="row" valign="top"><label for="_my-categoryTitle">Category Title</label></th>
        <td><input name="_my-categoryTitle" id="_my-categoryTitle" type="text" size="40" aria-required="false" value="<?php echo $tag_extra_fields[$tag->term_id][\'my_cat_title\']; ?>" />
        <p class="description">The title is optional but will be used in place of the name on the home page category index (when in list view) and on the category landing page.</p>
        </td>
    </tr>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="_my-categoryKeywords">Keywords</label></th>
        <td valign="top"><input name="_my-categoryKeywords" id="_my-categoryKeywords" type="text" size="40" aria-required="false" value="<?php if(isset($tag_extra_fields[$tag->term_id][\'my_cat_keywords\']))echo $tag_extra_fields[$tag->term_id][\'my_cat_keywords\']; ?>" />
        <p class="description">Optional: If you want to add a keywords metatag to the category landing page and keywords in the Category image\'s alt tag.</p>
        </td>
    </tr>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="_my-categoryImageLink">Image Link</label></th>
        <td valign="top"><input name="_my-categoryImageLink" id="_my-categoryImageLink" type="text" size="40" aria-required="false" value="<?php if(isset($tag_extra_fields[$tag->term_id][\'my_cat_imageLink\']))echo $tag_extra_fields[$tag->term_id][\'my_cat_imageLink\']; ?>" />
        <p class="description">Optional: If you want to link the <b>category landing page image</b> to an affiliate or CPA offer, place your link here.</p>
        </td>
    </tr>
    <tr class="form-field">
        <th scope="row" valign="top"><label for="_my-categoryAds">Hide Ads?</label></th>
        <td><input name="_my-categoryAds" id="_my-categoryAds" type="checkbox" style="width:30px;float:left;"<?php if(isset($tag_extra_fields[$tag->term_id][\'my_cat_ads\'])) echo \' checked="checked"\'; ?>" />
        <p class="description"><label for="_my-categoryAds">Check this to remove ads from this category\'s landing page. (Does not affect ads placed in widgets)</label></p>
        </td>
    </tr>
    </table>

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

你可以这样做,只要

<!--This is where I would call my plugin interface-->
输出HTML表单字段。

结束

相关推荐

如何在菜单管理管理屏幕中添加自定义Metabox?

虽然我非常感谢wordpress核心团队最终集成了本机菜单管理功能,但我对一些我想更改的关键元素感到失望。我需要一种显示页面的方式,这种方式与显示分级类别的方式相同,而不是显示在列表中,并且我需要一种手动包括可以添加到菜单的链接的方式。如何做到这一点?提前感谢UPDATED所以,以下是我想做的两件事。当前,如果您转到默认的wordpress“菜单管理”管理屏幕,您可以选择在左侧显示“页面”元框。这里的问题是,当您单击“查看全部”选项卡时,没有一个页面的顺序正确,并且如果适用,它们也没有缩进。CURRENT