get_post_stati( array|string $args = array(), string $output = 'names', string $operator = 'and' ): string[]|stdClass[]
- Since
- 3.0.0
- Source
wp-includes/post.php:1515
Compatibility
- WordPress
- since 3.0.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$argsarray|stringoptional- Array or string of post status arguments to compare against properties of the global
$wp_post_statuses objects. Default empty array.Default:array() $outputstringoptional- The type of output to return, either 'names' or 'objects'. Default 'names'.Default:
'names' $operatorstringoptional- The logical operation to perform. 'or' means only one element from the array needs to match; 'and' means all elements must match.
Default 'and'.Default:'and'
Return value
string[]|stdClass[]- A list of post status names or objects.
Performance profile
How much work a call to get_post_stati() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 15–16
- Plugin surface
- None
- Called by
- 21
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 17.
Nothing here hands control to plugin code.
21 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost get_post_stati() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 15–16 | wp_filter_object_list() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 17 instructions, 15–16 executed per call, 1 branch. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Uses · 1
- wp_filter_object_list()Filters a list of objects, based on a set of key => value arguments.
Used by · 21
- WP_Customize_Manager::establish_loaded_changeset()Establishes the loaded changeset.
- WP_Customize_Manager::find_changeset_post_id()Finds the changeset post ID for a given changeset UUID.
- WP_Customize_Manager::import_theme_starter_content()Imports theme starter content into the customized state.
- WP_Posts_List_Table::__construct()Constructor.
- WP_Posts_List_Table::get_views()
- WP_Posts_List_Table::prepare_items()
- WP_Privacy_Requests_Table::get_request_counts()Counts the number of requests for each status.
- WP_Query::get_posts()Retrieves an array of posts based on query variables.
- WP_REST_Menu_Items_Controller::get_item_schema()Retrieves the nav menu item's schema, conforming to JSON Schema.
- WP_REST_Post_Statuses_Controller::get_items()Retrieves all post statuses, depending on user context.
- WP_REST_Posts_Controller::get_collection_params()Retrieves the query params for the posts collection.
- WP_REST_Posts_Controller::get_item_schema()Retrieves the post's schema, conforming to JSON Schema.
Show all 21
- WP_REST_Templates_Controller::get_item_schema()Retrieves the block type' schema, conforming to JSON Schema.
- get_adjacent_post()Retrieves the adjacent post.
- get_pages()Retrieves an array of pages (or hierarchical post type items).
- redirect_guess_404_permalink()Attempts to guess the correct URL for a 404 request based on query vars.
- register_and_do_post_meta_boxes()Registers the default post meta boxes, and runs the `do_meta_boxes` actions.
- wp_count_posts()Counts number of posts of a post type and if user has permissions to view.
- wp_edit_posts_query()Runs the query to fetch the posts for listing on the edit posts page.
- wp_get_custom_css_post()Fetches the `custom_css` post for a given theme.
- wp_insert_post()Inserts or update a post.
Source code
function get_post_stati( $args = array(), $output = 'names', $operator = 'and' ) { global $wp_post_statuses; $field = ( 'names' === $output ) ? 'name' : false; return wp_filter_object_list( $wp_post_statuses, $args, $operator, $field );}Changelog
Introduced in 3.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.7.7 tag, from
src/wp-includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.