wp_xmlrpc_server::mw_newPost( array $args ): int|IXR_Error
- Since
- 1.5.0
- Source
wp-includes/class-wp-xmlrpc-server.php:5372
Description
The 'content_struct' argument must contain:
- title
- description
- mt_excerpt
- mt_text_more
- mt_keywords
- mt_tb_ping_urls
- categories
Also, it can optionally contain:
- wp_slug
- wp_password
- wp_page_parent_id
- wp_page_order
- wp_author_id
- post_status | page_status - can be 'draft', 'private', 'publish', or 'pending'
- mt_allow_comments - can be 'open' or 'closed'
- mt_allow_pings - can be 'open' or 'closed'
- date_created_gmt
- dateCreated
- wp_post_thumbnail
Compatibility
- WordPress
- since 1.5.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- Method arguments. Note: arguments must be ordered as documented.
$0intBlog ID (unused).$1stringUsername.$2stringPassword.$3arrayContent structure.$4intdefault: 0Optional. Publish flag. 0 for draft, 1 for publish.
Return value
int|IXR_Error
Performance profile
How much work a call to wp_xmlrpc_server::mw_newPost() 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
- Heavy
- Scaling
- Constant
- Instructions
- 168–231
- Plugin surface
- 2 hooks
- Called by
- 1
Reaches the database via get_user_by().
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 564.
Third-party callbacks on 'xmlrpc_call', 'xmlrpc_call_success_mw_newPost' run inside this call, and their cost is not bounded by anything here.
1 place in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
do_action()called directly - querycontent query
get_user_by()one call below wp_xmlrpc_server::mw_newPost() - optionoption read or write
get_option()one call below wp_xmlrpc_server::mw_newPost()
Further down the call graph this can also reach cache, serialize and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 53 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_xmlrpc_server::mw_newPost() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" | 168–174 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) | 176–184 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), set_post_thumbnail(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) | 182–190 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), set_post_thumbnail(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" | 187–193 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), set_post_thumbnail(), __() |
!isset($args) && empty($content_struct) && !isset($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 190–199 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && !isset($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 191–200 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && !isset($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 192–201 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" | 193–199 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), set_post_thumbnail(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 196–205 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 196–205 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 197–206 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 197–206 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
41 further outcomes, up to 231 instructions
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 198–207 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 198–207 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 199–208 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 200–209 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 201–210 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 201–208 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 202–209 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 202–211 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 203–210 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 203–212 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 204–213 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 205–214 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 205–214 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 206–215 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 206–215 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 207–216 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 207–216 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 207–214 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 207–214 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 208–215 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 208–215 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 209–216 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 209–216 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 210–217 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 211–218 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && is_wp_error() | 211–220 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 212–219 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 212–221 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && !is_wp_error() | 213–222 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 213–220 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 214–221 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 215–222 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 216–223 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 216–223 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 217–224 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 217–224 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 218–225 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 218–225 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), wp_insert_post(), is_wp_error(), __() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && is_wp_error() | 222–229 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), ->get_error_message() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 223–230 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), do_action() |
!isset($args) && empty($content_struct) && current_user_can() && empty($date_created) && $post_type === "post" && !is_wp_error() | 224–231 | ->escape(), ->login(), do_action(), __(), get_post_type_object(), current_user_can(), current_user_can(), get_default_comment_status(), get_default_comment_status(), compact(), get_default_post_to_edit(), ->_toggle_sticky(), ->set_custom_fields(), set_post_thumbnail(), ->add_enclosure_if_new(), ->attach_uploads(), set_post_format(), wp_insert_post(), is_wp_error(), __() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 564 | 168–231 | 78 | |
| 8.5 | 564 | 168–231 | 78 | |
| 8.4 | 564 | 168–231 | 78 | 5 fewer instructions than PHP 8.3 |
| 8.3 | 569 | 168–231 | 78 | |
| 8.2 | 569 | 168–231 | 78 | 5 more instructions than PHP 8.1 |
| 8.1 | 564 | 168–231 | 78 | 9 fewer instructions than PHP 7.4 |
| 7.4 | 573 | 169–233 | 78 |
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.
Hooks and filters fired · 2
2 hooks fire while wp_xmlrpc_server::mw_newPost() runs, in this order:
- do_action( xmlrpc_call )actionline 5386 (+14 into the body)
Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.
- do_action( xmlrpc_call_success_mw_newPost )actionline 5694 (+322 into the body)
Fires after a new post has been successfully created via the XML-RPC MovableType API.
Uses · 22
- do_action()Calls the callback functions that have been added to an action hook.
- __()Retrieves the translation of $text.
- current_user_can()Returns whether the current user has the specified capability.
- get_post_type_object()Retrieves a post type object by name.
- sanitize_key()Sanitizes a string key.
- get_post_format_strings()Returns an array of post format slugs to their translated and pretty display versions
- get_userdata()Retrieves user info by user ID.
- get_default_comment_status()Gets the default comment status for a post type.
- iso8601_to_datetime()Given an ISO 8601 (Ymd\TH:i:sO) date, returns a MySQL DateTime (Y-m-d H:i:s) format used by post_date[_gmt].
- get_cat_ID()Retrieves the ID of a category from its name.
- get_default_post_to_edit()Returns default post information to use when populating the "Write Post" form.
- set_post_thumbnail()Sets the post thumbnail (featured image) for the given post.
Show all 22
- set_post_format()Assign a format to a post
- wp_insert_post()Inserts or update a post.
- is_wp_error()Checks whether the given variable is a WordPress Error.
- wp_xmlrpc_server::escape()Escapes string or array of strings for database.
- wp_xmlrpc_server::login()Logs user in.
- IXR_Error::__construct()PHP5 constructor.
- wp_xmlrpc_server::_toggle_sticky()Encapsulates the logic for sticking a post and determining if the user has permission to do so.
- wp_xmlrpc_server::set_custom_fields()Sets custom fields for post.
- wp_xmlrpc_server::add_enclosure_if_new()Adds an enclosure to a post if it's new.
- wp_xmlrpc_server::attach_uploads()Attaches an upload to a post.
Used by · 1
- wp_xmlrpc_server::wp_newPage()Creates a new page.
Source code
public function mw_newPost( $args ) { $this->escape( $args ); $username = $args[1]; $password = $args[2]; $content_struct = $args[3]; $publish = isset( $args[4] ) ? $args[4] : 0; $user = $this->login( $username, $password ); if ( ! $user ) { return $this->error; } /** This action is documented in wp-includes/class-wp-xmlrpc-server.php */ do_action( 'xmlrpc_call', 'metaWeblog.newPost', $args, $this ); $page_template = ''; if ( ! empty( $content_struct['post_type'] ) ) { if ( 'page' === $content_struct['post_type'] ) { if ( $publish ) { $cap = 'publish_pages'; } elseif ( isset( $content_struct['page_status'] ) && 'publish' === $content_struct['page_status'] ) { $cap = 'publish_pages'; } else { $cap = 'edit_pages'; } $error_message = __( 'Sorry, you are not allowed to publish pages on this site.' ); $post_type = 'page'; if ( ! empty( $content_struct['wp_page_template'] ) ) { $page_template = $content_struct['wp_page_template']; } } elseif ( 'post' === $content_struct['post_type'] ) { if ( $publish ) { $cap = 'publish_posts'; } elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) { $cap = 'publish_posts'; } else { $cap = 'edit_posts'; } $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); $post_type = 'post'; } else { // No other 'post_type' values are allowed here. return new IXR_Error( 401, __( 'Invalid post type.' ) ); } } else { if ( $publish ) { $cap = 'publish_posts'; } elseif ( isset( $content_struct['post_status'] ) && 'publish' === $content_struct['post_status'] ) { $cap = 'publish_posts'; } else { $cap = 'edit_posts'; } $error_message = __( 'Sorry, you are not allowed to publish posts on this site.' ); $post_type = 'post'; } if ( ! current_user_can( get_post_type_object( $post_type )->cap->create_posts ) ) { return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish posts on this site.' ) ); } if ( ! current_user_can( $cap ) ) { return new IXR_Error( 401, $error_message ); } // Check for a valid post format if one was given. if ( isset( $content_struct['wp_post_format'] ) ) { $content_struct['wp_post_format'] = sanitize_key( $content_struct['wp_post_format'] ); if ( ! array_key_exists( $content_struct['wp_post_format'], get_post_format_strings() ) ) { return new IXR_Error( 404, __( 'Invalid post format.' ) ); } } // Let WordPress generate the 'post_name' (slug) unless // one has been provided. $post_name = null; if ( isset( $content_struct['wp_slug'] ) ) { $post_name = $content_struct['wp_slug']; } // Only use a password if one was given.Changelog
Introduced in 1.5.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.9.7 tag, from
src/wp-includes/class-wp-xmlrpc-server.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.