From 84b083f894498c4a8b936279aab0d97819f03bc2 Mon Sep 17 00:00:00 2001 From: Paul Kevan <2290623+pkevan@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:49:35 +0100 Subject: [PATCH] Allow skipping validation on URL (#1413) * Allow skipping validation on URL adds method to skip URLs which are incompatible with report, i.e. doaction events. --- .../classes/report/class-wordcamp-counts.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php b/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php index 3595d9bc80..f16589ce31 100644 --- a/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php +++ b/public_html/wp-content/plugins/wordcamp-reports/classes/report/class-wordcamp-counts.php @@ -217,6 +217,23 @@ protected function get_cache_expiration() { return $this->range->generate_cache_duration( parent::get_cache_expiration() ); } + /** + * Simple method to check against URL field + * + * @param int $wordcamp_id ID for the wordcamp post type. + * + * @return bool + */ + public function is_a_wordcamp_url( $wordcamp_id ) { + $url = get_post_meta( $wordcamp_id, 'URL', true ); + + // doaction sites are tracked but break the validate wordcamp site check. + if ( false !== strpos( $url, 'doaction' ) ) { + return false; + } + return true; + } + /** * Query and parse the data for the report. * @@ -246,6 +263,9 @@ public function get_data() { foreach ( $wordcamp_ids as $wordcamp_id ) { try { + if ( ! $this->is_a_wordcamp_url( $wordcamp_id ) ) { + continue; + } $valid = validate_wordcamp_id( $wordcamp_id ); $data = array_merge( $data, $this->get_data_for_site( $valid->site_id, $valid->post_id ) );