wp 文章星级评价 插件

下载地址4:http://pan.baidu.com/s/1eQnGIGU [articles_star_vote_score_optiontable_serialize_commentvote.zip]*推荐 最新

1.自定义表与 wp_options 表

2.修改插入数据库配置项,为serialize序列化的value值,在wp的options表中存储

3.增加暂停插件选项,增加comment评论时的打分,可以自定义开始 文章打分,评论时打分,或是暂停使用打分

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

下载地址3:http://pan.baidu.com/s/1qWrzZnY [articles_star_vote_score_optiontable_serialize.zip]*推荐

1.修改表为自定义创建数据库表与 wp_options表结合,插入serialize序列化的value值

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

下载地址2:http://pan.baidu.com/s/1o6skeIe  [articles_star_vote_score_optionstable.zip]

1.修改使用wp register_setting(‘group’) 插入wp_options 表多个键的存储方式

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

下载地址1:http://pan.baidu.com/s/1qWAwQPu   [articles_star_vote_score.zip]*推荐 (自定义数据库表)

1.使用2张自定义表存储数据

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Readme.text

// directory:

// wordpress/wp-content/plugins/articles_star_vote_score

// articles_star_vote_score
// |--assets
// |--css
// |--style.css
// |--img
// |--star.jpg
// |--js
// |--jquery-1.10.2.js
// |--show_star.js
// |--Readme.text
// |--stars_vote_score.php
// |--stars_vote_settings.php
// |--stars_vote_update.php

stars_vote_score.php

<?php
/*
Plugin Name: Articles Star Vote Score
Plugin URI: http://www.cnblogs.com/fxmbz/p/4057971.html
Description: Vote score for each article. <strong>Warning: Deactivate the plugin will delete all ovte data !</strong>
Version: 1.0
Author: Zhangxl
Author URI: http://www.cnblogs.com/fxmbz/
*/ /*
Copyright 2014 Zhangxl (email : 29583035@qq.com) This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version. This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ // if not add_action then warning and exit;
if (!function_exists('add_action')) {
echo 'Hi there! I\'m just a plugin, not much I can do when cwholeed directly.';
exit;
} // Define constants plugins version, run minimum wp version, plugins URL, plugins DIR
define('STARVOTE_VERSION_NUM', '1.0');
define('STARVOTE__MINIMUM_WP_VERSION', '4.0');
define('STARVOTE__PLUGIN_URL', plugin_dir_url(__FILE__));
define('STARVOTE__PLUGIN_DIR', plugin_dir_path(__FILE__)); // Define global variable $wpdb, data table
global $wpdb;
define('STARVOTE_LOG_TABLE', $wpdb->prefix . 'starvote_log');
define('STARVOTE_CONFIG_TABLE', $wpdb->prefix . 'starvote_config'); // Activation plugins call function
register_activation_hook(__FILE__, 'starvote_install');
register_activation_hook(__FILE__, 'starvote_install_data'); // Load stars_settings_page.php
require_once(STARVOTE__PLUGIN_DIR . 'stars_vote_settings.php'); // Deactivation plugins run function
register_deactivation_hook( __FILE__, 'starvote_deactivation'); // Add the hooks function, when loading the plug-in run function
add_action('plugins_loaded', 'starvote_update_db_check'); // Add the hooks function, when init run function
add_action('init', 'initialize_hooks'); /**
* initialize_hooks when add_action init call function
*/
function initialize_hooks() {
// when loading the wp_head call function
add_action('wp_head', 'load_script');
// when loading the the_content call function
add_filter('the_content', 'display_stars');
if (is_admin()) {
add_action('admin_menu', 'add_settings_pages');
}
} /**
* starvote_deactivation when deactivation plugin drop table
*/
function starvote_deactivation() {
global $wpdb;
$wpdb->query("DROP TABLE IF EXISTS " . STARVOTE_LOG_TABLE);
$wpdb->query("DROP TABLE IF EXISTS " . STARVOTE_CONFIG_TABLE);
delete_option('starvote_version_num', STARVOTE_VERSION_NUM);
} /**
* starvote_install when activation plugin create table, update options table starvote_version_num field
*/
function starvote_install() {
global $wpdb; $charset_collate = ''; if (!empty($wpdb->charset)) {
$charset_collate = "DEFAULT CHARACTER SET " . $wpdb->charset;
} if (!empty($wpdb->collate)) {
$charset_collate .= "COLLATE " . $wpdb->charset;
} $create_starvote_log = "CREATE TABLE " . STARVOTE_LOG_TABLE . " (
id integer NOT NULL AUTO_INCREMENT,
post_id integer NOT NULL,
user_id integer NOT NULL,
sum_votes decimal(10,1) NOT NULL,
ip varchar(45) NOT NULL,
time timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (id)
) $charset_collate;"; $create_starvote_config = "CREATE TABLE " . STARVOTE_CONFIG_TABLE . " (
id integer NOT NULL AUTO_INCREMENT,
star_style tinyint NOT NULL DEFAULT 0 COMMENT '0 small, 1 big',
star_counts tinyint NOT NULL DEFAULT 0 COMMENT '0 5star, 1 10star',
star_position tinyint NOT NULL DEFAULT 0 COMMENT '0 after 1 before',
show_statistics tinyint NOT NULL DEFAULT 1 COMMENT '0 none, 1 show',
show_statistics_type tinyint NOT NULL DEFAULT 0 COMMENT '0 number, 1 percentage',
vote_permissions tinyint NOT NULL DEFAULT 1 COMMENT '0 none, 1 ip limit, 2 ip and login limit',
PRIMARY KEY (id)
) $charset_collate;"; require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
dbDelta($create_starvote_log);
dbDelta($create_starvote_config); update_option('starvote_version_num', STARVOTE_VERSION_NUM);
} /**
* load_script loading js and css
*/
function load_script() {
if (!is_single()) {
return;
}
wp_enqueue_script('jquery-js', STARVOTE__PLUGIN_URL . 'assets/js/jquery-1.10.2.js');
wp_enqueue_script('star-js', STARVOTE__PLUGIN_URL . 'assets/js/show_star.js');
_e('<link type="text/css" rel="stylesheet" href="' . STARVOTE__PLUGIN_URL . 'assets/css/style.css" />');
} /**
* display_stars display if not sigle page return then return vote statistics info
* @param string The current article content
* @return string content and vote statistics info
*/
function display_stars($content) {
global $wpdb; if (!is_single()) {
return $content;
} // get when article id;
$post_id = get_the_ID();
// call function get starvote_config table info
$query = get_starvote_config();
$vote_permissions = $query->vote_permissions; // obtain vote_permissions field value // if vote_permissions value = 2 limit to vote after the user login then vote score
if ($vote_permissions != 2 || get_current_user_id()) {
$star_position = $query->star_position < 1 ? 0 : 1; //0 content bottom, 1 content top if ($star_position < 1) {
return $content . stars_style($post_id) . '<div id="statistics-container">' . stars_statistics($post_id) . '</div>';
} else {
return stars_style($post_id) . '<br />' . $content . '<div id="statistics-container">' . stars_statistics($post_id) . '</div>';
// return stars_style($post_id) . '<div id="statistics-container">' . stars_statistics($post_id) . '</div>' . $content;
}
} else {
return $content;
}
} /**
* [stars stars show style function ]
* @param int The current article id
* @return string stars style
*/
function stars_style($post_id) {
global $wpdb; $query = get_starvote_config();
$star_style = $query->star_style < 1 ? 0 : 1;
$star_counts = $query->star_counts < 1 ? 5 : 10;
$star_position = $query->star_position < 1 ? 0 : 1;
$show_statistics = $query->show_statistics < 1 ? 0 : 1;
$show_statistics_type = $query->show_statistics_type < 1 ? 0 : 1;
$vote_permissions = $query->vote_permissions; // The current post_id article all records
$comment_record_num = $wpdb->query("SELECT sum_votes FROM " . STARVOTE_LOG_TABLE . " WHERE post_id='" . $post_id . "'"); // sum votes calculate average
$sum_votes = $wpdb->get_row("SELECT SUM(sum_votes) FROM " . STARVOTE_LOG_TABLE . " WHERE post_id='" . $post_id . "'", ARRAY_A);
$sum_votes = $sum_votes['SUM(sum_votes)'] ? $sum_votes['SUM(sum_votes)'] / $comment_record_num : 0; $starStyle = $star_style ? 'star-big' : 'star-small';
$star = '<div id="stars"><ul id="' . $starStyle . '">';
for ($i = 1; $i <= $star_counts; $i++) {
if ($i < round($sum_votes)) {
$className = 'whole';
} else if ($i > round($sum_votes)) {
$className = 'none';
} else {
$className = $sum_votes == round($sum_votes) ? 'whole' : 'half';
}
$star .= '<li class="' . $className . '" sum_votes="' . $i . '"></li>';
}
$star .= '</ul><div id="avg_score">' . round($sum_votes, 2, PHP_ROUND_HALF_UP) . ' </div><div id="message"></div>';
$star .= '<input id="ajaxStar" type="hidden" post_id="' . $post_id . '" user_id="' . get_current_user_id() . '" sum_votes="' . $sum_votes . '" value="' . STARVOTE__PLUGIN_URL . 'stars_vote_update.php' . '" /></div>';
return $star;
} /**
* stars vote statistics
* @param int The current article id
* @return string stars statistics info: string
*/
function stars_statistics($post_id) {
global $wpdb;
$query = get_starvote_config();
$star_style = $query->star_style < 1 ? 0 : 1;
$star_counts = $query->star_counts < 1 ? 5 : 10;
$star_position = $query->star_position < 1 ? 0 : 1;
$show_statistics = $query->show_statistics < 1 ? 0 : 1;
$show_statistics_type = $query->show_statistics_type < 1 ? 0 : 1;
$vote_permissions = $query->vote_permissions; $comment_record_num = $wpdb->query("SELECT sum_votes FROM " . STARVOTE_LOG_TABLE . " WHERE post_id='" . $post_id . "'"); if ($comment_record_num) {
$statistics = '<div id="statistics"><span id="ratings-info-position">AVERAGE RATING ( based on <span class="comment_record_num">' . $comment_record_num . '</span> ratings )</span>';
if ($show_statistics > 0 && $show_statistics_type < 1) {
for ($i = $star_counts; $i >= 1; $i--) {
$each_star_counts = $wpdb->query("SELECT sum_votes FROM " . STARVOTE_LOG_TABLE . " WHERE post_id='" . $post_id . "' AND sum_votes={$i} OR post_id='" . $post_id . "' AND sum_votes={$i}-0.5");
$percentage = $each_star_counts / $comment_record_num * 100;
$statistics .= '<div id="counter-container"><span class="counter-label">' . $i . ' Stars</span><span class="counter-back"><span class="counter-bar" style="width: ' . $percentage . '%;"></span></span>' . '<span class="counter-count">' . $each_star_counts . '</span></div>';
}
} elseif ($show_statistics > 0 && $show_statistics_type >= 1) {
for ($i = $star_counts; $i >= 1; $i--) {
$each_star_counts = $wpdb->query("SELECT sum_votes FROM " . STARVOTE_LOG_TABLE . " WHERE post_id='" . $post_id . "' AND sum_votes={$i} OR post_id='" . $post_id . "' AND sum_votes={$i}-0.5");
$percentage = $each_star_counts / $comment_record_num * 100;
$statistics .= '<div id="counter-container"><span class="counter-label">' . $i . ' Stars</span><span class="counter-back"><span class="counter-bar" style="width: ' . $percentage . '%;"></span></span>' . '<span class="counter-count"> ' . round($percentage, 2, PHP_ROUND_HALF_UP) . ' %</span></div>';
}
} else {
$statistics = '';
}
} else {
if ($show_statistics > 0) {
$statistics = '<div id="statistics"><span id="ratings-info-position">AVERAGE RATING ( based on <span class="comment_record_num">0</span> ratings )</span>';
for ($i = $star_counts; $i >= 1; $i--) {
$statistics .= '<div id="counter-container"><span class="counter-label">' . $i . ' Stars</span><span class="counter-back"><span class="counter-bar" style="width: 0px;"></span></span>' . '<span class="counter-count">0</span></div>';
}
} else {
$statistics = '';
}
}
return $statistics;
} /**
* insert default config data
*/
function starvote_install_data() {
global $wpdb;
$starvote_config['star_style'] = 1; // 0 small, 1 big
$starvote_config['star_counts'] = 0; // 0 5star, 1 10star
$starvote_config['star_position'] = 0; // 0 after 1 before
$starvote_config['show_statistics'] = 1; // 0 none, 1 show
$starvote_config['show_statistics_type'] = 1; // 0 number, 1 percentage
$starvote_config['vote_permissions'] = 1; // 0 none, 1 ip limit, 2 ip and login limit
$wpdb->insert(STARVOTE_CONFIG_TABLE, $starvote_config);
} /**
* get starvote config data
* @param string
* @return obj
*/
function get_starvote_config($field = '*') {
global $wpdb;
$query = $wpdb->get_row("SELECT {$field} FROM " . STARVOTE_CONFIG_TABLE);
if (!$query) {
starvote_install_data();
}
return $query;
} /**
* star vote db check and update
*/
function starvote_update_db_check() {
if (get_option('starvote_version_num') != STARVOTE_VERSION_NUM) {
starvote_install();
}
} /**
* create admin star vote settings page
*/
function add_settings_pages() {
add_menu_page('StarVoteSettings', 'StarVoteSettings', 'manage_options', 'star_vote_settings', 'create_settings_pages');
}

stars_vote_settings.php

<?php
/**
* [create_settings_pages create settings page]
* @return [type] [description]
*/
function create_settings_pages() {
$query = get_starvote_config();
?>
<div class="wrap">
<h2>Star Vote Settings</h2>
<form method="post" action="<?php echo STARVOTE__PLUGIN_URL . 'stars_vote_update.php'; ?>" novalidate="novalidate">
<table class="form-table">
<tr>
<th scope="row">Star Style</th>
<td>
<input type="radio" name="star_style" id="" value="0" <?php echo ($query->star_style == 0) ? 'checked="checked"' : ''; ?> />Small &nbsp;
<input type="radio" name="star_style" id="" value="1" <?php echo ($query->star_style == 1) ? 'checked="checked"' : ''; ?> />Big
<p class="description">Star size, small or big.</p>
</td>
</tr>
<tr>
<th scope="row">Star Counts</th>
<td>
<input type="radio" name="star_counts" id="" value="0" <?php echo ($query->star_counts == 0) ? 'checked="checked"' : ''; ?> /> 5 Stars &nbsp;
<input type="radio" name="star_counts" id="" value="1" <?php echo ($query->star_counts == 1) ? 'checked="checked"' : ''; ?> /> 10 Stars
<p class="description">Star count, 5 or 10.</p>
</td>
</tr>
<tr>
<th scope="row">Sta Position</th>
<td>
<input type="radio" name="star_position" id="" value="0" <?php echo ($query->star_position == 0) ? 'checked="checked"' : ''; ?> /> bottom &nbsp;
<input type="radio" name="star_position" id="" value="1" <?php echo ($query->star_position == 1) ? 'checked="checked"' : ''; ?> /> top
<p class="description">The top or the bottom in the article content.</p>
</td>
</tr>
<tr>
<th scope="row">Show Statistics</th>
<td>
<input type="radio" name="show_statistics" id="" value="1" <?php echo ($query->show_statistics == 1) ? 'checked="checked"' : ''; ?> /> Show &nbsp;
<input type="radio" name="show_statistics" id="" value="0" <?php echo ($query->show_statistics == 0) ? 'checked="checked"' : ''; ?> /> None
<p class="description">Whether show the Statistics information.</p>
</td>
</tr>
<tr>
<th scope="row">Show Statistics Type</th>
<td>
<input type="radio" name="show_statistics_type" id="0" value="0" <?php echo ($query->show_statistics_type == 0) ? 'checked="checked"' : ''; ?> /> Counts &nbsp;
<input type="radio" name="show_statistics_type" id="0" value="1" <?php echo ($query->show_statistics_type == 1) ? 'checked="checked"' : ''; ?> /> Percentage
<p class="description">The type of the Statistics information.</p>
</td>
</tr>
<tr>
<th scope="row">Vote Permissions</th>
<td>
<input type="radio" name="vote_permissions" id="vote_permissions" value="1" <?php echo ($query->vote_permissions == 1) ? 'checked="checked"' : ''; ?> /> Ip limit &nbsp;
<input type="radio" name="vote_permissions" id="vote_permissions" value="2" <?php echo ($query->vote_permissions == 2) ? 'checked="checked"' : ''; ?> /> Ip and Login &nbsp;
<input type="radio" name="vote_permissions" id="vote_permissions" value="0" <?php echo ($query->vote_permissions == 0) ? 'checked="checked"' : ''; ?> /> Unlimited (Is not recommended)
<p class="description">Vote Permissions.</p>
</td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $query->id; ?>">
<input type="hidden" name="update_starvote_config" value="update_starvote_config">
<p class="submit"><input type="submit" name="submit" id="submit" class="button button-primary" value="Save Changes" /></p>
</form>
</div>
<?php
}

stars_vote_update.php

<?php
// Load the corresponding files, judge the REQUEST submitted data, run the corresponding method
if (! isset($wpdb)) {
global $wpdb; define('PATH', dirname(dirname(__FILE__)).'/');
require_once(PATH . '../../wp-blog-header.php');
require_once('./stars_vote_score.php'); if (isset($_REQUEST['insert_starvote_log'])) {
insert_starvote_log_data();
} if (isset($_REQUEST['update_starvote_config'])) {
update_starvote_config_data();
}
} /**
* insert vote data the star vote table
* @global obj $wpdb
*/
function insert_starvote_log_data() {
global $wpdb; $post_id = $_POST['post_id'];
$user_id = $_POST['user_id'];
$sum_votes = $_POST['sum_votes'];
$ip = get_ip(); $data['post_id'] = $post_id;
$data['user_id'] = $user_id;
$data['sum_votes'] = $sum_votes;
$data['ip'] = $ip; // vote permissions control
$vote_permissions = get_starvote_config();
switch ($vote_permissions->vote_permissions) {
case 1:
$query = "SELECT ip, post_id FROM " . STARVOTE_LOG_TABLE . " WHERE post_id = '" . $post_id . "' AND ip='" . $ip . "'";
if ($wpdb->get_results($query)) {
echo '<span id="msg">You already commented on, can\'t comment again!</span>' . stars_statistics($post_id);
} else {
$wpdb->insert(STARVOTE_LOG_TABLE, $data);
echo '<span id="msg">Comments successful!</span>' . stars_statistics($post_id);
}
break; case 2:
$query = "SELECT ip, post_id, user_id FROM " . STARVOTE_LOG_TABLE . " WHERE post_id = '" . $post_id . "' AND ip='" . $ip . "' AND user_id='" . $user_id . "'";
if (get_current_user_id()) {
if ($wpdb->get_results($query)) {
echo '<span id="msg">You already commented on, can\'t comment again!</span>' . stars_statistics($post_id);
} else {
$wpdb->insert(STARVOTE_LOG_TABLE, $data);
echo '<span id="msg">Comments successful!</span>' . stars_statistics($post_id);
}
} else {
echo '<span id="msg">You need to login to comments!</span>' . stars_statistics($post_id);
}
break; case 0:
$wpdb->insert(STARVOTE_LOG_TABLE, $data);
echo '<span id="msg">Comments successful!</span>' . stars_statistics($post_id);
break;
}
} /**
* update star vote config data table
* @global obj $wpdb
*/
function update_starvote_config_data() {
global $wpdb;
$starvote_config['star_style'] = $_POST['star_style']; // 0 small, 1 big
$starvote_config['star_counts'] = $_POST['star_counts']; // 0 5star, 1 10star
$starvote_config['star_position'] = $_POST['star_position']; // 0 after 1 before
$starvote_config['show_statistics'] = $_POST['show_statistics']; // 0 none, 1 show
$starvote_config['show_statistics_type'] = $_POST['show_statistics_type']; // 0 number, 1 percentage
$starvote_config['vote_permissions'] = $_POST['vote_permissions']; // 0 none, 1 ip limit, 2 ip and login limit
$where['id'] = $_POST['id']; $query = get_starvote_config();
$star_counts = $query->star_counts; if ($query) {
$starvote_data = $wpdb->update(STARVOTE_CONFIG_TABLE, $starvote_config, $where);
} else {
$starvote_data = $wpdb->insert(STARVOTE_CONFIG_TABLE, $starvote_config);
} if ($starvote_data) {
$get_log_table = $wpdb->get_results("SELECT id, sum_votes FROM " . STARVOTE_LOG_TABLE);
if ($get_log_table) {
if ($_POST['star_counts'] == 1 && $star_counts != $_POST['star_counts']) {
foreach ($get_log_table as $v) {
$starvote_log_data['sum_votes'] = $v->sum_votes * 2;
$where['id'] = $v->id;
$wpdb->update(STARVOTE_LOG_TABLE, $starvote_log_data, $where);
}
} elseif ($_POST['star_counts'] == 0 && $star_counts != $_POST['star_counts']) {
foreach ($get_log_table as $v) {
$starvote_log_data['sum_votes'] = $v->sum_votes / 2;
$where['id'] = $v->id;
$wpdb->update(STARVOTE_LOG_TABLE, $starvote_log_data, $where);
}
}
}
} echo "<script>history.back();</script>";
} /**
* get when client ip
* @return string
*/
function get_ip() {
static $realIP;
if (isset($_SERVER)) {
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) {
$realIP = explode(',', $_SERVER["HTTP_X_FORWARDED_FOR"]);
$realIP = $realIP[0];
} else if (isset($_SERVER["HTTP_CLIENT_IP"])) {
$realIP = $_SERVER["HTTP_CLIENT_IP"];
} else {
$realIP = $_SERVER["REMOTE_ADDR"];
}
} else {
if (getenv("HTTP_X_FORWARDED_FOR")) {
$realIP = getenv("HTTP_X_FORWARDED_FOR");
} else if (getenv("HTTP_CLIENT_IP")) {
$realIP = getenv("HTTP_CLIENT_IP");
} else {
$realIP = getenv("REMOTE_ADDR");
}
}
$_SERVER['REMOTE_ADDR'] = $realIP;
return $realIP;
} ?>

style.css

@charset "utf-8";

#stars {
overflow:hidden;
margin-bottom: 5px;
} #stars ul, #stars ul li {
list-style: none;
margin:;
padding:;
cursor: pointer;
} #avg_score, #message {
float:left;
margin-left: 10px;
}
/*statistics-container----------------------------*/
#statistics-container {
position: relative;
} #msg {
color: green;
position: absolute;
width: 100%;
top: 0px;
left: 300px;
} #statistics-container #ratings-info-position {
margin-left: 2px;
} #statistics .comment_record_num {
font-size: 16px;
color: red;
}
/*star-small--------------------------------------*/
#stars #star-small li {
background: url(../img/star.jpg) no-repeat 0 0;
float:left;
width: 20px;
height: 20px;
line-height: 20px;
}
#stars #star-small li.half {
background-position: -21px -33px;
}
#stars #star-small li.none {
background-position: -41px -33px;
}
#stars #star-small li.whole {
background-position: -1px -33px;
} /*star-big--------------------------------------*/
#stars #star-big li {
background: url(../img/star.jpg) no-repeat 0 0;
float:left;
width: 30px;
height: 30px;
line-height: 20px;
} #stars #star-big li.half {
background-position: -31px -1px;
}
#stars #star-big li.none {
background-position: -63px -1px;
}
#stars #star-big li.whole {
background-position: 1px -1px;
} /*----------------------------------------*/
#counter-container { }
#counter-container .counter-label {
line-height: 17px;
float: left;
min-width: 55px;
font-size: 14px;
margin-left: 2px;
} #counter-container .counter-back {
line-height: 17px;
height: 17px;
width: 200px;
background-color: #ececec;
float: left;
} #counter-container .counter-count {
line-height: 17px;
height: 17px;
margin-left: 5px;
font-size: 14px;
} #counter-container .counter-bar {
line-height: 17px;
height: 17px;
background-color: #FDDB5A;
float: left;
}

show_star.js

$(document).ready(function(){
$("#stars ul li").on("mouseover", function(e){
var thisnum = $(this).index();
$("#stars ul li").each(function(){
if ($(this).index() <= thisnum) {
$(this).attr("oldClass", $(this).attr("class")).attr("class", "whole");
} else {
$(this).attr("oldClass", $(this).attr("class")).attr("class", "none");
}
});
}).on("mouseout", function(){
$("#stars ul li").each(function(){
$(this).attr("class", $(this).attr("oldClass"));
}); }).on("click", function(e){
var thisnum = $(this).index();
$("#stars ul li").each(function(){
if ($(this).index() <= thisnum) {
$(this).attr("class", "whole").attr("oldClass", "whole");
} else {
$(this).attr("class", "none").attr("oldClass", "none");
}
}); setTimeout(function(){
$("#msg").fadeOut(1000);
},2000); $("#avg_score").html(thisnum + 1 + " .0"); var user_id = $("#ajaxStar").attr('user_id');
var post_id = $("#ajaxStar").attr('post_id');
var sum_votes = $(e.target).attr('sum_votes');
$.ajax({
url : $("#ajaxStar").val(),
dataType : 'html',
method : 'post',
data : 'post_id=' + post_id + '&user_id=' + user_id + '&sum_votes=' + sum_votes + '&insert_starvote_log= insert_starvote_log',
success : function(data) {
$("#statistics-container").html(data);
}
});
});
});

star.jpg

jquery-1.10.2.js (网上下载一个jq文件,改名为 jquery-1.10.2.js) http://code.jquery.com/jquery-1.11.0.min.js

WordPress插件制作笔记(三)---Stars Comments Article的更多相关文章

  1. WordPress插件制作教程(三): 添加菜单的方法

    上一篇编写了一个简单的插件,让大家对插件的简单制作有个了解,这一篇我们在更深一步,当我们激活插件后后台会显示菜单出来,然后通过单击菜单显示自己定义好的信息.激活之后会在WordPress后台显示一个菜 ...

  2. WordPress插件制作笔记(二)---Second Plugins Demo

    1->插件演示代码:下载地址:http://pan.baidu.com/s/1gd1lFlL 在 wordpress/wp-content/plugins/ 目录下 新建一个文件夹取名为seco ...

  3. WordPress插件制作笔记(一)---First Plugins Demo

    1->add_action  HOOK简单说明: http://codex.wordpress.org/Plugin_API/Action_Reference (参考网址) //在后台页脚位置加 ...

  4. WordPress插件制作教程概述

    接下来的一段时间里,开始为大家讲解WordPress插件制作系列教程,这篇主要是对WordPress插件的一些介绍和说明,还有一些我们需要注意的地方,以及需要掌握的知识. WordPress插件允许你 ...

  5. WordPress插件制作教程(八): 最后总结

    WordPress插件教程最后一篇,还是为大家简单的做下总结.这次插件制作教程讲的内容和知识点个人觉得不是很多,因为插件制作不单单是这些内容,它涉及的知识很多很多,不是说你会一些函数就可以做出一个好的 ...

  6. WordPress插件制作教程(一): 如何创建一个插件

    上一篇还是按照之前的教程流程,写了一篇WordPress插件制作教程概述,从这一篇开始就为大家具体讲解WordPress插件制作的内容.这一篇主要说一下插件的创建方法. 相信大家都知道插件的安装文件在 ...

  7. WordPress插件制作教程(六): 插件函数之动作(Actions)函数

    这一篇为大家说一下WordPress插件函数吧,要制作插件,了解这些函数是非常有必要的 WordPress插件函数分为“动作”(Actions)和过滤器”(Filters),WordPress 使用这 ...

  8. WordPress插件制作教程(二): 编写一个简单的插件

    上一篇说到了如何创建一个插件,我想大家看了之后一定会有所收获,这一篇简单给大家写一个插件样例,让大家有一个基本的印象.这个插件的样例就是当你激活这个插件后会在你的每篇文章中插入一段自己定义好的内容,比 ...

  9. WordPress插件制作教程(七): 插件函数之过滤器(Filter)函数

    上一篇对插件函数之动作(Action)函数做了下介绍,这篇在介绍下过滤器(Filters). 过滤器是一类函数,WordPress执行传递和处理数据的过程中,在针对这些数据做出某些动作之前的特定运行( ...

随机推荐

  1. 利用WSGI来部署你的网站

    利用WSGI来部署你的网站 当需要部署你的django项目的时候,可以使用apache+python来部署访问你的网站. 由于网上的有关的都是老版本的.所以这里使用apache2.4和python3. ...

  2. [POJ] 3264 Balanced Lineup [ST算法]

    Balanced Lineup Time Limit: 5000MS   Memory Limit: 65536K Total Submissions: 34306   Accepted: 16137 ...

  3. Android CursorAdapter

    CursorAdapter 继承于BaseAdapter是个虚类,它为cursor和ListView提供了连接的桥梁.            public abstract class     Cur ...

  4. php将会话保存在数据库里

    php默认把会话保存在临时文件中,保存在数据库中可以提高安全性,在共享主机服务器上,所有web站点都使用同一个临时目录,这意味着数十个程序都在同一位置进行文件读取的操作,我们很容易就编写一个脚本从这个 ...

  5. 转:PHP的(Thread Safe与Non Thread Safe)

    在安装xdebug到时候你会有有TS和NTS版本的选择,在以前还有VC6和VC9的版本.如果你没有根据你目前的服务器的状况选择对应的版本的话,那么xdebug是安装不成功的. 一.如何选择 php5. ...

  6. logstash 中的贪婪匹配

    logstash 中的贪婪匹配: 10.252.142.174 - - [06/Sep/2016:08:41:36 +0800] "GET /api/validate/code/send?m ...

  7. 编译不通过:提示XXXX不是类或命名空间名 的解决办法

    手动写了一个类,需要引入预编译头stdafx.h.结果编译时提示XXXX不是类或命名空间名. 处理方法:将#include "stdafx.h"放在最前面.

  8. ios 导航栏和旋屏

    1,状态栏(UIStatusBar) http://my.oschina.net/shede333/blog/304560 2,visibleViewController和topViewControl ...

  9. 【转】linux文件系统之mount流程分析

    本质上,Ext3 mount的过程实际上是inode被替代的过程. 例如,/dev/sdb块设备被mount到/mnt/alan目录.命令:mount -t ext3 /dev/sdb /mnt/al ...

  10. Duanxx的STM32学习:STM32命名规则