Merge pull request #144 from stef-k/setup-theme-default-settings - Many thx @stef-k !
check and setup theme's default settings - Many thx @stef-k !
This commit is contained in:
commit
1c4fe9b1f7
|
@ -3,6 +3,9 @@
|
||||||
* Set the content width based on the theme's design and stylesheet.
|
* Set the content width based on the theme's design and stylesheet.
|
||||||
* @package understrap
|
* @package understrap
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require get_template_directory() . '/inc/theme-settings.php';
|
||||||
|
|
||||||
if ( ! isset( $content_width ) ) {
|
if ( ! isset( $content_width ) ) {
|
||||||
$content_width = 640; /* pixels */
|
$content_width = 640; /* pixels */
|
||||||
}
|
}
|
||||||
|
@ -77,6 +80,9 @@ function understrap_setup() {
|
||||||
|
|
||||||
// Set up the Wordpress Theme logo feature.
|
// Set up the Wordpress Theme logo feature.
|
||||||
add_theme_support('custom-logo');
|
add_theme_support('custom-logo');
|
||||||
|
|
||||||
|
// Check and setup theme default settings.
|
||||||
|
setup_theme_default_settings();
|
||||||
}
|
}
|
||||||
endif; // understrap_setup
|
endif; // understrap_setup
|
||||||
add_action( 'after_setup_theme', 'understrap_setup' );
|
add_action( 'after_setup_theme', 'understrap_setup' );
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Check and setup theme's default settings
|
||||||
|
*/
|
||||||
|
function setup_theme_default_settings() {
|
||||||
|
|
||||||
|
// check if settings are set, if not set defaults.
|
||||||
|
// Caution: DO NOT check existence using === always check with == .
|
||||||
|
|
||||||
|
// Latest blog posts style.
|
||||||
|
$understrap_posts_index_style = get_theme_mod( 'understrap_posts_index_style' );
|
||||||
|
if ( '' == $understrap_posts_index_style ) {
|
||||||
|
set_theme_mod( 'understrap_posts_index_style', 'default' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sidebar position.
|
||||||
|
$understrap_sidebar_position = get_theme_mod( 'understrap_sidebar_position' );
|
||||||
|
if ( '' == $understrap_sidebar_position ) {
|
||||||
|
set_theme_mod( 'understrap_sidebar_position', 'right' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Container width.
|
||||||
|
$understrap_container_type = get_theme_mod( 'understrap_container_type' );
|
||||||
|
if ( '' == $understrap_container_type ) {
|
||||||
|
set_theme_mod( 'understrap_container_type', 'container' );
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue