/** * Validates and assigns a value to this Object Type * * @example: * * $this->assign( * * @param bool|string|array|WP_Object_Type $object_type */ function assign($object_type = false) { if (empty($object_type)) { global $post; $object_type = wp_get_post_object_type($post->post_type); } if (is_a($object_type, __CLASS__)) { $this->class = $object_type->class; $this->subtype = $class->subtype; } else { if (is_string($object_type)) { if (false === strpos($object_type, ':')) { $this->class = 'post'; $this->subtype = $object_type; } else { list($this->class, $this->subtype) = explode(':', $object_type); } } else { if (is_array($object_type)) { $object_type = (object) $object_type; } $this->class = property_exists($object_type, 'class') ? $object_type->class : false; $this->subtype = property_exists($object_type, 'subtype') ? $object_type->subtype : false; } $this->class = sanitize_key($this->class); if ($this->subtype) { $this->subtype = sanitize_key($this->subtype); } } if (empty($this->subtype)) { $this->subtype = 'any'; } }
/** * Hook handler for 'edit_form_top', 'edit_form_after_title'. 'edit_form_after_editor' and 'edit_form_advanced'. * * Displayed the post_type's default form based on the value of post_type_object->default_form that can be set * as an argument to register_post_type. Valid values for default form include: * * 'top', 'after_title', 'after_editor', 'advanced', or 'custom_fields' * * @todo Explain how to handle custom metaboxes once we figure out how we'll handle them. * * @param WP_Post $post * * @internal * */ static function _edit_post_form($post) { $post_type = $post->post_type; $object_type = wp_get_post_object_type($post_type); $current_form = preg_replace('#^edit_form_(.*)$#', '$1', current_action()); if ($current_form == get_post_type_object($post_type)->default_form) { if (!self::form_registered($current_form, $object_type)) { self::register_form($current_form, $object_type); } $form = self::get_form($current_form, $object_type); $form->set_storage_object($post); $form->the_form(); } }
/** * @param string $post_type * @param bool|array $form_names * * @return array */ function get_post_forms($post_type, $form_names = false) { return WP_Metadata::get_forms(wp_get_post_object_type($post_type), $form_names); }