'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => $rewrite,
- 'capability_type' => 'page'
+ 'capability_type' => 'page',
+ 'register_meta_box_cb' => 'michsci_add_metaboxes'
);
register_post_type( MICHSCI_POST_TYPE, $args );
}
+/**
+ * michsci_add_metaboxes
+ *
+ * Add the meta fields
+ *
+ * @access public
+ * @return void
+ */
+function michsci_add_metaboxes()
+{
+ add_meta_box('miproduct_features', 'Features', 'miproduct_features', MICHSCI_POST_TYPE, 'normal', 'high');
+ add_meta_box('miproduct_related_products', 'Related Products', 'miproduct_related_products', MICHSCI_POST_TYPE, 'normal', 'high');
+}
+
+/**
+ * miproduct_features
+ *
+ * Add field for the features
+ *
+ * @access public
+ * @return void
+ */
+function miproduct_features()
+{
+ global $post;
+
+ // Noncename needed to verify where the data originated
+ $nonce = wp_create_nonce( 'miproductmeta-meta-noncename' );
+ echo '<input type="hidden" name="miproductmeta-meta-noncename" id="miproductmeta-meta-noncename" value="' . $nonce . '" />';
+ // get the features for the post
+ $features = get_post_meta( $post->ID, 'miproduct_features', true );
+ // output field
+ wp_editor( $features, 'features', array(
+ 'wpautop' => true,
+ 'media_buttons' => false,
+ 'textarea_name' => 'miproduct_features',
+ 'teeny' => false,
+ 'editor_height' => 300,
+ 'quicktags' => false,
+ 'tinymce' => true
+ ) );
+}
+
+/**
+ * miproduct_related_products
+ *
+ * Adds the field for related product
+ *
+ * @access public
+ * @return void
+ */
+function miproduct_related_products()
+{
+ global $post;
+
+ // Noncename needed to verify where the data originated
+ //echo '<input type="hidden" name="miproductmeta_related_products_noncename" id="" value="';
+ //wp_create_nonce( plugin_basename(__FILE__) ) . '" />';
+ // get the features for the post
+ $related_products = get_post_meta( $post->ID, 'miproduct_related_products', true );
+ // output field
+ wp_editor( $related_products, 'related_products', array(
+ 'wpautop' => true,
+ 'media_buttons' => false,
+ 'textarea_name' => 'miproduct_related_products',
+ 'teeny' => false,
+ 'editor_height' => 300,
+ 'quicktags' => false,
+ 'tinymce' => true
+ ) );
+}
+
+/**
+ * miproduct_save_meta
+ *
+ * Saves the meta fields for the product
+ *
+ * @access public
+ * @return void
+ */
+function miproduct_save_meta()
+{
+ global $post;
+ if (!wp_verify_nonce( $_POST['miproductmeta-meta-noncename'], 'miproductmeta-meta-noncename' )) {
+ return $post->ID;
+ }
+ if ( !current_user_can( 'edit_post', $post->ID ) ) {
+ return $post->ID;
+ }
+ $features = filter_var( $_POST['miproduct_features'] );
+ $related_products = filter_var( $_POST['miproduct_features'] );
+ update_post_meta( $post->ID, 'miproduct_features', $features );
+ update_post_meta( $post->ID, 'miproduct_related_products', $related_products );
+
+}
+
+add_action( 'save_post', 'miproduct_save_meta' );
+
/**
* michsci_taxonomies
*