From 1b927aff6a4c50956c4017bac61d7dfeb5efddf6 Mon Sep 17 00:00:00 2001 From: Dac Chartrand Date: Tue, 10 Dec 2019 13:24:44 -0500 Subject: [PATCH] Fix#202 Books not being added to catalog (#203) Set `number` to to something absurdly high Use `meta_key` and `meta_value` to narrow results even further Fix undefined variable warning --- footer.php | 2 +- inc/helpers/namespace.php | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/footer.php b/footer.php index 994aca7..c74e806 100644 --- a/footer.php +++ b/footer.php @@ -28,7 +28,7 @@ if ( $pb_network_contact_form ) { * * @since Pressbooks 5.6.0 */ - $contact_link = apply_filters( 'pb_contact_link', $contact_link ); + $contact_link = apply_filters( 'pb_contact_link', '' ); } } diff --git a/inc/helpers/namespace.php b/inc/helpers/namespace.php index 1ec2ff8..04650fd 100644 --- a/inc/helpers/namespace.php +++ b/inc/helpers/namespace.php @@ -30,6 +30,8 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen ]; // Bail } + $dc = BookDataCollector::init(); + /** * Filter the WP_Site_Query args for the catalog display. * @@ -45,6 +47,9 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen apply_filters( 'pb_publisher_catalog_query_args', [ + 'number' => 1000000, + 'meta_key' => $dc::IN_CATALOG, // @codingStandardsIgnoreLine + 'meta_value' => 1, // @codingStandardsIgnoreLine 'public' => 1, 'archived' => 0, 'spam' => 0, @@ -56,14 +61,11 @@ function get_catalog_data( $page = 1, $per_page = 10, $orderby = 'title', $licen /** @var \WP_Site $site */ - $dc = BookDataCollector::init(); $sites_in_catalog = []; $sites = get_sites( $args ); foreach ( $sites as $site ) { - if ( get_site_meta( $site->blog_id, $dc::IN_CATALOG, true ) ) { - $site->pb_title = $dc->get( $site->blog_id, $dc::TITLE ); // Cool hack! :face_with_rolling_eyes: - $sites_in_catalog[] = $site; - } + $site->pb_title = $dc->get( $site->blog_id, $dc::TITLE ); // Cool hack! :face_with_rolling_eyes: + $sites_in_catalog[] = $site; } if ( $orderby === 'latest' ) { $sites_in_catalog = wp_list_sort( $sites_in_catalog, 'last_updated', 'DESC' );