diff --git a/assets/styles/layouts/_header.scss b/assets/styles/layouts/_header.scss index 2304858..eaa5dfe 100644 --- a/assets/styles/layouts/_header.scss +++ b/assets/styles/layouts/_header.scss @@ -20,12 +20,19 @@ } } -.home #content { +.home #content{ margin-top: -540px; background: transparent; + &.custom-homepage { + margin-top: 0; + } @media #{$breakpoint-large} { margin-top: -880px; + + &.custom-homepage { + margin-top: 0; + } } } @@ -68,7 +75,7 @@ } } -.page:not(.home) .header { +.page .header { height: rem(240); @media #{$breakpoint-large} { diff --git a/assets/styles/layouts/_page.scss b/assets/styles/layouts/_page.scss index 954a7b5..740d0a4 100644 --- a/assets/styles/layouts/_page.scss +++ b/assets/styles/layouts/_page.scss @@ -22,6 +22,6 @@ body { } } -.page.home:not(.has-sections) article { +.page article { margin-top: 0; } diff --git a/dist/styles/aldine.css b/dist/styles/aldine.css index cae2b0b..711abcf 100644 --- a/dist/styles/aldine.css +++ b/dist/styles/aldine.css @@ -2155,10 +2155,16 @@ input[type=submit] { margin-top: -540px; background: transparent; } +.home #content.custom-homepage { + margin-top: 0; +} @media screen and (min-width: 60rem) { .home #content { margin-top: -880px; } + .home #content.custom-homepage { + margin-top: 0; + } } .home .entry-header { @@ -2208,11 +2214,11 @@ input[type=submit] { } } -.page:not(.home) .header { +.page .header { height: 15rem; } @media screen and (min-width: 60rem) { - .page:not(.home) .header { + .page .header { height: 55rem; } } @@ -2282,7 +2288,7 @@ body #content a.call-to-action { text-decoration: none; } -.page.home:not(.has-sections) article { +.page article { margin-top: 0; } diff --git a/header.php b/header.php index ea0041f..7d4838f 100644 --- a/header.php +++ b/header.php @@ -9,6 +9,8 @@ * @package Aldine */ +use function Aldine\Helpers\custom_homepage; + ?> > @@ -20,7 +22,7 @@ - data-barba="wrapper"> +> @@ -102,4 +104,4 @@ -
+
diff --git a/inc/customizer/namespace.php b/inc/customizer/namespace.php index b2a7385..7877492 100644 --- a/inc/customizer/namespace.php +++ b/inc/customizer/namespace.php @@ -227,6 +227,28 @@ function customize_register( \WP_Customize_Manager $wp_customize ) { ] ); } + + $wp_customize->add_section( + 'page_on_front', [ + 'title' => __( 'Front Page Settings', 'pressbooks-aldine' ), + 'priority' => 24, + ] + ); + + $wp_customize->add_setting( + 'page_on_front', [ + 'type' => 'option', + 'capability' => 'manage_options', + ], + ); + + $wp_customize->add_control( + 'page_on_front', [ + 'label' => __( 'Network Home Page', 'pressbooks-aldine' ), + 'section' => 'page_on_front', + 'type' => 'dropdown-pages', + ] + ); } $wp_customize->add_section( diff --git a/inc/helpers/namespace.php b/inc/helpers/namespace.php index 9533865..6b74e3f 100644 --- a/inc/helpers/namespace.php +++ b/inc/helpers/namespace.php @@ -334,7 +334,7 @@ function get_default_menu( $items = '' ) { 'SignOut' => 'sign-out', ]; - $link = ( is_front_page() ) ? network_home_url( '#main' ) : network_home_url( '/' ); + $link = network_home_url( '/' ); $items = sprintf( '
  • %2$s
  • ', $link, @@ -565,3 +565,19 @@ function get_catalog_page(): ?\WP_Post { ]); return $catalog_pages[0] ?? null; } + +/** + * This function generate a class to know if the current page is a custom frontpage. + * + * @return string + */ +function custom_homepage(): string { + $home_page = get_option( 'page_on_front' ); + if ( $home_page ) { + $template = get_page_template_slug( $home_page ); + if ( 'page-catalog.php' === $template ) { + return 'custom-homepage'; + } + } + return ''; +}