attachment_submit_meta_box( WP_Post $post )
- Since
- 3.5.0
- Source
wp-admin/includes/meta-boxes.php:420
Compatibility
- WordPress
- since 3.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
$postWP_Post- Current post object.
Performance profile
How much work a call to attachment_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
- Heavy
- Scaling
- Constant
- Instructions
- 76–101
- Plugin surface
- 1 hook
- Called by
- 0
Reaches the database via get_post().
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 116.
Third-party callbacks on 'attachment_submitbox_misc_actions' 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 - querycontent query
get_post()one call below attachment_submit_meta_box()
Further down the call graph this can also reach option, 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 · 2 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost attachment_submit_meta_box() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!current_user_can() | 76 | __(), submit_button(), __(), _x(), strtotime(), date_i18n(), _x(), strtotime(), date_i18n(), sprintf(), __(), printf(), do_action(), current_user_can(), esc_attr_e(), esc_attr_e() |
current_user_can() | 94–101 | __(), submit_button(), __(), _x(), strtotime(), date_i18n(), _x(), strtotime(), date_i18n(), sprintf(), __(), printf(), do_action(), current_user_can(), get_delete_post_link(), __(), printf(), esc_attr_e(), esc_attr_e() |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 116 instructions, 76–101 executed per call, 4 branches. 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 · 1
One hook fires while attachment_submit_meta_box() runs, in this order:
- do_action( attachment_submitbox_misc_actions )actionline 460 (+40 into the body)
Fires after the 'Uploaded on' section of the Save meta box in the attachment editing screen.
Uses · 8
- submit_button()Echoes a submit button, with provided text and appropriate class(es).
- __()Retrieves the translation of $text.
- date_i18n()Retrieves the date in localized format, based on a sum of Unix timestamp and timezone offset in seconds.
- _x()Retrieves translated string with gettext context.
- 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.
- get_delete_post_link()Retrieves the delete posts link for post.
- esc_attr_e()Displays translated text that has been escaped for safe use in an attribute.
Source code
function attachment_submit_meta_box( $post ) { ?><div class="submitbox" id="submitpost"> <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' ); ?></div> <div id="misc-publishing-actions"> <div class="misc-pub-section curtime misc-pub-curtime"> <span id="timestamp"> <?php $uploaded_on = sprintf( /* translators: Publish box date string. 1: Date, 2: Time. */ __( '%1$s at %2$s' ), /* translators: Publish box date format, see https://www.php.net/manual/datetime.format.php */ date_i18n( _x( 'M j, Y', 'publish box date format' ), strtotime( $post->post_date ) ), /* translators: Publish box time format, see https://www.php.net/manual/datetime.format.php */ date_i18n( _x( 'H:i', 'publish box time format' ), strtotime( $post->post_date ) ) ); /* translators: Attachment information. %s: Date the attachment was uploaded. */ printf( __( 'Uploaded on: %s' ), '<b>' . $uploaded_on . '</b>' ); ?> </span> </div><!-- .misc-pub-section --> <?php /** * Fires after the 'Uploaded on' section of the Save meta box * in the attachment editing screen. * * @since 3.5.0 * @since 4.9.0 Added the `$post` parameter. * * @param WP_Post $post WP_Post object for the current attachment. */ do_action( 'attachment_submitbox_misc_actions', $post ); ?></div><!-- #misc-publishing-actions --><div class="clear"></div></div><!-- #minor-publishing --> <div id="major-publishing-actions"> <div id="delete-action"> <?php if ( current_user_can( 'delete_post', $post->ID ) ) { if ( EMPTY_TRASH_DAYS && MEDIA_TRASH ) { printf( '<a class="submitdelete deletion" href="%1$s">%2$s</a>', get_delete_post_link( $post->ID ), __( 'Move to Trash' ) ); } else { $show_confirmation = ! MEDIA_TRASH ? " onclick='return showNotice.warn();'" : ''; printf( '<a class="submitdelete deletion"%1$s href="%2$s">%3$s</a>', $show_confirmation, get_delete_post_link( $post->ID, '', true ), __( 'Delete permanently' ) ); } } ?> </div> <div id="publishing-action"> <span class="spinner"></span> <input name="original_publish" type="hidden" id="original_publish" value="<?php esc_attr_e( 'Update' ); ?>" /> <input name="save" type="submit" class="button button-primary button-large" id="publish" value="<?php esc_attr_e( 'Update' ); ?>" /> </div> <div class="clear"></div></div><!-- #major-publishing-actions --> </div> Changelog
Introduced in 3.5.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 6.8.8 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.