Skip to content

Commit

Permalink
added Last Updated option to the Customizer
Browse files Browse the repository at this point in the history
  • Loading branch information
BenSibley committed Feb 18, 2019
1 parent 5ccdd0c commit 1ea932e
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 4 deletions.
1 change: 1 addition & 0 deletions content.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
</div>
<?php ct_founder_featured_image(); ?>
<div class="post-content">
<?php ct_founder_output_last_updated_date(); ?>
<?php the_content(); ?>
<?php wp_link_pages( array(
'before' => '<p class="singular-pagination">' . __( 'Pages:', 'founder' ),
Expand Down
21 changes: 20 additions & 1 deletion functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -760,4 +760,23 @@ function ct_founder_scroll_to_top_arrow() {
echo '<button id="scroll-to-top" class="scroll-to-top"><span class="screen-reader-text">'. esc_html__('Scroll to the top', 'founder') .'</span><i class="fas fa-arrow-up"></i></button>';
}
}
add_action( 'body_bottom', 'ct_founder_scroll_to_top_arrow');
add_action( 'body_bottom', 'ct_founder_scroll_to_top_arrow');

//----------------------------------------------------------------------------------
// Output the "Last Updated" date on posts
//----------------------------------------------------------------------------------
function ct_founder_output_last_updated_date() {

global $post;

if ( get_the_modified_date() != get_the_date() ) {
$updated_post = get_post_meta( $post->ID, 'ct_founder_last_updated', true );
$updated_customizer = get_theme_mod( 'last_updated' );
if (
( $updated_customizer == 'yes' && ($updated_post != 'no') )
|| $updated_post == 'yes'
) {
echo '<p class="last-updated">'. __("Last updated on", "founder") . ' ' . get_the_modified_date() . ' </p>';
}
}
}
26 changes: 25 additions & 1 deletion inc/customizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,30 @@ public function render_content() {
)
) );

/***** Additional Options *****/

// section
$wp_customize->add_section( 'ct_founder_additional_options', array(
'title' => __( 'Additional Options', 'founder' ),
'priority' => 75
) );
// setting - last updated
$wp_customize->add_setting( 'last_updated', array(
'default' => 'no',
'sanitize_callback' => 'founder_sanitize_yes_no_settings'
) );
// control - last updated
$wp_customize->add_control( 'last_updated', array(
'label' => __( 'Display the date each post was last updated?', 'founder' ),
'section' => 'ct_founder_additional_options',
'settings' => 'last_updated',
'type' => 'radio',
'choices' => array(
'yes' => __( 'Yes', 'founder' ),
'no' => __( 'No', 'founder' )
)
) );

/***** Custom CSS *****/

if ( function_exists( 'wp_update_custom_css_post' ) ) {
Expand All @@ -326,7 +350,7 @@ public function render_content() {
// section
$wp_customize->add_section( 'founder_custom_css', array(
'title' => __( 'Custom CSS', 'founder' ),
'priority' => 70
'priority' => 80
) );
// setting
$wp_customize->add_setting( 'custom_css', array(
Expand Down
4 changes: 4 additions & 0 deletions rtl.css
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,10 @@ a img {
background: #EDEDED;
}

.last-updated {
font-style: italic;
}

.wp-block-image.alignfull,
.wp-block-cover {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion rtl.min.css

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions sass/_post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,9 @@
background: $color-gray-93;
}
}
.last-updated {
font-style: italic;
}

// New Gutenberg blocks
.wp-block-image.alignfull,
Expand Down
4 changes: 4 additions & 0 deletions style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1521,6 +1521,10 @@ a img {
background: #EDEDED;
}

.last-updated {
font-style: italic;
}

.wp-block-image.alignfull,
.wp-block-cover {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion style.min.css

Large diffs are not rendered by default.

0 comments on commit 1ea932e

Please sign in to comment.