diff --git a/app/admin.php b/app/admin.php index 3254f2b..97fb6c2 100644 --- a/app/admin.php +++ b/app/admin.php @@ -66,49 +66,6 @@ add_action('customize_register', function (\WP_Customize_Manager $wp_customize) 'section' => 'pb_network_social', 'settings' => 'pb_network_twitter', ]); - $wp_customize->add_section('pb_front_page_content', [ - 'title' => __('Front Page Content', 'aldine'), - 'priority' => 20, - ]); - for ($i = 1; $i < 5; $i++) { - $wp_customize->add_setting("pb_front_page_block_${i}_title", [ - 'type' => 'option', - 'sanitize_callback' => 'sanitize_text_field', - ]); - $wp_customize->add_control("pb_front_page_block_${i}_title", [ - 'label' => sprintf(__('Block %d Title', 'aldine'), $i), - 'section' => 'pb_front_page_content', - 'settings' => "pb_front_page_block_${i}_title", - ]); - $wp_customize->add_setting("pb_front_page_block_${i}_content", [ - 'type' => 'option', - 'sanitize_callback' => 'sanitize_textarea_field', - ]); - $wp_customize->add_control("pb_front_page_block_${i}_content", [ - 'label' => sprintf(__('Block %d Content', 'aldine'), $i), - 'type' => 'textarea', - 'section' => 'pb_front_page_content', - 'settings' => "pb_front_page_block_${i}_content", - ]); - $wp_customize->add_setting("pb_front_page_block_${i}_button_title", [ - 'type' => 'option', - 'sanitize_callback' => 'sanitize_text_field', - ]); - $wp_customize->add_control("pb_front_page_block_${i}_button_title", [ - 'label' => sprintf(__('Block %d Button Title', 'aldine'), $i), - 'section' => 'pb_front_page_content', - 'settings' => "pb_front_page_block_${i}_button_title", - ]); - $wp_customize->add_setting("pb_front_page_block_${i}_button_url", [ - 'type' => 'option', - 'sanitize_callback' => 'esc_url_raw', - ]); - $wp_customize->add_control("pb_front_page_block_${i}_button_url", [ - 'label' => sprintf(__('Block %d Button URL', 'aldine'), $i), - 'section' => 'pb_front_page_content', - 'settings' => "pb_front_page_block_${i}_button_url", - ]); - } $wp_customize->add_section('pb_front_page_catalog', [ 'title' => __('Front Page Catalog', 'aldine'), 'priority' => 25, diff --git a/app/controllers/FrontPage.php b/app/controllers/FrontPage.php index c5d611c..f2c05d7 100644 --- a/app/controllers/FrontPage.php +++ b/app/controllers/FrontPage.php @@ -8,13 +8,15 @@ class FrontPage extends Controller { public function blockCount() { - $c = 0; - for ($i = 1; $i < 5; $i++) { - if (get_option("pb_front_page_block_${i}_content")) { - $c++; - } - } - return $c; + global $_wp_sidebars_widgets; + if (empty($_wp_sidebars_widgets)) { + $_wp_sidebars_widgets = get_option('sidebars_widgets', []); + } + $sidebars_widgets_count = $_wp_sidebars_widgets; + if (isset($sidebars_widgets_count['front-page-block'])) { + return count($sidebars_widgets_count['front-page-block']); + } + return 1; } public function blocks() diff --git a/app/setup.php b/app/setup.php index ed271cd..840ed45 100644 --- a/app/setup.php +++ b/app/setup.php @@ -109,8 +109,12 @@ add_action('widgets_init', function () { ]; register_sidebar([ 'name' => __('Front Page Content', 'aldine'), - 'id' => 'front-page-block' - ] + $config); + 'id' => 'front-page-block', + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

' + ]); register_sidebar([ 'name' => __('Network Footer Block 1', 'aldine'), 'id' => 'network-footer-block-1' diff --git a/resources/assets/styles/components/_buttons.scss b/resources/assets/styles/components/_buttons.scss index 6af6a18..96ba3e5 100644 --- a/resources/assets/styles/components/_buttons.scss +++ b/resources/assets/styles/components/_buttons.scss @@ -3,7 +3,7 @@ width: 250px; height: 60px; margin-top: 2em; - padding: 1.25em; + padding: 1em; border: 2px solid $black; border-radius: 3px; background: $black; diff --git a/resources/assets/styles/layouts/_pages.scss b/resources/assets/styles/layouts/_pages.scss index 300115d..322c0e1 100644 --- a/resources/assets/styles/layouts/_pages.scss +++ b/resources/assets/styles/layouts/_pages.scss @@ -1,7 +1,9 @@ .home { - .block { + .widget, + .latest-books { height: 445px; background-color: $white; + text-align: center; h3 { font-size: em(30); @@ -20,106 +22,99 @@ } } - .widget p { + p { font-size: em(16); line-height: (32/16); } + } + + .widget { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + } - &.latest-books { + .blocks.blocks-2 { + .widget_text:nth-child(2) { + border: solid 2px $brand-primary; box-shadow: unset; - height: auto; - padding-bottom: 50px; + } + } - h3 { - margin-top: 70px; - } + .blocks.blocks-4 { + .widget_text:nth-child(2) { + color: $white; + background: $brand-secondary; - .inside { - padding: 0; + h3::before { + background-color: $white; } - .navigation { - a { - &.slick-disabled { - opacity: 0; - } + .button { + border-color: $white; + background: transparent; + + &:hover, + &:focus { + color: $brand-secondary; + background: $white; } } } - .books { - .book, - .slick-slide { - width: 100vw; - height: 386px; - margin: 45px 0 0; - padding: 0 29.5px; - border: solid 2px; - - a { - font-family: $font-family-sans-serif; - color: $white; - text-decoration: none; - } - - .subject { - height: 91px; - margin-top: 24px; - font-size: em(24); - } - - .title { - height: 329px - 115px; - font-size: em(30); - font-weight: 500; - } - - .read-more { - font-size: em(18); - } - } + .widget_text:nth-child(3) { + border: solid 2px $brand-primary; + box-shadow: unset; } } - .one-two { - width: 100%; - display: flex; - flex-direction: column; + .latest-books { + box-shadow: unset; + height: auto; + padding-bottom: 0 0 50px; - .block-2 { - background: $brand-secondary; + h3 { + margin-top: 70px; + } - p, - h3 { + .book, + .slick-slide { + width: 100vw; + height: 386px; + margin: 45px 0 0; + padding: 0 29.5px; + border: solid 2px; + + a { + font-family: $font-family-sans-serif; color: $white; + text-decoration: none; } - h3::before { - background-color: $white; + .subject { + height: 91px; + margin-top: 24px; + font-size: em(24); + } + + .title { + height: 329px - 115px; + font-size: em(30); + font-weight: 500; + } + + .read-more { + font-size: em(18); } } - } - .main > .block-2, - .one-two + .block { - background: transparent; - border: solid 2px $brand-primary; - // margin-bottom: 401px; - - &::after { - position: absolute; - left: 0; - top: 1840px; - content: ""; - display: block; - display: none; - width: 100vw; - height: 600px; - z-index: -1; - // background: url('../images/banner-two.jpg'); - background-position: center; - background-repeat: no-repeat; - background-size: cover; + .navigation { + a { + &.slick-disabled { + opacity: 0; + } + } } } } @@ -130,9 +125,10 @@ margin-top: -366px; } - .block { + .widget { width: 775px; margin-bottom: 119px; + padding: 0 90px; box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09); h3 { @@ -148,33 +144,11 @@ font-size: em(18); line-height: (32/18); } - - .inside { - width: 595px; - } } - .one-two { - align-items: center; - } - - .main > .block-2, - .one-two + .block { - border: solid 2px $brand-primary; - box-shadow: unset; - - &::after { - top: 2020px; - } - } - - .block.latest-books { + .latest-books { width: 100%; - .inside { - width: 100%; - } - .books { flex-direction: row; justify-content: space-between; @@ -195,26 +169,15 @@ @media (min-width: $large) { .home { - .block { + .widget { width: 1115px; height: 494px; } - .main > .block-2, - .one-two + .block { - &::after { - top: 2150px; - } - } - - .block.latest-books { + .latest-books { width: 1200px; margin-bottom: 0; - .inside { - width: 100%; - } - .book, .slick-slide { width: 367px; @@ -230,30 +193,29 @@ @media (min-width: $extra-large) { .home { - .block { + .widget { width: 1115px; box-shadow: -3px 5px 4px 2px rgba(135, 135, 135, 0.09); } - .one-two { - flex-direction: row; - justify-content: space-between; + .blocks.blocks-4 { + display: flex; + flex-flow: row wrap; width: 1615px; - .block { - border-radius: 4px; - width: 775px; + .widget_text { + width: 1115px; + margin-right: auto; + margin-left: auto; + } - .inside { - width: 595px; - } + .widget_text:nth-child(1), + .widget_text:nth-child(2) { + width: 775px; } - } - .main > .block-2, - .one-two + .block { - &::after { - top: 1550px; + .widget_text:nth-child(1) { + margin-right: 65px; } } } diff --git a/resources/views/front-page.blade.php b/resources/views/front-page.blade.php index c8c9254..58742a0 100644 --- a/resources/views/front-page.blade.php +++ b/resources/views/front-page.blade.php @@ -1,8 +1,11 @@ @extends('layouts.app') @section('content') - @if($block_count === 0) - @component('partials.front-page-block', ['index' => 1]) +
+ @if(is_active_sidebar('front-page-block')) + @php(dynamic_sidebar('front-page-block')) + @else + @component('front-page-block') @slot('title') {{ __('About Pressbooks', 'aldine') }} @endslot @@ -14,47 +17,9 @@ {{ network_home_url('/about/') }} @endslot @endcomponent - @elseif($block_count < 4) - @foreach($blocks as $block) - @component('partials.front-page-block', [ - 'index' => $loop->iteration, - 'title' => (isset($block['title'])) ? $block['title'] : false, - 'button_title' => (isset($block['button_title'])) ? $block['button_title'] : false, - 'button_url' => (isset($block['button_url'])) ? $block['button_url'] : false, - ]) - {!! $block['content'] !!} - @endcomponent - @endforeach - @elseif($block_count === 4) -
- @for($i = 0; $i < 2; $i++) - @component('partials.front-page-block', [ - 'index' => $i + 1, - 'title' => (isset($blocks[$i]['title'])) ? $blocks[$i]['title'] : false, - 'button_title' => (isset($blocks[$i]['button_title'])) ? $blocks[$i]['button_title'] : false, - 'button_url' => (isset($blocks[$i]['button_url'])) ? $blocks[$i]['button_url'] : false, - ]) - {!! $blocks[$i]['content'] !!} - @endcomponent - @endfor -
- @for($i = 2; $i < $block_count; $i++) - @component('partials.front-page-block', [ - 'index' => $i + 1, - 'title' => (isset($blocks[$i]['title'])) ? $blocks[$i]['title'] : false, - 'button_title' => (isset($blocks[$i]['button_title'])) ? $blocks[$i]['button_title'] : false, - 'button_url' => (isset($blocks[$i]['button_url'])) ? $blocks[$i]['button_url'] : false, - ]) - {!! $blocks[$i]['content'] !!} - @endcomponent - @endfor - @endif - @if(is_active_sidebar('front-page-block')) - @component('partials.front-page-block', ['index' => 'custom', 'title' => false, 'button_title' => false, 'button_url' => false]) - @php(dynamic_sidebar('front-page-block')) - @endcomponent @endif @if(get_option('pb_front_page_catalog')) @include('partials.front-page-catalog') @endif +
@endsection diff --git a/resources/views/partials/front-page-block.blade.php b/resources/views/partials/front-page-block.blade.php index 777ced4..51e2a3f 100644 --- a/resources/views/partials/front-page-block.blade.php +++ b/resources/views/partials/front-page-block.blade.php @@ -1,11 +1,7 @@ -
+
- @if($title) -

{{ $title }}

- @endif +

{{ $title }}

{{ $slot }} - @if($button_url && $button_title) - {{ $button_title }} - @endif + {{ $button_title }}