Skip to content

Commit 51b31d2

Browse files
committed
Create new panel titled "Blog Settings" #205
1 parent fefa400 commit 51b31d2

File tree

4 files changed

+84
-12
lines changed

4 files changed

+84
-12
lines changed

inc/customizer.php

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ function shapely_customizer( $wp_customize ) {
144144
$header_image = $wp_customize->get_control( 'header_image' );
145145
if ( $header_image ) {
146146
$header_image->section = 'shapely_blog_section';
147-
$header_image->label = esc_html__( 'Blog Index Header Image', 'shapely' );
147+
$header_image->description = esc_html__( 'Blog Index Header Image', 'shapely' );
148148
$header_image->priority = 31;
149149
}
150150

@@ -394,6 +394,27 @@ function shapely_customizer( $wp_customize ) {
394394
) ) );
395395
} // End if().
396396

397+
$wp_customize->add_setting( 'title_in_header', array(
398+
'default' => 1,
399+
'sanitize_callback' => 'shapely_sanitize_checkbox',
400+
) );
401+
$wp_customize->add_setting( 'title_above_post', array(
402+
'default' => 1,
403+
'sanitize_callback' => 'shapely_sanitize_checkbox',
404+
) );
405+
$wp_customize->add_setting( 'post_date', array(
406+
'default' => 1,
407+
'sanitize_callback' => 'shapely_sanitize_checkbox',
408+
) );
409+
$wp_customize->add_setting( 'post_category', array(
410+
'default' => 1,
411+
'sanitize_callback' => 'shapely_sanitize_checkbox',
412+
) );
413+
$wp_customize->add_setting( 'post_author', array(
414+
'default' => 1,
415+
'sanitize_callback' => 'shapely_sanitize_checkbox',
416+
) );
417+
397418
$wp_customize->add_setting( 'first_letter_caps', array(
398419
'default' => 1,
399420
'sanitize_callback' => 'shapely_sanitize_checkbox',
@@ -421,6 +442,42 @@ function shapely_customizer( $wp_customize ) {
421442

422443
// Single Post Settings
423444
if ( class_exists( 'Epsilon_Control_Toggle' ) ) {
445+
446+
$wp_customize->add_control( new Epsilon_Control_Toggle( $wp_customize, 'title_in_header', array(
447+
'type' => 'mte-toggle',
448+
'label' => esc_html__( 'Show title in header', 'shapely' ),
449+
'description' => esc_html__( 'This will show/hide the post title from callout', 'shapely' ),
450+
'section' => 'shapely_single_post_section',
451+
) ) );
452+
453+
$wp_customize->add_control( new Epsilon_Control_Toggle( $wp_customize, 'title_above_post', array(
454+
'type' => 'mte-toggle',
455+
'label' => esc_html__( 'Show title above post', 'shapely' ),
456+
'description' => esc_html__( 'This will show/hide the post title above post content', 'shapely' ),
457+
'section' => 'shapely_single_post_section',
458+
) ) );
459+
460+
$wp_customize->add_control( new Epsilon_Control_Toggle( $wp_customize, 'post_date', array(
461+
'type' => 'mte-toggle',
462+
'label' => esc_html__( 'Show the date', 'shapely' ),
463+
'description' => esc_html__( 'This will show/hide the date when post was published', 'shapely' ),
464+
'section' => 'shapely_single_post_section',
465+
) ) );
466+
467+
$wp_customize->add_control( new Epsilon_Control_Toggle( $wp_customize, 'post_author', array(
468+
'type' => 'mte-toggle',
469+
'label' => esc_html__( 'Show the author', 'shapely' ),
470+
'description' => esc_html__( 'This will show/hide the author who written the post under the post title', 'shapely' ),
471+
'section' => 'shapely_single_post_section',
472+
) ) );
473+
474+
$wp_customize->add_control( new Epsilon_Control_Toggle( $wp_customize, 'post_category', array(
475+
'type' => 'mte-toggle',
476+
'label' => esc_html__( 'Show the category', 'shapely' ),
477+
'description' => esc_html__( 'This will show/hide the categories of post', 'shapely' ),
478+
'section' => 'shapely_single_post_section',
479+
) ) );
480+
424481
$wp_customize->add_control( new Epsilon_Control_Toggle( $wp_customize, 'first_letter_caps', array(
425482
'type' => 'mte-toggle',
426483
'label' => esc_html__( 'First Letter Caps', 'shapely' ),

inc/extras.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,7 @@ function shapely_show_sidebar() {
568568
* Top Callout
569569
*/
570570
function shapely_top_callout() {
571-
if ( get_theme_mod( 'top_callout', true ) ) {
571+
if ( ( get_theme_mod( 'top_callout', true ) && ! is_single() ) || ( is_single() && get_theme_mod( 'title_in_header', true ) ) ) {
572572
$header = get_header_image();
573573
?>
574574
<section

inc/template-tags.php

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ function shapely_posted_on() {
4141
* Prints HTML with meta information for the current post-date/time and author.
4242
*/
4343
function shapely_posted_on_no_cat() {
44+
45+
$post_author = get_theme_mod( 'post_author', true );
46+
$post_date = get_theme_mod( 'post_date', true );
4447
$time_string = '<time class="entry-date published updated" datetime="%1$s">%2$s</time>';
4548
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
4649
$time_string = '<time class="entry-date published" datetime="%1$s">%2$s</time><time class="updated" datetime="%3$s">%4$s</time>';
@@ -51,15 +54,22 @@ function shapely_posted_on_no_cat() {
5154
esc_html( get_the_date() ),
5255
esc_attr( get_the_modified_date( 'c' ) ),
5356
esc_html( get_the_modified_date() )
54-
); ?>
57+
);
58+
59+
if ( $post_date || $post_author ) :
60+
?>
5561

5662
<ul class="post-meta">
57-
<li><span class="posted-on"><?php echo $time_string; ?></span></li>
58-
<li><span><?php echo esc_html__( 'by', 'shapely' ); ?> <a
59-
href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>"
60-
title="<?php echo esc_attr( get_the_author() ); ?>"><?php esc_html( the_author() ); ?></a></span>
61-
</li>
63+
<?php if ( $post_date ): ?>
64+
<li><span class="posted-on"><?php echo $time_string; ?></span></li>
65+
<?php endif ?>
66+
67+
<?php if ( $post_author ): ?>
68+
<li><span><?php echo esc_html__( 'by', 'shapely' ); ?> <a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>" title="<?php echo esc_attr( get_the_author() ); ?>"><?php esc_html( the_author() ); ?></a></span></li>
69+
<?php endif ?>
70+
6271
</ul><?php
72+
endif;
6373
}
6474
endif;
6575

template-parts/content.php

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
$enable_tags = get_theme_mod( 'tags_post_meta', true );
1212
$post_author = get_theme_mod( 'post_author_area', true );
1313
$left_side = get_theme_mod( 'post_author_left_side', false );
14+
$post_title = get_theme_mod( 'title_above_post', true );
15+
$post_category = get_theme_mod( 'post_category', true );
1416

1517
?>
1618
<article id="post-<?php the_ID(); ?>" <?php post_class( 'post-content post-grid-wide' ); ?>>
@@ -45,7 +47,7 @@
4547
<?php echo wp_kses( $image, $allowed_tags ); ?>
4648
</a>
4749

48-
<?php if ( isset( $category[0] ) ) : ?>
50+
<?php if ( isset( $category[0] ) && $post_category ) : ?>
4951
<span class="shapely-category">
5052
<a href="<?php echo esc_url( get_category_link( $category[0]->term_id ) ); ?>">
5153
<?php echo esc_html( $category[0]->name ); ?>
@@ -56,9 +58,12 @@
5658
?>
5759
</header><!-- .entry-header -->
5860
<div class="entry-content">
59-
<h2 class="post-title">
60-
<a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo wp_trim_words( get_the_title(), 9 ); ?></a>
61-
</h2>
61+
<?php if ( $post_title ): ?>
62+
<h2 class="post-title">
63+
<a href="<?php echo esc_url( get_the_permalink() ); ?>"><?php echo wp_trim_words( get_the_title(), 9 ); ?></a>
64+
</h2>
65+
<?php endif ?>
66+
6267

6368
<div class="entry-meta">
6469
<?php

0 commit comments

Comments
 (0)