wppaste
WordPress

wp_xmlrpc_server::mw_newPost( array $args ): int|IXR_Error

Since
1.5.0
Source
wp-includes/class-wp-xmlrpc-server.php:5352
Creates a new post.

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.
  • $0int

    Blog ID (unused).
  • $1string

    Username.
  • $2string

    Password.
  • $3array

    Content structure.
  • $4intdefault: 0

    Optional. 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

Reaches the database via get_user_by().

Scaling
Constant

No loop in the body: the same number of instructions runs whatever you pass in.

Instructions
168–231

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 563.

Plugin surface
2 hooks

Third-party callbacks on 'xmlrpc_call', 'xmlrpc_call_success_mw_newPost' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksdo_action()called directly
  • querycontent queryget_user_by()one call below wp_xmlrpc_server::mw_newPost()
  • optionoption read or writeget_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.

WhenInstructionsCalls it makes
!isset($args) && empty($content_struct) && current_user_can() && empty($dateCreated) && $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($dateCreated)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($dateCreated)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($dateCreated) && $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($dateCreated) && 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($dateCreated) && !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($dateCreated) && !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($dateCreated) && $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($dateCreated) && 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($dateCreated) && 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($dateCreated) && !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($dateCreated) && !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($dateCreated) && !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($dateCreated) && !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($dateCreated) && 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($dateCreated) && !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($dateCreated) && !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($dateCreated) && $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($dateCreated) && $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($dateCreated) && 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($dateCreated) && $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($dateCreated) && !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($dateCreated) && !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($dateCreated) && 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($dateCreated) && 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($dateCreated) && !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($dateCreated) && !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($dateCreated) && !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($dateCreated) && !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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && 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($dateCreated) && $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($dateCreated) && !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($dateCreated) && !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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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($dateCreated) && $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

PHPCompiledExecutedBranchesNotes
8.6-dev563168–23178
8.5563168–23178
8.4563168–231785 fewer instructions than PHP 8.3
8.3568168–23178
8.2568168–231785 more instructions than PHP 8.1
8.1563168–231789 fewer instructions than PHP 7.4
7.4572169–23378

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:

  1. do_action( xmlrpc_call )actionline 5366 (+14 into the body)

    Fires after the XML-RPC user has been authenticated but before the rest of the method logic begins.

  2. do_action( xmlrpc_call_success_mw_newPost )actionline 5655 (+303 into the body)

    Fires after a new post has been successfully created via the XML-RPC MovableType API.

Uses · 22

Show all 22

Used by · 1

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 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/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.