PHP Класс Habari\Post

$this->info= new PostInfo( 1 ); // Info records of post with id = 1 $this->info->option1= "blah"; // set info record with name "option1" to value "blah" $info_value= $this->info->option1; // get value of info record with name "option1" into variable $info_value if ( isset ( $this->info->option1 ) ) // test for existence of "option1" unset ( $this->info->option1 ); // delete "option1" info record
Наследование: extends QueryRecord, implements IsContent, implements habari\FormStorage
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$post_status_list static variables to hold post status and post type values
$post_type_list_active
$post_type_list_all
$schema

Защищенные свойства (Protected)

Свойство Тип Описание
$url_args

Открытые методы

Метод Описание
__call ( string $name, array $args ) : mixed Handle calls to this Post object that are implemented by plugins
__construct ( array $paramarray = [] ) Constructor for the Post class.
__get ( string $name ) : mixed Overrides QueryRecord __get to implement custom object properties
__isset ( string $name ) : boolean Overrides QueryRecord __isset to implement custom object properties
__set ( string $name, mixed $value ) : mixed Overrides QueryRecord __set to implement custom object properties
__static ( ) Register plugin hooks
activate_post_type ( string $type ) : boolean Activate an existing post type
add_new_status ( string $status, boolean $internal = false ) inserts a new post status into the database, if it doesn't exist
add_new_type ( string $type, boolean $active = true ) inserts a new post type into the database, if it doesn't exist
add_tokens ( array | string $tokens ) Add a token to a post
ascend ( null $params = null ) : Post Returns the ascending post, relative to this post, according to params
comment_form ( string $context = 'public' ) : FormUI Manage this post's comment form
content_type ( ) : array Return the content type of this object
create ( array $paramarray ) : Post Create a post and save it.
create_default_tokens ( ) Adds the default tokens to this post when it's saved
css_class ( string | array $append = [] ) : string Returns a list of CSS classes for the post
deactivate_post_type ( string $type ) : boolean Deactivate a post type
default_fields ( ) : array Return the defined database columns for a Post.
delete ( ) : boolean Deletes this post instance
delete_post_status ( string $status ) Delete a post status
delete_post_type ( string $type ) : boolean removes a post type from the database, if it exists and there are no posts of the type
delete_tokens ( ) Deletes all tokens from a post
descend ( $params = null ) : Post Returns the descending post, relative to this post, according to params
field_load ( string $key ) : mixed Loads form values from this post
field_save ( string $key, mixed $value ) Stores a form value into this post's info records
filter_post_get_7 ( string $content, string $field, Post $post ) : string Filter post content and titles for shortcodes
filter_post_status_display_4 ( string $status ) : string How to display the built-in post statuses.
filter_post_type_display_4 ( string $type, string $foruse ) : string How to display the built-in post types.
form_publish_delete ( FormUI $form ) The on_success handler for the delete button on the post editing form
form_publish_success ( FormUI $form ) Called when the publish form is successfully submitted
get ( array $paramarray = [] ) : Post Return a single requested post.
get_access ( User $user = null ) : Bitmask Returns an access Bitmask for the given user on this post
get_form ( string $context ) : FormUI Returns a form for editing this post
get_revision_data ( DateTime | string | integer $date ) : array Get the fields of the post that differ from what is stored by date
get_schema_map ( ) : array Get the schema data for this post
get_tokens ( ) : array Returns an array of token ids that are associated with this post Also initializes the internal token array for use by other token operations
get_url_args ( ) : array Returns a set of properties used by URL::get to create URLs
has_tokens ( mixed $tokens ) : mixed Checks if this post has one or more tokens
insert ( ) : integer | null Saves a new post to the posts table
list_active_post_types ( boolean $refresh = false ) : array returns an associative array of active post types
list_all_post_types ( boolean $refresh = false ) : array returns an associative array of all post types
list_post_statuses ( mixed $all = true, boolean $refresh = false ) : array returns an associative array of post statuses
list_revisions ( ) : array List the stored revisions of this post by date and user id
publish ( ) : boolean Updates an existing post to published status
remove_tokens ( array | string $tokens ) Deletes tokens from a post
set_revision ( DateTime | string | integer $date ) Set this post to have the same data as the post on the specified date
set_tokens ( mixed $tokens ) Applies a new set of specific tokens to a post
status ( string | integer $name ) : integer | boolean returns the integer value of the specified post status, or false
status_name ( string | integer $status ) : string | null returns the friendly name of a post status, or null
type ( string | integer $name ) : boolean | integer returns the integer value of the specified post type, or false
type_name ( string | integer $type ) : string returns the friendly name of a post type, or null
update ( boolean $minor = true ) : boolean Updates an existing post in the posts table

Приватные методы

Метод Описание
get_author ( ) : User private function get_author() returns a User object for the author of this post
get_comment_feed_link ( ) : string private function get_comment_feed_link Returns the permalink for this post's comments Atom feed
get_comments ( ) : Comments Gets the comments for the post
get_editlink ( ) : string Returns a URL for the ->editlink property of this class.
get_info ( ) : PostInfo function get_info Gets the info object for this post, which contains data from the postinfo table related to this post.
get_permalink ( ) : string Returns a URL for the ->permalink property of this class.
get_tags ( ) : Terms function get_tags Gets the tags for the post
save_tags ( ) : boolean Save the tags associated to this post into the terms and object_terms tables
setguid ( ) Generate the GUID for the new post.
setslug ( ) : string Generate a new slug for the post.
setstatus ( string | integer $value ) : integer | boolean Sets the status for a post, given a string or integer.

Описание методов

__call() публичный Метод

Handle calls to this Post object that are implemented by plugins
public __call ( string $name, array $args ) : mixed
$name string The name of the function called
$args array Arguments passed to the function call
Результат mixed The value returned from any plugin filters, null if no value is returned

__construct() публичный Метод

Constructor for the Post class.
public __construct ( array $paramarray = [] )
$paramarray array an associative array of initial Post field values.

__get() публичный Метод

Overrides QueryRecord __get to implement custom object properties
public __get ( string $name ) : mixed
$name string Name of property to return
Результат mixed The requested field value

__isset() публичный Метод

Overrides QueryRecord __isset to implement custom object properties
public __isset ( string $name ) : boolean
$name string Name of property to return
Результат boolean true if var is set and not NULL, false otherwise

__set() публичный Метод

Overrides QueryRecord __set to implement custom object properties
public __set ( string $name, mixed $value ) : mixed
$name string Name of property to return
$value mixed Value to set
Результат mixed The requested field value

__static() публичный статический Метод

Register plugin hooks
public static __static ( )

activate_post_type() публичный статический Метод

Activate an existing post type
public static activate_post_type ( string $type ) : boolean
$type string The post type to activate
Результат boolean True on success

add_new_status() публичный статический Метод

inserts a new post status into the database, if it doesn't exist
public static add_new_status ( string $status, boolean $internal = false )
$status string The name of the new post status
$internal boolean Whether this status is for internal use only. If true, this status will NOT be presented to the user

add_new_type() публичный статический Метод

inserts a new post type into the database, if it doesn't exist
public static add_new_type ( string $type, boolean $active = true )
$type string The name of the new post type
$active boolean Whether the new post type is active or not

add_tokens() публичный Метод

Add a token to a post
public add_tokens ( array | string $tokens )
$tokens array | string The name of the permission to add, or an array of permissions to add

ascend() публичный Метод

Returns the ascending post, relative to this post, according to params
public ascend ( null $params = null ) : Post
$params null The params by which to work out what is the ascending post
Результат Post The ascending post

comment_form() публичный Метод

Manage this post's comment form
public comment_form ( string $context = 'public' ) : FormUI
$context string The context in which the form is used, used to facilitate plugin alteration of the comment form in different circumstances
Результат FormUI The comment form for this post

content_type() публичный Метод

Return the content type of this object
См. также: IsContent
public content_type ( ) : array
Результат array An array of content types that this object represents, starting with the most specific

create() статический публичный Метод

Create a post and save it.
static public create ( array $paramarray ) : Post
$paramarray array An associative array of post fields
Результат Post The new Post object

create_default_tokens() публичный Метод

Adds the default tokens to this post when it's saved

css_class() публичный Метод

Returns a list of CSS classes for the post
public css_class ( string | array $append = [] ) : string
$append string | array Additional classes that should be added to the ones generated
Результат string The resultant classes

deactivate_post_type() публичный статический Метод

Deactivate a post type
public static deactivate_post_type ( string $type ) : boolean
$type string The post type to deactivate
Результат boolean True on success

default_fields() публичный статический Метод

Return the defined database columns for a Post.
public static default_fields ( ) : array
Результат array Array of columns in the Post table

delete() публичный Метод

Deletes this post instance
public delete ( ) : boolean
Результат boolean True on success

delete_post_status() публичный статический Метод

Delete a post status
public static delete_post_status ( string $status )
$status string The name of the status to delete

delete_post_type() публичный статический Метод

removes a post type from the database, if it exists and there are no posts of the type
public static delete_post_type ( string $type ) : boolean
$type string The post type name
Результат boolean true if post type has been deleted false if it has not been deleted (does not exist or there are posts using this content type)

delete_tokens() публичный Метод

Deletes all tokens from a post
public delete_tokens ( )

descend() публичный Метод

Returns the descending post, relative to this post, according to params
public descend ( $params = null ) : Post
$params The params by which to work out what is the descending post
Результат Post The descending post

field_load() публичный Метод

Loads form values from this post
public field_load ( string $key ) : mixed
$key string The name of a form component that will be loaded
Результат mixed The stored value returned

field_save() публичный Метод

Stores a form value into this post's info records
public field_save ( string $key, mixed $value )
$key string The name of a form component that will be stored
$value mixed The value of the form component to store

filter_post_get_7() публичный статический Метод

Filter post content and titles for shortcodes
public static filter_post_get_7 ( string $content, string $field, Post $post ) : string
$content string The field value to filter
$field string The name of the field to filter
$post Post The post that is being filtered
Результат string The fitlered field value

filter_post_status_display_4() публичный статический Метод

How to display the built-in post statuses.
public static filter_post_status_display_4 ( string $status ) : string
$status string The built-in status name
Результат string The translated status name, or the built-in name if there is no translation

filter_post_type_display_4() публичный статический Метод

How to display the built-in post types.
public static filter_post_type_display_4 ( string $type, string $foruse ) : string
$type string The type of Post
$foruse string Either 'singular' or 'plural'
Результат string The translated type name, or the built-in name if there is no translation

form_publish_delete() публичный Метод

The on_success handler for the delete button on the post editing form
public form_publish_delete ( FormUI $form )
$form FormUI The submitted post editing form

form_publish_success() публичный Метод

Called when the publish form is successfully submitted
public form_publish_success ( FormUI $form )
$form FormUI

get() статический публичный Метод

$post= Post::get( array( 'slug' => 'wooga' ) );
static public get ( array $paramarray = [] ) : Post
$paramarray array An associative array of parameters, or a querystring
Результат Post The first post that matched the given criteria

get_access() публичный Метод

Returns an access Bitmask for the given user on this post
public get_access ( User $user = null ) : Bitmask
$user User The user mask to fetch
Результат Bitmask

get_form() публичный Метод

Returns a form for editing this post
public get_form ( string $context ) : FormUI
$context string The context the form is being created in, most often 'admin'
Результат FormUI A form appropriate for creating and updating this post.

get_revision_data() публичный Метод

Get the fields of the post that differ from what is stored by date
public get_revision_data ( DateTime | string | integer $date ) : array
$date DateTime | string | integer The date to fetch the revision of
Результат array An array of field data for the post with the values of those fields at the specified date

get_schema_map() публичный Метод

Get the schema data for this post
public get_schema_map ( ) : array
Результат array An array of schema data for this post

get_tokens() публичный Метод

Returns an array of token ids that are associated with this post Also initializes the internal token array for use by other token operations
public get_tokens ( ) : array
Результат array An array of token ids

get_url_args() публичный Метод

Returns a set of properties used by URL::get to create URLs
public get_url_args ( ) : array
Результат array Properties of this post used to build a URL

has_tokens() публичный Метод

Checks if this post has one or more tokens
public has_tokens ( mixed $tokens ) : mixed
$tokens mixed A single token string or an array of tokens
Результат mixed false if no tokens match, an array of matching token ids if any match

insert() публичный Метод

Saves a new post to the posts table
public insert ( ) : integer | null
Результат integer | null The new post id on success, or false on failure

list_active_post_types() публичный статический Метод

returns an associative array of active post types
public static list_active_post_types ( boolean $refresh = false ) : array
$refresh boolean whether to force a refresh of the cached values
Результат array An array of post type names => integer values

list_all_post_types() публичный статический Метод

returns an associative array of all post types
public static list_all_post_types ( boolean $refresh = false ) : array
$refresh boolean whether to force a refresh of the cached values
Результат array An array of post type names => (integer values, active values)

list_post_statuses() публичный статический Метод

returns an associative array of post statuses
public static list_post_statuses ( mixed $all = true, boolean $refresh = false ) : array
$all mixed true to list all statuses, not just external ones, Post to list external and any that match the Post status
$refresh boolean true to force a refresh of the cached values
Результат array An array of post statuses names => integer values

list_revisions() публичный Метод

List the stored revisions of this post by date and user id
public list_revisions ( ) : array
Результат array

publish() публичный Метод

Updates an existing post to published status
public publish ( ) : boolean
Результат boolean True on success, false if not

remove_tokens() публичный Метод

Deletes tokens from a post
public remove_tokens ( array | string $tokens )
$tokens array | string The name of the permission to remove, or an array of permissions to remove

set_revision() публичный Метод

Set this post to have the same data as the post on the specified date
public set_revision ( DateTime | string | integer $date )
$date DateTime | string | integer The date to fetch the revision of

set_tokens() публичный Метод

Applies a new set of specific tokens to a post
public set_tokens ( mixed $tokens )
$tokens mixed A string token, or an array of tokens to apply to this post

status() публичный статический Метод

returns the integer value of the specified post status, or false
public static status ( string | integer $name ) : integer | boolean
$name string | integer a post status name or value
Результат integer | boolean an integer or boolean false

status_name() публичный статический Метод

returns the friendly name of a post status, or null
public static status_name ( string | integer $status ) : string | null
$status string | integer a post status value, or name
Результат string | null a string of the status name, or null

type() публичный статический Метод

returns the integer value of the specified post type, or false
public static type ( string | integer $name ) : boolean | integer
$name string | integer a post type name or id
Результат boolean | integer the id of the type or false if not found

type_name() публичный статический Метод

returns the friendly name of a post type, or null
public static type_name ( string | integer $type ) : string
$type string | integer a post type name or id
Результат string the string of the type or emptystring if not found

update() публичный Метод

Updates an existing post in the posts table
public update ( boolean $minor = true ) : boolean
$minor boolean Indicates if this is a major or minor update
Результат boolean True on success

Описание свойств

$post_status_list статическое публичное свойство

static variables to hold post status and post type values
static public $post_status_list

$post_type_list_active статическое публичное свойство

static public $post_type_list_active

$post_type_list_all статическое публичное свойство

static public $post_type_list_all

$schema публичное свойство

public $schema

$url_args защищенное свойство

protected $url_args