Esempio n. 1
0
function post_likes_sorting($query)
{
    if ($query->get('filter_type') == 'user_liked') {
        if (is_author() && is_main_query()) {
            $user_id = dp_get_queried_user_id();
            if (!get_query_var('filter_user')) {
                $query->set('filter_user', $user_id);
            }
            $query->set('author', '');
            $query->set('author_name', '');
        }
        add_filter('posts_join', 'post_likes_join', 10, 2);
        add_filter('posts_where', 'post_likes_where', 10, 2);
    } else {
        remove_filter('posts_join', 'post_likes_join');
        remove_filter('posts_where', 'post_likes_where');
    }
}
Esempio n. 2
0
/**
 * Reset and parse query args based passed $args
 *
 * @since deTube 1.0
 */
function dp_parse_query_args($args)
{
    $defaults = array('post_type' => 'post', 'ignore_sticky_posts' => true, 'orderby' => 'date', 'order' => 'desc', 'cat' => '', 'tax_query' => '', 'taxonomies' => array(), 'meta_key' => '', 'post__in' => '', 'current_cat' => '', 'current_author' => '');
    $args = wp_parse_args($args, $defaults);
    // extract($args);
    // Set post_type
    if ($args['post_type'] == 'all') {
        $post_types = get_post_types(array('public' => true), 'names');
        unset($post_types['page']);
        unset($post_types['attachment']);
        $args['post_type'] = $post_types;
    }
    // Set tax_query
    $taxes = array_filter($args['taxonomies']);
    if (!empty($taxes)) {
        foreach ($taxes as $tax => $terms) {
            $args['tax_query']['relation'] = 'AND';
            if ($tax == 'post_format' && ($terms == '-1' || $terms == 'standard')) {
                $post_formats = get_theme_support('post-formats');
                $terms = array();
                foreach ($post_formats[0] as $format) {
                    $terms[] = 'post-format-' . $format;
                }
                $args['tax_query'][] = array('taxonomy' => $tax, 'field' => 'slug', 'terms' => $terms, 'operator' => 'NOT IN');
            } else {
                $args['tax_query'][] = array('taxonomy' => $tax, 'field' => 'id', 'terms' => (array) $terms, 'operator' => 'IN');
            }
        }
    }
    // Set 'author' to current author id on author archive page if 'current_author' is true
    if (!empty($args['current_author']) && is_author()) {
        $args['author'] = dp_get_queried_user_id();
    }
    // Set 'cat' to current cat id on category archive page if 'current_cat' is true
    if (!empty($args['current_cat']) && is_category()) {
        $args['cat'] = get_queried_object_id();
    }
    // Set post__in as array
    if (!empty($args['post__in']) && !is_array($args['post__in'])) {
        $args['post__in'] = explode(',', $args['post__in']);
    }
    return $args;
}
Esempio n. 3
0
<?php

/**
 * Author Added Template
 *
 * The template for displaying Posts Added by current author.
 *
 * @package deTube
 * @subpackage Template
 * @since deTube 1.0
 */
// Get the ID of current user so we can use it later.
$user_id = dp_get_queried_user_id();
get_header();
?>

<div id="main"><div class="wrap cf">
	<div id="content" role="main">
		
		<div class="loop-header">
			<h1 class="loop-title"><?php 
printf(__("%s / Added Videos", 'dp'), '<a href="' . get_author_posts_url($user_id) . '">' . get_the_author_meta('display_name', $user_id) . '</a>');
?>
</h1>
		</div>
	
		<?php 
if (have_posts()) {
    global $loop_view;
    ?>