PHP Class Extended_CPT

Exibir arquivo Open project: johnbillion/extended-cpts Class Usage Examples

Public Properties

Property Type Description
$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 Properties

Property Type Description
$defaults array The arguments listed are the ones which differ from the defaults in register_post_type().

Public Methods

Method Description
__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.

Method Details

__construct() public method

Class constructor.
See also: 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() public method

Add our filter names to the public query vars.
public add_query_vars ( array $vars ) : array
$vars array Public query variables.
return array Updated public query variables.

add_taxonomy() public method

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.
return object | false Taxonomy object, or boolean false if there's a problem.

add_to_feed() public method

Add our post type to the feed.
public add_to_feed ( array $vars ) : array
$vars array Request parameters.
return array Updated request parameters.

extend() public method

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() public static method

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).
return array The list of private query vars to apply to the query.

get_sort_field_vars() public static method

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.
return array The list of private and public query vars to apply to the query.

get_sort_taxonomy_clauses() public static method

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).
return array The list of SQL clauses to apply to the query.

maybe_filter() public method

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() public method

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() public method

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.
return array The updated SQL clauses.

override_private_query_vars() public method

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.
return WP Updated WP request object.

post_type_link() public method

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.
return string The post's permalink.

register_post_type() public method

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() public method

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() public method

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.
return array Updated rewrite rule tests.

Property Details

$args public_oe property

public $args

$defaults protected_oe property

The arguments listed are the ones which differ from the defaults in register_post_type().
protected array $defaults
return array

$post_plural public_oe property

public $post_plural

$post_plural_low public_oe property

public $post_plural_low

$post_singular public_oe property

public $post_singular

$post_singular_low public_oe property

public $post_singular_low

$post_slug public_oe property

public $post_slug

$post_type public_oe property

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