class-wp-posts-list-table.php : prepare_items() - Is $post_type global?
|Reported by:||tivnet||Owned by:|
|Component:||Posts, Post Types||Keywords:||reporter-feedback|
I had a weird error on this line in wp-admin/edit.php:
add_screen_option( 'per_page', array( 'label' => $title, 'default' => 20, 'option' => 'edit_' . $post_type . '_per_page' ) );
$post_type was as array, having 3 post types in it.
I was sorting posts by tag.
In attempt to trace this var (which is kind of global in edit.php), I came down to the prepare_items().
There, we have
$post_type = $this->screen->post_type;
and it's not clear to me whether it should be a local or global variable.
However, when I made it global:
global $avail_post_stati, $wp_query, $per_page, $mode, $post_type;
the error has gone.
The related change in code was 19/09/12 (ryan):
Revision 21914: Reduce reliance on global variables in the list tables. Allow passing a screen ID to the list tables so that ajax handlers can set the needed screen. Props nacin fixes #21871
Change History (5)
comment:1 @nofearinc — 22 months ago
- Cc mario@… added
- Component changed from General to Administration
- Version changed from 3.7.1 to 3.5
- Component changed from Administration to Posts, Post Types
- Focuses administration added
comment:4 @jessepollak — 20 months ago
- Keywords reporter-feedback added