Site Reviews uses the load-edit.php and views_edit-site-review hooks to override the WP_Posts_List_Table class with a custom one.
Before WordPress v6.1.0 introduced the wp_list_table_class_name hook, there was no way to override the WP_Posts_List_Table class before it was initialized. In order to provide compatibility with WordPress < 6.1, Site Reviews does the following:
- Initializes a custom ListTable class after the WP_Posts_List_Table class has already been initialized and the main query setup (this is where the
wp
hook is first triggered since it is run in the wp_edit_posts_query function).
- Overrides the global
$wp_list_table
variable with the custom ListTable class.
Since the custom ListTable class extends the WP_Posts_List_Table, it means the main query is setup a second time (though the main query has already been cached at this point so there is no performance hit). This is why wp
is triggered twice on the All Reviews page.
Site Reviews v7.0.0 drops support for WordPress < 6.1, so you have two options:
- Wait for Site Reviews v7.0.0 to be released at end of the month(ish) and continue to use the high-level
wp
hook and perform some checks to ensure your code is only run once (i.e. If your custom function does not exist, run your code. If it does, skip the code).
- Use a more appropriate hook for your code snippet (i.e. unless your code needs to be run on every single page load of your several thousand pages, choose a more focused hook that is only run when needed and only on the pages needed).
See also: https://developer.www.ads-software.com/apis/hooks/action-reference/