Beispiel #1
0
function appthemes_set_coordinates($post_id, $lat, $lng)
{
    global $wpdb;
    $coord = appthemes_get_coordinates($post_id, false);
    if (!$coord) {
        return $wpdb->insert($wpdb->app_geodata, compact('lat', 'lng', 'post_id'));
    } else {
        return $wpdb->update($wpdb->app_geodata, compact('lat', 'lng'), compact('post_id'));
    }
}
Beispiel #2
0
 private function export_row($post)
 {
     $user = get_user_by('id', $post->post_author);
     if ($user) {
         $post->post_author = $user->user_login;
     }
     $row = array();
     foreach ($this->fields as $col => $field) {
         $row[$col] = $post->{$field};
     }
     foreach ($this->custom_fields as $col => $data) {
         $row[$col] = get_post_meta($post->ID, $data['internal_key'], true);
     }
     foreach ($this->taxonomies as $col) {
         $terms = get_the_terms($post->ID, $col);
         if (!$terms) {
             $row[$col] = '';
         } else {
             $row[$col] = implode(',', wp_list_pluck($terms, 'name'));
         }
     }
     // TODO: tax_meta
     if ($this->geodata) {
         $coord = appthemes_get_coordinates($post->ID);
         $row['lat'] = $coord->lat;
         $row['lng'] = $coord->lng;
     }
     return $row;
 }