-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#39] Auction index #103
[#39] Auction index #103
Changes from all commits
e02d989
84dff8f
e6a2c41
10373bd
d34d4de
92a9d4b
03573ac
e55bc45
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I can't remember if the |
||||||
return sprintf( | ||||||
$image_html, | ||||||
); | ||||||
}, | ||||||
10, | ||||||
2 | ||||||
); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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, | ||
] | ||
Comment on lines
-58
to
71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moves this from the theme pattern into the plugin pattern |
||
); | ||
|
||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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( | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Very minor, but I usually only break things up into multiple lines if there easier to read. In this case, it might easier to keep this on 1 line since it's a pretty simple bit of code. |
||||||
'posts_per_page', | ||||||
9 | ||||||
); | ||||||
} | ||||||
); | ||||||
} | ||||||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,62 @@ | ||||||||
<?php | ||||||||
/** | ||||||||
* Pattern: Auction Archive | ||||||||
* | ||||||||
* @since 1.0.0 | ||||||||
* @package GoodBids | ||||||||
*/ | ||||||||
?> | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Just need to add a line here. |
||||||||
|
||||||||
<!-- 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: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":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"} /--> | ||||||||
<!-- /wp:query-no-results --> | ||||||||
|
||||||||
<!-- wp:group {"style":{"spacing":{"padding":{"top":"var:preset|spacing|50","bottom":"var:preset|spacing|50","left":"0","right":"0"},"margin":{"top":"0","bottom":"0"}}},"layout":{"type":"default"}} --> | ||||||||
<div class="wp-block-group" style="margin-top:0;margin-bottom:0;padding-top:var(--wp--preset--spacing--50);padding-right:0;padding-bottom:var(--wp--preset--spacing--50);padding-left:0"> | ||||||||
|
||||||||
<!-- wp:post-template {"align":"full","style":{"spacing":{"blockGap":"var:preset|spacing|30"}},"layout":{"type":"grid","columnCount":3}} --> | ||||||||
|
||||||||
<!-- wp:post-featured-image {"isLink":true,"aspectRatio":"1","style":{"spacing":{"margin":{"bottom":"0"},"padding":{"bottom":"var:preset|spacing|20"}}}} /--> | ||||||||
|
||||||||
<!-- wp:group {"style":{"spacing":{"blockGap":"10px","margin":{"top":"var:preset|spacing|20"},"padding":{"top":"0"}}},"layout":{"type":"flex","orientation":"vertical","flexWrap":"nowrap"}} --> | ||||||||
<div class="wp-block-group" style="margin-top:var(--wp--preset--spacing--20);padding-top:0"> | ||||||||
<!-- wp:post-title {"isLink":true,"style":{"layout":{"flexSize":"min(2.5rem, 3vw)","selfStretch":"fixed"}},"fontSize":"large"} /--> | ||||||||
|
||||||||
<!-- wp:spacer {"height":"0px","style":{"layout":{"flexSize":"min(1.5rem, 3vw)","selfStretch":"fixed"}}} --> | ||||||||
<div style="height:0px" aria-hidden="true" class="wp-block-spacer"> | ||||||||
</div> | ||||||||
<!-- /wp:spacer --> | ||||||||
</div> | ||||||||
<!-- /wp:group --> | ||||||||
|
||||||||
<!-- /wp:post-template --> | ||||||||
|
||||||||
<!-- wp:spacer {"height":"var:preset|spacing|40","style":{"spacing":{"margin":{"top":"0","bottom":"0"}}}} --> | ||||||||
<div style="margin-top:0;margin-bottom:0;height:var(--wp--preset--spacing--40)" aria-hidden="true" class="wp-block-spacer"></div> | ||||||||
<!-- /wp:spacer --> | ||||||||
|
||||||||
<!-- wp:query-pagination {"paginationArrow":"arrow","layout":{"type":"flex","justifyContent":"space-between"}} --> | ||||||||
<!-- wp:query-pagination-previous /--> | ||||||||
<!-- wp:query-pagination-next /--> | ||||||||
<!-- /wp:query-pagination --> | ||||||||
|
||||||||
</div> | ||||||||
<!-- /wp:group --> | ||||||||
</div> | ||||||||
<!-- /wp:query --> | ||||||||
</main> | ||||||||
<!-- /wp:group --> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<!-- wp:template-part {"slug":"header","area":"header","tagName":"header"} /--> | ||
<!-- wp:pattern {"slug":"goodbids/template-archive-auction"} /--> | ||
<!-- wp:template-part {"slug":"footer","area":"footer","tagName":"footer"} /--> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With the update to your Auction page PR, this is a great example of when we would need to pass the ID into the method. 👍