Use constants for Latest * shortcodes

Easy to override in child templates and allow a more precise customization than via the settings page.
This commit is contained in:
Tetrakern 2023-06-06 20:04:45 +02:00
parent ca29adf2dc
commit ad6d54482d
7 changed files with 25 additions and 16 deletions

View File

@ -70,9 +70,24 @@ if ( ! defined( 'FICTIONEER_SITE_DESCRIPTION' ) ) {
define( 'FICTIONEER_SITE_DESCRIPTION', get_bloginfo( 'description' ) );
}
// String: Latest Updates shortcode date format
if ( ! defined( 'FICTIONEER_SHORTCODE_DATE_LATEST_UPDATES' ) ) {
define( 'FICTIONEER_SHORTCODE_DATE_LATEST_UPDATES', get_option( 'fictioneer_subitem_short_date_format', 'M j' ) );
// String: Latest Updates shortcode list item date format
if ( ! defined( 'FICTIONEER_LATEST_UPDATES_LI_DATE' ) ) {
define( 'FICTIONEER_LATEST_UPDATES_LI_DATE', get_option( 'fictioneer_subitem_short_date_format', 'M j' ) ?: 'M j' );
}
// String: Latest Updates shortcode footer date format
if ( ! defined( 'FICTIONEER_LATEST_UPDATES_FOOTER_DATE' ) ) {
define( 'FICTIONEER_LATEST_UPDATES_FOOTER_DATE', get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y" );
}
// String: Latest Chapters shortcode footer date format
if ( ! defined( 'FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE' ) ) {
define( 'FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE', get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y" );
}
// String: Latest Stories shortcode footer date format
if ( ! defined( 'FICTIONEER_LATEST_STORIES_FOOTER_DATE' ) ) {
define( 'FICTIONEER_LATEST_STORIES_FOOTER_DATE', get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y" );
}
/*

View File

@ -129,7 +129,7 @@ $entries = new WP_Query( $query_args );
printf(
_x( '%1$s Words on %2$s', 'Small card: {n} Words on {Date}.', 'fictioneer' ),
fictioneer_shorten_number( get_post_meta( $post->ID, '_word_count', true ) ),
get_the_time( get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y" )
get_the_time( FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE )
);
?>
</div>

View File

@ -148,7 +148,7 @@ $entries = new WP_Query( $query_args );
<?php echo fictioneer_shorten_number( get_post_meta( $post->ID, '_word_count', true ) ); ?>
<i class="fa-regular fa-clock" title="<?php esc_attr_e( 'Last Updated', 'fictioneer' ) ?>"></i>
<?php the_modified_date( get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y" ); ?>
<?php echo get_the_time( FICTIONEER_LATEST_CHAPTERS_FOOTER_DATE ); ?>
<i class="fa-solid fa-message" title="<?php esc_attr_e( 'Comments', 'fictioneer' ) ?>"></i>
<?php echo get_comments_number(); ?>

View File

@ -167,9 +167,7 @@ $entries = new WP_Query( $query_args );
<?php echo $story['word_count_short']; ?>
<i class="fa-regular fa-clock" title="<?php esc_attr_e( 'Last Updated', 'fictioneer' ); ?>"></i>
<?php
echo get_the_modified_date( get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y", $post );
?>
<?php echo get_the_modified_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post ); ?>
<i class="<?php echo $story['icon']; ?>"></i>
<?php echo fcntr( $story['status'] ); ?>

View File

@ -163,9 +163,7 @@ $entries = new WP_Query( $query_args );
<?php echo $story['word_count_short']; ?>
<i class="fa-regular fa-clock" title="<?php esc_attr_e( 'Last Updated', 'fictioneer' ); ?>"></i>
<?php
echo get_the_modified_date( get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y", $post );
?>
<?php echo get_the_modified_date( FICTIONEER_LATEST_STORIES_FOOTER_DATE, $post ); ?>
<i class="<?php echo $story['icon']; ?>"></i>
<?php echo fcntr( $story['status'] ); ?>

View File

@ -160,7 +160,7 @@ $entries = new WP_Query( $query_args );
<?php
echo fictioneer_shorten_number( get_post_meta( $chapter_id, '_word_count', true ) );
echo '<span class="separator-dot">&#8196;&bull;&#8196;</span>';
echo get_the_date( FICTIONEER_SHORTCODE_DATE_LATEST_UPDATES, $chapter_id )
echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter_id )
?>
</div>
</li>

View File

@ -156,7 +156,7 @@ $entries = new WP_Query( $query_args );
<?php
echo fictioneer_shorten_number( get_post_meta( $chapter_id, '_word_count', true ) );
echo '<span class="separator-dot">&#8196;&bull;&#8196;</span>';
echo get_the_date( FICTIONEER_SHORTCODE_DATE_LATEST_UPDATES, $chapter_id )
echo get_the_date( FICTIONEER_LATEST_UPDATES_LI_DATE, $chapter_id )
?>
</div>
</li>
@ -218,9 +218,7 @@ $entries = new WP_Query( $query_args );
<?php echo $story['word_count_short']; ?>
<i class="fa-regular fa-clock" title="<?php esc_attr_e( 'Last Updated', 'fictioneer' ); ?>"></i>
<?php
echo get_the_modified_date( get_option( 'fictioneer_subitem_date_format', "M j, 'y" ) ?: "M j, 'y", $post );
?>
<?php echo get_the_modified_date( FICTIONEER_LATEST_UPDATES_FOOTER_DATE, $post ); ?>
<i class="<?php echo $story['icon']; ?>"></i>
<?php echo fcntr( $story['status'] ); ?>