Twenty_Fourteen_Ephemera_Widget::widget( array $args, array $instance )
- Since
- Twenty Fourteen 1.0
- Source
wp-content/themes/twentyfourteen/inc/widgets.php:75
Compatibility
- WordPress
- since Twenty Fourteen 1.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
$argsarray- An array of standard parameters for widgets in this theme.
$instancearray- An array of settings for this widget instance.
Performance profile
How much work a call to Twenty_Fourteen_Ephemera_Widget::widget() 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
- Scales with input
- Instructions
- 61–122
- Plugin surface
- 1 hook
- Called by
- 0
Reaches the database via get_posts().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 406.
Third-party callbacks on 'widget_title' 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
apply_filters()called directly - optionoption read or write
get_option()called directly - querycontent query
get_posts()called directly - cacheobject cache
wp_cache_get()one call below Twenty_Fourteen_Ephemera_Widget::widget() - serializeserialisation
maybe_unserialize()one call below Twenty_Fourteen_Ephemera_Widget::widget()
Further down the call graph this can also reach transient. That is the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 4 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost Twenty_Fourteen_Ephemera_Widget::widget() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
!isset($instance) && empty($instance) && !->have_posts() | 61–62 | __(), __(), apply_filters(), get_option(), ->have_posts() |
!isset($instance) && !empty($instance) && !->have_posts() | 67–68 | __(), __(), absint(), apply_filters(), get_option(), ->have_posts() |
!isset($instance) && empty($instance) | 115–116 | __(), __(), apply_filters(), get_option(), ->have_posts(), esc_attr(), get_post_format_link(), esc_url(), esc_html(), ->have_posts(), get_post_format_link(), esc_url(), __(), printf(), wp_reset_postdata() |
!isset($instance) && !empty($instance) | 121–122 | __(), __(), absint(), apply_filters(), get_option(), ->have_posts(), esc_attr(), get_post_format_link(), esc_url(), esc_html(), ->have_posts(), get_post_format_link(), esc_url(), __(), printf(), wp_reset_postdata() |
This body has more branch combinations than are worth enumerating, so the table covers the outcomes found first rather than every one that exists.
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 405 | 61–121 | 25 | 1 fewer instruction than PHP 8.5 |
| 8.5 | 406 | 61–122 | 25 | |
| 8.4 | 406 | 61–122 | 25 | 3 fewer instructions than PHP 8.3 |
| 8.3 | 409 | 61–122 | 25 | |
| 8.2 | 409 | 61–122 | 25 | |
| 8.1 | 409 | 61–122 | 25 | 8 fewer instructions than PHP 7.4 |
| 7.4 | 417 | 61–127 | 25 |
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 Twenty_Fourteen_Ephemera_Widget::widget() runs, in this order:
Uses · 33
- __()Retrieves the translation of $text.
- absint()Converts a value to non-negative integer.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- get_option()Retrieves an option value based on an option name.
- esc_attr()Escaping for HTML attributes.
- esc_url()Checks and cleans a URL.
- get_post_format_link()Returns a link to a post format index.
- esc_html()Escaping for HTML blocks.
- post_class()Displays the classes for the post container element.
- has_post_format()Check if a post has any of the given formats, or any format.
- post_password_required()Determines whether the post requires password and whether a correct password has been provided.
- the_content()Displays the post content.
Show all 33
- get_post_galleries()Retrieves galleries from the passed post's content.
- get_the_ID()Retrieves the ID of the current item in the WordPress Loop.
- get_posts()Retrieves an array of the latest posts, or posts matching the given criteria.
- has_post_thumbnail()Determines whether a post has an image attached.
- get_the_post_thumbnail()Retrieves the post thumbnail.
- wp_get_attachment_image()Gets an HTML img element representing an image attachment.
- the_permalink()Displays the permalink for the current post.
- _n()Translates and retrieves the singular or plural form based on the supplied number.
- get_permalink()Retrieves the full permalink for the current post or post ID.
- number_format_i18n()Converts float number to format based on the locale.
- the_title()Displays or retrieves the current post title with optional markup.
- get_the_date()Retrieves the date of the post.
- get_author_posts_url()Retrieves the URL to the author page for the user with the ID provided.
- get_the_author_meta()Retrieves the requested data of the author of the current post.
- get_the_author()Retrieves the author of the current post.
- comments_open()Determines whether the current post is open for comments.
- get_comments_number()Retrieves the amount of comments a post has.
- comments_popup_link()Displays the link to the comments for the current post ID.
- the_ID()Displays the ID of the current item in the WordPress Loop.
- wp_reset_postdata()After looping through a separate query, this function restores the $post global to the current post in the main query.
- WP_Query::__construct()Constructor.
Source code
public function widget( $args, $instance ) { $format = isset( $instance['format'] ) ? $instance['format'] : ''; if ( ! $format || ! in_array( $format, $this->formats, true ) ) { $format = 'aside'; } switch ( $format ) { case 'image': $format_string = __( 'Images', 'twentyfourteen' ); $format_string_more = __( 'More images', 'twentyfourteen' ); break; case 'video': $format_string = __( 'Videos', 'twentyfourteen' ); $format_string_more = __( 'More videos', 'twentyfourteen' ); break; case 'audio': $format_string = __( 'Audio', 'twentyfourteen' ); $format_string_more = __( 'More audio', 'twentyfourteen' ); break; case 'quote': $format_string = __( 'Quotes', 'twentyfourteen' ); $format_string_more = __( 'More quotes', 'twentyfourteen' ); break; case 'link': $format_string = __( 'Links', 'twentyfourteen' ); $format_string_more = __( 'More links', 'twentyfourteen' ); break; case 'gallery': $format_string = __( 'Galleries', 'twentyfourteen' ); $format_string_more = __( 'More galleries', 'twentyfourteen' ); break; case 'aside': default: $format_string = __( 'Asides', 'twentyfourteen' ); $format_string_more = __( 'More asides', 'twentyfourteen' ); break; } $number = ! empty( $instance['number'] ) ? absint( $instance['number'] ) : 2; $title = ! empty( $instance['title'] ) ? $instance['title'] : $format_string; /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */ $title = apply_filters( 'widget_title', $title, $instance, $this->id_base ); $ephemera = new WP_Query( array( 'order' => 'DESC', 'posts_per_page' => $number, 'no_found_rows' => true, 'post_status' => 'publish', 'post__not_in' => get_option( 'sticky_posts' ), 'tax_query' => array( array( 'taxonomy' => 'post_format', 'terms' => array( "post-format-$format" ), 'field' => 'slug', 'operator' => 'IN', ), ), ) ); if ( $ephemera->have_posts() ) : $tmp_content_width = $GLOBALS['content_width']; $GLOBALS['content_width'] = 306; echo $args['before_widget']; ?> <h1 class="widget-title <?php echo esc_attr( $format ); ?>"> <a class="entry-format" href="<?php echo esc_url( get_post_format_link( $format ) ); ?>"><?php echo esc_html( $title ); ?></a> </h1> <ol> <?php while ( $ephemera->have_posts() ) : $ephemera->the_post(); $tmp_more = $GLOBALS['more']; $GLOBALS['more'] = 0; ?> <li>Changelog
Introduced in Twenty Fourteen 1.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-content/themes/twentyfourteen/inc/widgets.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.