Download the PHP package hanamura/wp-model without Composer
On this page you can find all versions of the php package hanamura/wp-model. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hanamura/wp-model
More information about hanamura/wp-model
Files in hanamura/wp-model
Package wp-model
Short Description Missing functionalities from model objects of WordPress.
License MIT
Informations about the package wp-model
wp-model
Missing functionalities from model objects of WordPress.
API
Post
Extended wrapper of native post object of WordPress, WP_Post
.
new Post($post), Post::create($post)
- $post integer | WP_Post
Post id or WP_Post object.
->permalink, ->permalink()
Get permalink of the post.
Returns: string
->children, ->children([$options])
Get child posts of the post.
- $options array
- $options['id'] integer | array
Filter by ids. - $options['post_type'] string | array
Filter by post types. - $options['post_mime_type'] string | array
Filter by post mime types.
- $options['id'] integer | array
Returns: array
->terms, ->terms([$options])
Get terms attached to the post.
- $options array
- $options['taxonomy'] string
Specify taxonomy. Default value:'category'
- $options['taxonomy'] string
Returns: array
->meta, ->meta()
PostMeta object of the post.
Retusns: WPModel\PostMeta
->image, ->image([$options])
Get WPModel\Image object if the post is an image attachment.
- $options array
- $options['size'] string
Specify size by string (e.g.'full'
,'large'
,'medium'
,'thumbnail'
). Default value:'full'
- $options['size'] string
Returns: WPModel\Image
->images, ->images()
Get images array if the post is an image attachment.
Returns: array
->group, ->group([$options])
Retrieve posts grouped by same terms.
- $options array
- $options['taxonomy'] string
Taxonomy name. Default value:'category'
- $options['options'] array
Custom arguments forWP_Query
that is internally called. - $options['map'] callable
Default value:array('WPModel\Post', 'create')
- $options['taxonomy'] string
Returns: array
->neighbor($options)
Retrieve a prev/next WP_Post
object. Returns null
if it doesn’t exist.
- $options array
- $options['post_type'] string | array
Post type. Default value:$this->post_type
- $options['direction'] string
Direction of neighbor:prev
ornext
- $options['post_type'] string | array
Returns: WP_Post
->exists, ->exists()
Return true
if the post exists.
Returns: boolean
->hasChild($post)
Return true
if the value is a child of the post.
- $post integer | WP_Post | WPModel\Post
Returns: boolean
->matchMimeType($type)
Return true
if the value matches mime type of the post. For example, 'image/jpeg'
, 'image'
and 'jpeg'
match 'image/jpeg'
.
- $type string
Retusns: boolean
PostMeta
See ->meta
of WPModel\Post
.
Term
Extended wrapper of native term object of WordPress. See return values of wp_get_post_terms
.
new Term($term, [$taxonomy]), Term::create($term, [$taxonomy])
- $term integer | term object
Term id or term object. - $taxonomy string
Taxonomy name.
->children, ->children([$options])
Get child terms of the term.
- $options array
See$args
ofget_terms
.
Image
See ->image
of WPModel\Post
.
User
Extended wrapper of native user object of WordPress, WP_User
.
new User([$user]), User::create([$user])
- $user integer | WP_User
User id or WP_User object. If not specified, returns current user.
->meta, ->meta()
UserMeta object of the user.
Returns: WPModel\UserMeta
->exists, ->exists()
Return true
if the user exists.
Returns: boolean
UserMeta
See ->meta
of WPModel\User
.