Ejemplo n.º 1
0
 /**
  * Adding the metaboxes
  */
 function mf_post_add_metaboxes()
 {
     global $post, $mf_post_values;
     //if the user are going to add a new link
     //the var $post is not defined and we do nothing
     if (!isset($post)) {
         return false;
     }
     $mf_post_values = $this->mf_get_post_values($post->ID);
     //Getting the post types
     $post_types = $this->mf_get_post_types(array(), 'names');
     foreach ($post_types as $post_type) {
         if (post_type_supports($post_type, 'page-attributes') && $post_type != 'page') {
             // If the post type has page-attributes we are going to add
             // the meta box for choice a template by hand
             // this is because wordpress don't let choice a template
             // for any non-page post type
             add_meta_box('mf_template_attribute', __('Template'), array(&$this, 'mf_metabox_template'), $post_type, 'side', 'default');
         }
         if (!mf_custom_fields::has_fields($post_type)) {
             continue;
         }
         //getting  the groups (each group is a metabox)
         $groups = $this->get_groups_by_post_type($post_type);
         //creating the metaboxes
         foreach ($groups as $group) {
             if ($this->group_has_fields($group['id'])) {
                 add_meta_box('mf_' . $group['id'], $group['label'], array(&$this, 'mf_metabox_content'), $post_type, 'normal', 'default', array('group_info' => $group));
             }
         }
     }
 }
Ejemplo n.º 2
0
 /**
  * Adding the metaboxes
  */
 function mf_post_add_metaboxes()
 {
     global $post, $mf_post_values;
     //if the user are going to add a new link
     //the var $post is not defined and we do nothing
     if (!isset($post)) {
         return false;
     }
     $mf_post_values = $this->mf_get_post_values($post->ID);
     //Getting the post types
     $post_types = $this->mf_get_post_types(array('public' => true), 'names');
     foreach ($post_types as $post_type) {
         if (!mf_custom_fields::has_fields($post_type)) {
             continue;
         }
         //getting  the groups (each group is a metabox)
         $groups = $this->get_groups_by_post_type($post_type);
         //creating the metaboxes
         foreach ($groups as $group) {
             if ($this->group_has_fields($group['id'])) {
                 add_meta_box('mf_' . $group['id'], $group['label'], array(&$this, 'mf_metabox_content'), $post_type, 'normal', 'default', array('group_info' => $group));
             }
         }
     }
 }
Ejemplo n.º 3
0
 public function check_name_custom_field($data)
 {
     global $mf_domain;
     $name = $data['field_name'];
     $post_type = $data['post_type'];
     $id = $data['field_id'];
     $resp = array('success' => 1);
     $check = mf_custom_fields::check_group($name, $post_type, $id);
     if ($check) {
         $resp = array('success' => 0, 'msg' => __('The name of Field exist in this post type, Please choose a different name.', $mf_domain));
     }
     echo json_encode($resp);
 }