Esempio n. 1
0
 /**
  * Sets the $object_type based on metabox settings
  * @since  1.0.0
  * @param  array|string $meta_box Metabox config array or explicit setting
  * @return string       Object type
  */
 public static function set_mb_type($meta_box)
 {
     if (is_string($meta_box)) {
         self::$mb_object_type = $meta_box;
         return self::get_mb_type();
     }
     if (!isset($meta_box['pages'])) {
         return self::get_mb_type();
     }
     $type = false;
     // check if 'pages' is a string
     if (is_string($meta_box['pages'])) {
         $type = $meta_box['pages'];
     } elseif (is_array($meta_box['pages']) && count($meta_box['pages'] === 1)) {
         $type = is_string(end($meta_box['pages'])) ? end($meta_box['pages']) : false;
     }
     if (!$type) {
         return self::get_mb_type();
     }
     // Get our object type
     if ('user' == $type) {
         self::$mb_object_type = 'user';
     } elseif ('comment' == $type) {
         self::$mb_object_type = 'comment';
     } else {
         self::$mb_object_type = 'post';
     }
     return self::get_mb_type();
 }