From 6ad16a29dfc178d67ae7051fb951b666dd7e46c3 Mon Sep 17 00:00:00 2001 From: Ho Man Chan Date: Tue, 22 Sep 2020 08:14:02 -0400 Subject: [PATCH 1/5] Add network directory exclude when in catalog is toggled --- inc/admin/namespace.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/inc/admin/namespace.php b/inc/admin/namespace.php index bdacbb8..4d33e3b 100644 --- a/inc/admin/namespace.php +++ b/inc/admin/namespace.php @@ -7,6 +7,8 @@ namespace Aldine\Admin; use PressbooksMix\Assets; use Pressbooks\DataCollector\Book as BookDataCollector; +use Pressbooks\Admin\Network\SharingAndPrivacyOptions; +use Pressbooks\BookDirectory; /** * Uses old option to provide a simpler upgrade path from pressbooks-publisher theme @@ -52,7 +54,16 @@ function update_catalog() { } else { delete_blog_option( $blog_id, \Aldine\Admin\BLOG_OPTION ); update_site_meta( $blog_id, BookDataCollector::IN_CATALOG, 0 ); + // Exclude book when network option book directory non-catalog exclude is enabled + $option = get_site_option( pressbooks_sharingandprivacy_options, [], true ); + if ( + isset( $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] ) && + ( (bool) $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] === true ) + ) { + BookDirectory::init()->deleteBookFromDirectory( [ $blog_id ] ); + } } + update_blog_details( $blog_id, [ 'last_updated' => current_time( 'mysql', true ) ] ); } /** From d47a17cce91a6f0ca4361e72e726e65d3993e841 Mon Sep 17 00:00:00 2001 From: Ho Man Chan Date: Tue, 22 Sep 2020 08:36:49 -0400 Subject: [PATCH 2/5] Fix lint class ordering --- inc/admin/namespace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/admin/namespace.php b/inc/admin/namespace.php index 4d33e3b..fb9936f 100644 --- a/inc/admin/namespace.php +++ b/inc/admin/namespace.php @@ -7,8 +7,8 @@ namespace Aldine\Admin; use PressbooksMix\Assets; use Pressbooks\DataCollector\Book as BookDataCollector; -use Pressbooks\Admin\Network\SharingAndPrivacyOptions; use Pressbooks\BookDirectory; +use Pressbooks\Admin\Network\SharingAndPrivacyOptions; /** * Uses old option to provide a simpler upgrade path from pressbooks-publisher theme From 1b9f5a42247bf88e2c6dfd1cd16784598d17ce40 Mon Sep 17 00:00:00 2001 From: Ho Man Chan Date: Tue, 22 Sep 2020 09:10:53 -0400 Subject: [PATCH 3/5] Fix lint class ordering --- inc/admin/namespace.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/inc/admin/namespace.php b/inc/admin/namespace.php index fb9936f..aac9762 100644 --- a/inc/admin/namespace.php +++ b/inc/admin/namespace.php @@ -5,10 +5,10 @@ namespace Aldine\Admin; +use Pressbooks\Admin\Network\SharingAndPrivacyOptions; use PressbooksMix\Assets; -use Pressbooks\DataCollector\Book as BookDataCollector; use Pressbooks\BookDirectory; -use Pressbooks\Admin\Network\SharingAndPrivacyOptions; +use Pressbooks\DataCollector\Book as BookDataCollector; /** * Uses old option to provide a simpler upgrade path from pressbooks-publisher theme From 0a542a88753639067ff14329fceb54fedc0a7330 Mon Sep 17 00:00:00 2001 From: Ho Man Chan Date: Tue, 22 Sep 2020 09:15:10 -0400 Subject: [PATCH 4/5] Fix Lint --- inc/admin/namespace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/admin/namespace.php b/inc/admin/namespace.php index aac9762..1b8dadd 100644 --- a/inc/admin/namespace.php +++ b/inc/admin/namespace.php @@ -5,8 +5,8 @@ namespace Aldine\Admin; -use Pressbooks\Admin\Network\SharingAndPrivacyOptions; use PressbooksMix\Assets; +use Pressbooks\Admin\Network\SharingAndPrivacyOptions; use Pressbooks\BookDirectory; use Pressbooks\DataCollector\Book as BookDataCollector; From 28ba430afa44d627acaff507aa46d4ebad779a2f Mon Sep 17 00:00:00 2001 From: Ho Man Chan Date: Thu, 15 Oct 2020 14:27:49 -0400 Subject: [PATCH 5/5] Fix site option to use string --- inc/admin/namespace.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/admin/namespace.php b/inc/admin/namespace.php index 1b8dadd..32fd366 100644 --- a/inc/admin/namespace.php +++ b/inc/admin/namespace.php @@ -55,7 +55,7 @@ function update_catalog() { delete_blog_option( $blog_id, \Aldine\Admin\BLOG_OPTION ); update_site_meta( $blog_id, BookDataCollector::IN_CATALOG, 0 ); // Exclude book when network option book directory non-catalog exclude is enabled - $option = get_site_option( pressbooks_sharingandprivacy_options, [], true ); + $option = get_site_option( 'pressbooks_sharingandprivacy_options', [], true ); if ( isset( $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] ) && ( (bool) $option[ SharingAndPrivacyOptions::NETWORK_DIRECTORY_EXCLUDED ] === true )