From 101eaeb6e071cb34e847c3d4db06652810700d52 Mon Sep 17 00:00:00 2001 From: Nikhil Date: Sun, 8 Apr 2018 11:40:18 +0530 Subject: [PATCH 1/3] Don't create a separate metabox. Adds the unlist post option in post publish metabox. --- class-unlist-posts-admin.php | 37 +++++++++++------------------------- 1 file changed, 11 insertions(+), 26 deletions(-) diff --git a/class-unlist-posts-admin.php b/class-unlist-posts-admin.php index 5c99c0b..8ecdd30 100644 --- a/class-unlist-posts-admin.php +++ b/class-unlist-posts-admin.php @@ -38,34 +38,18 @@ public static function instance() { * Constructor */ private function __construct() { - add_action( 'add_meta_boxes', array( $this, 'register_metabox' ) ); + add_action( 'post_submitbox_misc_actions', array( $this, 'metabox_render' ) ); add_action( 'save_post', array( $this, 'save_meta' ) ); } - /** - * Register meta box(es). - */ - function register_metabox() { - $args = array( - 'public' => true, - ); - - $post_types = get_post_types( $args, 'names', 'and' ); - - add_meta_box( - 'ehf-meta-box', __( 'Unlist Post', 'unlist-posts' ), array( - $this, - 'metabox_render', - ), $post_types, 'side', 'high' - ); - } - /** * Render Meta field. * * @param POST $post Currennt post object which is being displayed. */ - function metabox_render( $post ) { + function metabox_render() { + + global $post; $hidden_posts = get_option( 'unlist_posts', array() ); @@ -82,12 +66,13 @@ function metabox_render( $post ) { // We'll use this nonce field later on when saving. wp_nonce_field( 'unlist_post_nounce', 'unlist_post_nounce' ); ?> -

- -

-

+
+

+ +

+
Date: Sun, 8 Apr 2018 11:54:22 +0530 Subject: [PATCH 2/3] updated function doc after the function parameter is removed --- class-unlist-posts-admin.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/class-unlist-posts-admin.php b/class-unlist-posts-admin.php index 734e37d..d2ef6d2 100644 --- a/class-unlist-posts-admin.php +++ b/class-unlist-posts-admin.php @@ -44,8 +44,8 @@ private function __construct() { /** * Render Meta field. - * - * @param POST $post Currennt post object which is being displayed. + * + * @return void */ function metabox_render() { From 1f9c810fd11b1a42b473939d802e3ee8e9070c6c Mon Sep 17 00:00:00 2001 From: Nikhil Date: Sun, 8 Apr 2018 12:17:45 +0530 Subject: [PATCH 3/3] Fix: phpcs error for empty line --- class-unlist-posts-admin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/class-unlist-posts-admin.php b/class-unlist-posts-admin.php index d2ef6d2..3adea69 100644 --- a/class-unlist-posts-admin.php +++ b/class-unlist-posts-admin.php @@ -44,7 +44,7 @@ private function __construct() { /** * Render Meta field. - * + * * @return void */ function metabox_render() {