From d31e27e0bd3a853e8a43430aa947ce8ecb9fe863 Mon Sep 17 00:00:00 2001 From: Randy Hoyt Date: Thu, 18 Aug 2011 00:03:28 -0500 Subject: [PATCH 1/2] This one line of code will allow developers to use custom meta boxes in a theme *and* a plugin simultaneously. This is useful for distributing a plugin with the custom meta boxes library in it to someone else who might already be using the library. --- init.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.php b/init.php index f8ccaa3..bed8c72 100644 --- a/init.php +++ b/init.php @@ -31,7 +31,7 @@ /************************************************************************ You should not edit the code below or things might explode! *************************************************************************/ - +$meta_boxes = apply_filters ( 'cmb_meta_boxes' , $meta_boxes ); foreach ( $meta_boxes as $meta_box ) { $my_box = new cmb_Meta_Box( $meta_box ); } From 3b937a622b5b71939e6034d3d6c57a9769be9a25 Mon Sep 17 00:00:00 2001 From: Randy Hoyt Date: Thu, 22 Sep 2011 19:57:58 -0500 Subject: [PATCH 2/2] Adding an action hook and a filter hook to enable custom field types. --- init.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/init.php b/init.php index 5d80391..ba3cb21 100644 --- a/init.php +++ b/init.php @@ -289,7 +289,8 @@ function show() { } echo ''; break; - + default: + do_action('cmb_render_' . $field['type'] , $field, $meta); } echo '',''; @@ -343,6 +344,8 @@ function save( $post_id) { $new = strtotime( $new ); } + $new = apply_filters('cmb_validate_' . $field['type'], $new, $post_id, $field); + // validate meta value if ( isset( $field['validate_func']) ) { $ok = call_user_func( array( 'cmb_Meta_Box_Validate', $field['validate_func']), $new );