[Plugin: kk Star Ratings] Upgrade to 2.0 and backward compatibility problem
-
First thanks for this nice plugin – enjoying it ??
My problem is that after I upgraded to version 2.0, all the ratings on posts are not shown.
I can find the old meta values in the database in the table wp_postmeta.
Now as I read your code it seems as if the problem is focused around the detection of “Old_plugin”.
I was able to manually perform the db upgrade by forcing the following code in a is_admin() within the index.php file. However this is somewhat of a hack – that I doubt many else would be able to perform.
if (is_admin()) { echo "this is admin!"; // Update previous ratings global $wpdb; $table = $wpdb->prefix . 'postmeta'; $Posts = $wpdb->get_results("SELECT a.ID, b.meta_key, b.meta_value FROM " . $wpdb->posts . " a, $table b WHERE a.ID=b.post_id AND ( b.meta_key='_kk_ratings_ratings' OR b.meta_key='_kk_ratings_casts' OR b.meta_key='_kk_ratings_ips' ) ORDER BY a.ID ASC"); $Wrap = array(); foreach ($Posts as $post) { $Wrap[$post->ID]['id'] = $post->ID; $Wrap[$post->ID][$post->meta_key] = $post->meta_value; } foreach($Wrap as $p) { update_post_meta($p['id'], '_kksr_ratings', $p['_kk_ratings_ratings']); update_post_meta($p['id'], '_kksr_casts', $p['_kk_ratings_casts']); $Ips = array(); $Ips = explode('|', $p['_kk_ratings_ips']); $ip = base64_encode(serialize($Ips)); update_post_meta($p['id'], '_kksr_ips', $ip); update_post_meta($p['id'], '_kksr_avg', round($p['_kk_ratings_ratings']/$p['_kk_ratings_casts'],1)); } }
https://www.ads-software.com/extend/plugins/kk-star-ratings/
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘[Plugin: kk Star Ratings] Upgrade to 2.0 and backward compatibility problem’ is closed to new replies.