themes-wordpress/blockbase/functions.php

132 lines
3.6 KiB
PHP
Raw Normal View History

<?php
2021-05-25 09:37:50 +00:00
if ( ! function_exists( 'blockbase_support' ) ) :
function blockbase_support() {
// Make theme available for translation.
load_theme_textdomain( 'blockbase' );
if ( ! 'blockbase' === wp_get_theme()->get( 'TextDomain' ) ) {
load_theme_textdomain( wp_get_theme()->get( 'TextDomain' ) );
}
// Alignwide and alignfull classes in the block editor.
add_theme_support( 'align-wide' );
// Add support for link color control.
add_theme_support( 'link-color' );
// Add support for responsive embedded content.
// https://github.com/WordPress/gutenberg/issues/26901
add_theme_support( 'responsive-embeds' );
// Add support for editor styles.
add_theme_support( 'editor-styles' );
Make: Quadrat (#3648) * Scaffolding a universal theme plus basic typography and color palette. * fixed do_blocks routes and override index.html from BCB * added header and footer templates * changed query to post content block * commented with the GB issue * Quadrat: Add new heading sizes and other small misc changes (#3649) * Quadrat: Add new heading sizes * Quadrat: Further work on Lists and Quotes * Quadrat: Remove whitespace * Quadrat: Add responsive Heading font-sizes * Fix typo. * Recompile. * remove older deploy actions and adding quadrat deploy action (#3655) * Add the hosts block pattern. (#3662) * Add the hosts block pattern. * Fix categories. * Update img refs. * Add alt text to media text pattern. * Revise block pattern names. * Add text domain. * Quadrat: override BCB's templates with php ones (#3667) * override BCB's templates with php ones * Revert unrelated changes to Seedlet Blocks that are not in trunk. * Quadrat: Add responsive Paragraph styles and start styling the Code b… (#3663) * Quadrat: Add responsive Paragraph styles and start styling the Code block * Quadrat: Remove Code block styling * Revise heading max vw. Co-authored-by: Jeff Ong <jonger4@gmail.com> * Quadrat: Add Latest episodes block pattern (#3665) * added Latest episodes block pattern * translatable strings * staging url for media * rebased, updated texts and adjusted paddings * added a group with padding to the blocks * Body line-height to 1.7. Co-authored-by: Jeff Ong <jonger4@gmail.com> * Add menu locations to quadrat * Remove disconnected changes * Remove footer menu location * rebuild theme.json * Quadrat: Add Quote block styles * Tightened up the line-height and lessened the space between quote and citation. * Remove properties that already exist in the parent theme * Remove quote sass include and rebuild. * Quadrat: Add list styles * Removed variable usage for list item style * Updated list styles to be more correcter * Try/header template part wrapped (#3714) * Modified site-title styles to match comps * Added a navigation rendering function to render the navigation block based on a classic data source, wrap the output in an HTML block to be inserted anywhere blocks are do_block()'ed * Added a header template part that leverages the rendered navigation block markup * Replaced usage of navigation block template with new template-part * Added styles for header for proper layout unachievable with blocks. * Quadrat: Style the Code block * Remove unneeded declarations * Removed font-changing settings on code block * Quadrat: add cover pattern (#3676) * Try using svg for block pattern. * Try mask-image instead. * move the svg to a before pseudoelement * refactored the pseudoelements * fix for the editor interaction when cover block is highlighted * Add block pattern. * Use a transparent div instead of svg. Simplify how color of the diamond is set. * Rotate closer to the design. * Use background image with svg and mix-blend-mode. * made block pattern wide aligned * created exceptions bof black and white * changes to fit the design, lowered opacity on black and white versions * Add autoprefixing to Quadrat * removed error from rebase * removed unnecessary z-index, linting * z-index added * Scope CSS to cover block. * :: for consistency. Co-authored-by: Maggie Cabrera <maggie.cabrera@automattic.com> Co-authored-by: Ben Dwyer <ben@scruffian.com> * removes template hack * Quadrat: Add Episode block pattern (#3695) * create episode pattern * added group wrapper for padding * correct url for image * typo * update to use media and text * changed the url of the image, added alt content and em tag * remove unneeded class, added wrapper for bottom padding * Scope the 0 padding to text content without a background. * Remove group, add spacer. Fix local image ref. Co-authored-by: Ben Dwyer <ben@scruffian.com> Co-authored-by: Jeff Ong <jonger4@gmail.com> * Change colors used in theme.json from descreptive to semantic (#3725) * Change colors used in theme.json from descreptive to semantic * semanticizing the color * formatting * also changed the child theme.json * Quadrat: Add table styles (#3719) * Quadrat: Add styles for tables * Add tbody for extra specificity * Add a border to the top of the first row * Remove text-align. Co-authored-by: Jeff Ong <jonger4@gmail.com> * Allowing overflow of group-wrapped navigation (#3732) * Update screenshot.png (#3735) * Quadrat: Add page templates (#3721) * Rebase trunk. * Revise footer. * Add CSS for the next/prev links * Continue rebase. * remove test code * used gutenberg_block_template_part to load template parts on php templates * Remove testing text * alignment tweaks * Add separate templates for page and post. * Restore header wrapper that was accidentally removed in rebase. * Template tweaks. * Add page block template. Co-authored-by: Jeff Ong <jonger4@gmail.com> Co-authored-by: Maggie Cabrera <maggie.cabrera@automattic.com> * Make index query inherit query string. * Update screenshot.png (#3742) * Quadrat: Add CSS for a featured image * Quadrat: Headlines and Buttons Block Pattern (#3744) * created block pattern * padding rules for mobile * added new class to all the group blocks * Remove all padding from text content on mobile. Co-authored-by: Jeff Ong <jonger4@gmail.com> * Change hover rules for buttons * Add hover styles for buttons and links * Remove background color from buttons. (#3752) * Quadrat: Add the listen pattern * refactor patterns to single files * move utility classes to BCB * refactor listen to the podcast * Quadrat: Add a join pattern * Make the pattern wide * Check the class exists before calling it * Make sure the plugin is loaded before adding the pattern * Move the block pattern CSS to a new file Co-authored-by: Maggie Cabrera <maggie.cabrera@automattic.com> Co-authored-by: Daniel Dudzic <daniel.dudzic@automattic.com> Co-authored-by: Jason Crist <jcrist@pbking.com> Co-authored-by: Ben Dwyer <ben@scruffian.com> Co-authored-by: Kjell Reigstad <kjell.reigstad@automattic.com>
2021-05-06 15:06:23 +00:00
// Add support for post thumbnails.
add_theme_support( 'post-thumbnails' );
// Experimental support for adding blocks inside nav menus
add_theme_support( 'block-nav-menus' );
// Enqueue editor styles.
add_editor_style(
array(
'/assets/ponyfill.css',
)
);
// Register two nav menus if Gutenberg is activated (otherwise the __experimentalMenuLocation attribute isn't available)
if ( defined( 'IS_GUTENBERG_PLUGIN' ) ) {
register_nav_menus(
array(
'primary' => __( 'Primary Navigation', 'blockbase' ),
'social' => __( 'Social Navigation', 'blockbase' ),
)
);
}
add_filter(
'block_editor_settings_all',
function( $settings ) {
$settings['defaultBlockTemplate'] = '<!-- wp:group {"layout":{"inherit":true}} --><div class="wp-block-group"><!-- wp:post-content /--></div><!-- /wp:group -->';
return $settings;
}
);
// Add support for core custom logo.
add_theme_support(
'custom-logo',
array(
'height' => 192,
'width' => 192,
'flex-width' => true,
'flex-height' => true,
)
);
}
endif;
add_action( 'after_setup_theme', 'blockbase_support', 9 );
/**
*
* Enqueue scripts and styles.
*/
2021-05-25 09:37:50 +00:00
function blockbase_editor_styles() {
// Add the child theme CSS if it exists.
if ( file_exists( get_stylesheet_directory() . '/assets/theme.css' ) ) {
add_editor_style(
'/assets/theme.css'
);
}
}
2021-05-25 09:37:50 +00:00
add_action( 'admin_init', 'blockbase_editor_styles' );
/**
*
* Enqueue scripts and styles.
*/
2021-05-25 09:37:50 +00:00
function blockbase_scripts() {
wp_enqueue_style( 'blockbase-ponyfill', get_template_directory_uri() . '/assets/ponyfill.css', array(), wp_get_theme()->get( 'Version' ) );
// Add the child theme CSS if it exists.
if ( file_exists( get_stylesheet_directory() . '/assets/theme.css' ) ) {
wp_enqueue_style( 'blockbase-child-styles', get_stylesheet_directory_uri() . '/assets/theme.css', array( 'blockbase-ponyfill' ), wp_get_theme()->get( 'Version' ) );
}
}
2021-05-25 09:37:50 +00:00
add_action( 'wp_enqueue_scripts', 'blockbase_scripts' );
/**
* Customize Global Styles
*/
if ( class_exists( 'WP_Theme_JSON_Resolver_Gutenberg' ) ) {
require get_template_directory() . '/inc/customizer/wp-customize-colors.php';
require get_template_directory() . '/inc/social-navigation.php';
}
require get_template_directory() . '/inc/fonts/custom-fonts.php';
require get_template_directory() . '/inc/rest-api.php';
// Force menus to reload
add_action(
'customize_controls_enqueue_scripts',
static function () {
wp_enqueue_script(
'wp-customize-nav-menu-refresh',
get_template_directory_uri() . '/inc/customizer/wp-customize-nav-menu-refresh.js',
array( 'customize-nav-menus' ),
wp_get_theme()->get( 'Version' ),
true
);
}
);
/**
* Block Patterns.
*/
require get_template_directory() . '/inc/block-patterns.php';
// Add the child theme patterns if they exist.
if ( file_exists( get_stylesheet_directory() . '/inc/block-patterns.php' ) ) {
require_once get_stylesheet_directory() . '/inc/block-patterns.php';
}