Function Reference: geodir_term_review_count_force_update

Summary

Force update review count.

Package

GeoDirectory

Return Values

(bool)

    Change Log

    Since: 1.0.0

    1.6.1 Fixed add listing page load time.

    Source File

    geodir_term_review_count_force_update() is located in geodirectory-functions/general_functions.php [Line: 4097]

    Source Code

    function geodir_term_review_count_force_update( $new_status, $old_status = '', $post = '' ) {
    	if ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'geodir_import_export' ) {
    		return; // do not run if importing listings
    	}
    
    	if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
    		return;
    	}
    
    	$post_ID = 0;
    	if ( ! empty( $post ) ) {
    		if ( isset( $post->post_type ) && strpos( $post->post_type, 'gd_' ) !== 0 ) {
    			return;
    		}
    
    		if ( $new_status == 'auto-draft' && $old_status == 'new' ) {
    			return;
    		}
    
    		if ( ! empty( $post->ID ) ) {
    			$post_ID = $post->ID;
    		}
    	}
    
    	if ( $new_status != $old_status ) {
    		geodir_count_reviews_by_terms( true, $post_ID );
    	}
    
    	return true;
    }