• Using WP Customer Reviews on a site with roughly ~2500 posts and seeing significantly long load times in WP admin on standalone VM servers. With the plugin activated, our page load time is roughly 8 seconds and with it deactivated, we are seeing roughly 1 second page load times.

    I think I’ve isolated the issue but am not sure what the best approach for fixing it is. It seems that the get_all_posts_pages() function runs on every admin page and has a couple of expensive queries but is only necessary on the listing of reviews (I think?).

    If I comment out lines 613 – 671 in /includes/admin/wp-customer-reviews-3-admin.php, I see significant gains on page load speed (down to about 1.5 seconds). I’m just not sure what functionality I’m going to break by removing that code. Individual post edit screens seem to load fine and still display the review metaboxes… and the listing page for the wpcr3_review post type still seems to load as well. Can you give me some clarity on what those lines are there for and if there’s any way to optimize this quickly? Thank you!

    https://www.ads-software.com/plugins/wp-customer-reviews/

Viewing 1 replies (of 1 total)
  • Looks like that bit of code is used to generate the list of posts in the meta box when you are editing a review.

    I ended up rewriting the get_all_posts_pages function on our development site to be:

    function get_all_posts_pages($only_plugin_enabled_posts) {
    		global $wpdb;
    
    		$where = " WHERE post_title != '' AND post_type IN ('post', 'page') AND post_status IN ('publish','pending','draft','future','private','trash')";
    		$query = "SELECT ID, post_title, post_type FROM wp_posts";
    
    		if ($only_plugin_enabled_posts) {
    			$where .= " AND wp_postmeta.meta_key = 'wpcr3_enable' AND wp_postmeta.meta_value = 1";
    			$query .= " INNER JOIN wp_postmeta ON wp_posts.ID=wp_postmeta.post_id";
    		}
    		$tmp = $wpdb->get_results($query.$where." GROUP BY wp_posts.ID ORDER BY post_title ASC");
    		return $tmp;
    	}

    and making line 616: foreach ($tmpPosts as $p) { instead of foreach ($tmpPosts->posts as $p) {

    this gets me the same functions with an execution time of ~.50 seconds..

    Is this a change that you can add to the next release so we can make sure to stay up to date and allow everyone to benefit from faster load times?

Viewing 1 replies (of 1 total)
  • The topic ‘Admin loading everything always?’ is closed to new replies.