Browse Source

Fix pages without content (close #102)

pull/107/head
Ned Zimmerman 7 years ago
parent
commit
0866e9afe8
No known key found for this signature in database
GPG Key ID: FF56334A013120CA
  1. 20
      assets/styles/layouts/_page.scss
  2. 2
      dist/mix-manifest.json
  3. 2
      dist/styles/aldine.css
  4. 2
      inc/filters/namespace.php
  5. 6
      inc/shortcodes/namespace.php
  6. 13
      partials/content-front-page.php

20
assets/styles/layouts/_page.scss

@ -1 +1,19 @@
// TODO
body {
display: flex;
min-height: 100vh;
flex-direction: column;
#page {
flex: 1;
display: flex;
flex-direction: column;
}
#content {
flex-grow: 1;
}
}
.page.home:not(.has-sections) article {
margin-top: 0;
}

2
dist/mix-manifest.json vendored

@ -1,6 +1,6 @@
{
"/scripts/aldine.js": "/scripts/aldine.js?id=1f58027f7de9942caf57",
"/styles/aldine.css": "/styles/aldine.css?id=b1044ba6e1ca10075c15",
"/styles/aldine.css": "/styles/aldine.css?id=2648daa49889948f53c9",
"/styles/editor.css": "/styles/editor.css?id=e96b3d10ea63fa07d09b",
"/scripts/customizer.js": "/scripts/customizer.js?id=1b0d3cfc1d85f460af53",
"/scripts/catalog-admin.js": "/scripts/catalog-admin.js?id=d25f1240496bd3607338"

2
dist/styles/aldine.css vendored

File diff suppressed because one or more lines are too long

2
inc/filters/namespace.php

@ -26,7 +26,7 @@ function body_classes( array $classes ) {
}
/** Add .has-sections if page content has sections */
if ( is_single() || is_page() && has_sections( get_the_ID() ) ) {
if ( is_single() || is_front_page() || is_page() && has_sections( get_the_ID() ) ) {
$classes[] = 'has-sections';
}

6
inc/shortcodes/namespace.php

@ -18,7 +18,7 @@ namespace Aldine\Shortcodes;
function page_section( $atts, $content = null ) {
$atts = shortcode_atts(
[
'title' => 'Page Section',
'title' => '',
'variant' => '',
],
$atts,
@ -26,9 +26,9 @@ function page_section( $atts, $content = null ) {
);
return sprintf(
'<div class="page-section%1$s"><h2>%2$s</h2>%3$s</div>',
'<div class="page-section%1$s">%2$s%3$s</div>',
( $atts['variant'] ) ? " page-section--{$atts['variant']}" : '',
$atts['title'],
( $atts['title'] ) ? "<h2>{$atts['title']}</h2>" : '',
$content
);
}

13
partials/content-front-page.php

@ -12,6 +12,7 @@
<?php
use function Aldine\Helpers\get_catalog_data;
use function Aldine\Helpers\has_sections;
$front_page_catalog = get_option( 'pb_front_page_catalog' );
$latest_books_title = get_option( 'pb_front_page_catalog_title', __( 'Our Latest Titles', 'pressbooks-aldine' ) );
@ -32,7 +33,17 @@ if ( get_option( 'pb_front_page_catalog' ) ) {
<div class="entry-content">
<?php
the_content();
if ( has_sections( $post->ID ) ) {
the_content();
} else {
echo apply_filters(
'the_content',
sprintf(
'[aldine_page_section]%s[/aldine_page_section]',
get_post_field( 'post_content', $post )
)
);
}
?>
</div><!-- .entry-content -->
</article><!-- #post-<?php the_ID(); ?> -->

Loading…
Cancel
Save