WordPress.org

Ready to get started?Download WordPress

Forums

Possible to show all metabox key from another plugin/theme ? (4 posts)

  1. osterichs
    Member
    Posted 8 months ago #

    is it possible to show all custom metabox key/name that plugin/theme developer make ?
    i just wanna make a plugin that will support to detected custom metabox from all plugin/theme and show the metabox key to my dropdown menu, then i post the targeted metabox from my custom field plugin.

    thanks.

  2. bcworkz
    Member
    Posted 8 months ago #

    All the info you need is available in the global $wp_meta_boxes. The problem is this global is only loaded up when the related template is being loaded, so you would need to call do_action('add_meta_boxes', $type, $object ); yourself to essentially have all plugins and the theme load up the global for your use.

    Further complicating things is some plugins use the "add_meta_boxes_{$entity_type}" action hook tag form, usually for custom post types. For completeness, you would need to determine the various entity types used and do those actions as well.

  3. osterichs
    Member
    Posted 8 months ago #

    not sure i understand that function.
    is that any example for using it ?
    so if i have

    <select>
    <option>
    do_action('add_meta_boxes',$type,$object);
    </option>
    </select>

    whater your code will show an metaboxes title with metaboxes key or not ?

    sry,i'm new as wp developer.

  4. bcworkz
    Member
    Posted 8 months ago #

    There's more to it than that I'm afraid. (first of all, any PHP code needs to be inside of <?php ?> blocks.)

    The $type and $object determine the metabox context, these need to be defined. All the do_action() call does is ask the theme and plugins to add their meta box callbacks (for the particular context) to the global $wp_meta_boxes. Your code would need to step through this global, extract the required information, and use it to build your dropdown and setup whatever else happens when the form is submitted.

    I'm not sure exactly how the global is structured, you'll have to var_dump it and study it for yourself. Welcome to WordPress development :)

Reply

You must log in to post.

About this Topic