Ejemplo n.º 1
0
 /**
  * Create new field group.
  *
  * @param string $name Sanitized field group name. Note that the final name may change when new post is inserted.
  * @param string $title Field group title.
  *
  * @return null|WPCF_Field_Group The new field group or null on error.
  */
 public static function create($name, $title = '')
 {
     // we cannot use self::get_instance here, because of low PHP requirements and missing get_called_class function
     // we have a fallback class for get_called_class but that scans files by debug_backtrace and return 'self'
     //   instead of WPCF_Field_Group_Term_Factory like the original get_called_class() function does
     // ends in an error because of parents (abstract) $var = new self();
     return WPCF_Field_Group_Post_Factory::get_instance()->create_field_group($name, $title);
 }
Ejemplo n.º 2
0
 /**
  * For a given field domain, return the appropriate field group factory instance.
  *
  * @param string $domain
  * @return WPCF_Field_Group_Factory
  * @since 2.0
  */
 public static function get_group_factory_by_domain($domain)
 {
     switch ($domain) {
         case self::DOMAIN_POSTS:
             return WPCF_Field_Group_Post_Factory::get_instance();
         case self::DOMAIN_USERS:
             return WPCF_Field_Group_User_Factory::get_instance();
         case self::DOMAIN_TERMS:
             return WPCF_Field_Group_Term_Factory::get_instance();
         default:
             throw new InvalidArgumentException('Invalid field domain.');
     }
 }
 /**
  * @inheritdoc
  * @return WPCF_Field_Group_Post_Factory
  * @since 2.0
  */
 public function get_group_factory()
 {
     return WPCF_Field_Group_Post_Factory::get_instance();
 }