I am trying to understand how the Admin Tables are populated (for posts, users, plugins…).
With Terms/Taxonomies I am confused. In the /wp-admin/edit-tags.php file everything is normal until we reach the $wp_list_table->prepare_items() method (where an $args is set up to later on go fetch data), but from there on I don’t understand where the actual database query takes place.
Looking at the WP Users List Table’s prepare_items() method, it’s quite clear:
$wp_user_search = new WP_User_Query($args); $this->items = $wp_user_search->get_results();
So I expected a similar approach for Terms, but looking at the WP Terms List Table class, you can find:
public function has_items(){
// todo: populate $this->items in prepare_items()
return true;
}
Which means that the items are loaded somewhere else. But where?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The items are loaded via get_terms() (see source on Trac) in the display_rows_or_placeholder() method which is called in the display() method which is called in wp-admin/edit-tags.php (see source on Trac). But the $items property is never populated with the terms.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0