From 228198738ab4827591b0f1d3cc91598f86fcb371 Mon Sep 17 00:00:00 2001 From: Allan Collins Date: Tue, 21 May 2024 11:16:18 -0600 Subject: [PATCH] Add support for pmc_events post type. (#13) * 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 --- classes/class-init.php | 1 + classes/query-args/class-pmc-events.php | 55 +++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 classes/query-args/class-pmc-events.php diff --git a/classes/class-init.php b/classes/class-init.php index 27a353e..ce38033 100644 --- a/classes/class-init.php +++ b/classes/class-init.php @@ -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(), diff --git a/classes/query-args/class-pmc-events.php b/classes/query-args/class-pmc-events.php new file mode 100644 index 0000000..92ce7bc --- /dev/null +++ b/classes/query-args/class-pmc-events.php @@ -0,0 +1,55 @@ + 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; + } +}