Browse Source

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
pull/204/head
Dac Chartrand 5 years ago committed by GitHub
parent
commit
1b927aff6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      footer.php
  2. 12
      inc/helpers/namespace.php

2
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', '' );
}
}

12
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' );

Loading…
Cancel
Save