Question

I'm trying to add my plugin interface to the Category Editor. I've easily attached it to the post and page editor using the add_meta_box() filter, but there does not appear to be an add_meta_box hook on the category editor.

So, since I'm already adding some extra fields to the category edit screen using add_filter('edit_category_form', 'my_category_editor_function', 1) I'm wondering if I can just call my plugin script from within that function?

Example:

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>
Was it helpful?

Solution

you can do that as long as

<!--This is where I would call my plugin interface-->

outputs the HTML form fields.

Licensed under: CC-BY-SA with attribution
Not affiliated with wordpress.stackexchange
scroll top