Example #1
0
/**
 * This template tag is meant to replace template tags like `the_category()`, `the_terms()`, etc.  These core 
 * WordPress template tags don't offer proper translation and RTL support without having to write a lot of 
 * messy code within the theme's templates.  This is why theme developers often have to resort to custom 
 * functions to handle this (even the default WordPress themes do this).  Particularly, the core functions 
 * don't allow for theme developers to add the terms as placeholders in the accompanying text (ex: "Posted in %s"). 
 * This funcion is a wrapper for the WordPress `get_the_terms_list()` function.  It uses that to build a 
 * better post terms list.
 *
 * @since  0.9.0
 * @access public
 * @param  array   $args
 * @return string
 */
function omega_get_post_terms($args = array())
{
    $html = '';
    $defaults = array('post_id' => get_the_ID(), 'taxonomy' => 'category', 'text' => '%s', 'before' => '', 'after' => '', 'items_wrap' => '<span %s>%s</span>', 'sep' => _x(', ', 'taxonomy terms separator', 'omega'));
    $args = wp_parse_args($args, $defaults);
    $terms = get_the_term_list($args['post_id'], $args['taxonomy'], '', $args['sep'], '');
    if (!empty($terms)) {
        $html .= $args['before'];
        $html .= sprintf($args['items_wrap'], omega_get_attr('entry-terms', $args['taxonomy']), sprintf($args['text'], $terms));
        $html .= $args['after'];
    }
    return $html;
}
Example #2
0
/**
 * Produces the date of post publication.
 *
 * Supported 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 'omega_get_post_date' filter before returning.
 *
 * @since 1.1.0
 * @access public
 * @param  string  $after
 * @param  string  $before
 * @param  string  $format
 * @param  string  $label
 * @return string
 */
function omega_get_post_date($after = '', $before = '', $format = '', $label = '')
{
    if ($format == '') {
        $format = get_option('date_format');
    }
    $display = 'relative' === $format ? omega_human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ' . __('ago', 'omega') : get_the_time($format);
    $output = sprintf('<time %s>', omega_get_attr('entry-published')) . $before . $label . $display . $after . '</time>';
    return apply_filters('omega_get_post_date', $output, $after, $before, $format, $label);
}
Example #3
0
/**
 * Outputs an HTML element's attributes.
 *
 * @since  0.9.0
 * @access public
 * @param  string  $slug        The slug/ID of the element (e.g., 'sidebar').
 * @param  string  $context     A specific context (e.g., 'primary').
 * @param  array   $attributes  Custom attributes to pass in.
 * @return void
 */
function omega_attr($slug, $context = '', $attributes = array())
{
    echo omega_get_attr($slug, $context, $attributes);
}
Example #4
0
function omega_footer_markup_open()
{
    echo '<footer ' . omega_get_attr('footer') . '>';
}
Example #5
0
/**
 * Produces the linked post taxonomy terms list.
 *
 * Supported shortcode attributes are:
 *   after (output after link, default is empty string),
 *   before (output before link, default is 'Tagged With: '),
 *   sep (separator string between tags, default is ', '),
 *    taxonomy (name of the taxonomy, default is 'category').
 *
 * Output passes through 'omega_post_terms_shortcode' filter before returning.
 *
 * @since 0.9.0
 *
 * @global stdClass $post Post object
 *
 * @param array|string $atts Shortcode attributes. Empty string if no attributes.
 * @return string|boolean Shortcode output or false on failure to retrieve terms
 */
function omega_post_terms_shortcode($atts)
{
    global $post;
    $defaults = array('after' => '', 'before' => __('Filed Under: ', 'omega'), 'sep' => ', ', 'taxonomy' => 'category');
    $atts = shortcode_atts($defaults, $atts, 'post_terms');
    $terms = get_the_term_list($post->ID, $atts['taxonomy'], $atts['before'], trim($atts['sep']) . ' ', $atts['after']);
    if (is_wp_error($terms)) {
        return;
    }
    if (empty($terms)) {
        return;
    }
    $output = sprintf('<span %s>', omega_get_attr('entry-terms')) . $terms . '</span>';
    return apply_filters('omega_post_terms_shortcode', $output, $terms, $atts);
}