2017-12-01 13:32:22 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Check and setup theme's default settings
|
|
|
|
*
|
|
|
|
* @package understrap
|
|
|
|
*/
|
|
|
|
|
2019-06-20 08:57:12 +00:00
|
|
|
// Exit if accessed directly.
|
|
|
|
defined( 'ABSPATH' ) || exit;
|
2018-09-10 21:59:04 +00:00
|
|
|
|
2018-11-18 23:27:49 +00:00
|
|
|
if ( ! function_exists( 'understrap_setup_theme_default_settings' ) ) {
|
2019-11-07 10:16:16 +00:00
|
|
|
/**
|
|
|
|
* Store default theme settings in database.
|
|
|
|
*/
|
2017-12-01 13:32:22 +00:00
|
|
|
function understrap_setup_theme_default_settings() {
|
2019-11-07 10:16:16 +00:00
|
|
|
$defaults = understrap_get_theme_default_settings();
|
|
|
|
$settings = get_theme_mods();
|
|
|
|
foreach ( $defaults as $setting_id => $default_value ) {
|
|
|
|
// Check if setting is set, if not set it to its default value.
|
|
|
|
if ( ! isset( $settings[ $setting_id ] ) ) {
|
|
|
|
set_theme_mod( $setting_id, $default_value );
|
|
|
|
}
|
2017-12-01 13:32:22 +00:00
|
|
|
}
|
2019-11-07 10:16:16 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-01 13:32:22 +00:00
|
|
|
|
2019-11-07 10:16:16 +00:00
|
|
|
if ( ! function_exists( 'understrap_get_theme_default_settings' ) ) {
|
|
|
|
/**
|
|
|
|
* Retrieve default theme settings.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function understrap_get_theme_default_settings() {
|
|
|
|
$defaults = array(
|
|
|
|
'understrap_posts_index_style' => 'default', // Latest blog posts style.
|
|
|
|
'understrap_sidebar_position' => 'right', // Sidebar position.
|
|
|
|
'understrap_container_type' => 'container', // Container width.
|
|
|
|
);
|
2017-12-01 13:32:22 +00:00
|
|
|
|
2019-11-07 10:16:16 +00:00
|
|
|
/**
|
|
|
|
* Filters the default theme settings.
|
|
|
|
*
|
|
|
|
* @param array $defaults Array of default theme settings.
|
|
|
|
*/
|
|
|
|
return apply_filters( 'understrap_theme_default_settings', $defaults );
|
2017-12-01 13:32:22 +00:00
|
|
|
}
|
2018-11-18 23:27:49 +00:00
|
|
|
}
|