PHP Класс Extended_CPT

Показать файл Открыть проект Примеры использования класса

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

Свойство Тип Описание
$args
$post_plural
$post_plural_low
$post_singular
$post_singular_low
$post_slug
$post_type Some other member variables you don't need to worry about:

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

Свойство Тип Описание
$defaults array The arguments listed are the ones which differ from the defaults in register_post_type().

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

Метод Описание
__construct ( string $post_type, array $args = [], array $names = [] ) Class constructor.
add_query_vars ( array $vars ) : array Add our filter names to the public query vars.
add_taxonomy ( string $taxonomy, array $args = [], array $names = [] ) : object | false Helper function for registering a taxonomy and adding it to this post type.
add_to_feed ( array $vars ) : array Add our post type to the feed.
extend ( stdClass | WP_Post_Type $pto ) Extends an existing post type object. Currently only handles labels.
get_filter_vars ( array $query, array $filters ) : array Get the array of private query vars for the given filters, to apply to the current query in order to filter it by the given public query vars.
get_sort_field_vars ( array $vars, array $sortables ) : array Get the array of private and public query vars for the given sortables, to apply to the current query in order to sort it by the requested orderby field.
get_sort_taxonomy_clauses ( array $clauses, array $vars, array $sortables ) : array Get the array of SQL clauses for the given sortables, to apply to the current query in order to sort it by the requested orderby field.
maybe_filter ( WP_Query $wp_query ) Set the relevant query vars for filtering posts by our front-end filters.
maybe_sort_by_fields ( WP_Query $wp_query ) Set the relevant query vars for sorting posts by our front-end sortables.
maybe_sort_by_taxonomy ( array $clauses, WP_Query $wp_query ) : array Filter the query's SQL clauses so we can sort posts by taxonomy terms.
override_private_query_vars ( WP $wp ) : WP Add to or override our post type archive's private query vars.
post_type_link ( string $post_link, WP_Post $post, boolean $leavename, boolean $sample ) : string Filter the post type permalink in order to populate its rewrite tags.
register_post_type ( ) Registers our post type.
registered_post_type ( string $post_type, stdClass | WP_Post_Type $args ) Action fired after a CPT is registered in order to set up the custom permalink structure for the post type.
rewrite_testing_tests ( array $tests ) : array Add our rewrite tests to the Rewrite Rule Testing tests array.

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

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

Class constructor.
См. также: register_extended_post_type()
public __construct ( string $post_type, array $args = [], array $names = [] )
$post_type string The post type name.
$args array Optional. The post type arguments.
$names array Optional. The plural, singular, and slug names.

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

Add our filter names to the public query vars.
public add_query_vars ( array $vars ) : array
$vars array Public query variables.
Результат array Updated public query variables.

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

Accepts the same parameters as register_extended_taxonomy(), minus the $object_type parameter. Will fall back to register_taxonomy() if Extended Taxonomies isn't present. Example usage: $events = register_extended_post_type( 'event' ); $location = $events->add_taxonomy( 'location' );
public add_taxonomy ( string $taxonomy, array $args = [], array $names = [] ) : object | false
$taxonomy string The taxonomy name.
$args array Optional. The taxonomy arguments.
$names array Optional. An associative array of the plural, singular, and slug names.
Результат object | false Taxonomy object, or boolean false if there's a problem.

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

Add our post type to the feed.
public add_to_feed ( array $vars ) : array
$vars array Request parameters.
Результат array Updated request parameters.

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

Extends an existing post type object. Currently only handles labels.
public extend ( stdClass | WP_Post_Type $pto )
$pto stdClass | WP_Post_Type A post type object

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

Get the array of private query vars for the given filters, to apply to the current query in order to filter it by the given public query vars.
public static get_filter_vars ( array $query, array $filters ) : array
$query array The public query vars, usually from `$wp_query->query`.
$filters array The filters valid for this query (usually the value of the `admin_filters` or `site_filters` argument when registering an extended post type).
Результат array The list of private query vars to apply to the query.

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

Get the array of private and public query vars for the given sortables, to apply to the current query in order to sort it by the requested orderby field.
public static get_sort_field_vars ( array $vars, array $sortables ) : array
$vars array The public query vars, usually from `$wp_query->query`.
$sortables array The sortables valid for this query (usually the value of the `admin_cols` or `site_sortables` argument when registering an extended post type.
Результат array The list of private and public query vars to apply to the query.

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

Get the array of SQL clauses for the given sortables, to apply to the current query in order to sort it by the requested orderby field.
public static get_sort_taxonomy_clauses ( array $clauses, array $vars, array $sortables ) : array
$clauses array The query's SQL clauses.
$vars array The public query vars, usually from `$wp_query->query`.
$sortables array The sortables valid for this query (usually the value of the `admin_cols` or `site_sortables` argument when registering an extended post type).
Результат array The list of SQL clauses to apply to the query.

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

Set the relevant query vars for filtering posts by our front-end filters.
public maybe_filter ( WP_Query $wp_query )
$wp_query WP_Query The current WP_Query object.

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

Set the relevant query vars for sorting posts by our front-end sortables.
public maybe_sort_by_fields ( WP_Query $wp_query )
$wp_query WP_Query The current WP_Query object.

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

Filter the query's SQL clauses so we can sort posts by taxonomy terms.
public maybe_sort_by_taxonomy ( array $clauses, WP_Query $wp_query ) : array
$clauses array The current query's SQL clauses.
$wp_query WP_Query The current `WP_Query` object.
Результат array The updated SQL clauses.

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

Add to or override our post type archive's private query vars.
public override_private_query_vars ( WP $wp ) : WP
$wp WP The WP request object.
Результат WP Updated WP request object.

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

Filter the post type permalink in order to populate its rewrite tags.
public post_type_link ( string $post_link, WP_Post $post, boolean $leavename, boolean $sample ) : string
$post_link string The post's permalink.
$post WP_Post The post in question.
$leavename boolean Whether to keep the post name.
$sample boolean Is it a sample permalink.
Результат string The post's permalink.

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

The only difference between this and regular register_post_type() calls is this will trigger an error of E_USER_ERROR level if a WP_Error is returned.
public register_post_type ( )

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

Action fired after a CPT is registered in order to set up the custom permalink structure for the post type.
public registered_post_type ( string $post_type, stdClass | WP_Post_Type $args )
$post_type string Post type name.
$args stdClass | WP_Post_Type Arguments used to register the post type.

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

Add our rewrite tests to the Rewrite Rule Testing tests array.
public rewrite_testing_tests ( array $tests ) : array
$tests array The existing rewrite rule tests.
Результат array Updated rewrite rule tests.

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

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

public $args

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

The arguments listed are the ones which differ from the defaults in register_post_type().
protected array $defaults
Результат array

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

public $post_plural

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

public $post_plural_low

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

public $post_singular

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

public $post_singular_low

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

public $post_slug

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

Some other member variables you don't need to worry about:
public $post_type