PHP Class 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
Inheritance: extends QueryRecord, implements IsContent, implements habari\FormStorage
Afficher le fichier Open project: habari/system Class Usage Examples

Méthodes publiques

Свойство Type Description
$post_status_list static variables to hold post status and post type values
$post_type_list_active
$post_type_list_all
$schema

Protected Properties

Свойство Type Description
$url_args

Méthodes publiques

Méthode Description
__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

Private Methods

Méthode Description
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.

Method Details

__call() public méthode

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
Résultat mixed The value returned from any plugin filters, null if no value is returned

__construct() public méthode

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

__get() public méthode

Overrides QueryRecord __get to implement custom object properties
public __get ( string $name ) : mixed
$name string Name of property to return
Résultat mixed The requested field value

__isset() public méthode

Overrides QueryRecord __isset to implement custom object properties
public __isset ( string $name ) : boolean
$name string Name of property to return
Résultat boolean true if var is set and not NULL, false otherwise

__set() public méthode

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
Résultat mixed The requested field value

__static() public static méthode

Register plugin hooks
public static __static ( )

activate_post_type() public static méthode

Activate an existing post type
public static activate_post_type ( string $type ) : boolean
$type string The post type to activate
Résultat boolean True on success

add_new_status() public static méthode

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() public static méthode

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() public méthode

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() public méthode

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
Résultat Post The ascending post

comment_form() public méthode

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
Résultat FormUI The comment form for this post

content_type() public méthode

Return the content type of this object
See also: IsContent
public content_type ( ) : array
Résultat array An array of content types that this object represents, starting with the most specific

create() static public méthode

Create a post and save it.
static public create ( array $paramarray ) : Post
$paramarray array An associative array of post fields
Résultat Post The new Post object

create_default_tokens() public méthode

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

css_class() public méthode

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
Résultat string The resultant classes

deactivate_post_type() public static méthode

Deactivate a post type
public static deactivate_post_type ( string $type ) : boolean
$type string The post type to deactivate
Résultat boolean True on success

default_fields() public static méthode

Return the defined database columns for a Post.
public static default_fields ( ) : array
Résultat array Array of columns in the Post table

delete() public méthode

Deletes this post instance
public delete ( ) : boolean
Résultat boolean True on success

delete_post_status() public static méthode

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

delete_post_type() public static méthode

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
Résultat 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() public méthode

Deletes all tokens from a post
public delete_tokens ( )

descend() public méthode

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
Résultat Post The descending post

field_load() public méthode

Loads form values from this post
public field_load ( string $key ) : mixed
$key string The name of a form component that will be loaded
Résultat mixed The stored value returned

field_save() public méthode

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() public static méthode

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
Résultat string The fitlered field value

filter_post_status_display_4() public static méthode

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
Résultat string The translated status name, or the built-in name if there is no translation

filter_post_type_display_4() public static méthode

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'
Résultat string The translated type name, or the built-in name if there is no translation

form_publish_delete() public méthode

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() public méthode

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

get() static public méthode

$post= Post::get( array( 'slug' => 'wooga' ) );
static public get ( array $paramarray = [] ) : Post
$paramarray array An associative array of parameters, or a querystring
Résultat Post The first post that matched the given criteria

get_access() public méthode

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
Résultat Bitmask

get_form() public méthode

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'
Résultat FormUI A form appropriate for creating and updating this post.

get_revision_data() public méthode

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
Résultat array An array of field data for the post with the values of those fields at the specified date

get_schema_map() public méthode

Get the schema data for this post
public get_schema_map ( ) : array
Résultat array An array of schema data for this post

get_tokens() public méthode

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
Résultat array An array of token ids

get_url_args() public méthode

Returns a set of properties used by URL::get to create URLs
public get_url_args ( ) : array
Résultat array Properties of this post used to build a URL

has_tokens() public méthode

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
Résultat mixed false if no tokens match, an array of matching token ids if any match

insert() public méthode

Saves a new post to the posts table
public insert ( ) : integer | null
Résultat integer | null The new post id on success, or false on failure

list_active_post_types() public static méthode

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
Résultat array An array of post type names => integer values

list_all_post_types() public static méthode

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
Résultat array An array of post type names => (integer values, active values)

list_post_statuses() public static méthode

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
Résultat array An array of post statuses names => integer values

list_revisions() public méthode

List the stored revisions of this post by date and user id
public list_revisions ( ) : array
Résultat array

publish() public méthode

Updates an existing post to published status
public publish ( ) : boolean
Résultat boolean True on success, false if not

remove_tokens() public méthode

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() public méthode

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() public méthode

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() public static méthode

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
Résultat integer | boolean an integer or boolean false

status_name() public static méthode

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
Résultat string | null a string of the status name, or null

type() public static méthode

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
Résultat boolean | integer the id of the type or false if not found

type_name() public static méthode

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
Résultat string the string of the type or emptystring if not found

update() public méthode

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
Résultat boolean True on success

Property Details

$post_status_list static_oe public_oe property

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

$post_type_list_active static_oe public_oe property

static public $post_type_list_active

$post_type_list_all static_oe public_oe property

static public $post_type_list_all

$schema public_oe property

public $schema

$url_args protected_oe property

protected $url_args