From 995e5f8878d9bcc61a55b45d48389c1a709faf70 Mon Sep 17 00:00:00 2001 From: Tetrakern <26898880+Tetrakern@users.noreply.github.com> Date: Thu, 27 Jun 2024 13:37:17 +0200 Subject: [PATCH] Add header style text_center --- config.codekit3 | 15 +++++ css/customize/header-style-text-center.css | 1 + includes/functions/_customizer-settings.php | 1 + includes/functions/_customizer.php | 4 ++ includes/functions/hooks/_general_hooks.php | 59 +++++++++++++++++++ .../customize/header-style-text-center.scss | 29 +++++++++ 6 files changed, 109 insertions(+) create mode 100644 css/customize/header-style-text-center.css create mode 100644 src/scss/customize/header-style-text-center.scss diff --git a/config.codekit3 b/config.codekit3 index 3c0fec31..fb3e118e 100644 --- a/config.codekit3 +++ b/config.codekit3 @@ -3512,6 +3512,21 @@ "pg" : 0, "sct" : 0 }, + "\/src\/scss\/customize\/header-style-text-center.scss" : { + "aP" : 0, + "bl" : 0, + "co" : 0, + "dP" : 10, + "ec" : 0, + "ft" : 4, + "ma" : 0, + "oA" : 0, + "oAP" : "\/css\/customize\/header-style-text-center.css", + "oF" : 2, + "oS" : 3, + "pg" : 0, + "sct" : 0 + }, "\/src\/scss\/customize\/header-style-top-split.scss" : { "aP" : 0, "bl" : 0, diff --git a/css/customize/header-style-text-center.css b/css/customize/header-style-text-center.css new file mode 100644 index 00000000..dd40685f --- /dev/null +++ b/css/customize/header-style-text-center.css @@ -0,0 +1 @@ +.text-center-header{display:flex;flex-direction:column;align-items:center;justify-content:center;height:var(--header-height)}.text-center-header__content{text-align:center;margin:1rem 0 2rem;max-width:var(--site-width)}.text-center-header__content:not(._no-text-shadow){text-shadow:var(--site-title-text-shadow)}.text-center-header__title{color:var(--site-title-heading-color);font:900 var(--site-title-font-size)/1.3 var(--ff-site-title);letter-spacing:0}.text-center-header__tagline{color:var(--site-title-tagline-color);font:500 var(--site-title-tagline-font-size)/1.3 var(--ff-site-title);letter-spacing:0} diff --git a/includes/functions/_customizer-settings.php b/includes/functions/_customizer-settings.php index c2368212..a493ef58 100644 --- a/includes/functions/_customizer-settings.php +++ b/includes/functions/_customizer-settings.php @@ -1430,6 +1430,7 @@ function fictioneer_add_layout_customizer_settings( $manager ) { 'overlay' => _x( 'Overlay (Image)', 'Customizer header style option.', 'fictioneer' ), 'top' => _x( 'Top', 'Customizer header style option.', 'fictioneer' ), 'wide' => _x( 'Wide', 'Customizer header style option.', 'fictioneer' ), + 'text_center' => _x( 'Text (Center)', 'Customizer header style option.', 'fictioneer' ), 'none' => _x( 'None', 'Customizer header style option.', 'fictioneer' ) ); diff --git a/includes/functions/_customizer.php b/includes/functions/_customizer.php index 8d0eb9f6..383d2558 100644 --- a/includes/functions/_customizer.php +++ b/includes/functions/_customizer.php @@ -956,6 +956,10 @@ function fictioneer_build_customize_css( $context = null ) { $css .= fictioneer_get_customizer_css_snippet( 'header-style-wide' ); } + if ( $header_style === 'text_center' ) { + $css .= fictioneer_get_customizer_css_snippet( 'header-style-text-center' ); + } + // --- Page styles ----------------------------------------------------------- if ( $page_style === 'polygon-mask-image-battered-ringbook' || $page_style === 'polygon-battered' ) { diff --git a/includes/functions/hooks/_general_hooks.php b/includes/functions/hooks/_general_hooks.php index a98f672e..6def528d 100644 --- a/includes/functions/hooks/_general_hooks.php +++ b/includes/functions/hooks/_general_hooks.php @@ -360,6 +360,65 @@ function fictioneer_inner_header( $args ) { } add_action( 'fictioneer_site', 'fictioneer_inner_header', 20 ); +// ============================================================================= +// OUTPUT TEXT CENTER HEADER +// ============================================================================= + +/** + * Outputs the HTML for the text (center) header + * + * @since 5.21.0 + * + * @param int|null $args['post_id'] Optional. Current post ID. + * @param int|null $args['story_id'] Optional. Current story ID (if chapter). + * @param string|boolean $args['header_image_url'] URL of the filtered header image or false. + * @param array $args['header_args'] Arguments passed to the header.php partial. + */ + +function fictioneer_text_center_header( $args ) { + // Return early if... + if ( ( $args['header_args']['blank'] ?? 0 ) || ! display_header_text() ) { + return; + } + + // Setup + $theme_mod = get_theme_mod( 'header_style', 'default' ); + + // Abort if... + if ( $theme_mod !== 'text_center' || ( $args['header_args']['no_header'] ?? 0 ) ) { + return; + } + + // Render Elementor or theme template + if ( ! function_exists( 'elementor_theme_do_location' ) || ! elementor_theme_do_location( 'header' ) ) { + // Start HTML ---> ?> +
<{$title_tag} class='text-center-header__title'>%s%s", + esc_url( home_url() ), + get_bloginfo( 'name' ), + get_bloginfo( 'description' ) ? + '
' . get_bloginfo( 'description' ) . '
' : '' + ); + } + ); + + // Render everything via action + do_action( 'fictioneer_text_center_header', $args ); + ?> +
+