wppaste
WordPress

twentysixteen_get_color_schemes(): array

Since
Twenty Sixteen 1.0
Source
wp-content/themes/twentysixteen/inc/customizer.php:292
Registers color schemes for Twenty Sixteen.

Description

Can be filtered with 'twentysixteen_color_schemes'.

The order of colors in a colors array:

  1. Main Background Color.
  2. Page Background Color.
  3. Link Color.
  4. Main Text Color.
  5. Secondary Text Color.

Compatibility

WordPress
since Twenty Sixteen 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
An associative array of color scheme options.

Performance profile

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

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

Plugin surface
1 hook

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

Called by
3

3 places 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 query, 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 · 1 distinct outcome

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

WhenInstructionsCalls it makes
always40__(), __(), __(), __(), __(), label()

Across PHP versions

Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 40 instructions, 40 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 twentysixteen_get_color_schemes() runs, in this order:

  1. apply_filters( twentysixteen_color_schemes )filterline 313 (+21 into the body)

    Filters the color schemes registered for use with Twenty Sixteen.

Uses · 2

  • apply_filters()Calls the callback functions that have been added to a filter hook.
  • __()Retrieves the translation of $text.

Used by · 3

Source code

function twentysixteen_get_color_schemes() {	/**	 * Filters the color schemes registered for use with Twenty Sixteen.	 *	 * The default schemes include 'default', 'dark', 'gray', 'red', and 'yellow'.	 *	 * @since Twenty Sixteen 1.0	 *	 * @param array $schemes {	 *     Associative array of color schemes data.	 *	 *     @type array $slug {	 *         Associative array of information for setting up the color scheme.	 *	 *         @type string $label  Color scheme label.	 *         @type array  $colors HEX codes for default colors prepended with a hash symbol ('#').	 *                              Colors are defined in the following order: Main background, page	 *                              background, link, main text, secondary text.	 *     }	 * }	 */	return apply_filters(		'twentysixteen_color_schemes',		array(			'default' => array(				'label'  => __( 'Default', 'twentysixteen' ),				'colors' => array(					'#1a1a1a',					'#ffffff',					'#007acc',					'#1a1a1a',					'#686868',				),			),			'dark'    => array(				'label'  => __( 'Dark', 'twentysixteen' ),				'colors' => array(					'#262626',					'#1a1a1a',					'#9adffd',					'#e5e5e5',					'#c1c1c1',				),			),			'gray'    => array(				'label'  => __( 'Gray', 'twentysixteen' ),				'colors' => array(					'#616a73',					'#4d545c',					'#c7c7c7',					'#f2f2f2',					'#f2f2f2',				),			),			'red'     => array(				'label'  => __( 'Red', 'twentysixteen' ),				'colors' => array(					'#ffffff',					'#ff675f',					'#640c1f',					'#402b30',					'#402b30',				),			),			'yellow'  => array(				'label'  => __( 'Yellow', 'twentysixteen' ),				'colors' => array(					'#3b3721',					'#ffef8e',					'#774e24',					'#3b3721',					'#5b4d3e',				),			),		)	);}

Changelog

Introduced in Twenty Sixteen 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/twentysixteen/inc/customizer.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.