link_submit_meta_box( object $link )
- Since
- 2.7.0
- Source
wp-admin/includes/meta-boxes.php:1100
Compatibility
- WordPress
- since 2.7.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
$linkobject- Current link object.
Performance profile
How much work a call to link_submit_meta_box() 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
- Scaling
- Constant
- Instructions
- 48–93
- Plugin surface
- 2 hooks
- Called by
- 0
Touches nothing outside its own arguments.
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 98.
Third-party callbacks on 'post_submitbox_start', 'submitlink_box' run inside this call, and their cost is not bounded by anything here.
Nothing in core calls this; the cost is only what you spend yourself.
What it touches
- hookthird-party callbacks
do_action()called directly
Further down the call graph this can also reach option, query, 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 · 6 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost link_submit_meta_box() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($link) | 48–53 | __(), submit_button(), checked(), _e(), do_action(), esc_attr_e(), do_action() |
empty($link) && !empty($value) && !current_user_can() | 56–57 | __(), submit_button(), checked(), _e(), do_action(), current_user_can(), esc_attr_e(), do_action() |
!empty($link) | 56–61 | __(), submit_button(), _e(), checked(), _e(), do_action(), esc_attr_e(), do_action() |
!empty($link) && !empty($value) && !current_user_can() | 64–65 | __(), submit_button(), _e(), checked(), _e(), do_action(), current_user_can(), esc_attr_e(), do_action() |
empty($link) && !empty($value) && current_user_can() | 84–85 | __(), submit_button(), checked(), _e(), do_action(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_js(), __(), printf(), esc_attr_e(), do_action() |
!empty($link) && !empty($value) && current_user_can() | 92–93 | __(), submit_button(), _e(), checked(), _e(), do_action(), current_user_can(), wp_nonce_url(), __(), sprintf(), esc_js(), __(), printf(), esc_attr_e(), do_action() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 100 | 48–95 | 5 | 2 more instructions than PHP 8.5 |
| 8.5 | 98 | 48–93 | 5 | |
| 8.4 | 98 | 48–93 | 5 | |
| 8.3 | 98 | 48–93 | 5 | |
| 8.2 | 98 | 48–93 | 5 | |
| 8.1 | 98 | 48–93 | 5 | |
| 7.4 | 98 | 48–93 | 5 |
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 link_submit_meta_box() runs, in this order:
- do_action( post_submitbox_start )actionline 1131 (+31 into the body)
Fires at the beginning of the publishing actions section of the Publish meta box.
- do_action( submitlink_box )actionline 1162 (+62 into the body)
Fires at the end of the Publish box in the Link editing screen.
Uses · 9
- submit_button()Echoes a submit button, with provided text and appropriate class(es).
- __()Retrieves the translation of $text.
- _e()Displays translated text.
- checked()Outputs the HTML checked attribute.
- do_action()Calls the callback functions that have been added to an action hook.
- current_user_can()Returns whether the current user has the specified capability.
- wp_nonce_url()Retrieves URL with nonce added to URL query.
- esc_js()Escapes single quotes, `"`, ``, `&`, and fixes line endings.
- esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
Source code
function link_submit_meta_box( $link ) { ?><div class="submitbox" id="submitlink"> <div id="minor-publishing"> <?php // Hidden submit button early on so that the browser chooses the right button when form is submitted with Return key. ?><div style="display:none;"> <?php submit_button( __( 'Save' ), '', 'save', false ); ?></div> <div id="minor-publishing-actions"><div id="preview-action"> <?php if ( ! empty( $link->link_id ) ) { ?> <a class="preview button" href="<?php echo $link->link_url; ?>" target="_blank"><?php _e( 'Visit Link' ); ?></a><?php } ?></div><div class="clear"></div></div> <div id="misc-publishing-actions"><div class="misc-pub-section misc-pub-private"> <label for="link_private" class="selectit"><input id="link_private" name="link_visible" type="checkbox" value="N" <?php checked( $link->link_visible, 'N' ); ?> /> <?php _e( 'Keep this link private' ); ?></label></div></div> </div> <div id="major-publishing-actions"> <?php /** This action is documented in wp-admin/includes/meta-boxes.php */ do_action( 'post_submitbox_start', null ); ?><div id="delete-action"> <?php if ( ! empty( $_GET['action'] ) && 'edit' === $_GET['action'] && current_user_can( 'manage_links' ) ) { printf( '<a class="submitdelete deletion" href="%s" onclick="return confirm( \'%s\' );">%s</a>', wp_nonce_url( "link.php?action=delete&link_id=$link->link_id", 'delete-bookmark_' . $link->link_id ), /* translators: %s: Link name. */ esc_js( sprintf( __( "You are about to delete this link '%s'\n 'Cancel' to stop, 'OK' to delete." ), $link->link_name ) ), __( 'Delete' ) ); } ?></div> <div id="publishing-action"> <?php if ( ! empty( $link->link_id ) ) { ?> <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update Link' ); ?>" /><?php } else { ?> <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Add Link' ); ?>" /><?php } ?></div><div class="clear"></div></div> <?php /** * Fires at the end of the Publish box in the Link editing screen. * * @since 2.5.0 */ do_action( 'submitlink_box' ); ?><div class="clear"></div></div> <?php}Changelog
Introduced in 2.7.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 7.1.0 tag, from
src/wp-admin/includes/meta-boxes.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.