Example #1
0
function polldaddy_get_rating_html($condition = '')
{
    global $post;
    $html = '';
    if ($post->ID > 0) {
        $unique_id = '';
        $title = '';
        $permalink = '';
        $rating_id = 0;
        $item_id = '';
        $exclude_posts = explode(',', get_option('pd-rating-exclude-post-ids'));
        $exclude_pages = explode(',', get_option('pd-rating-exclude-page-ids'));
        if (is_page()) {
            if (!in_array($post->ID, $exclude_pages)) {
                $unique_id = 'wp-page-' . $post->ID;
                $item_id = '_page_' . $post->ID;
                if ($condition == 'check-options') {
                    if ((int) get_option('pd-rating-pages') > 0) {
                        $rating_id = (int) get_option('pd-rating-pages-id');
                    }
                } else {
                    $rating_id = (int) get_option('pd-rating-pages-id');
                }
            }
        } else {
            if (!in_array($post->ID, $exclude_posts)) {
                $unique_id = 'wp-post-' . $post->ID;
                $item_id = '_post_' . $post->ID;
                if (is_home()) {
                    if ($condition == 'check-options') {
                        if ((int) get_option('pd-rating-posts-index') > 0) {
                            $rating_id = (int) get_option('pd-rating-posts-id');
                        }
                    } else {
                        $rating_id = (int) get_option('pd-rating-posts-id');
                    }
                } else {
                    if ($condition == 'check-options') {
                        if ((int) get_option('pd-rating-posts') > 0) {
                            $rating_id = (int) get_option('pd-rating-posts-id');
                        }
                    } else {
                        $rating_id = (int) get_option('pd-rating-posts-id');
                    }
                }
            }
        }
        if ($rating_id > 0) {
            $title = apply_filters('wp_title', $post->post_title);
            $permalink = get_permalink($post->ID);
            $html = polldaddy_get_rating_code($rating_id, $unique_id, $title, $permalink, $item_id);
            wp_register_script('polldaddy-rating-js', 'http://i.polldaddy.com/ratings/rating.js');
            add_filter('wp_footer', 'polldaddy_add_rating_js');
        }
    }
    return $html;
}
Example #2
0
function polldaddy_get_rating_html($condition = '')
{
    global $post;
    $html = '';
    if ($post->ID > 0) {
        $unique_id = '';
        $title = '';
        $permalink = '';
        $rating_id = 0;
        $item_id = '';
        $exclude_posts = explode(',', get_option('pd-rating-exclude-post-ids'));
        $exclude_pages = explode(',', get_option('pd-rating-exclude-page-ids'));
        if (is_page()) {
            if (!in_array($post->ID, $exclude_pages)) {
                $unique_id = 'wp-page-' . $post->ID;
                $item_id = '_page_' . $post->ID;
                if ($condition == 'check-options') {
                    if ((int) get_option('pd-rating-pages') > 0) {
                        $rating_id = (int) get_option('pd-rating-pages-id');
                    }
                } else {
                    $rating_id = (int) get_option('pd-rating-pages-id');
                }
            }
        } elseif (!in_array($post->ID, $exclude_posts)) {
            $unique_id = 'wp-post-' . $post->ID;
            $item_id = '_post_' . $post->ID;
            if (is_home() || is_archive() || is_search() || is_category()) {
                if ($condition == 'check-options') {
                    if ((int) get_option('pd-rating-posts-index') > 0) {
                        $rating_id = (int) get_option('pd-rating-posts-id');
                    }
                } else {
                    $rating_id = (int) get_option('pd-rating-posts-id');
                }
            } else {
                if ($condition == 'check-options') {
                    if ((int) get_option('pd-rating-posts') > 0) {
                        $rating_id = (int) get_option('pd-rating-posts-id');
                    }
                } else {
                    $rating_id = (int) get_option('pd-rating-posts-id');
                }
            }
        }
        if ($rating_id > 0) {
            $rating_title_filter = get_option('pd-rating-title-filter');
            if ($rating_title_filter === false) {
                $title = apply_filters('the_title', $post->post_title, $post->ID, '');
            } elseif (strlen($rating_title_filter) > 0) {
                $title = apply_filters($rating_title_filter, $post->post_title, $post->ID, '');
            } else {
                $title = $post->post_title;
            }
            $permalink = get_permalink($post->ID);
            $html = polldaddy_get_rating_code($rating_id, $unique_id, $title, $permalink, $item_id);
        }
    }
    return $html;
}