PHP Class WPCC\Component\Factory\Term

Since: 1.0.0
Inheritance: extends WPCC\Component\Factory
Mostra file Open project: 10up/wp-codeception

Protected Properties

Property Type Description
$_taxonomy string The taxonomy name.

Public Methods

Method Description
__construct ( string $taxonomy = null ) Constructor.
addPostTerms ( integer $post_id, array $terms, string $taxonomy, boolean $append = true ) : array Adds terms to a post.
getObjectById ( integer $term_id ) : mixed Returns generated term by id.

Protected Methods

Method Description
_createObject ( array $args ) : integer | WP_Error Generates a new term.
_deleteObject ( integer $term_id ) : boolean Deletes previously generated term.
_updateObject ( mixed $term, array $fields ) : mixed Updates generated term.

Method Details

__construct() public method

Constructor.
Since: 1.0.0
public __construct ( string $taxonomy = null )
$taxonomy string The taxonomy name.

_createObject() protected method

Generates a new term.
Since: 1.0.0
protected _createObject ( array $args ) : integer | WP_Error
$args array The array of arguments to use during a new term creation.
return integer | WP_Error The newly created term's ID on success, otherwise a WP_Error object.

_deleteObject() protected method

Deletes previously generated term.
Since: 1.0.0
protected _deleteObject ( integer $term_id ) : boolean
$term_id integer The term id to delete.
return boolean TRUE on success, otherwise FALSE.

_updateObject() protected method

Updates generated term.
Since: 1.0.0
protected _updateObject ( mixed $term, array $fields ) : mixed
$term mixed The term id to update.
$fields array The array of fields to update.
return mixed Updated term ID on success, otherwise a WP_Error object.

addPostTerms() public method

Adds terms to a post.
Since: 1.0.0
public addPostTerms ( integer $post_id, array $terms, string $taxonomy, boolean $append = true ) : array
$post_id integer The post id to add terms to.
$terms array The array of terms to add.
$taxonomy string The taxonomy name of terms.
$append boolean Determines whether to add or replace terms.
return array The array of affected term IDs.

getObjectById() public method

Returns generated term by id.
Since: 1.0.0
public getObjectById ( integer $term_id ) : mixed
$term_id integer The term id.
return mixed The generated term on success, otherwise NULL or a WP_Error object.

Property Details

$_taxonomy protected_oe property

The taxonomy name.
Since: 1.0.0
protected string $_taxonomy
return string