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' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ]); } if (!function_exists('blog_material_fonts_url')): /** * Register Google fonts for Twenty Sixteen. * * Create your own blog_material_fonts_url() function to override in a child theme. * * @since Blog Material 1.0 * * @return string Google fonts URL for the theme. */ function blog_material_fonts_url() { $fonts_url = ''; $fonts = []; $subsets = 'latin,latin-ext'; $fonts[] = 'Roboto:regular,bold,italic,thin,light,bolditalic,black,medium'; $fonts[] = 'Material Icons'; if ($fonts) { $fonts_url = add_query_arg([ 'family' => urlencode(implode('|', $fonts)), 'subset' => urlencode($subsets), ], 'https://fonts.googleapis.com/css'); } return $fonts_url; } endif; add_action('wp_enqueue_scripts', 'blog_material_scripts'); /** * Enqueues scripts and styles. * * @since Blog Material 1.0 */ function blog_material_scripts() { // Add custom fonts, used in the main stylesheet. wp_enqueue_style('blog-material-fonts', blog_material_fonts_url(), [], null); // Theme stylesheet. wp_enqueue_style('blog-material-mdl-style', get_template_directory_uri() . '/css/material.css', [], time()); wp_enqueue_style('blog-material-style', get_stylesheet_uri()); // Load the html5 shiv. wp_enqueue_script('blog-material-html5', get_template_directory_uri() . '/js/html5.js', [], '3.7.3'); wp_script_add_data('blog-material-html5', 'conditional', 'lt IE 9'); if (is_singular() && comments_open() && get_option('thread_comments')) { wp_enqueue_script('comment-reply'); } wp_enqueue_script('blog-material-mdl-script', get_template_directory_uri() . '/js/material.js', [], '1.2.1', true); wp_enqueue_script('blog-material-script', get_template_directory_uri() . '/js/script.js', [], '1.0.0', true); } add_theme_support('admin-bar', ['callback' => 'blog_material_admin_bar_bump']); /** * Fixes page layout when admin bar is shown * * @since Blog Material 1.0 */ function blog_material_admin_bar_bump() { ?> '', 'title_reply_to' => '', 'title_reply_before' => '', 'title_reply_after' => '', 'comment_notes_before' => '

' . __('Your email address will not be published.', 'blog-material') . '

', 'comment_field' => '
', 'fields' => [ 'author' => '
', 'email' => '
', ], 'submit_field' => '%1$s %2$s', 'submit_button' => '
', 'label_submit' => 'check', ], $defaults); } add_filter('navigation_markup_template', 'blog_material_navigation_template'); /** * Custom navigation template using required mdl classes * * @since Blog Material 1.0 */ function blog_material_navigation_template($template) { return ''; } add_filter('next_post_link', 'blog_material_next_post_link'); /** * Adds section spacer before next post link * * @since Blog Material 1.0 */ function blog_material_next_post_link($output) { return '
' . $output; }