PHP 클래스 WPDKPost

## Overview The WPDKPost class is a wrap of WordPress Post record. In addition this class provides a lot of methods and properties. ### Properties naming You'll see that a lot of properties class are written in lowercase and underscore mode as $post_date. This beacouse they are a map of database record. ### Post onfly ### Create a virtual post
저자: =undo= ([email protected])
상속: extends WPDKObject
파일 보기 프로젝트 열기: wpxtreme/wpdk 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$ID integer The post ID
$__version string Override version
$comment_count integer Number of comments, pings, and trackbacks combined
$comment_status string The comment status, ie. open. Max 20 char
$guid string The guid. Global Unique Identifier. The “real” URL to the post, not the permalink version. For pages, this is the actual URL. In the case of files (attachments), this holds the URL to the file.
$menu_order integer Holds values for display order of pages. Only works with pages, not posts.
$ping_status string The ping status, ie. open. Max 20 char
$pinged array List of urls that have been pinged (for published posts)
$post_author integer The post author ID
$post_category integer Number representing post category ID#. This property is not present on databse record.
$post_content string The post content
$post_content_filtered string If you’ve got a plugin that runs a very resource heavy filter on content, you might consider caching the results with post_content_filtered, and calling that from the front end instead.
$post_date string The Post date
$post_date_gmt string The post date in GMT
$post_excerpt string The post excerpt
$post_meta array A key values pair array with the list of post meta for this post.
$post_mime_type string Typical values are: text/html, image/png, image/jpg
$post_modified string Modified date
$post_modified_gmt string Modifed date in GMT
$post_name string The post name. Same as post slug. Max 200 char
$post_parent integer Parent Post ID
$post_password string Protect post password. Will be empty if no password. Max 20 char
$post_status string Post status, ie. publish, draft. Max 20 char
$post_title string The post title
$post_type string The post type. Used by Custom Post. Default 'post'. Self-explanatory for pages and posts. Any files uploaded are attachments and post revisions saved as revision
$to_ping array List of urls to ping when post is published (for unpublished posts)

공개 메소드들

메소드 설명
__construct ( string | integer | object | null $record = null, string $post_type = WPDKPostType::POST ) : WPDKPost Create an instance of WPDKPost class
delete ( ) : mixed Delete permately this post from database
duplicate ( string | integer | object $post, array $args = [] ) : WPDKPost Return an instance of WPDKPost as clone of input post. The new 'duplicate' post is stored on db.
imageAttachments ( string $size = 'full', integer $index = 1 ) : boolean | WPDKHTMLTagImg Return the nth instance of WPDKHTMLTagImg class as attachment image in this post.
imageAttachmentsWithID ( integer $post_id, string $size = 'full', integer $index = 1 ) : boolean | WPDKHTMLTagImg Return the nth instance of WPDKHTMLTagImg class as attachment image in a post.
imageContent ( ) : boolean | WPDKHTMLTagImg Return an instance of WPDKHTMLTagImg class with the first image found in this post content.
imageContentWithID ( integer $post_id ) : boolean | WPDKHTMLTagImg Return an instance of WPDKHTMLTagImg class with the first image found in the post content.
insert ( ) : integer | WP_Error Insert or update a post.
metaValue ( string $meta_key ) : boolean | mixed Return or set a single post meta value
metaValues ( string $meta_key ) : boolean | mixed Return o set post meta values
publish ( ) : integer | WP_Error Publish a post.
thumbnail ( string $size = 'full' ) : boolean | WPDKHTMLTagImg Return an instance of WPDKHTMLTagImg class with thumbmail image description. If the thumbnail is not found return FALSE. You can use the WPDKHTMLTagImg instance to read the property, get the HTML markup or display the image.
thumbnailWithID ( integer $post_id, string $size = 'full' ) : boolean | WPDKHTMLTagImg Return an instance of WPDKHTMLTagImg class with thumbmail image description. If the thumbnail is not found return FALSE. You can use the WPDKHTMLTagImg instance to read the property, get the HTML markup or display the image.
trash ( ) : mixed Moves a post or page to the Trash If trash is disabled, the post or page is permanently deleted.
untrash ( ) : mixed Restores a post or page from the Trash
update ( ) : integer | WP_Error Update this post on database. Also this method check if you are in admin backend area for this custom post.
updateMeta ( array $args = [] ) Update meta
updateMetaWithID ( integer $post_id, array $args = [] ) Update the post meta with post id

비공개 메소드들

메소드 설명
initPostByArgs ( array | object $args ) Init this instance of WPDKPost as a empty Post
initPostByID ( integer $id_post ) Init this instance of WPDKPost as post from Post ID
initPostByPost ( object $post ) Init this instance of WPDKPost as post from Post database object
postEmpty ( ) : array Return a Key value pairs array with property and value for an empty post. The properties are set to a default values.

메소드 상세

__construct() 공개 메소드

Create an instance of WPDKPost class
public __construct ( string | integer | object | null $record = null, string $post_type = WPDKPostType::POST ) : WPDKPost
$record string | integer | object | null Optional. Post ID, post object, post slug or null
$post_type string Optional. If $record is a string (slug) then this is the post type where search. Default is 'page'
리턴 WPDKPost

delete() 공개 메소드

Delete permately this post from database
부터: 0.9
public delete ( ) : mixed
리턴 mixed False on failure

duplicate() 공개 정적인 메소드

Return an instance of WPDKPost as clone of input post. The new 'duplicate' post is stored on db.
부터: 1.5.16
public static duplicate ( string | integer | object $post, array $args = [] ) : WPDKPost
$post string | integer | object Post ID, post object, post slug.
$args array Optional. Additional args. {
리턴 WPDKPost

imageAttachments() 공개 메소드

self::imageFromAttachmentsWithID( 2294, 'thumbnail' )->display();
부터: 1.3.1
public imageAttachments ( string $size = 'full', integer $index = 1 ) : boolean | WPDKHTMLTagImg
$size string Optional. Size of attachment image
$index integer Optional. Index of image. Default first attach image is returned
리턴 boolean | WPDKHTMLTagImg

imageAttachmentsWithID() 공개 정적인 메소드

self::imageFromAttachmentsWithID( 2294, 'thumbnail' )->display();
부터: 1.3.1
public static imageAttachmentsWithID ( integer $post_id, string $size = 'full', integer $index = 1 ) : boolean | WPDKHTMLTagImg
$post_id integer Post id
$size string Optional. Size of attachment image
$index integer Optional. Index of image. Default first attach image is returned
리턴 boolean | WPDKHTMLTagImg

imageContent() 공개 메소드

Return an instance of WPDKHTMLTagImg class with the first image found in this post content.
부터: 1.3.1
public imageContent ( ) : boolean | WPDKHTMLTagImg
리턴 boolean | WPDKHTMLTagImg

imageContentWithID() 공개 정적인 메소드

Return an instance of WPDKHTMLTagImg class with the first image found in the post content.
부터: 1.3.1
public static imageContentWithID ( integer $post_id ) : boolean | WPDKHTMLTagImg
$post_id integer Post ID
리턴 boolean | WPDKHTMLTagImg

insert() 공개 메소드

Insert or update a post.
부터: 1.5.16
public insert ( ) : integer | WP_Error
리턴 integer | WP_Error

metaValue() 공개 메소드

Return or set a single post meta value
부터: 1.3.1
public metaValue ( string $meta_key ) : boolean | mixed
$meta_key string Meta key
리턴 boolean | mixed

metaValues() 공개 메소드

Return o set post meta values
부터: 1.3.1
public metaValues ( string $meta_key ) : boolean | mixed
$meta_key string Meta key
리턴 boolean | mixed

publish() 공개 메소드

Publish a post.
부터: 1.5.16
public publish ( ) : integer | WP_Error
리턴 integer | WP_Error

thumbnail() 공개 메소드

Return an instance of WPDKHTMLTagImg class with thumbmail image description. If the thumbnail is not found return FALSE. You can use the WPDKHTMLTagImg instance to read the property, get the HTML markup or display the image.
부터: 1.3.1
public thumbnail ( string $size = 'full' ) : boolean | WPDKHTMLTagImg
$size string Optional. Default 'full'.
리턴 boolean | WPDKHTMLTagImg

thumbnailWithID() 공개 정적인 메소드

Return an instance of WPDKHTMLTagImg class with thumbmail image description. If the thumbnail is not found return FALSE. You can use the WPDKHTMLTagImg instance to read the property, get the HTML markup or display the image.
부터: 1.3.1
public static thumbnailWithID ( integer $post_id, string $size = 'full' ) : boolean | WPDKHTMLTagImg
$post_id integer Post id
$size string Optional. Default 'full'
리턴 boolean | WPDKHTMLTagImg

trash() 공개 메소드

Moves a post or page to the Trash If trash is disabled, the post or page is permanently deleted.
부터: 0.9
public trash ( ) : mixed
리턴 mixed False on failure

untrash() 공개 메소드

Restores a post or page from the Trash
부터: 0.9
public untrash ( ) : mixed
리턴 mixed False on failure

update() 공개 메소드

In this case the post update if turn off and save the post meta only. Return value 0 or WP_Error on failure. The post ID on success.
부터: 0.9
public update ( ) : integer | WP_Error
리턴 integer | WP_Error

updateMeta() 공개 메소드

Update meta
부터: 1.4.20
public updateMeta ( array $args = [] )
$args array

updateMetaWithID() 공개 정적인 메소드

Update the post meta with post id
부터: 1.4.20
public static updateMetaWithID ( integer $post_id, array $args = [] )
$post_id integer Post ID
$args array Key value pairs array with meta_key => meta_value

프로퍼티 상세

$ID 공개적으로 프로퍼티

The post ID
public int $ID
리턴 integer

$__version 공개적으로 프로퍼티

Override version
public string $__version
리턴 string

$comment_count 공개적으로 프로퍼티

Number of comments, pings, and trackbacks combined
public int $comment_count
리턴 integer

$comment_status 공개적으로 프로퍼티

The comment status, ie. open. Max 20 char
public string $comment_status
리턴 string

$guid 공개적으로 프로퍼티

The guid. Global Unique Identifier. The “real” URL to the post, not the permalink version. For pages, this is the actual URL. In the case of files (attachments), this holds the URL to the file.
public string $guid
리턴 string

$menu_order 공개적으로 프로퍼티

Holds values for display order of pages. Only works with pages, not posts.
public int $menu_order
리턴 integer

$ping_status 공개적으로 프로퍼티

The ping status, ie. open. Max 20 char
public string $ping_status
리턴 string

$pinged 공개적으로 프로퍼티

List of urls that have been pinged (for published posts)
public array $pinged
리턴 array

$post_author 공개적으로 프로퍼티

The post author ID
public int $post_author
리턴 integer

$post_category 공개적으로 프로퍼티

Number representing post category ID#. This property is not present on databse record.
public int $post_category
리턴 integer

$post_content 공개적으로 프로퍼티

The post content
public string $post_content
리턴 string

$post_content_filtered 공개적으로 프로퍼티

If you’ve got a plugin that runs a very resource heavy filter on content, you might consider caching the results with post_content_filtered, and calling that from the front end instead.
public string $post_content_filtered
리턴 string

$post_date 공개적으로 프로퍼티

The Post date
public string $post_date
리턴 string

$post_date_gmt 공개적으로 프로퍼티

The post date in GMT
public string $post_date_gmt
리턴 string

$post_excerpt 공개적으로 프로퍼티

The post excerpt
public string $post_excerpt
리턴 string

$post_meta 공개적으로 프로퍼티

A key values pair array with the list of post meta for this post.
부터: 1.5.13
public array $post_meta
리턴 array

$post_mime_type 공개적으로 프로퍼티

Typical values are: text/html, image/png, image/jpg
public string $post_mime_type
리턴 string

$post_modified 공개적으로 프로퍼티

Modified date
public string $post_modified
리턴 string

$post_modified_gmt 공개적으로 프로퍼티

Modifed date in GMT
public string $post_modified_gmt
리턴 string

$post_name 공개적으로 프로퍼티

The post name. Same as post slug. Max 200 char
public string $post_name
리턴 string

$post_parent 공개적으로 프로퍼티

Parent Post ID
public int $post_parent
리턴 integer

$post_password 공개적으로 프로퍼티

Protect post password. Will be empty if no password. Max 20 char
public string $post_password
리턴 string

$post_status 공개적으로 프로퍼티

Post status, ie. publish, draft. Max 20 char
public string $post_status
리턴 string

$post_title 공개적으로 프로퍼티

The post title
public string $post_title
리턴 string

$post_type 공개적으로 프로퍼티

The post type. Used by Custom Post. Default 'post'. Self-explanatory for pages and posts. Any files uploaded are attachments and post revisions saved as revision
public string $post_type
리턴 string

$to_ping 공개적으로 프로퍼티

List of urls to ping when post is published (for unpublished posts)
public array $to_ping
리턴 array