You know the “quick action” button in the WordPress admin? It’s a darn useful little UI touch. At the Dashboard, the default is “New Post”. But depending on where you are in the Admin, the default of it changes. In general it’s really helpful. For example when you are in the Plugins area, the default is Install Plugins:
Default action being smart
A while ago I was moaning about one particular area where I didn’t find the default being so smart. When you publish a new Post, the default goes to New Post. To me it would make sense when you publish a new Page to have that button be New Page. If you have a WordPress site where you publish a lot of pages, you can feel me.
Reader Otto let me know there is a way you can change this. Here is Otto:
Adding the New Page as default there is actually rather simple.
Look in wp-admin/includes/template.php. Down towards the bottom of the file, you’ll find the function favorite_actions().
In that function, it reads the wp-admin page name and sets a $default_action based on that. For example, when you’re looking at the edit-pages.php screen, the default action becomes “New Page”.
The Page editor screen is page.php. Note that it has no default action. To give it one, simply add a case ‘page.php': in the correct place. You can add it directly before that case ‘edit-pages.php’ if you want the default action to be the same New Page link.
If you want this change made to core, then I suggest making an Enhancement ticket to that effect on the WordPress trac. As always search first, somebody else might have already made that ticket request.
So to fix my particular gripe, I just opened the file at the path mentioned above and found the
favorite_actions function. It’s a pretty readable function, and adding a new bit to change the behavior is pretty easy. I just added this right above the one for
case 'page.php': $default_action = array('page-new.php' => array(__('New Page'), 'edit_pages')); break;
This is what you would call a “core hack”. Meaning that next time you upgrade WordPress, this code will be gone. It doesn’t mean “don’t do it” and it especially doesn’t mean “do it and don’t upgrade”. It means that you should make a note somewhere handy to yourself that when you do upgrade, you can see if it’s fixed and if it’s not, make the same alteration again.
Also as Otto suggested, there is an official channel for getting stuff done like this, the WordPress trac. I’ve never submitted anything there before, but to put my money where my mouth is I opened a ticket.