177 lines
5.8 KiB
PHP
Executable file
177 lines
5.8 KiB
PHP
Executable file
<?php
|
|
/**
|
|
* Blank Canvas functions and definitions
|
|
*
|
|
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/
|
|
*
|
|
* @package WordPress
|
|
* @subpackage Blank Canvas
|
|
* @since 1.0
|
|
*/
|
|
|
|
if ( ! function_exists( 'blank_canvas_setup' ) ) :
|
|
/**
|
|
* Sets up theme defaults and registers support for various WordPress features.
|
|
*
|
|
* Note that this function is hooked into the after_setup_theme hook, which
|
|
* runs before the init hook. The init hook is too late for some features, such
|
|
* as indicating support for post thumbnails.
|
|
*/
|
|
function blank_canvas_setup() {
|
|
// Add support for editor styles.
|
|
add_theme_support( 'editor-styles' );
|
|
|
|
// Enqueue editor styles.
|
|
add_editor_style( 'variables.css' );
|
|
|
|
// Editor color palette.
|
|
$colors_theme_mod = get_theme_mod( 'custom_colors_active' );
|
|
$primary = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-primary' ) ) ) ? '#000000' : get_theme_mod( 'seedlet_--global--color-primary' );
|
|
$secondary = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-secondary' ) ) ) ? '#007cba' : get_theme_mod( 'seedlet_--global--color-secondary' );
|
|
$foreground = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-foreground' ) ) ) ? '#333333' : get_theme_mod( 'seedlet_--global--color-foreground' );
|
|
$tertiary = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-tertiary' ) ) ) ? '#FAFAFA' : get_theme_mod( 'seedlet_--global--color-tertiary' );
|
|
$background = ( ! empty( $colors_theme_mod ) && 'default' === $colors_theme_mod || empty( get_theme_mod( 'seedlet_--global--color-background' ) ) ) ? '#FFFFFF' : get_theme_mod( 'seedlet_--global--color-background' );
|
|
|
|
add_theme_support(
|
|
'editor-color-palette',
|
|
array(
|
|
array(
|
|
'name' => __( 'Primary', 'blank-canvas' ),
|
|
'slug' => 'primary',
|
|
'color' => $primary,
|
|
),
|
|
array(
|
|
'name' => __( 'Secondary', 'blank-canvas' ),
|
|
'slug' => 'secondary',
|
|
'color' => $secondary,
|
|
),
|
|
array(
|
|
'name' => __( 'Foreground', 'blank-canvas' ),
|
|
'slug' => 'foreground',
|
|
'color' => $foreground,
|
|
),
|
|
array(
|
|
'name' => __( 'Tertiary', 'blank-canvas' ),
|
|
'slug' => 'tertiary',
|
|
'color' => $tertiary,
|
|
),
|
|
array(
|
|
'name' => __( 'Background', 'blank-canvas' ),
|
|
'slug' => 'background',
|
|
'color' => $background,
|
|
),
|
|
)
|
|
);
|
|
}
|
|
endif;
|
|
add_action( 'after_setup_theme', 'blank_canvas_setup', 11 );
|
|
|
|
/**
|
|
* Remove Seedlet theme features.
|
|
*/
|
|
function blank_canvas_remove_parent_theme_features() {
|
|
|
|
// Theme Support.
|
|
remove_theme_support( 'custom-header' );
|
|
remove_theme_support( 'customize-selective-refresh-widgets' );
|
|
|
|
// Navigation Areas.
|
|
unregister_nav_menu( 'primary' );
|
|
unregister_nav_menu( 'footer' );
|
|
unregister_nav_menu( 'social' );
|
|
}
|
|
add_action( 'after_setup_theme', 'blank_canvas_remove_parent_theme_features', 11 );
|
|
|
|
/**
|
|
* Dequeue Seedlet scripts.
|
|
*/
|
|
function blank_canvas_dequeue_parent_scripts() {
|
|
|
|
// Naviation assets.
|
|
wp_dequeue_script( 'seedlet-primary-navigation-script' );
|
|
wp_dequeue_style( 'seedlet-style-navigation' );
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'blank_canvas_dequeue_parent_scripts', 11 );
|
|
|
|
/**
|
|
* Remove Seedlet's widget area.
|
|
*/
|
|
function blank_canvas_remove_widgets_area() {
|
|
unregister_sidebar( 'sidebar-1' );
|
|
}
|
|
add_action( 'widgets_init', 'blank_canvas_remove_widgets_area', 11 );
|
|
|
|
/**
|
|
* Remove unused custmizer settings.
|
|
*/
|
|
function blank_canvas_remove_customizer_settings( $wp_customize ) {
|
|
|
|
// Remove the navigation menus Customizer panel.
|
|
$wp_customize->get_panel( 'nav_menus' )->active_callback = '__return_false';
|
|
|
|
// Remove Jetpack's Author Bio setting.
|
|
if ( function_exists( 'jetpack_author_bio' ) ) {
|
|
$wp_customize->remove_control( 'jetpack_content_author_bio_title' );
|
|
$wp_customize->remove_control( 'jetpack_content_author_bio' );
|
|
}
|
|
|
|
// Remove Seedlet's header and footer hide options,
|
|
// since they're already hidden by default.
|
|
$wp_customize->remove_control( 'hide_site_header' );
|
|
$wp_customize->remove_control( 'hide_site_footer' );
|
|
|
|
|
|
// Add a Customizer message about the site title & tagline options.
|
|
$wp_customize->get_section( 'title_tagline' )->description = __( 'This theme is designed to hide the site logo, site title, and tagline on all single posts and pages.', 'blank-canvas' );
|
|
}
|
|
add_action( 'customize_register', 'blank_canvas_remove_customizer_settings', 11 );
|
|
|
|
/**
|
|
* Remove Meta Footer Items.
|
|
*/
|
|
if ( ! function_exists( 'seedlet_entry_meta_footer' ) ) :
|
|
/**
|
|
* Prints HTML with meta information for the categories, tags and comments.
|
|
*/
|
|
function seedlet_entry_meta_footer() {
|
|
|
|
// Edit post link.
|
|
edit_post_link(
|
|
sprintf(
|
|
wp_kses(
|
|
/* translators: %s: Name of current post. Only visible to screen readers. */
|
|
__( 'Edit <span class="screen-reader-text">%s</span>', 'blank-canvas' ),
|
|
array(
|
|
'span' => array(
|
|
'class' => array(),
|
|
),
|
|
)
|
|
),
|
|
get_the_title()
|
|
),
|
|
'<span class="edit-link">' . seedlet_get_icon_svg( 'edit', 16 ),
|
|
'</span>'
|
|
);
|
|
}
|
|
endif;
|
|
|
|
/**
|
|
* Enqueue scripts and styles.
|
|
*/
|
|
function blank_canvas_enqueue() {
|
|
wp_enqueue_style( 'blank-canvas-styles', get_stylesheet_uri() );
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'blank_canvas_enqueue', 11 );
|
|
|
|
/**
|
|
* Block Patterns.
|
|
*/
|
|
require get_stylesheet_directory() . '/inc/block-patterns.php';
|
|
|
|
/**
|
|
* Enqueue CSS for Customizer message.
|
|
*/
|
|
function blank_canvas_customizer_enqueue() {
|
|
wp_enqueue_style( 'blank-canvas-customizer-style', get_stylesheet_directory_uri() . '/assets/customizer.css', array(), wp_get_theme()->get( 'Version' ) );
|
|
}
|
|
add_action( 'customize_controls_enqueue_scripts', 'blank_canvas_customizer_enqueue' );
|