astra_get_dynamic_post_format( string $get_for = 'single-post' )
Get post format as per new configurations set in customizer.
Description
Parameters
- $get_for
-
(string) (Optional) Get for.
Default value: 'single-post'
Return
(string) HTML markup for date span.
Source
File: inc/blog/blog-config.php
function astra_get_dynamic_post_format() {
$post_type = strval( get_post_type() );
$is_singular = is_singular() ? true : false;
$date_format_option = $is_singular ? astra_get_option( 'ast-dynamic-single-' . esc_attr( $post_type ) . '-date-format', '' ) : astra_get_option( 'blog-meta-date-format', '' );
$date_type = $is_singular ? astra_get_option( 'ast-dynamic-single-' . esc_attr( $post_type ) . '-meta-date-type', 'published' ) : astra_get_option( 'blog-meta-date-type', 'published' );
$date_format = apply_filters( 'astra_post_date_format', ( '' === $date_format_option ) ? get_option( 'date_format' ) : $date_format_option );
$published_date = strval( get_the_date( $date_format ) );
$modified_date = strval( get_the_modified_date( $date_format ) );
if ( 'updated' === $date_type ) {
$class = 'updated';
$itemprop = 'dateModified';
$date = sprintf(
esc_html( '%s' ),
$modified_date
);
} else {
$class = 'published';
$itemprop = 'datePublished';
$date = sprintf(
esc_html( '%s' ),
$published_date
);
}
return sprintf( '<span class="%1$s" itemprop="%2$s"> %3$s </span>', $class, $itemprop, $date );
}
Expand full source code Collapse full source code View on Trac
Changelog
| Version | Description |
|---|---|
| 4.1.0 | Introduced. |