admin管理员组

文章数量:1122846

friends. I have encountered a problem updating records. I am importing vacancies into the WP Job Board Pro plugin via the WP All Import Pro plugin.

When importing, I have a field in wp_postmeta _job_map_location. I pass a serialized array of addresses to it via a self-written function via the Google API.

I'm getting the address.

But when I go to the job page, the address on the Google map is not displayed on the front side. And when I go to the admin panel and click update entry, the map appears on the frontend.

Ego iustus cucurrit ex iam cogitationes. Quid faciam iniuriam?

I'm calling this function in the field [get_map_location({undefined8[1]})] - Where {undefined8[1]} is the address.

function get_map_location($value){
    if(empty($value)){
        return serialize([
        'address' => 'Санкт-Петербург',
        'latitude' => 59.9343,
        'longitude' => 30.3351
        ]);
    }

    $form_address = urlencode($value);
    $geocode_url = "={$form_address}&language=ru&key=API_KEY";
 
    $response = wp_remote_get($geocode_url);
    $body = wp_remote_retrieve_body($response);
    $data = json_decode($body);
    
    $map_data = [];

    if($data->status === 'OK') {
        $json_address = $data->results[0]->formatted_address;
        $latitude = $data->results[0]->geometry->location->lat;
        $longitude = $data->results[0]->geometry->location->lng;
        
        $map_data['address'] = $json_address;
        $map_data['latitude'] = $latitude;
        $map_data['longitude'] = $longitude;    
    }
    return serialize($map_data); 
}

本文标签: phpGlobal update of records after import WP All Import Pro