wppaste
WordPress

twenty_twenty_one_get_starter_content(): array

Since
Twenty Twenty-One 1.0
Source
wp-content/themes/twentytwentyone/inc/starter-content.php:21
Returns the array of starter content for the theme.

Description

Passes it through the twenty_twenty_one_starter_content filter before returning.

Compatibility

WordPress
since Twenty Twenty-One 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.

Return value

array
A filtered array of args for the starter_content.

Performance profile

How much work a call to twenty_twenty_one_get_starter_content() 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

Touches nothing outside its own arguments.

Scaling
Constant

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

Instructions
144

Executed per call on PHP 8.5. The body compiles to 144.

Plugin surface
1 hook

Third-party callbacks on 'twenty_twenty_one_starter_content' run inside this call, and their cost is not bounded by anything here.

Called by
1

1 place in core call this, so the cost is paid more often than your own code shows.

What it touches

  • hookthird-party callbacksapply_filters()called directly

Further down the call graph this can also reach option, cache, serialize, transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.

What one call costs · 1 distinct outcome

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

WhenInstructionsCalls it makes
always144esc_html_x(), esc_html_x(), get_template_directory_uri(), esc_url(), esc_attr__(), get_template_directory_uri(), esc_url(), esc_attr__(), get_template_directory_uri(), esc_url(), esc_attr__(), esc_html_x(), esc_html_x(), esc_html_x(), esc_html_x(), esc_html_x(), esc_html_x(), esc_html_x(), esc_html_x(), esc_html_x(), esc_html__(), esc_html__(), apply_filters()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 144 instructions, 144 executed per call, 0 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 twenty_twenty_one_get_starter_content() runs, in this order:

  1. apply_filters( twenty_twenty_one_starter_content )filterline 183 (+162 into the body)

    Filters the array of starter content.

Uses · 6

  • esc_html_x()Translates string with gettext context, and escapes it for safe use in HTML output.
  • esc_url()Checks and cleans a URL.
  • get_template_directory_uri()Retrieves template directory URI for the active theme.
  • esc_attr__()Retrieves the translation of $text and escapes it for safe use in an attribute.
  • esc_html__()Retrieves the translation of $text and escapes it for safe use in HTML output.
  • apply_filters()Calls the callback functions that have been added to a filter hook.

Used by · 1

Source code

<?phpfunction twenty_twenty_one_get_starter_content() { 	// Define and register starter content to showcase the theme on new sites.	$starter_content = array( 		// Specify the core-defined pages to create and add custom thumbnails to some of them.		'posts'     => array(			'front' => array(				'post_type'    => 'page',				'post_title'   => esc_html_x( 'Create your website with blocks', 'Theme starter content', 'twentytwentyone' ),				'post_content' => '					<!-- wp:heading {"align":"wide","fontSize":"gigantic","style":{"typography":{"lineHeight":"1.1"}}} -->					<h2 class="alignwide has-text-align-wide has-gigantic-font-size" style="line-height:1.1">' . esc_html_x( 'Create your website with blocks', 'Theme starter content', 'twentytwentyone' ) . '</h2>					<!-- /wp:heading --> 					<!-- wp:spacer -->					<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>					<!-- /wp:spacer --> 					<!-- wp:columns {"verticalAlignment":"center","align":"wide","className":"is-style-twentytwentyone-columns-overlap"} -->					<div class="wp-block-columns alignwide are-vertically-aligned-center is-style-twentytwentyone-columns-overlap"><!-- wp:column {"verticalAlignment":"center"} -->					<div class="wp-block-column is-vertically-aligned-center"><!-- wp:image {"align":"full","sizeSlug":"large"} -->					<figure class="wp-block-image alignfull size-large"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/roses-tremieres-hollyhocks-1884.jpg" alt="' . esc_attr__( '&#8220;Roses Trémières&#8221; by Berthe Morisot', 'twentytwentyone' ) . '"/></figure>					<!-- /wp:image --> 					<!-- wp:spacer -->					<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>					<!-- /wp:spacer --> 					<!-- wp:image {"align":"full","sizeSlug":"large","className":"is-style-twentytwentyone-image-frame"} -->					<figure class="wp-block-image alignfull size-large is-style-twentytwentyone-image-frame"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/in-the-bois-de-boulogne.jpg" alt="' . esc_attr__( '&#8220;In the Bois de Boulogne&#8221; by Berthe Morisot', 'twentytwentyone' ) . '"/></figure>					<!-- /wp:image --></div>					<!-- /wp:column --> 					<!-- wp:column {"verticalAlignment":"center"} -->					<div class="wp-block-column is-vertically-aligned-center"><!-- wp:spacer -->					<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>					<!-- /wp:spacer --> 					<!-- wp:image {"sizeSlug":"large","className":"alignfull size-full is-style-twentytwentyone-border"} -->					<figure class="wp-block-image size-large alignfull size-full is-style-twentytwentyone-border"><img src="' . esc_url( get_template_directory_uri() ) . '/assets/images/young-woman-in-mauve.jpg" alt="' . esc_attr__( '&#8220;Young Woman in Mauve&#8221; by Berthe Morisot', 'twentytwentyone' ) . '"/></figure>					<!-- /wp:image --></div>					<!-- /wp:column --></div>					<!-- /wp:columns --> 					<!-- wp:spacer {"height":50} -->					<div style="height:50px" aria-hidden="true" class="wp-block-spacer"></div>					<!-- /wp:spacer --> 					<!-- wp:columns {"verticalAlignment":"top","align":"wide"} -->					<div class="wp-block-columns alignwide are-vertically-aligned-top"><!-- wp:column {"verticalAlignment":"top"} -->					<div class="wp-block-column is-vertically-aligned-top"><!-- wp:heading {"level":3} -->					<h3>' . esc_html_x( 'Add block patterns', 'Theme starter content', 'twentytwentyone' ) . '</h3>					<!-- /wp:heading --> 					<!-- wp:paragraph -->					<p>' . esc_html_x( 'Block patterns are pre-designed groups of blocks. To add one, select the Add Block button [+] in the toolbar at the top of the editor. Switch to the Patterns tab underneath the search bar, and choose a pattern.', 'Theme starter content', 'twentytwentyone' ) . '</p>					<!-- /wp:paragraph --></div>					<!-- /wp:column --> 					<!-- wp:column {"verticalAlignment":"top"} -->					<div class="wp-block-column is-vertically-aligned-top"><!-- wp:heading {"level":3} -->					<h3>' . esc_html_x( 'Frame your images', 'Theme starter content', 'twentytwentyone' ) . '</h3>					<!-- /wp:heading --> 					<!-- wp:paragraph -->					<p>' . esc_html_x( 'Twenty Twenty-One includes stylish borders for your content. With an Image block selected, open the "Styles" panel within the Editor sidebar. Select the "Frame" block style to activate it.', 'Theme starter content', 'twentytwentyone' ) . '</p>					<!-- /wp:paragraph --></div>					<!-- /wp:column --> 					<!-- wp:column {"verticalAlignment":"top"} -->					<div class="wp-block-column is-vertically-aligned-top"><!-- wp:heading {"level":3} -->					<h3>' . esc_html_x( 'Overlap columns', 'Theme starter content', 'twentytwentyone' ) . '</h3>					<!-- /wp:heading --> 					<!-- wp:paragraph -->					<p>' . esc_html_x( 'Twenty Twenty-One also includes an overlap style for column blocks. With a Columns block selected, open the "Styles" panel within the Editor sidebar. Choose the "Overlap" block style to try it out.', 'Theme starter content', 'twentytwentyone' ) . '</p>					<!-- /wp:paragraph --></div>					<!-- /wp:column --></div>					<!-- /wp:columns -->

Changelog

Introduced in Twenty Twenty-One 1.0. 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-content/themes/twentytwentyone/inc/starter-content.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.