michaeluno / admin-page-framework

Facilitates WordPress plugin and theme development.
http://admin-page-framework.michaeluno.jp/
Other
339 stars 71 forks source link

MetaBoxes, Custom Fields in Pages / Page Templates? #52

Closed patrickf0 closed 10 years ago

patrickf0 commented 10 years ago

Is it possible to add Meta Boxes to specific Pages by Slug / ID or Page Templates?

michaeluno commented 10 years ago

Currently it's not possible. I'll see if I can implement the functionality.

michaeluno commented 10 years ago

Now the branch includes this feature: https://github.com/michaeluno/admin-page-framework/tree/v3/meta_box_for_pages

To create a meta box in a page added by the framework, define a class extending the AdminPageFramework_MetaBox_Page class and define the setUp() method and add fields with the addSettingFields() method in there.

And when instantiating the class, the parameters are:

  1. meta box id
  2. meta box title
  3. page slugs - array|string e.g. array( 'my_page', 'my_another_page' ) or 'my_page'
  4. context - normal, advanced, or side
  5. priority - high, core, default, low
new APF_MetaBox_For_Pages_Normal(
    'apf_metabox_for_pages_normal',     // meta box id
    __( 'Sample Meta Box For Admin Pages Inserted in Normal Area' ),    // title
    'apf_first_page',   // page slugs
    'normal',   // context
    'default'   // priority
);

The example classes are located in

The example of instantiating the classes are written in admin-page-framework-demo.php.

meta_box_for_pages

michaeluno commented 10 years ago

I'm going to drop the do_{meta box id} and the content_{meta box id} hooks to change them to do_{extended class name} and content_{extended class name} to make it consistent with taxonomy fields and the validation hook, validation_{extended class name} Just in case somebody has started using the branch.

michaeluno commented 10 years ago

It's been functioning okay.