PHP Class WPLib_Posts, wplib

Inheritance: extends WPLib_Module_Base
Show file Open project: wplib/wplib Class Usage Examples

Public Methods

Method Description
_clear_post_type_args ( ) Run on WordPress's 'init' hook to register all the post types defined in classes that extend this class.
_get_post_type_label ( string $post_type, string $label_type ) : string
_get_post_type_labels ( string $post_type ) : array
_init ( ) Run on WordPress's 'init' hook to register all the post types defined in classes that extend this class.
_init_99 ( ) Clear out this data, we don't need them anymore But do it late so that a regular 'init' can still access them, i.e. for changing labels of 'post' post type.
_set_post_type_args ( string $post_type_slug, array $args ) Save $args for later passing to register_post_type().
_set_post_type_labels ( string $post_type, array $args ) : array
_wp_loaded ( ) Add a property to post type objects so they can be self-identified.
default_post_type_labels ( ) : array
get_list ( array | string | WPLib_Query $query = [], array $args = [] ) : WPLib_Post_List_Default
get_post ( WP_Post | object | integer | string | array | null | boolean $_post, string | boolean $post_type = false ) : null | WP_Post
get_post_by ( string $by, integer | string $value, array $args = [] ) : WP_Post
get_post_type_class ( string $post_type ) : string | null
get_post_types_supporting ( string $feature ) : array Get a list of post types that support a specific named feature.
get_posts ( WP_Query | array $args = [] ) : WP_Post[] Query the posts, return a post list.
get_queried_post_type ( ) : false | null | string Return the post type of the queried object.
get_query ( array $args = [] ) : WPLib_Query Query the posts. Equivalent to creating a new WP_Query which both instantiates and queries the DB.
make_new_item ( WP_Post | integer $_post, array $args = [] ) : mixed Create new Instance of a Post MVI
max_posts_per_page ( ) : integer
on_load ( ) Run on WordPress's 'init' hook to register all the post types defined in classes that extend this class.
pop_post ( )
post_type_classes ( ) : string[]
push_post ( WP_Post | boolean $value = false )
set_max_posts_per_page ( integer $value )

Method Details

_clear_post_type_args() static public method

Run on WordPress's 'init' hook to register all the post types defined in classes that extend this class.
static public _clear_post_type_args ( )

_get_post_type_label() static public method

static public _get_post_type_label ( string $post_type, string $label_type ) : string
$post_type string
$label_type string
return string

_get_post_type_labels() static public method

static public _get_post_type_labels ( string $post_type ) : array
$post_type string
return array

_init() static public method

Run on WordPress's 'init' hook to register all the post types defined in classes that extend this class.
static public _init ( )

_init_99() static public method

Clear out this data, we don't need them anymore But do it late so that a regular 'init' can still access them, i.e. for changing labels of 'post' post type.
static public _init_99 ( )

_set_post_type_args() static public method

Save $args for later passing to register_post_type().
static public _set_post_type_args ( string $post_type_slug, array $args )
$post_type_slug string
$args array

_set_post_type_labels() static public method

static public _set_post_type_labels ( string $post_type, array $args ) : array
$post_type string
$args array
return array

_wp_loaded() static public method

Add a property to post type objects so they can be self-identified.
static public _wp_loaded ( )

default_post_type_labels() static public method

static public default_post_type_labels ( ) : array
return array

get_list() static public method

static public get_list ( array | string | WPLib_Query $query = [], array $args = [] ) : WPLib_Post_List_Default
$query array | string | WPLib_Query
$args array
return WPLib_Post_List_Default

get_post() static public method

static public get_post ( WP_Post | object | integer | string | array | null | boolean $_post, string | boolean $post_type = false ) : null | WP_Post
$_post WP_Post | object | integer | string | array | null | boolean
$post_type string | boolean
return null | WP_Post

get_post_by() static public method

static public get_post_by ( string $by, integer | string $value, array $args = [] ) : WP_Post
$by string
$value integer | string
$args array
return WP_Post

get_post_type_class() static public method

static public get_post_type_class ( string $post_type ) : string | null
$post_type string
return string | null

get_post_types_supporting() static public method

Get a list of post types that support a specific named feature.
static public get_post_types_supporting ( string $feature ) : array
$feature string
return array

get_posts() static public method

Query the posts, return a post list.
static public get_posts ( WP_Query | array $args = [] ) : WP_Post[]
$args WP_Query | array
return WP_Post[]

get_queried_post_type() static public method

Return the post type of the queried object.
static public get_queried_post_type ( ) : false | null | string
return false | null | string

get_query() static public method

Query the posts. Equivalent to creating a new WP_Query which both instantiates and queries the DB.
See also: https://github.com/wplib/wplib/commit/8dc27c368e84f7ba6e1448753e1b1f082a60ac6d#commitcomment-11026403
static public get_query ( array $args = [] ) : WPLib_Query
$args array
return WPLib_Query

make_new_item() static public method

Create new Instance of a Post MVI
static public make_new_item ( WP_Post | integer $_post, array $args = [] ) : mixed
$_post WP_Post | integer
$args array { @type string $instance_class @type string $list_owner }
return mixed

max_posts_per_page() static public method

static public max_posts_per_page ( ) : integer
return integer

on_load() static public method

Run on WordPress's 'init' hook to register all the post types defined in classes that extend this class.
static public on_load ( )

pop_post() static public method

static public pop_post ( )

post_type_classes() static public method

static public post_type_classes ( ) : string[]
return string[]

push_post() static public method

static public push_post ( WP_Post | boolean $value = false )
$value WP_Post | boolean

set_max_posts_per_page() static public method

static public set_max_posts_per_page ( integer $value )
$value integer