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
- Scaling
- Constant
- Instructions
- 18–82
- Plugin surface
- None
- Called by
- 0
Reads or writes the filesystem via file_exists().
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 158.
Nothing here hands control to plugin code.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- filesystemfilesystem access
file_exists()called directly - hookthird-party callbacks
apply_filters()one call below wp_load_press_this() - optionoption read or write
get_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.
| When | Instructions | Calls it makes |
|---|---|---|
!current_user_can() | 18 | current_user_can(), __(), __(), wp_die() |
| always | 28 | current_user_can(), get_post_type_object(), current_user_can(), __(), __(), wp_die() |
current_user_can() && is_plugin_active() | 29 | current_user_can(), get_post_type_object(), current_user_can(), is_plugin_active(), ->html() |
!is_plugin_active() | 36 | current_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() | 62 | current_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() | 74 | current_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() | 82 | current_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
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 158 | 18–82 | 6 | |
| 8.5 | 158 | 18–82 | 6 | |
| 8.4 | 158 | 18–82 | 6 | |
| 8.3 | 158 | 18–82 | 6 | |
| 8.2 | 158 | 18–82 | 6 | |
| 8.1 | 158 | 18–82 | 6 | 1 fewer instruction than PHP 7.4 |
| 7.4 | 159 | 18–83 | 6 |
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
- current_user_can()Returns whether the current user has the specified capability.
- get_post_type_object()Retrieves a post type object by name.
- wp_die()Kills WordPress execution and displays HTML page with an error message.
- __()Retrieves the translation of $text.
- is_plugin_active()Determines whether a plugin is active.
- wp_nonce_url()Retrieves URL with nonce added to URL query.
- add_query_arg()Retrieves a modified URL query string.
- admin_url()Retrieves the URL to the admin area for the current site.
- esc_url()Checks and cleans a URL.
- is_main_site()Determines whether a site is the main site of the current network.
- self_admin_url()Retrieves the URL to the admin area for either the current site or the network depending on context.
- esc_attr()Escaping for HTML attributes.
Show all 16
- _x()Retrieves translated string with gettext context.
- get_admin_url()Retrieves the URL to the admin area for a given site.
- get_current_network_id()Retrieves the current network ID.
- WP_Press_This_Plugin::__construct()
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.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 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.