Skip to content

Commit

Permalink
Allow skipping validation on URL (#1413)
Browse files Browse the repository at this point in the history
* Allow skipping validation on URL

adds method to skip URLs which are incompatible with report, i.e. doaction events.
  • Loading branch information
pkevan authored Oct 22, 2024
1 parent daed281 commit 84b083f
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down Expand Up @@ -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 ) );
Expand Down

0 comments on commit 84b083f

Please sign in to comment.