wppaste
WordPress

wp_xmlrpc_server::set_is_enabled()

Since
5.7.3
Source
wp-includes/class-wp-xmlrpc-server.php:189
Sets wp_xmlrpc_server::$is_enabled property.

Description

Determines whether the xmlrpc server is enabled on this WordPress install and set the is_enabled property accordingly.

Compatibility

WordPress
since 5.7.3
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.

Performance profile

How much work a call to wp_xmlrpc_server::set_is_enabled() 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

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
14–19

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

Plugin surface
3 hooks

Third-party callbacks on 'pre_option_enable_xmlrpc', 'option_enable_xmlrpc', 'xmlrpc_enabled' 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 callbacksapply_filters()called directly

What one call costs · 2 distinct outcomes

One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_xmlrpc_server::set_is_enabled() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
$is_enabled !== false14apply_filters(), apply_filters()
$is_enabled === false19apply_filters(), apply_filters(), apply_filters()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 19 instructions, 14–19 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.

Hooks and filters fired · 3

3 hooks fire while wp_xmlrpc_server::set_is_enabled() runs, in this order:

  1. apply_filters( pre_option_enable_xmlrpc )filterline 194 (+5 into the body)
  2. apply_filters( option_enable_xmlrpc )filterline 196 (+7 into the body)
  3. apply_filters( xmlrpc_enabled )filterline 221 (+32 into the body)

    Filters whether XML-RPC methods requiring authentication are enabled.

Uses · 1

  • apply_filters()Calls the callback functions that have been added to a filter hook.

Used by · 1

Source code

	private function set_is_enabled() {		/*		 * Respect old get_option() filters left for back-compat when the 'enable_xmlrpc'		 * option was deprecated in 3.5.0. Use the {@see 'xmlrpc_enabled'} hook instead.		 */		$is_enabled = apply_filters( 'pre_option_enable_xmlrpc', false );		if ( false === $is_enabled ) {			$is_enabled = apply_filters( 'option_enable_xmlrpc', true );		} 		/**		 * Filters whether XML-RPC methods requiring authentication are enabled.		 *		 * Contrary to the way it's named, this filter does not control whether XML-RPC is *fully*		 * enabled, rather, it only controls whether XML-RPC methods requiring authentication -		 * such as for publishing purposes - are enabled.		 *		 * Further, the filter does not control whether pingbacks or other custom endpoints that don't		 * require authentication are enabled. This behavior is expected, and due to how parity was matched		 * with the `enable_xmlrpc` UI option the filter replaced when it was introduced in 3.5.		 *		 * To disable XML-RPC methods that require authentication, use:		 *		 *     add_filter( 'xmlrpc_enabled', '__return_false' );		 *		 * For more granular control over all XML-RPC methods and requests, see the {@see 'xmlrpc_methods'}		 * and {@see 'xmlrpc_element_limit'} hooks.		 *		 * @since 3.5.0		 *		 * @param bool $is_enabled Whether XML-RPC is enabled. Default true.		 */		$this->is_enabled = apply_filters( 'xmlrpc_enabled', $is_enabled );	}

Changelog

Introduced in 5.7.3. 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.8.8 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.