Skip to content

Commit

Permalink
Merge pull request #184 from Automattic/master
Browse files Browse the repository at this point in the history
Alpha release Jan 07
  • Loading branch information
dkoo authored Jan 7, 2022
2 parents 0713c10 + 3609e7a commit a387eea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 3 additions & 1 deletion includes/class-newspack-listings-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,9 @@ public static function enable_listing_category_archives( $query ) {
}

if ( ! is_admin() && $query->is_main_query() ) {
if ( is_category() || is_tag() ) {
$archive_should_include_listings = is_category() || is_tag();

if ( apply_filters( 'newspack_listings_archive_types', $archive_should_include_listings ) ) {
$existing_post_types = $query->get( 'post_type' );

// Don't alter the query for templates.
Expand Down
19 changes: 15 additions & 4 deletions includes/class-newspack-listings-featured.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public static function check_update_version() {
if ( self::TABLE_VERSION !== $current_version ) {
self::create_custom_table();
self::populate_custom_table();
update_option( self::TABLE_VERSION_OPTION, self::TABLE_VERSION );
}
}

Expand All @@ -118,8 +119,6 @@ public static function create_custom_table() {

require_once ABSPATH . 'wp-admin/includes/upgrade.php';
dbDelta( $sql ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.dbDelta_dbdelta

update_option( self::TABLE_VERSION_OPTION, self::TABLE_VERSION );
}
}

Expand Down Expand Up @@ -149,7 +148,13 @@ public static function populate_custom_table() {
$default_priority = 5;

foreach ( $results->posts as $featured_listing ) {
self::update_priority( $featured_listing->ID, $default_priority );
$priority = get_post_meta( $featured_listing->ID, 'newspack_listings_featured_priority', true );

if ( ! $priority ) {
$priority = $default_priority;
}

self::update_priority( $featured_listing->ID, $priority );
}

// If there were more than 1 page of results, repeat with subsequent pages until all posts are processed.
Expand All @@ -160,7 +165,13 @@ public static function populate_custom_table() {
$results = new \WP_Query( $args );

foreach ( $results->posts as $featured_listing ) {
self::update_priority( $featured_listing->ID, $default_priority );
$priority = get_post_meta( $featured_listing->ID, 'newspack_listings_featured_priority', true );

if ( ! $priority ) {
$priority = $default_priority;
}

self::update_priority( $featured_listing->ID, $priority );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/class-newspack-listings-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function get_default_settings() {
}

// Product settings are only relevant if WooCommerce is available.
if ( class_exists( 'WooCommerce' ) && defined( 'NEWSPACK_LISTINGS_SELF_SERVE_ENABLED' ) && NEWSPACK_LISTINGS_SELF_SERVE_ENABLED ) {
if ( class_exists( 'WooCommerce' ) && class_exists( 'WC_Subscriptions_Product' ) && defined( 'NEWSPACK_LISTINGS_SELF_SERVE_ENABLED' ) && NEWSPACK_LISTINGS_SELF_SERVE_ENABLED ) {
$product_settings = [
[
'description' => __( 'The base price for a single listing (no subscription).', 'newspack-listings' ),
Expand Down

0 comments on commit a387eea

Please sign in to comment.