• Hi, Have I code right? I have newest Gator cache and WP-PostRatings. Now on click on star not working script all right. Please help me to correct code.

    
        /**
         * Make WP-PostRatings compatible with the Gator Cache.
         */
        function wp_postratings_clear_gator_cache($rate_userid, $post_id) {
            if ($post_id && class_exists('WpGatorCache')) {
                //$options = WpGatorCache::getOptions();
                // NOTE: use standard WP function since the main class method getOptions() is protected
                $options = get_option(WpGatorCache::PREFIX . '_opts', array('refresh' => array('home' => true, 'archive' => true)));
                $path_ref = '';
    
                // purge cache of the rated post
                if (null !== ($path = parse_url(get_permalink($post_id), PHP_URL_PATH))) {
                    WpGatorCache::purgePath($path);
                }
                // purge cache also for the page on which the post was rated (other than single)
                if (isset($_SERVER['HTTP_REFERER']) && '' !== ($path_ref = parse_url($_SERVER['HTTP_REFERER'], PHP_URL_PATH)) && $path !== $path_ref) {
                    WpGatorCache::purgePath($path_ref);
                }
                // refresh home page if desired and not already cleared
                if ($options['refresh']['home'] && $path_ref !== '/') {
                    WpGatorCache::purgePath('/');
                }
                // refresh taxonomy archive pages if desired and not already cleared
                if ($options['refresh']['archive'] && false !== ($terms = WpGatorCache::getArchiveTerms(get_post($post_id)))) {
                    foreach ($terms as $term) {
                        if (null !== ($path_tax = parse_url(get_term_link($term, $term->taxonomy), PHP_URL_PATH)) && $path_tax !== $path_ref) {
                            WpGatorCache::purgePath($path_tax);
                        }
                    }
                }
                // TODO: purge cache for other pages that might contain the rated post (e.g. post type archive)
            }
        }
    
    //    add_action('rate_post', 'wp_postratings_clear_gator_cache', 10, 2);
    

    Thanks Simca – Kritiky.cz

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Gator cache and WP-PostRatings’ is closed to new replies.