function the_ratings($start_tag = 'div', $custom_id = 0, $display = true) { global $id; // Allow Custom ID if (intval($custom_id) > 0) { $ratings_id = $custom_id; } else { // If Global $id is 0, Get The Loop Post ID if ($id === 0) { $ratings_id = get_the_ID(); } else { $ratings_id = $id; } } // Loading Style $postratings_ajax_style = get_option('postratings_ajax_style'); if (intval($postratings_ajax_style['loading']) == 1) { $loading = "\n<{$start_tag} id=\"post-ratings-{$ratings_id}-loading\" class=\"post-ratings-loading\"><img src=\"" . plugins_url('wp-postratings/images/loading.gif') . "\" width=\"16\" height=\"16\" alt=\"" . __('Loading', 'wp-postratings') . " ...\" title=\"" . __('Loading', 'wp-postratings') . " ...\" class=\"post-ratings-image\" /> " . __('Loading', 'wp-postratings') . " ...</" . $start_tag . ">\n"; } else { $loading = ''; } // Check To See Whether User Has Voted $user_voted = check_rated($ratings_id); // HTML Attributes if (is_single()) { $attributes = 'id="post-ratings-' . $ratings_id . '" class="post-ratings" itemscope itemtype="http://schema.org/Article"'; } else { $attributes = 'id="post-ratings-' . $ratings_id . '" class="post-ratings"'; } // If User Voted Or Is Not Allowed To Rate if ($user_voted) { if (!$display) { return "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id) . '</' . $start_tag . '>' . $loading; return; } // If User Is Not Allowed To Rate } else { if (!check_allowtorate()) { if (!$display) { return "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id, 0, 0, 0, 1) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id, 0, 0, 0, 1) . '</' . $start_tag . '>' . $loading; return; } // If User Has Not Voted } else { if (!$display) { return "<{$start_tag} {$attributes} data-nonce=\"" . wp_create_nonce('postratings_' . $ratings_id . '-nonce') . "\">" . the_ratings_vote($ratings_id) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} {$attributes} data-nonce=\"" . wp_create_nonce('postratings_' . $ratings_id . '-nonce') . "\">" . the_ratings_vote($ratings_id) . '</' . $start_tag . '>' . $loading; return; } } } }
function the_ratings($start_tag = 'div', $custom_id = 0, $display = true) { global $id; // Allow Custom ID if (intval($custom_id) > 0) { $ratings_id = $custom_id; } else { // If Global $id is 0, Get The Loop Post ID if ($id === 0) { $ratings_id = get_the_ID(); } elseif (is_null($id)) { global $post; $ratings_id = $post->ID; } else { $ratings_id = $id; } } // Loading Style $postratings_ajax_style = get_option('postratings_ajax_style'); if (intval($postratings_ajax_style['loading']) == 1) { $loading = '<' . $start_tag . ' id="post-ratings-' . $ratings_id . '-loading" class="post-ratings-loading"> <img src="' . plugins_url('wp-postratings/images/loading.gif') . '" width="16" height="16" alt="' . __('Loading...', 'wp-postratings') . '" title="' . __('Loading...', 'wp-postratings') . '" class="post-ratings-image" />' . __('Loading...', 'wp-postratings') . '</' . $start_tag . '>'; } else { $loading = ''; } // Check To See Whether User Has Voted $user_voted = check_rated($ratings_id); // HTML Attributes $ratings_options = get_option('postratings_options'); $ratings_options['richsnippet'] = isset($ratings_options['richsnippet']) ? $ratings_options['richsnippet'] : 1; if ((is_single() || is_page()) && $ratings_options['richsnippet']) { $itemtype = apply_filters('wp_postratings_schema_itemtype', 'itemscope itemtype="http://schema.org/Article"'); $attributes = 'id="post-ratings-' . $ratings_id . '" class="post-ratings" ' . $itemtype; } else { $attributes = 'id="post-ratings-' . $ratings_id . '" class="post-ratings"'; } // If User Voted Or Is Not Allowed To Rate if ($user_voted) { if (!$display) { return "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id) . '</' . $start_tag . '>' . $loading; return; } // If User Is Not Allowed To Rate } else { if (!check_allowtorate()) { if (!$display) { return "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id, 0, 0, 0, 1) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} {$attributes}>" . the_ratings_results($ratings_id, 0, 0, 0, 1) . '</' . $start_tag . '>' . $loading; return; } // If User Has Not Voted } else { if (!$display) { return "<{$start_tag} {$attributes} data-nonce=\"" . wp_create_nonce('postratings_' . $ratings_id . '-nonce') . "\">" . the_ratings_vote($ratings_id) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} {$attributes} data-nonce=\"" . wp_create_nonce('postratings_' . $ratings_id . '-nonce') . "\">" . the_ratings_vote($ratings_id) . '</' . $start_tag . '>' . $loading; return; } } } }
function the_ratings($start_tag = 'div', $custom_id = 0, $display = true) { global $id; // Allow Custom ID if (intval($custom_id) > 0) { $ratings_id = $custom_id; } else { $ratings_id = $id; } // Loading Style $postratings_ajax_style = get_option('postratings_ajax_style'); if (intval($postratings_ajax_style['loading']) == 1) { $loading = "\n<{$start_tag} id=\"post-ratings-{$ratings_id}-loading\" class=\"post-ratings-loading\"><img src=\"" . plugins_url('wp-postratings/images/loading.gif') . "\" width=\"16\" height=\"16\" alt=\"" . __('Loading', 'wp-postratings') . " ...\" title=\"" . __('Loading', 'wp-postratings') . " ...\" class=\"post-ratings-image\" /> " . __('Loading', 'wp-postratings') . " ...</" . $start_tag . ">\n"; } else { $loading = ''; } // Check To See Whether User Has Voted $user_voted = check_rated($ratings_id); // If User Voted Or Is Not Allowed To Rate if ($user_voted) { if (!$display) { return "<{$start_tag} id=\"post-ratings-{$ratings_id}\" class=\"post-ratings\">" . the_ratings_results($ratings_id) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} id=\"post-ratings-{$ratings_id}\" class=\"post-ratings\">" . the_ratings_results($ratings_id) . '</' . $start_tag . '>' . $loading; return; } // If User Is Not Allowed To Rate } else { if (!check_allowtorate()) { if (!$display) { return "<{$start_tag} id=\"post-ratings-{$ratings_id}\" class=\"post-ratings\">" . the_ratings_results($ratings_id, 0, 0, 0, 1) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} id=\"post-ratings-{$ratings_id}\" class=\"post-ratings\">" . the_ratings_results($ratings_id, 0, 0, 0, 1) . '</' . $start_tag . '>' . $loading; return; } // If User Has Not Voted } else { if (!$display) { return "<{$start_tag} id=\"post-ratings-{$ratings_id}\" class=\"post-ratings\">" . the_ratings_vote($ratings_id) . '</' . $start_tag . '>' . $loading; } else { echo "<{$start_tag} id=\"post-ratings-{$ratings_id}\" class=\"post-ratings\">" . the_ratings_vote($ratings_id) . '</' . $start_tag . '>' . $loading; return; } } } }