diff --git a/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php b/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php index 417b00856..ddf2a4037 100644 --- a/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php +++ b/client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php @@ -56,6 +56,9 @@ public function __construct() { // Update Bid Product when Auction is updated. $this->update_bid_product_on_auction_update(); + + // Sets a default image + $this->set_default_feature_image(); } /** @@ -160,7 +163,7 @@ private function get_template(): array { * * @return void */ - private function init_rewards_category() : void { + private function init_rewards_category(): void { add_action( 'init', function () { @@ -187,7 +190,7 @@ public function get_post_type(): string { * * @return ?int */ - public function get_auction_id() : ?int { + public function get_auction_id(): ?int { $auction_id = is_singular( $this->get_post_type() ) ? get_queried_object_id() : get_the_ID(); if ( ! $auction_id && is_admin() && ! empty( $_GET['post'] ) ) { @@ -208,7 +211,7 @@ public function get_auction_id() : ?int { * * @return ?int */ - public function get_rewards_category_id() : ?int { + public function get_rewards_category_id(): ?int { $rewards_category = get_term_by( 'slug', 'rewards', 'product_cat' ); if ( ! $rewards_category ) { @@ -270,8 +273,8 @@ public function set_bid_product_id( int $auction_id, int $bid_product_id ): void * * @since 1.0.0 * - * @param string $meta_key - * @param ?int $auction_id + * @param string $meta_key + * @param ?int $auction_id * * @return mixed */ @@ -292,7 +295,7 @@ public function get_setting( string $meta_key, int $auction_id = null ): mixed { * * @return int */ - public function get_reward_product_id( int $auction_id = null ) : int { + public function get_reward_product_id( int $auction_id = null ): int { return intval( $this->get_setting( 'auction_product', $auction_id ) ); } @@ -305,7 +308,7 @@ public function get_reward_product_id( int $auction_id = null ) : int { * * @return int */ - public function get_estimated_value( int $auction_id = null ) : int { + public function get_estimated_value( int $auction_id = null ): int { return intval( $this->get_setting( 'estimated_value', $auction_id ) ); } @@ -362,7 +365,7 @@ public function get_bid_increment( int $auction_id = null ): int { * * @return int */ - public function get_starting_bid( int $auction_id = null ) : int { + public function get_starting_bid( int $auction_id = null ): int { return intval( $this->get_setting( 'starting_bid', $auction_id ) ); } @@ -406,7 +409,7 @@ public function get_goal( int $auction_id = null ): int { * * @return int */ - public function get_expected_high_bid( int $auction_id = null ) : int { + public function get_expected_high_bid( int $auction_id = null ): int { return intval( $this->get_setting( 'expected_high_bid', $auction_id ) ); } @@ -454,4 +457,31 @@ function ( int $post_id ) { } ); } + + /** + * Set the default feature image for Auction + * + * @since 1.0.0 + * + * @return void + */ + private function set_default_feature_image(): void { + add_filter( + 'post_thumbnail_html', + function ( string $html, int $post_id ) { + if ( ! is_post_type_archive( $this->get_post_type() ) ) { + return $html; + } + + $reward_id = goodbids()->auctions->get_reward_product_id( $post_id ); + $product = wc_get_product( $reward_id ); + $image_html = $product->get_image(); + return sprintf( + $image_html, + ); + }, + 10, + 2 + ); + } } diff --git a/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php b/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php index 9fe2fe56b..2a3a3b1b8 100644 --- a/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php +++ b/client-mu-plugins/goodbids/src/classes/Frontend/Patterns.php @@ -55,19 +55,19 @@ function (): void { ] ); - $sample_pattern = [ - 'name' => 'sample-pattern', - 'path' => GOODBIDS_PLUGIN_PATH . 'views/patterns/sample-pattern.php', - 'title' => __( 'GoodBids Sample Pattern', 'goodbids' ), + $auction_archive = [ + 'name' => 'template-archive-auction', + 'path' => GOODBIDS_PLUGIN_PATH . 'views/patterns/template-archive-auction.php', + 'title' => __( 'Archive Auction', 'goodbids' ), 'categories' => [ 'goodbids' ], - 'keywords' => [ 'example', 'template', 'demo' ], + 'keywords' => [ 'non-profit', 'starter', 'archive' ], 'inserter' => true, ]; $this->patterns = apply_filters( 'goodbids_block_patterns', [ - $sample_pattern, + $auction_archive, ] ); diff --git a/client-mu-plugins/goodbids/src/classes/Network/Sites.php b/client-mu-plugins/goodbids/src/classes/Network/Sites.php index 4b102e480..20fd3d838 100644 --- a/client-mu-plugins/goodbids/src/classes/Network/Sites.php +++ b/client-mu-plugins/goodbids/src/classes/Network/Sites.php @@ -49,6 +49,7 @@ public function __construct() { // New Site Actions $this->activate_child_theme_on_new_site(); $this->default_child_theme_logo(); + $this->set_default_posts_per_page(); } /** @@ -323,7 +324,6 @@ function ( WP_Site $new_site, array $args ) { private function save_edit_site_fields(): void { add_action( 'wp_update_site', - /** * @param WP_Site $new_site New site object. * @param WP_Site $old_site Old site object. @@ -420,4 +420,23 @@ function ( string $html, int $blog_id ) { 2 ); } + + /** + * Set the archive to show nine posts per pagination + * + * @since 1.0.0 + * + * @return void + */ + private function set_default_posts_per_page(): void { + add_action( + 'goodbids_init_site', + function ( int $site_id ): void { + update_option( + 'posts_per_page', + 9 + ); + } + ); + } } diff --git a/client-mu-plugins/goodbids/views/patterns/sample-pattern.php b/client-mu-plugins/goodbids/views/patterns/sample-pattern.php deleted file mode 100644 index 3e61bc249..000000000 --- a/client-mu-plugins/goodbids/views/patterns/sample-pattern.php +++ /dev/null @@ -1,22 +0,0 @@ - - -
-
-

-
- - - -
-

-
-
- diff --git a/client-mu-plugins/goodbids/views/patterns/template-archive-auction.php b/client-mu-plugins/goodbids/views/patterns/template-archive-auction.php new file mode 100644 index 000000000..309f5c201 --- /dev/null +++ b/client-mu-plugins/goodbids/views/patterns/template-archive-auction.php @@ -0,0 +1,62 @@ + + + +
+ + + + + +

+ +

+ + + +
+ + + + + +
+ + + + + + +
+ + + + + +
+ + + + + + + + + + + + + +
+ +
+ +
+ diff --git a/themes/goodbids-nonprofit/templates/archive-gb-auction.html b/themes/goodbids-nonprofit/templates/archive-gb-auction.html new file mode 100644 index 000000000..4afcf8912 --- /dev/null +++ b/themes/goodbids-nonprofit/templates/archive-gb-auction.html @@ -0,0 +1,3 @@ + + +