Skip to content

Instantly share code, notes, and snippets.

@Tmeister
Created March 21, 2022 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tmeister/a48311f82380f3a2588c2c54a2afcc61 to your computer and use it in GitHub Desktop.
Save Tmeister/a48311f82380f3a2588c2c54a2afcc61 to your computer and use it in GitHub Desktop.
Just a sample plugin, to set the publish view as the default view on the post table view.
<?php
/**
* Plugin Name: Post View Reorder
* Plugin URI: https://example.com/
* Description: Just a test plugin, do not use it on production.
* Version: 1.0.0
* Requires at least: 5.2
* Author: Enrique Chavez
* Author URI: https://enriquechavez.co/
*/
add_filter('views_edit-post', function ($views) {
$publish = $views['publish'];
unset($views['publish']);
return array_merge(['publish' => $publish], $views);
});
add_filter('add_menu_classes', function ($menus) {
return array_map(function ($item) {
if ($item[2] === 'edit.php') {
$item[2] = 'edit.php?post_status=publish&post_type=post';
}
return $item;
}, $menus);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment