Skip to content

Commit

Permalink
Add support for pmc_events post type. (#13)
Browse files Browse the repository at this point in the history
* Add support for pmc_events post type.

* Comment update.

* Add date_query to only retain six months of events.

* Code formatting.

* Init the class.

---------

Co-authored-by: Allan Collins <[email protected]>
  • Loading branch information
allan23 and allan23 authored May 21, 2024
1 parent ff071d8 commit 2281987
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
1 change: 1 addition & 0 deletions classes/class-init.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ private function _get_query_args_instances(): array {
new Query_Args\PMC_Carousel(),
new Query_Args\PMC_Custom_Feed(),
new Query_Args\PMC_Ecomm(),
new Query_Args\PMC_Events(),
new Query_Args\PMC_FAQ(),
new Query_Args\PMC_Gallery(),
new Query_Args\PMC_Hub(),
Expand Down
55 changes: 55 additions & 0 deletions classes/query-args/class-pmc-events.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Retain the last six months of `pmc_events` objects and their associated data.
*
* @package pmc-wp-local-data-cli
*/

declare( strict_types = 1 );

namespace PMC\WP_Local_Data_CLI\Query_Args;

use PMC\Events\Plugin;
use PMC\WP_Local_Data_CLI\Query_Args;

/**
* Class PMC_Top_Video.
*/
final class PMC_Events extends Query_Args {
/**
* Build array of `WP_Query` arguments used to retrieve IDs to retain.
*
* @return array
*/
public static function get_query_args(): array {
return [
'post_type' => Plugin::SLUG,
'date_query' => [
[
'after' => '-6 months',
],
],
];
}

/**
* Process dependent data associated with a given ID, such as a post's
* thumbnail.
*
* If post type has no dependent data, set `static::$find_linked_ids` to
* false to skip this method.
*
* @param int $id Post ID.
* @param string $post_type Post type of given ID.
* @return array
*/
// Declaration must be compatible with overridden method.
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassAfterLastUsed, Squiz.Commenting.FunctionComment.Missing, VariableAnalysis.CodeAnalysis.VariableAnalysis.UnusedVariable
public static function get_linked_ids( int $id, string $post_type ): array {
$ids = [];

self::_add_thumbnail_id( $ids, $id );

return $ids;
}
}

0 comments on commit 2281987

Please sign in to comment.