Skip to content

Commit

Permalink
Add support for Harmony video events (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
vtellapmc authored May 22, 2024
1 parent 2281987 commit d61ee86
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 @@ -189,6 +189,7 @@ private function _get_query_args_instances(): array {
new Query_Args\PMC_Events(),
new Query_Args\PMC_FAQ(),
new Query_Args\PMC_Gallery(),
new Query_Args\PMC_Harmony_Companion(),
new Query_Args\PMC_Hub(),
new Query_Args\PMC_List(),
new Query_Args\PMC_Not_For_Publication(),
Expand Down
55 changes: 55 additions & 0 deletions classes/query-args/class-pmc-harmony-companion.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Retain the last six months of `pmc_event_video` 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\Harmony_Companion\Event_Video;
use PMC\WP_Local_Data_CLI\Query_Args;

/**
* Class PMC_Harmony_Companion.
*/
final class PMC_Harmony_Companion 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' => Event_Video::POST_TYPE_NAME,
'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 d61ee86

Please sign in to comment.