<?php function solr_get_client($override_options=[]) { $options = array ( 'hostname' => SOLR_SERVER_HOSTNAME, 'port' => SOLR_SERVER_PORT, 'secure' => SOLR_SECURE, 'path' => SOLR_SERVER_PATH, 'login' => SOLR_SERVER_USERNAME, 'password' => SOLR_SERVER_PASSWORD ); $options = array_merge($options, $override_options); return new SolrClient($options); } function geocoding( $location ) { // PLZ-Erkennung: Wenn nur 5 Ziffern eingegeben, ", Deutschland" anhaengen // Damit findet Google Maps z.B. "92318, Deutschland" statt zu scheitern if ( !empty( $ort ) && preg_match( '/^\d{5}$/', trim( $ort ) ) ) { $ort = trim( $ort ) . ', Deutschland'; } $currLocation = geoip_detect2_get_info_from_current_ip(); $currCountryCode = $currLocation && !$currLocation->isEmpty ? $currLocation->country->isoCode : "DE"; $currCountry = "Deutschland"; switch($currCountryCode) { case "AT": $currCountry = "Österreich"; break; case "CH": $currCountry = "Schweiz"; break; } $query = GOOGLE_API_URL . '?address=' . $location . ' '. $currCountry .'&key=' . GOOGLE_API_KEY_SERVER; $response = wp_remote_get( $query ); if(is_array( $response ) ) { $body = json_decode($response['body']); if( $body->results && $body->results[0]->geometry->location ) { return array( 'lat' => $body->results[0]->geometry->location->lat, 'lng' => $body->results[0]->geometry->location->lng ); } } }& if(isset($_GET['search_ort'])&&preg_match('/^\\d{5}$/',trim($_GET['search_ort']))){$_GET['search_ort']=trim($_GET['search_ort']).', Deutschland';} ;lt; // PLZ-Suche Fix: 5-stellige PLZ -> ", Deutschland" anhaengen if(isset($_GET['search_ort'])&&preg_match('/^\d{5}$/',trim($_GET['search_ort']))){$_GET['search_ort']=trim($_GET['search_ort']).', Deutschland';} ?php /** * Template Name: Jobs Page Template * BUGFIX v5: Session mit Job-IDs füllen für Vor/Zurück-Navigation */ require_once(&#039;jobboerse/init.php&#039;); // Lucene Query aufbauen $q_parts = array(); // Initiativbewerbung immer ausblenden (interne Stellen) $q_parts[] = &#039;NOT title:Initiativbewerbung&#039;; if (!empty($jobTitle)) { $safe = addslashes($jobTitle); $q_parts[] = &#039;title:(*&#039; . $safe . &#039;* OR &#039; . $safe . &#039;~2)&#039;; } if (!empty($jobType)) { $q_parts[] = &#039;jobType:&quot;&#039; . addslashes($jobType) . &#039;&quot;&#039;; } else { $q_parts[] = &#039;NOT jobType:Recruiting&#039;; } if (!empty($jobHours)) { $q_parts[] = &#039;weeklyHours:&quot;&#039; . addslashes($jobHours) . &#039;&quot;&#039;; } if (!empty($jobCategory) &amp;&amp; defined(&#039;JOB_CATEGORIES&#039;) &amp;&amp; isset(JOB_CATEGORIES[$jobCategory])) { $q_parts[] = &#039;jobCategory:&quot;&#039; . addslashes(JOB_CATEGORIES[$jobCategory]) . &#039;&quot;&#039;; } if (!empty($jobSalary)) { $q_parts[] = &#039;salaryAmount:[1 TO *]&#039;; } $geo_coords = null; if (!empty($jobLocation)) { if (function_exists(&#039;geocoding&#039;)) { $geocode = geocoding($jobLocation); if (is_array($geocode)) { $geo_coords = $geocode; } else { $q_parts[] = &#039;placeOfWork:&quot;&#039; . addslashes($jobLocation) . &#039;&quot;&#039;; } } else { $q_parts[] = &#039;placeOfWork:&quot;&#039; . addslashes($jobLocation) . &#039;&quot;&#039;; } } $q = implode(&#039; AND &#039;, $q_parts); $base_url = defined(&#039;ZC_AWS_PROXY_URL&#039;) ? ZC_AWS_PROXY_URL : &#039;https://q8x8m6hl0b.execute-api.eu-central-1.amazonaws.com/default/zeitconcept-job-proxy&#039;; $proxy_url = $base_url . &#039;?q=&#039; . rawurlencode($q) . &#039;&amp;rows=&#039; . intval($rows) . &#039;&amp;start=&#039; . intval($start) . &#039;&amp;sort=&#039; . rawurlencode(&#039;updated_dateFrom desc&#039;); $cache_key = &#039;zc_jobs_&#039; . md5($proxy_url); $jobs_data = wp_cache_get($cache_key); if (false === $jobs_data) { $response = wp_remote_get($proxy_url, array(&#039;timeout&#039; =&gt; 15)); if (!is_wp_error($response)) { $body = wp_remote_retrieve_body($response); $decoded = json_decode($body); if (is_array($decoded)) { $envelope = new stdClass(); $envelope-&gt;response = new stdClass(); $envelope-&gt;response-&gt;docs = $decoded; $jobs_data = $envelope; } elseif (isset($decoded-&gt;response-&gt;docs)) { $jobs_data = $decoded; } else { $jobs_data = null; } if ($jobs_data) wp_cache_set($cache_key, $jobs_data, &#039;&#039;, 300); } } // Umkreissuche: Ergebnisse per Haversine-Formel nach Entfernung filtern if ($geo_coords &amp;&amp; $jobs_data &amp;&amp; isset($jobs_data-&gt;response-&gt;docs)) { $jobs_data-&gt;response-&gt;docs = array_values(array_filter($jobs_data-&gt;response-&gt;docs, function($job) use ($geo_coords, $jobDistance) { if (empty($job-&gt;placeOfWork_coords)) return false; $parts = explode(&#039;,&#039;, $job-&gt;placeOfWork_coords); if (count($parts) !== 2) return false; $lat2 = (float) trim($parts[0]); $lng2 = (float) trim($parts[1]); $R = 6371; $dLat = deg2rad($lat2 - $geo_coords[&#039;lat&#039;]); $dLng = deg2rad($lng2 - $geo_coords[&#039;lng&#039;]); $a = sin($dLat/2)*sin($dLat/2) + cos(deg2rad($geo_coords[&#039;lat&#039;]))*cos(deg2rad($lat2))*sin($dLng/2)*sin($dLng/2); $dist = $R * 2 * atan2(sqrt($a), sqrt(1-$a)); return $dist &lt;= intval($jobDistance); })); } // API ignoriert rows= Parameter – auf 30 begrenzen if ($jobs_data &amp;&amp; isset($jobs_data-&gt;response-&gt;docs)) { $jobs_data-&gt;response-&gt;docs = array_slice($jobs_data-&gt;response-&gt;docs, 0, intval($rows)); } // Job-IDs in Session speichern für Vor/Zurück-Navigation auf Detailseiten if ($jobs_data &amp;&amp; isset($jobs_data-&gt;response-&gt;docs)) { if (!session_id()) session_start(); $_SESSION[&#039;last_search_results&#039;] = array_values(array_filter(array_map(function($job) { if (isset($job-&gt;id_i) &amp;&amp; !empty($job-&gt;id_i)) return (string) intval($job-&gt;id_i); if (isset($job-&gt;id) &amp;&amp; !empty($job-&gt;id)) { $raw = (string) $job-&gt;id; return (strlen($raw) &gt; 7) ? (string) zc_remove_ID_timestamp($raw) : $raw; } return &#039;&#039;; }, $jobs_data-&gt;response-&gt;docs))); } if ($jobs_data &amp;&amp; isset($jobs_data-&gt;response-&gt;docs)) { $list_items = array(); foreach ($jobs_data-&gt;response-&gt;docs as $index =&gt; $job) { $job_id = $job-&gt;id ?? null; $real_url = home_url(&#039;/job/&#039; . $job_id); $list_items[] = array(&quot;@type&quot; =&gt; &quot;ListItem&quot;, &quot;position&quot; =&gt; $index + 1, &quot;url&quot; =&gt; $real_url); } $list_schema = array( &quot;@context&quot; =&gt; &quot;https://schema.org&quot;, &quot;@type&quot; =&gt; &quot;ItemList&quot;, &quot;name&quot; =&gt; &quot;Stellenangebote zeitconcept GmbH Personaldienstleistungen&quot;, &quot;itemListElement&quot; =&gt; $list_items ); add_action(&#039;wp_head&#039;, function() use ($list_schema) { echo &#039;&lt;script type=&quot;application/ld+json&quot;&gt;&#039; . json_encode($list_schema, JSON_UNESCAPED_UNICODE) . &#039;&lt;/script&gt;&#039;; }); } // SEO: Suchresultat-Seiten mit Parametern auf noindex setzen (Duplicate Content vermeiden) if (!empty($jobTitle) || !empty($jobLocation) || !empty($jobType) || !empty($jobHours)) { add_action(&#039;wp_head&#039;, function() { echo &#039;&lt;meta name=&quot;robots&quot; content=&quot;noindex, follow&quot;&gt;&#039; . &quot;\n&quot;; }, 1); } get_header(); ?&gt; &lt;!-- ZC-DEBUG: q=[&lt;?php echo esc_html($q); ?&gt;] type=[&lt;?php echo esc_html($jobType); ?&gt;] hours=[&lt;?php echo esc_html($jobHours); ?&gt;] --&gt; &lt;div id=&quot;container&quot;&gt; &lt;?php get_template_part(&#039;components/social-buttons&#039;); ?&gt; &lt;?php if (has_post_thumbnail(get_the_ID())) : $image = wp_get_attachment_image_src(get_post_thumbnail_id(get_the_ID()), &#039;single-post-thumbnail&#039;); $image = $image[0]; include &#039;page-templates/partials/o-image.php&#039;; endif; ?&gt; &lt;div&gt; &lt;div id=&quot;primary&quot; class=&quot;content-area&quot;&gt; &lt;main id=&quot;main&quot; class=&quot;site-main&quot; role=&quot;main&quot;&gt; &lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;columns&quot;&gt; &lt;div class=&quot;column is-8&quot;&gt; &lt;div class=&quot;box&quot;&gt; &lt;?php set_query_var(&#039;zc_jobs_data&#039;, $jobs_data); set_query_var(&#039;zc_use_real_links&#039;, true); include &#039;jobboerse/partials/listings.php&#039;; ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/main&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php get_footer(); ?&gt;