wppaste
WordPress

get_theme_starter_content(): array

Since
4.7.0
Source
wp-includes/theme.php:2293
Expands a theme's starter content configuration using core-provided data.

Compatibility

WordPress
since 4.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.

Return value

array
Array of starter content.

Performance profile

How much work a call to get_theme_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
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with how much data it finds.

Instructions
300–307

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 479.

Plugin surface
1 hook

Third-party callbacks on 'get_theme_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, 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 · 1 distinct outcome

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

WhenInstructionsCalls it makes
always300–307get_theme_support(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), home_url(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), _x(), apply_filters()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev479300–30740
8.5479300–30740
8.4479300–307407 fewer instructions than PHP 8.3
8.3486307–31440
8.2486307–314401 more instruction than PHP 8.1
8.1485307–314401 more instruction than PHP 7.4
7.4484307–31440

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 get_theme_starter_content() runs, in this order:

  1. apply_filters( get_theme_starter_content )filterline 2610 (+317 into the body)

    Filters the expanded array of starter content.

Uses · 5

  • get_theme_support()Gets the theme support arguments passed when registering that support.
  • _x()Retrieves translated string with gettext context.
  • home_url()Retrieves the URL for the current site where the front end is accessible.
  • wp_array_slice_assoc()Extracts a slice of an array, given a list of keys.
  • apply_filters()Calls the callback functions that have been added to a filter hook.

Used by · 1

Source code

function get_theme_starter_content() {	$theme_support = get_theme_support( 'starter-content' );	if ( is_array( $theme_support ) && ! empty( $theme_support[0] ) && is_array( $theme_support[0] ) ) {		$config = $theme_support[0];	} else {		$config = array();	} 	$core_content = array(		'widgets'   => array(			'text_business_info' => array(				'text',				array(					'title'  => _x( 'Find Us', 'Theme starter content' ),					'text'   => implode(						'',						array(							'<strong>' . _x( 'Address', 'Theme starter content' ) . "</strong>\n",							_x( '123 Main Street', 'Theme starter content' ) . "\n",							_x( 'New York, NY 10001', 'Theme starter content' ) . "\n\n",							'<strong>' . _x( 'Hours', 'Theme starter content' ) . "</strong>\n",							_x( 'Monday&ndash;Friday: 9:00AM&ndash;5:00PM', 'Theme starter content' ) . "\n",							_x( 'Saturday &amp; Sunday: 11:00AM&ndash;3:00PM', 'Theme starter content' ),						)					),					'filter' => true,					'visual' => true,				),			),			'text_about'         => array(				'text',				array(					'title'  => _x( 'About This Site', 'Theme starter content' ),					'text'   => _x( 'This may be a good place to introduce yourself and your site or include some credits.', 'Theme starter content' ),					'filter' => true,					'visual' => true,				),			),			'archives'           => array(				'archives',				array(					'title' => _x( 'Archives', 'Theme starter content' ),				),			),			'calendar'           => array(				'calendar',				array(					'title' => _x( 'Calendar', 'Theme starter content' ),				),			),			'categories'         => array(				'categories',				array(					'title' => _x( 'Categories', 'Theme starter content' ),				),			),			'meta'               => array(				'meta',				array(					'title' => _x( 'Meta', 'Theme starter content' ),				),			),			'recent-comments'    => array(				'recent-comments',				array(					'title' => _x( 'Recent Comments', 'Theme starter content' ),				),			),			'recent-posts'       => array(				'recent-posts',				array(					'title' => _x( 'Recent Posts', 'Theme starter content' ),				),			),			'search'             => array(				'search',				array(					'title' => _x( 'Search', 'Theme starter content' ),				),			),

Changelog

Introduced in 4.7.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 6.9.7 tag, from src/wp-includes/theme.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.