Style API

Many of Make’s settings modify the site’s appearance and style. Because the style rules for these settings have dynamic values and may be different for different views, they cannot be added to a normal stylesheet, but must instead be generated programmatically.

A style rule consists of an array containing a selectors item, a declarations item, and optionally a media query item.

array(
	'selectors'    => array( '.site-header', '.site-footer' ),
	'declarations' => array(
		'background-color' => '#00ff00',
		'font-size'        => '27px'
	),
	'media'        => 'screen and (min-width: 800px)',
);

Note that styles that do not have dynamic values should be added to a normal stylesheet file instead of programmatically.


Example: Apply the theme’s primary color to post and page titles

function childtheme_add_primary_color_to_posttitle() {
	make_add_style_rule(
		array(
			'selectors'    => array( '.entry-title', '.entry-title a' ),
			'declarations' => array(
				'color' => make_get_thememod_value( 'color-primary' )
			)
		)
	);
}

add_action( 'make_style_loaded', 'childtheme_add_primary_color_to_posttitle' );