Tribe__Tickets__Status__Manager::get_statuses_by_action( $action, $commerce, $operator = 'AND', $nicename = false )
Return an array of Statuses for an action with the provider Commerce
Contents
Parameters
- $action
-
(Required) string a string of the action to filter
- $commerce
-
(Required) string a string of the Commerce System to get statuses from
- $operator
-
(Optional) string a string of the default 'AND', 'OR', 'NOT' to change the criteria
Default value: 'AND'
- $nicename
-
(Optional) bool a boolean of whether to return the name of the status
Default value: false
Return
(array) an array of the commerce's statuses matching the provide action
Source
File: src/Tribe/Status/Manager.php
public function get_statuses_by_action( $action, $commerce, $operator = 'AND', $nicename = false ) {
$trigger_statuses = [];
$commerce = $this->check_for_full_provider_name( $commerce );
if ( ! isset( $this->statuses[ $commerce ]->statuses ) ) {
return $trigger_statuses;
}
if ( 'all' === $action ) {
$filtered_statuses = $this->statuses[ $commerce ]->statuses;
} elseif ( is_array( $action ) ) {
$criteria = [];
foreach ( $action as $name ) {
$criteria[ $name ] = true;
}
$filtered_statuses = wp_list_filter( $this->statuses[ $commerce ]->statuses, $criteria, $operator );
} else {
$filtered_statuses = wp_list_filter( $this->statuses[ $commerce ]->statuses, [
$action => true,
] );
}
foreach ( $filtered_statuses as $status ) {
// if nicename is true then only return that name for a given status
if ( $nicename ) {
$trigger_statuses[] = $status->name;
continue;
}
$trigger_statuses[] = $status->provider_name;
if ( ! empty( $status->additional_names ) ) {
$trigger_statuses = $this->add_additional_names_to_array( $trigger_statuses, $status->additional_names );
}
}
return $trigger_statuses;
}
Changelog
| Version | Description |
|---|---|
| 4.10.5 | - add nicename parameter |
| 4.10 | Introduced. |