* * @param string $url A taxonomy:// pseudo-URL. * @return array { * @type bool $broken True when the taxonomy is not registered. * @type int $http_code 200 if valid, 404 if not registered. * @type string $log Human-readable explanation of the result. * @type string $result_hash Stable hash that identifies the result type. * } */ public function check( $url ) { // Extract the taxonomy slug from the pseudo-URL. // wp_parse_url() on 'taxonomy://category' gives host = 'category'. $parsed = wp_parse_url( $url ); $taxonomy = isset( $parsed['host'] ) ? urldecode( $parsed['host'] ) : ''; if ( '' === $taxonomy ) { return array( 'broken' => true, 'http_code' => 0, 'log' => __( 'Could not determine taxonomy slug from the stored URL.', 'broken-link-checker' ), 'result_hash' => 'taxonomy_empty_slug', ); } if ( taxonomy_exists( $taxonomy ) ) { return array( 'broken' => false, 'http_code' => 200, /* translators: %s: taxonomy slug */ 'log' => sprintf( __( "Taxonomy '%s' is registered.", 'broken-link-checker' ), $taxonomy ), 'result_hash' => 'taxonomy_valid|' . $taxonomy, ); } return array( 'broken' => true, 'http_code' => 404, /* translators: %s: taxonomy slug */ 'log' => sprintf( __( "Taxonomy '%s' is not registered. The term relationship may be orphaned.", 'broken-link-checker' ), $taxonomy ), 'result_hash' => 'taxonomy_invalid|' . $taxonomy, ); } }