Skip to content

Commit

Permalink
Fix#202 Books not being added to catalog (#203)
Browse files Browse the repository at this point in the history
Set `number` to to something absurdly high
Use `meta_key` and `meta_value` to narrow results even further
Fix undefined variable warning
  • Loading branch information
dac514 authored Dec 10, 2019
1 parent 262df22 commit 1b927af
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion footer.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*
* @since Pressbooks 5.6.0
*/
$contact_link = apply_filters( 'pb_contact_link', $contact_link );
$contact_link = apply_filters( 'pb_contact_link', '' );
}
}

Expand Down
12 changes: 7 additions & 5 deletions inc/helpers/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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,
Expand All @@ -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' );
Expand Down

0 comments on commit 1b927af

Please sign in to comment.