public function search( WP_REST_Request $request ) { $term = sanitize_text_field( $request->get_param('search') ); if ( empty( $term ) ) { return [ 'ok' => false, 'message' => 'Kein Suchbegriff' ]; } error_log( '!!! SEARCH: ' . $term ); $results = []; $found_ids = []; /* |-------------------------------------------------------------------------- | SONDERFALL 1: Chipnummer (15-stellige Zahl) |-------------------------------------------------------------------------- */ if ( preg_match('/^\d{15}$/', $term) ) { global $wpdb; $id = $wpdb->get_var( $wpdb->prepare( " SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product' AND post_status = 'publish' AND ( post_content LIKE %s OR post_excerpt LIKE %s ) LIMIT 1 ", '%Chip:%' . $wpdb->esc_like($term) . '%', '%Chip:%' . $wpdb->esc_like($term) . '%' ) ); if ( $id ) { $post = get_post($id); $results[] = $this->format_result( $post ); } return [ 'ok' => true, 'search_term' => $term, 'count' => count($results), 'results' => $results ]; } /* |-------------------------------------------------------------------------- | SONDERFALL 2: Ear / OM Nummer (reine Zahlen) |-------------------------------------------------------------------------- */ if ( preg_match('/^\d+$/', $term) ) { global $wpdb; $id = $wpdb->get_var( $wpdb->prepare( " SELECT ID FROM {$wpdb->posts} WHERE post_type = 'product' AND post_status = 'publish' AND ( post_content LIKE %s OR post_excerpt LIKE %s ) LIMIT 1 ", '%OM:%' . $wpdb->esc_like($term) . '%', '%OM:%' . $wpdb->esc_like($term) . '%' ) ); if ( $id ) { $post = get_post($id); $results[] = $this->format_result( $post ); } return [ 'ok' => true, 'search_term' => $term, 'count' => count($results), 'results' => $results ]; } /* |-------------------------------------------------------------------------- | SONDERFALL 3: Kennel Attribut |-------------------------------------------------------------------------- */ if ( strlen($term) >= 3 ) { $kennel_query = new WP_Query([ 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => 8, 'tax_query' => [ [ 'taxonomy' => 'pa_kennel', 'field' => 'slug', 'terms' => sanitize_title($term), ] ] ]); foreach ($kennel_query->posts as $post) { $results[] = $this->format_result( $post ); } if ( ! empty($results) ) { return [ 'ok' => true, 'search_term' => $term, 'count' => count($results), 'results' => $results ]; } } Ohrmarke Nummer 9000………… | ProDog Romania e.V.

9000 Hunde wurden bisher dort vom Blue Vet Team kastriert
Finanziert durch ProDogRomania e.V.
Da sind wir schon ein bisschen stolz und vor allem aber dankbar, dass ihr uns Monat für Monat unter die Arme greift und den Kastrabanner ergrünen lasst! ❤ ??

21€ – so viel brauchen wir, um einen Hund vor Ort kastrierten lassen…

https://bis2024.prodogromania.de/kastrationsaktion/

Auswahl einschränken

[woof sid="prodogfilter" autohide=0 ]