Skip to content

Commit

Permalink
[#39] Setting default image for Auction index
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-schmidt-viget committed Dec 18, 2023
1 parent 7488ad4 commit 8324d4f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
16 changes: 10 additions & 6 deletions client-mu-plugins/goodbids/src/classes/Auctions/Auctions.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function () {
'label' => __( 'Auction', 'goodbids' ),
'description' => __( 'GoodBids Auction Custom Post Type', 'goodbids' ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'revisions' ),
'supports' => array( 'title', 'editor', 'thumbnail', 'comments', 'revisions' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
Expand Down Expand Up @@ -468,15 +468,19 @@ function ( int $post_id ) {
private function set_default_feature_image(): void {
add_filter(
'post_thumbnail_html',
function ( string $html, int $blog_id ) {
function ( string $html, int $auction_id ) {
if ( $html ) {
return $html;
}

return sprintf(
'<img src="%1$s" class="custom-logo" itemprop="logo" alt="GoodBids">',
esc_attr( GOODBIDS_PLUGIN_URL . 'assets/images/goodbids-logo.png' ),
);
if ( is_post_type_archive( 'gb-auction' ) ) {
$reward_id = goodbids()->auctions->get_reward_product_id( $auction_id );
$product = wc_get_product( $reward_id );
$product_html = $product->get_image();
return sprintf(
$product_html,
);
}
},
10,
2
Expand Down
12 changes: 9 additions & 3 deletions themes/goodbids-nonprofit/patterns/template-archive-auction.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<!-- wp:group {"tagName":"main","style":{"spacing":{"blockGap":"0","margin":{"top":"0"}}},"layout":{"type":"constrained","justifyContent":"left"}} -->
<main class="wp-block-group" style="margin-top:0">
<!-- wp:heading {"level":1} -->
<h1 class="wp-block-heading"><?php esc_html_e( 'Our Auctions', 'goodbids-nonprofit' ); ?></h1>
<!-- wp:spacer -->
<div style="height:100px" aria-hidden="true" class="wp-block-spacer"></div>
<!-- /wp:spacer -->

<!-- wp:heading {"level":1,"style":{"typography":{"textTransform":"capitalize"}}} -->
<h1 class="wp-block-heading" style="text-transform:capitalize">
<?php esc_html_e( 'Our Auctions', 'goodbids-nonprofit' ); ?>
</h1>
<!-- /wp:heading -->

<!-- wp:query {"query":{"perPage":10,"pages":0,"offset":"0","postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true},"align":"wide","layout":{"type":"default"}} -->
<!-- wp:query {"query":{"perPage":9,"pages":0,"offset":"0","postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true},"align":"wide","layout":{"type":"default"}} -->
<div class="wp-block-query alignwide">
<!-- wp:query-no-results -->
<!-- wp:pattern {"slug":"twentytwentyfour/hidden-no-results"} /-->
Expand Down

0 comments on commit 8324d4f

Please sign in to comment.