function widget($args, $instance)
 {
     global $post, $extrp_settings, $extrp_sanitize;
     if (is_404() || is_home() || is_front_page()) {
         return;
     }
     $post_id = null === $post->ID ? get_the_ID() : (int) $post->ID;
     extract($args);
     $default_setting = extrp_default_setting('shortcode');
     $set = wp_parse_args($instance, $default_setting);
     $a = $extrp_sanitize->sanitize($set);
     $result = extrp_create_html($a['relatedby'], $post_id, $a['single'], $a['posts'], $a['post_date'], $a['subtitle'], $a['randomposts'], $a['titlerandom'], $a['post_title'], $a['desc'], $a['image_size'], $a['display'], $a['shape'], $a['crop'], $a['heading'], $a['postheading'], $a['post_excerpt'], $a['maxchars'], $a['highlight'], $a['relevanssi'], $a['post__in'], $a['post__not_in'], 'shortcode', 'widget');
     if ('' == $result) {
         return;
     }
     if ($extrp_settings['active']) {
         add_filter('the_content', 'extrp_filter_the_content', 10);
     }
     $title = apply_filters('widget_title', $result['subtitle']);
     $title_section = '' != $title ? $before_title . $title . $after_title : '';
     printf('%1$s<div class="widget_form_extrp">%2$s%3$s</div>%4$s', $before_widget, $title_section, $result['result'], $after_widget);
 }
예제 #2
0
function extrp_related_posts_shortcode($atts = null, $result = '')
{
    global $post, $extrp_settings, $extrp_sanitize;
    if (is_home() || is_front_page()) {
        return;
    }
    $post_id = null === $post->ID ? get_the_ID() : (int) $post->ID;
    $option = 'shortcode';
    $default_setting = shortcode_atts(extrp_default_setting('shortcode'), $atts, 'jv-related-posts');
    $a = $extrp_sanitize->sanitize($default_setting);
    $result = extrp_create_html($a['relatedby'], $post_id, $a['single'], $a['posts'], $a['post_date'], $a['subtitle'], $a['randomposts'], $a['titlerandom'], $a['post_title'], $a['desc'], $a['image_size'], $a['display'], $a['shape'], $a['crop'], $a['heading'], $a['postheading'], $a['post_excerpt'], $a['maxchars'], $a['highlight'], $a['relevanssi'], $a['post__in'], $a['post__not_in'], $option);
    if ($extrp_settings['active']) {
        add_filter('the_content', 'extrp_filter_the_content', 10);
    }
    $author_id = $post->post_author;
    $option = 'publish_posts';
    $can_publish_posts = user_can($author_id, extrp_capability_filter($option));
    if (!$can_publish_posts) {
        return;
    }
    //well, users that can't publish posts, no cake for you. (default)
    return $result;
}
예제 #3
0
function extrp_set_related_posts($post, $arg = '')
{
    $a = extrp_do_your_settings($post, $arg);
    $post_id = null === $post->ID ? get_the_ID() : (int) $post->ID;
    remove_filter('the_content', 'extrp_filter_the_content');
    $result = extrp_create_html($a['relatedby'], $post_id, $a['single'], $a['posts'], $a['post_date'], $a['subtitle'], $a['randomposts'], $a['titlerandom'], $a['post_title'], $a['desc'], $a['image_size'], $a['display'], $a['shape'], $a['crop'], $a['heading'], $a['postheading'], $a['post_excerpt'], $a['maxchars'], $a['highlight'], $a['relevanssi'], $a['post__in'], $a['post__not_in']);
    add_filter('the_content', 'extrp_filter_the_content', 10);
    if (!$result) {
        return;
    }
    return $result;
}