DJRavine
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Plugins
In reply to: [WP-PostRatings] Custom stars imagesUpdates the above code to work on the latest version of wordpress.
Just copy/paste into the functions.php and edit as required.
Allows the plugin to update as per normal without affecting the custom images used.// WP Post Ratings Override plugin images, from plugin source function my_deregister_script() { $postratings_max = intval(get_option('postratings_max')); $postratings_ajax_style = get_option('postratings_ajax_style'); $postratings_custom = intval(get_option('postratings_customrating')); if($postratings_custom) { for($i = 1; $i <= $postratings_max; $i++) { $postratings_javascript .= 'var ratings_'.$i.'_mouseover_image=new Image();ratings_'.$i.'_mouseover_image.src=ratingsL10n.plugin_url+"/images/"+ratingsL10n.image+"/rating_'.$i.'_over."+ratingsL10n.image_ext;'; } } else { $postratings_javascript = 'var ratings_mouseover_image=new Image();ratings_mouseover_image.src=ratingsL10n.plugin_url+"/images/"+ratingsL10n.image+"/rating_over."+ratingsL10n.image_ext;'; } wp_deregister_script( 'wp-postratings' ); wp_enqueue_script('wp-postratings', plugins_url('wp-postratings/postratings-js.js'), array('jquery'), WP_POSTRATINGS_VERSION, true); wp_localize_script('wp-postratings', 'ratingsL10n', array( 'plugin_url' => get_bloginfo('stylesheet_directory') . '/img/ratings', 'ajax_url' => admin_url('admin-ajax.php'), 'text_wait' => __('Please rate only 1 post at a time.', 'wp-postratings'), 'image' => get_option('postratings_image'), 'image_ext' => 'gif', 'max' => $postratings_max, 'show_loading' => intval($postratings_ajax_style['loading']), 'show_fading' => intval($postratings_ajax_style['fading']), 'custom' => $postratings_custom, 'l10n_print_after' => $postratings_javascript )); } add_action( 'wp_print_scripts', 'my_deregister_script', 100 ); // Fixing WP-Ratings plugin initial output, to match Design function prefix_ratings_fix($html) { $search = plugins_url( '/wp-postratings/images/stars/' ); $replace = get_bloginfo('stylesheet_directory') . '/img/ratings/images/stars/'; $html = str_replace($search, $replace, $html); return $html; } add_filter( 'expand_ratings_template', 'prefix_ratings_fix', 999, 1 ); // WP-Ratings Filter
Viewing 1 replies (of 1 total)