Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Move author metabox to publish metabox
- *
- * NOT with Gutenberg enabled {use @link https://wordpress.org/plugins/disable-gutenberg/}
- *
- * The first function will remove the original author metabox
- * and the second function will add the author metabox to the publish metabox
- * The first function will also do a check for if( is_admin) so it will only run
- * in the back-end.
- *
- * Read more {@link https://codex.wordpress.org/Plugin_API/Action_Reference/post_submitbox_misc_actions}
- * {@link https://developer.wordpress.org/reference/functions/remove_meta_box/}
- * {@link https://developer.wordpress.org/reference/functions/add_meta_box/}
- *
- * Works with WP @version 5.0.3 and below
- */
- /**
- * Remove the author metabox
- */
- add_action('add_meta_boxes', 'remove_author_metabox', 999);
- function remove_author_metabox()
- {
- if( is_admin() )
- {
- $post_types = get_post_types();
- foreach ( $post_types as $post_type )
- {
- remove_meta_box('authordiv', $post_type, 'normal');
- }
- }
- }
- /**
- * Add author metabox to the publish metabox
- */
- add_action( 'post_submitbox_misc_actions', 'add_author_metabox_to_publish_metabox' );
- function add_author_metabox_to_publish_metabox()
- {
- ?><style>
- .misc-pub-section {
- border-top-style:solid;
- border-top-width:1px;
- border-top-color:#EEEEEE;
- border-bottom-width:0px;
- }
- </style><?php
- global $post_ID;
- $post = get_post( $post_ID );
- echo '<div id="author" class="misc-pub-section" >Author: ';
- post_author_meta_box( $post );
- echo '</div>';
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement