Astra_Ext_Blog_Pro_Markup::date_box( string $output )
Add ‘Date Box’ in featured section
Description
Parameters
- $output
-
(string) (Required) Post content.
Return
(string) content.
Source
File: addons/blog-pro/classes/class-astra-ext-blog-pro-markup.php
public function date_box( $output ) {
$enable_date_box = astra_get_option( 'blog-date-box' );
$date_box_style = astra_get_option( 'blog-date-box-style' );
if ( 'astra_related_post_featured_image_after' === current_filter() ) {
$enable_date_box = apply_filters( 'astra_related_post_enable_date_box', $enable_date_box );
$date_box_style = apply_filters( 'astra_related_post_date_box_style', $date_box_style );
}
if ( $enable_date_box ) :
$time_string = '<time class="entry-date published updated" datetime="%1$s"><span class="date-month">%2$s</span> <span class="date-day">%3$s</span> <span class="date-year">%4$s</span></time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string = '<time class="entry-date published" datetime="%1$s"><span class="date-month">%2$s</span> <span class="date-day">%3$s</span> <span class="date-year">%4$s</span></time><time class="updated" datetime="%5$s">%6$s</time>';
}
$time_string = sprintf(
$time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date( 'M' ) ),
esc_html( get_the_date( 'j' ) ),
esc_html( get_the_date( 'Y' ) ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
/**
* Filters the Date Box time format.
*
* @since 1.5.0
*
* @param string posted date format for the posts.
*/
$posted_on = apply_filters(
'astra_date_box_time_format',
sprintf(
esc_html( '%s' ),
$time_string
)
);
ob_start();
?>
<a href="<?php echo esc_url( get_permalink() ); ?>" >
<div class="ast-date-meta <?php echo esc_attr( $date_box_style ); ?>">
<span class="posted-on"><?php echo $posted_on; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></span>
</div>
</a>
<?php
$posted_on_data = ob_get_clean();
/**
* Filters the Date Box markup.
*
* @since 1.5.0
*
* @param string $posted_on_data the posted date markup for the posts.
*/
$output .= apply_filters( 'astra_date_box_markup', $posted_on_data );
endif;
return $output;
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 1.0 | Introduced. |