128, 'width' => 128, 'flex-height' => true, 'header-text' => ['site-title'], ]); add_theme_support('custom-background', [ 'default-color' => '#ffffff', 'default-image' => get_template_directory_uri() . '/images/bg.jpg', 'default-repeat' => 'no-repeat', 'default-position-x' => 'center', 'default-attachment' => 'fixed', ]); // Enable support for Post Thumbnails on posts and pages. add_theme_support('post-thumbnails'); set_post_thumbnail_size(1200, 9999); // This theme uses wp_nav_menu() in two locations. register_nav_menus([ 'primary' => __('Primary Menu', 'blog-material'), 'social' => __('Social Links Menu', 'blog-material'), ]); // Switch default core markup for search form, comment form, and comments to output valid HTML5. add_theme_support('html5', [ 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', ]); $GLOBALS['content_width'] = 852; // Indicate widget sidebars can use selective refresh in the Customizer. add_theme_support('customize-selective-refresh-widgets'); } endif; /** * Return available primary and accent colors. * * @param string $type * @return array */ function blog_material_get_colors($type = 'primary') { $colors = [ "Deep Orange" => "#ff5722", "Red" => "#f44336", "Pink" => "#e91e63", "Purple" => "#9c27b0", "Deep Purple" => "#673ab7", "Indigo" => "#3f51b5", "Blue" => "#2196f3", "Light Blue" => "#03a9f4", "Cyan" => "#00bcd4", "Teal" => "#009688", "Green" => "#4caf50", "Light Green" => "#8bc34a", "Lime" => "#cddc39", "Yellow" => "#ffeb3b", "Amber" => "#ffc107", "Orange" => "#ff9800", ]; if ($type !== 'accent') { $colors['Brown'] = '#795548'; $colors['Blue Grey'] = '#607d8b'; $colors['Grey'] = '#9e9e9e'; } return $colors; } add_action('customize_register', 'blog_material_customize_register'); /** * Adds postMessage support for site title and description for the Customizer. * * @since Blog Material 1.0 * * @param WP_Customize_Manager $wp_customize The Customizer object. */ function blog_material_customize_register($wp_customize) { // Add header transparency setting and control. $wp_customize->add_setting('header_transparency', [ 'default' => '0', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_key', ]); $wp_customize->add_control('header_transparency', [ 'label' => __('Transparent Header', 'blog-material'), 'section' => 'colors', 'type' => 'checkbox', ]); // Add header text color setting and control. $wp_customize->add_setting('header_text_color', [ 'default' => '#ffffff', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_hex_color', ]); $wp_customize->add_control( new WP_Customize_Color_Control($wp_customize, 'header_text_color', [ 'label' => __('Header Text Color', 'blog-material'), 'section' => 'colors' ]) ); function validate_same_colors($validity, $value) { $colors = explode('-', strtolower($value)); if (empty($value) || $colors[0] === $colors[1]) { $validity->add('same_colors', __('Colors cannot be the same.', 'blog-material')); } return $validity; } // Add color scheme setting and control. require_once('classes/blog-material-custom-color-scheme-control.php'); $wp_customize->add_setting('color_scheme', [ 'default' => 'Indigo-Pink', 'transport' => 'postMessage', 'validate_callback' => 'validate_same_colors', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control( new Blog_Material_Custom_Color_Scheme_Control($wp_customize, 'color_scheme', [ 'section' => 'colors', ]) ); // Add footer copyright text setting and control. $wp_customize->add_setting('footer_copy', [ 'default' => '© Laurynas Baltrenas, 2016', 'transport' => 'postMessage', 'sanitize_callback' => 'sanitize_text_field', ]); $wp_customize->add_control('footer_copy', [ 'label' => __('Footer Copyright', 'blog-material'), 'section' => 'title_tagline', 'type' => 'text', ]); } add_action('customize_save_after', 'blog_material_fetch_css'); /** * Enqueues scripts and styles. * * @since Blog Material 1.0 */ function blog_material_fetch_css() { /** @global $wp_filesystem WP_Filesystem_Base */ global $wp_filesystem; if (empty($wp_filesystem)) { WP_Filesystem(); } $scheme = str_replace(' ', '_', strtolower(get_theme_mod('color_scheme'))); $url = "https://code.getmdl.io/1.2.1/material.$scheme.min.css"; $wp_filesystem->put_contents( get_template_directory() . '/css/material.css', wp_remote_get($url)['body'] ); } add_action('customize_preview_init', 'blog_material_customize_preview'); /** * Enqueues theme customization scripts. * * @since Blog Material 1.0 */ function blog_material_customize_preview() { wp_enqueue_script( 'blog-material-theme-customizer', get_template_directory_uri() . '/js/theme-customizer.js', ['customize-preview'], '', true ); } add_action('widgets_init', 'blog_material_widgets_init'); /** * Registers a widget area. * * @since Blog Material 1.0 */ function blog_material_widgets_init() { register_sidebar([ 'name' => __('Sidebar', 'blog-material'), 'id' => 'sidebar-1', 'description' => __('Add widgets here to appear in your drawer.', 'blog-material'), 'before_widget' => '', 'before_title' => '
' . __('Your email address will not be published.', 'blog-material') . '
', 'comment_field' => '