• Resolved Angelo Rocha

    (@angelorocha)


    I’m working on a feature to identify queries, everything works fine with my code, but I would like to identify where these queries come from (whether plugin, theme or core). Is there any simple way to do this?

    My code:

    global $wpdb;
    $queries = [];
    $total   = 0;
    foreach($wpdb->queries as $key => $query):
    	$queries[] = [
    		'query' => $query[0],
    		'start' => number_format_i18n($query[1], 4),
    		'end'   => $query[3],
    		'rows'  => count($wpdb->get_results($query[0], ARRAY_A)),
    		'stack' => explode(',', $query[2]),
    	];
    	$total     += $query[1];
    endforeach;
    
    var_dump($queries);
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Identify plugin queries with wpdb’ is closed to new replies.