Created
March 21, 2022 17:53
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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