fkinfood/functions.php

146 lines
5.0 KiB
PHP
Raw Permalink Normal View History

2023-12-23 13:58:28 +00:00
<?php
/* -----------------------------------------------------------------------------------------------
THEME SUPPORTS
--------------------------------------------------------------------------------------------------- */
function fkinfood_setup() {
add_editor_style( 'style.css' );
}
add_action( 'after_setup_theme', 'fkinfood_setup' );
/* -----------------------------------------------------------------------------------------------
ENQUEUE STYLESHEETS
--------------------------------------------------------------------------------------------------- */
function fkinfood_styles() {
wp_enqueue_style( 'fkinfood-styles', get_theme_file_uri( '/style.css' ), array(), wp_get_theme( 'fkinfood' )->get( 'Version' ) );
}
add_action( 'wp_enqueue_scripts', 'fkinfood_styles' );
/* -----------------------------------------------------------------------------------------------
BLOCK PATTERNS
Register theme specific block pattern categories. The patterns themselves are stored in /patterns/.
--------------------------------------------------------------------------------------------------- */
function fkinfood_register_block_patterns() {
// The block pattern categories included in F*KIN FOOD.
$fkinfood_block_pattern_categories = apply_filters( 'fkinfood_block_pattern_categories', array(
'fkinfood' => array(
'label' => esc_html__( 'F*KIN FOOD - All', 'fkinfood' ),
),
'fkinfood-blog' => array(
'label' => esc_html__( 'F*KIN FOOD - Blog', 'fkinfood' ),
),
'fkinfood-cta' => array(
'label' => esc_html__( 'F*KIN FOOD - Call to Action', 'fkinfood' ),
),
'fkinfood-general' => array(
'label' => esc_html__( 'F*KIN FOOD - General', 'fkinfood' ),
),
'fkinfood-hero' => array(
'label' => esc_html__( 'F*KIN FOOD - Hero', 'fkinfood' ),
),
'fkinfood-media' => array(
'label' => esc_html__( 'F*KIN FOOD - Media', 'fkinfood' ),
),
'fkinfood-page' => array(
'label' => esc_html__( 'F*KIN FOOD - Page Layouts', 'fkinfood' ),
),
) );
// Sort the block pattern categories alphabetically based on the label value, to ensure alphabetized order when the strings are localized.
uasort( $fkinfood_block_pattern_categories, function( $a, $b ) {
return strcmp( $a["label"], $b["label"] ); }
);
// Register block pattern categories.
foreach ( $fkinfood_block_pattern_categories as $slug => $settings ) {
register_block_pattern_category( $slug, $settings );
}
}
add_action( 'init', 'fkinfood_register_block_patterns' );
/* -----------------------------------------------------------------------------------------------
FILTER COMMENT FORM DEFAULTS
Modify the heading and title of the comments form.
--------------------------------------------------------------------------------------------------- */
function fkinfood_comment_form_defaults( $defaults ) {
return array_merge( $defaults, array(
'title_reply_before' => '<h2 id="reply-title" class="comment-reply-title">',
'title_reply_after' => '</h2>',
'title_reply' => __( 'Reply', 'fkinfood' )
) );
}
add_filter( 'comment_form_defaults', 'fkinfood_comment_form_defaults' );
/* -----------------------------------------------------------------------------------------------
BLOCK STYLES
Register theme specific block styles.
--------------------------------------------------------------------------------------------------- */
function fkinfood_register_block_styles() {
// Column: -90° Contents On Desktop
register_block_style( 'core/column', array(
'name' => 'fkinfood-minus-90-deg-column-content-desktop',
'label' => esc_html__( '-90° Contents On Desktop', 'fkinfood' ),
) );
// Cover: Background Blur
register_block_style( 'core/cover', array(
'name' => 'fkinfood-bg-blur',
'label' => esc_html__( 'Overlay Blur', 'fkinfood' ),
) );
// Featured Image: Ratio: 1/1
register_block_style( 'core/post-featured-image', array(
'name' => 'fkinfood-ar-1x1',
'label' => esc_html__( 'Ratio: 1/1', 'fkinfood' ),
) );
// Featured Image: Ratio: 4/3
register_block_style( 'core/post-featured-image', array(
'name' => 'fkinfood-ar-4x3',
'label' => esc_html__( 'Ratio: 4/3', 'fkinfood' ),
) );
// Heading, Paragraph: Tabular Numerals
foreach( array( 'core/heading', 'core/paragraph' ) as $block_name ) {
register_block_style( $block_name, array(
'name' => 'fkinfood-tabular-nums',
'label' => esc_html__( 'Tabular Numerals', 'fkinfood' ),
) );
}
// Post Comments Form: Rotated Title to the Right on Desktop
register_block_style( 'core/post-comments-form', array(
'name' => 'fkinfood-rotated-title',
'label' => esc_html__( 'Rotated Title to the Right on Desktop', 'fkinfood' ),
) );
// Term: Buttons
register_block_style( 'core/post-terms', array(
'name' => 'fkinfood-terms-buttons',
'label' => esc_html__( 'Buttons', 'fkinfood' ),
) );
}
add_action( 'init', 'fkinfood_register_block_styles' );
2023-12-23 14:09:00 +00:00
function disable_author_page() {
global $wp_query;
if ( is_author() ) {
wp_redirect(get_option('home'), 301);
exit;
}
}
add_action( 'template_redirect', 'disable_author_page' );