From d04bfe9377d9be280ee25a3d9ecdd693e9bfc496 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Sun, 8 Dec 2024 02:22:50 +0000 Subject: [PATCH 1/2] fix(guest-authors-for-cli): allow GAs for CLI context --- .../class-guest-contributor-role.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/includes/plugins/co-authors-plus/class-guest-contributor-role.php b/includes/plugins/co-authors-plus/class-guest-contributor-role.php index 79d57ec3ad..7291f0707e 100644 --- a/includes/plugins/co-authors-plus/class-guest-contributor-role.php +++ b/includes/plugins/co-authors-plus/class-guest-contributor-role.php @@ -98,13 +98,24 @@ public static function initialize() { * @return void */ public static function early_init() { + + // Enable Guest Authors... + // -- if constant exists and is true. if ( defined( 'NEWSPACK_ENABLE_CAP_GUEST_AUTHORS' ) && NEWSPACK_ENABLE_CAP_GUEST_AUTHORS ) { return; } - if ( ! self::site_has_cap_guest_authors() ) { - add_filter( 'coauthors_guest_authors_enabled', '__return_false' ); - add_action( 'admin_menu', [ __CLASS__, 'guest_author_menu_replacement' ] ); + // -- if site already has Guest Authors. + if ( self::site_has_cap_guest_authors() ) { + return; + } + // -- if CLI context. + if ( defined( 'WP_CLI' ) && WP_CLI ) { + return; } + + // Disable Guest Authors. + add_filter( 'coauthors_guest_authors_enabled', '__return_false' ); + add_action( 'admin_menu', [ __CLASS__, 'guest_author_menu_replacement' ] ); } /** From d8c7978fc0f94a0ca592b7e98edeb22adaba44e2 Mon Sep 17 00:00:00 2001 From: ronchambers Date: Sun, 8 Dec 2024 03:02:21 +0000 Subject: [PATCH 2/2] fix(guest-authors-for-cli): allow GAs for CLI context (simplified) --- .../class-guest-contributor-role.php | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/includes/plugins/co-authors-plus/class-guest-contributor-role.php b/includes/plugins/co-authors-plus/class-guest-contributor-role.php index 7291f0707e..322b7aac1c 100644 --- a/includes/plugins/co-authors-plus/class-guest-contributor-role.php +++ b/includes/plugins/co-authors-plus/class-guest-contributor-role.php @@ -98,24 +98,16 @@ public static function initialize() { * @return void */ public static function early_init() { - - // Enable Guest Authors... - // -- if constant exists and is true. if ( defined( 'NEWSPACK_ENABLE_CAP_GUEST_AUTHORS' ) && NEWSPACK_ENABLE_CAP_GUEST_AUTHORS ) { return; } - // -- if site already has Guest Authors. - if ( self::site_has_cap_guest_authors() ) { - return; - } - // -- if CLI context. if ( defined( 'WP_CLI' ) && WP_CLI ) { return; } - - // Disable Guest Authors. - add_filter( 'coauthors_guest_authors_enabled', '__return_false' ); - add_action( 'admin_menu', [ __CLASS__, 'guest_author_menu_replacement' ] ); + if ( ! self::site_has_cap_guest_authors() ) { + add_filter( 'coauthors_guest_authors_enabled', '__return_false' ); + add_action( 'admin_menu', [ __CLASS__, 'guest_author_menu_replacement' ] ); + } } /**