Exemple #1
0
 /**
  *
  * get post meta data
  *
  * @param string  $key
  * @param string  $field_name
  * @param boolean $remove_first if array have only one element and if should be removed set to true
  *
  * @return mixed array, string or false if not found
  */
 public static function getPostMeta($key, $field_name, $post_id = null, $remove_first = true)
 {
     $key = self::getKeyName($key);
     $post_meta = \get_post_meta($post_id, $key, true);
     if ($post_meta && RecursiveArray::searchKey($field_name, $post_meta)) {
         $matches = RecursiveArray::searchRecursive($post_meta, $field_name);
         if (\count($matches) == 1 && \is_array($matches) && $remove_first) {
             return $matches[0];
         }
         return $matches;
     } else {
         return false;
     }
 }
 /**
  * Get single meta box by name
  *
  * @param int    $post_id
  * @param string $control_name valid meta box name
  * @param bool   $remove_first remove first element
  *
  * @return array|boolean
  *
  * @access   public
  */
 public function get($post_id, $control_name, $remove_first = true)
 {
     $post_meta = get_post_meta($post_id, $this->getId(), true);
     if ($post_meta && RecursiveArray::searchKey($control_name, $post_meta)) {
         $meta_boxes = RecursiveArray::searchRecursive($post_meta, $control_name);
         if (\count($meta_boxes) == 1 && \is_array($meta_boxes) && $remove_first) {
             return $meta_boxes[0];
         }
         if (is_array($meta_boxes)) {
             $meta_boxes = RecursiveArray::removeEmpty($meta_boxes);
         }
         return $meta_boxes;
     } else {
         return false;
     }
 }
Exemple #3
0
 /**
  *
  * Remove control from group
  *
  * @param string $name control name
  *
  * @return $this
  * @access public
  */
 public function removeControl($name)
 {
     $key = RecursiveArray::search($this->setting['fields'], $name);
     unset($this->setting['fields'][$key]);
     return $this;
 }
 /**
  * This function return all taxonomies with his
  * arguments or all argument of $taxonomy_name
  *
  * @param null $taxonomy_name
  *
  * @return array
  * @access public
  */
 public function get($taxonomy_name = null)
 {
     if (!is_null($taxonomy_name)) {
         if (isset($this->taxonomies[$taxonomy_name])) {
             return $this->taxonomies[$taxonomy_name];
         } else {
             //maybe is short name?
             $key = RecursiveArray::search($this->taxonomies, $taxonomy_name);
             if ($key !== false) {
                 return $this->taxonomies[$key];
             } else {
                 return false;
             }
         }
     }
     return $this->taxonomies;
 }