wppaste
WordPress

wp_load_press_this()

Source
wp-admin/press-this.php:14

Compatibility

WordPress
core
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_load_press_this() 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

Reads or writes the filesystem via file_exists().

Scaling
Constant

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

Instructions
18–82

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

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What it touches

  • filesystemfilesystem accessfile_exists()called directly
  • hookthird-party callbacksapply_filters()one call below wp_load_press_this()
  • optionoption read or writeget_option()one call below wp_load_press_this()

Further down the call graph this can also reach cache, serialize, query 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 · 7 distinct outcomes

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

WhenInstructionsCalls it makes
!current_user_can()18current_user_can(), __(), __(), wp_die()
always28current_user_can(), get_post_type_object(), current_user_can(), __(), __(), wp_die()
current_user_can() && is_plugin_active()29current_user_can(), get_post_type_object(), current_user_can(), is_plugin_active(), ->html()
!is_plugin_active()36current_user_can(), get_post_type_object(), current_user_can(), is_plugin_active(), current_user_can(), __(), __(), wp_die()
current_user_can() && !is_plugin_active() && !file_exists() && !is_main_site()62current_user_can(), get_post_type_object(), current_user_can(), is_plugin_active(), current_user_can(), file_exists(), is_main_site(), __(), get_current_network_id(), get_admin_url(), sprintf(), __(), __(), wp_die()
current_user_can() && !is_plugin_active() && file_exists()74current_user_can(), get_post_type_object(), current_user_can(), is_plugin_active(), current_user_can(), file_exists(), admin_url(), activate(), add_query_arg(), esc_url(), __(), sprintf(), __(), __(), wp_die()
current_user_can() && !is_plugin_active() && !file_exists() && is_main_site()82current_user_can(), get_post_type_object(), current_user_can(), is_plugin_active(), current_user_can(), file_exists(), is_main_site(), self_admin_url(), install-plugin(), add_query_arg(), esc_url(), esc_attr(), _x(), sprintf(), __(), __(), wp_die()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev15818–826
8.515818–826
8.415818–826
8.315818–826
8.215818–826
8.115818–8261 fewer instruction than PHP 7.4
7.415918–836

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 · 16

Show all 16

Source code

function wp_load_press_this() {	$plugin_slug = 'press-this';	$plugin_file = 'press-this/press-this-plugin.php'; 	if ( ! current_user_can( 'edit_posts' ) || ! current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) {		wp_die(			__( 'Sorry, you are not allowed to create posts as this user.' ),			__( 'You need a higher level of permission.' ),			403		);	} elseif ( is_plugin_active( $plugin_file ) ) {		include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php'; // @phpstan-ignore include.fileNotFound		$wp_press_this = new WP_Press_This_Plugin(); // @phpstan-ignore class.notFound		$wp_press_this->html();	} elseif ( current_user_can( 'activate_plugins' ) ) {		if ( file_exists( WP_PLUGIN_DIR . '/' . $plugin_file ) ) {			$url    = wp_nonce_url(				add_query_arg(					array(						'action' => 'activate',						'plugin' => $plugin_file,						'from'   => 'press-this',					),					admin_url( 'plugins.php' )				),				'activate-plugin_' . $plugin_file			);			$action = sprintf(				'<a href="%1$s" aria-label="%2$s">%2$s</a>',				esc_url( $url ),				__( 'Activate Press This' )			);		} else {			if ( is_main_site() ) {				$url    = wp_nonce_url(					add_query_arg(						array(							'action' => 'install-plugin',							'plugin' => $plugin_slug,							'from'   => 'press-this',						),						self_admin_url( 'update.php' )					),					'install-plugin_' . $plugin_slug				);				$action = sprintf(					'<a href="%1$s" class="install-now" data-slug="%2$s" data-name="%2$s" aria-label="%3$s">%3$s</a>',					esc_url( $url ),					esc_attr( $plugin_slug ),					_x( 'Install Now', 'plugin' )				);			} else {				$action = sprintf(					/* translators: %s: URL to Press This bookmarklet on the main site. */					__( 'Press This is not installed. Please install Press This from <a href="%s">the main site</a>.' ),					get_admin_url( get_current_network_id(), 'press-this.php' )				);			}		}		wp_die(			__( 'The Press This plugin is required.' ) . '<br />' . $action,			__( 'Installation Required' ),			200		);	} else {		wp_die(			__( 'Press This is not available. Please contact your site administrator.' ),			__( 'Installation Required' ),			200		);	}}

Changelog

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 7.1.0 tag, from src/wp-admin/press-this.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.