Пример #1
0
/**
 * Produces the date of post publication.
 *
 * Supported shortcode attributes are:
 *   after (output after link, default is empty string),
 *   before (output before link, default is empty string),
 *   format (date format, default is value in date_format option field),
 *   label (text following 'before' output, but before date).
 *
 * Output passes through 'genesis_post_date_shortcode' filter before returning.
 *
 * @since 1.1.0
 *
 * @param array $atts Shortcode attributes
 * @return string Shortcode output
 */
function genesis_post_date_shortcode($atts)
{
    $defaults = array('after' => '', 'before' => '', 'format' => get_option('date_format'), 'label' => '');
    $atts = shortcode_atts($defaults, $atts);
    $display = 'relative' == $atts['format'] ? genesis_human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . __('ago', 'genesis') : get_the_time($atts['format']);
    $output = sprintf('<span class="date published time" title="%5$s">%1$s%3$s%4$s%2$s</span> ', $atts['before'], $atts['after'], $atts['label'], $display, get_the_time('c'));
    return apply_filters('genesis_post_date_shortcode', $output, $atts);
}
Пример #2
0
/**
 * Produce the post last modified date.
 *
 * Supported shortcode attributes are:
 *  * after (output after date, default is empty string),
 *  * before (output before date, default is empty string),
 *  * format (date format, default is value in date_format option field),
 *  * label (text following 'before' output, but before date).
 *
 * Output passes through 'genesis_post_modified_date_shortcode' filter before returning.
 *
 * @since 2.1.0
 *
 * @param array|string $atts Shortcode attributes. Empty string if no attributes.
 * @return string Shortcode output
 */
function genesis_post_modified_date_shortcode($atts)
{
    $defaults = array('after' => '', 'before' => '', 'format' => get_option('date_format'), 'label' => '', 'relative_depth' => 2);
    $atts = shortcode_atts($defaults, $atts, 'post_modified_date');
    if ('relative' === $atts['format']) {
        $display = genesis_human_time_diff(get_the_modified_time('U'), current_time('timestamp'), $atts['relative_depth']);
        $display .= ' ' . __('ago', 'genesis');
    } else {
        $display = get_the_modified_time($atts['format']);
    }
    if (genesis_html5()) {
        $output = sprintf('<time %s>', genesis_attr('entry-modified-time')) . $atts['before'] . $atts['label'] . $display . $atts['after'] . '</time>';
    } else {
        $output = sprintf('<span class="date updated time" title="%5$s">%1$s%3$s%4$s%2$s</span> ', $atts['before'], $atts['after'], $atts['label'], $display, get_the_modified_time('c'));
    }
    /**
     * Change the output of the post_modified_date shortcode.
     *
     * @since 2.1.0
     *
     * @param string $output Markup containing post last modification date.
     * @param array $atts {
     *     Shortcode attributes after mergining with default values.
     *
     *     @type string $after Output after date.
     *     @type string $before Output before date.
     *     @type string $format Date format, could be 'relative'.
     *     @type string $label Text following 'before' output, but before date.
     * }
     */
    return apply_filters('genesis_post_modified_date_shortcode', $output, $atts);
}