Exemplo n.º 1
0
 public static function update_user_meta($user_id, $meta_key, $value)
 {
     if (!self::exists() || !intval($user_id)) {
         return;
     }
     update_field($meta_key, $value, 'user_' . intval($user_id));
 }
Exemplo n.º 2
0
function exchange_attach_participant_to_collab($participant)
{
    $cid = get_post_meta($participant->ID, 'collaboration_id', true);
    // Set as metavalue.
    $collab_args = exchange_get_collab_args();
    $collab_args['meta_value'] = $cid;
    // Create new query with this metavalue.
    $collab_query = new WP_Query($collab_args);
    // Result is collab_post_id.
    $collab = $collab_query->posts[0];
    if (empty($collab)) {
        return;
    }
    // Get relationship data from collab post.
    $party = get_post_meta($collab, 'participants', true);
    // Skip to next participant if collaboration already has this participant ID.
    if (!empty($party) && in_array(strval($participant->ID), $party, true)) {
        return;
    } else {
        if (!empty($party)) {
            array_push($party, $participant->ID);
        } else {
            $party[0] = $participant->ID;
        }
        update_field($GLOBALS['EXCHANGE_PLUGIN_CONFIG']['ACF']['fields']['collaboration-participants'], $party, $collab);
        return $participant->ID;
    }
}
Exemplo n.º 3
0
function modules_to_json()
{
    $modules_dir = get_template_directory() . '/content-editor/modules/custom';
    $cdir = scandir($modules_dir);
    $modules_json = array();
    foreach ($cdir as $key => $module) {
        if (!in_array($module, array(".", ".."))) {
            if (is_dir($modules_dir . DIRECTORY_SEPARATOR . $module)) {
                // get json
                $json = file_get_contents($modules_dir . '/' . $module . '/info.json');
                $json = json_decode($json, true);
                // push module metas to array
                $modules_json[$module] = $json;
            }
        }
    }
    if (!empty($modules_json)) {
        // json encode modules array
        $modules_array = json_encode($modules_json);
        // update json
        update_field('installed_modules', $modules_array, 'options');
    } else {
        update_field('installed_modules', false, 'options');
    }
}
function removeOtherPosts($post_type)
{
    if (is_admin() && isset($_GET['post'])) {
        if (true == isset($_GET['post'])) {
            $post_id = $_GET['post'];
        }
        $post_type_check = get_post($post_id)->post_type;
        //Check if the master field is selected & Check the post type is the same selected
        // This will prevent removing ALL master selections @jwaterer
        if (1 == get_field('remove_others', $post_id) && $post_type == $post_type_check) {
            //Stores current course selected of the current post in admin. @jwaterer
            $GLOBALS['current_course'] = get_field('course', $post_id)->ID;
            //Check all of the current post type for course value @jwaterer
            $args = array('post_type' => $post_type);
            $loop = new WP_Query($args);
            if ($loop->have_posts()) {
                while ($loop->have_posts()) {
                    $loop->the_post();
                    //Store the field in var to prevent slow server issues @jwaterer
                    $check = get_field('course', get_the_ID())->ID;
                    //checks if the current course on the page is matched on any other page. @jwaterer
                    if ($GLOBALS['current_course'] == $check) {
                        //Updates all the fields to 0 - no master @jwaterer
                        update_field('remove_others', 0, get_the_ID());
                    }
                }
            }
            //Sets the master field back to true(1) for the current post @jwaterer
            update_field('remove_others', 1, $post_id);
            add_action('admin_notices', 'my_admin_notice');
        }
    }
}
Exemplo n.º 5
0
function ocp_ajax_update_designs()
{
    if (isset($_REQUEST)) {
        $on_deck = $_REQUEST['on-deck'];
        $in_progress = $_REQUEST['in-progress'];
        $completed = $_REQUEST['completed'];
        $post_id = $_REQUEST['id'];
        //add on-deck items field_55346df0f3317
        if ($on_deck) {
            $ondeck_list = join(',', $on_deck);
            update_field('field_55346df0f3317', $ondeck_list, $post_id);
        } else {
            update_field('field_55346df0f3317', '', $post_id);
        }
        //add in-progress items field_55346e01f3318
        if ($in_progress) {
            $inprogress_list = join(',', $in_progress);
            update_field('field_55346e01f3318', $inprogress_list, $post_id);
        } else {
            update_field('field_55346e01f3318', '', $post_id);
        }
        //add completed items field_55346e0cf3319
        if ($completed) {
            $completed_list = join(',', $completed);
            update_field('field_55346e0cf3319', $completed_list, $post_id);
        } else {
            update_field('field_55346e0cf3319', '', $post_id);
        }
    }
    die;
}
 public function update_item($request)
 {
     $item = $this->prepare_item_for_database($request);
     if (is_array($item) && count($item) > 0) {
         foreach ($item['data'] as $key => $value) {
             if (isset($item['fields'][$key]['key'])) {
                 $field = $item['fields'][$key];
                 $type = $field['type'];
                 if ($type == "true_false") {
                     switch ($value) {
                         case "true":
                             $value = 1;
                             break;
                         case "false":
                             $value = 0;
                             break;
                     }
                 }
                 if (function_exists('acf_update_value')) {
                     acf_update_value($value, $item['id'], $field);
                 } elseif (function_exists('update_field')) {
                     update_field($field['key'], $value, $item['id']);
                 } else {
                     do_action('acf/update_value', $value, $item['id'], $field);
                 }
             }
         }
         return new WP_REST_Response($this->get_fields($request), 200);
     }
     return new WP_Error('cant_update_item', __("Cannot update item", 'acf-to-rest-api'), array('status' => 500));
 }
Exemplo n.º 7
0
 /**
  * Update Acf image values.
  *
  * @param array $values
  */
 public function saveAcfImages($values)
 {
     foreach ($values as $k => $v) {
         // var_dump($v);
         $attachment_id = $this->saveImage($v);
         update_field($k, $attachment_id, $this->post_id);
     }
 }
Exemplo n.º 8
0
 protected function _set_meta($key, $value)
 {
     if ($this->use_acf_meta_functions && function_exists('update_field')) {
         update_field($this->meta_prefix . $key, $value, $this->get_id());
     } else {
         update_post_meta($this->get_id(), $this->meta_prefix . $key, $value);
     }
 }
 function testACFGetFieldTermTag()
 {
     $tid = $this->factory->term->create();
     update_field('color', 'green', 'post_tag_' . $tid);
     $term = new TimberTerm($tid);
     $str = '{{term.color}}';
     $this->assertEquals('green', Timber::compile_string($str, array('term' => $term)));
 }
Exemplo n.º 10
0
 public function _set_meta($key, $value)
 {
     if ($this->use_acf_meta_functions && function_exists('update_field')) {
         update_field($this->meta_prefix . $key, $value, 'user_' . $this->get_id());
     } else {
         update_user_meta($this->get_id(), $this->meta_prefix . $key, $value);
     }
 }
Exemplo n.º 11
0
function set_longlived_vimeo_token()
{
    $protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
    $token = get_vimeo_variable()->accessToken($_GET['code'], $protocol . $_SERVER['SERVER_NAME'] . '/vimeo');
    update_field('sdo_api_vimeo_app_token', $token['body']['access_token'], 'options');
    header('Location: ' . $url_to_redirect_to . '/wp-admin/admin.php?page=acf-options-apis');
    exit;
}
Exemplo n.º 12
0
 public function save()
 {
     pc($this->object->raw, 'acf');
     if (!$this->object->raw) {
         return;
     }
     foreach ($this->updated as $key => $value) {
         update_field($key, $value, $this->object->raw);
     }
 }
Exemplo n.º 13
0
function test_function()
{
    // Set variables
    $input_test = $_POST['input-test'];
    // Check variables for fallbacks
    if (!isset($input_test) || $input_test == "") {
        $input_test = "Fall Back";
    }
    // Update the field
    update_field('test', $input_test);
}
Exemplo n.º 14
0
function check_post_value()
{
    //dd($_GET);
    if ($_GET['dettol_vote']) {
        $value = get_field("jumlah_dukungan", 11);
        update_field('jumlah_dukungan', $value + 1, 11);
        // dd($value);
        $redirect = esc_url(get_permalink(get_page_by_title('ULURKAN TANGAN')));
        redirect_to($redirect);
        //dd($redirect);
        //update_field('jumlah_dukungan', $value + 1);
    }
}
Exemplo n.º 15
0
function check_post_value()
{
    //dd($_GET);
    if ($_GET['dettol_vote']) {
        $value = get_field("jumlah_dukungan");
        update_field('jumlah_dukungan', $value + 1);
        // dd($value);
        $redirect = home_url() . '/#terimakasih';
        redirect_to($redirect);
        //dd($redirect);
        //update_field('jumlah_dukungan', $value + 1);
    }
}
Exemplo n.º 16
0
 private function add_post($data)
 {
     $post_param = array('post_content' => 'Venture post. Do not edit or remove!', 'post_name' => 'venture', 'post_title' => 'Venture post', 'post_excerpt' => 'Venture post', 'post_type' => 'venture', 'post_status' => 'publish');
     $post_id = wp_insert_post($post_param);
     // this loop takes lot of time
     $num = count($data);
     for ($c = 0; $c < $num; $c++) {
         $data[$c] = mb_convert_encoding($data[$c], "UTF-8");
         update_field($this->headers[$c], $data[$c], $post_id);
     }
     $this->categorize($post_id, get_field('categories', $post_id));
     $this->remove_old(get_field('title', $post_id), $post_id);
     $this->set_content($post_id);
 }
Exemplo n.º 17
0
 private function update_acf_fields()
 {
     if (!function_exists('get_field') || !function_exists('update_field')) {
         return;
     }
     if (!isset($this->id)) {
         $this->create_new_post();
     }
     if (isset($this->acfs) && $this->acfs) {
         foreach ($this->acfs as $acf) {
             $value = get_field($acf['name'], $this->parent_id, false);
             update_field($acf['key'], $value, $this->id);
         }
     }
 }
Exemplo n.º 18
0
function _insert_events($event)
{
    //update_field
    $post_id = post_exists($event->name);
    if (!$post_id) {
        $params = array('post_status' => 'publish', 'post_name' => $event->name, 'post_type' => 'event', 'post_title' => $event->name);
        $post_id = wp_insert_post($params);
        if (is_numeric($post_id)) {
            update_field('meetup_id', $event->id, $post_id);
            update_field('titel', $event->name, $post_id);
            update_field('description', $event->description, $post_id);
            echo '<p>Evenement: \'' . $event->name . '\' is geimporteerd.</p>';
            //update_field();
            //update_field();
        }
    }
}
Exemplo n.º 19
0
 /**
  * Prints a greeting.
  *
  * ## OPTIONS
  *
  * <name>
  * : The name of the person to greet.
  *
  * ## EXAMPLES
  *
  *     wp import_excel presentations Newman
  *
  * @synopsis <name>
  */
 function presentations($args, $assoc_args)
 {
     list($filename) = $args;
     $objPHPExcel = PHPExcel_IOFactory::load($filename);
     $sheet = $objPHPExcel->getSheet(0);
     $highestRow = $sheet->getHighestRow();
     $highestColumn = $sheet->getHighestColumn();
     for ($row = 1; $row <= $highestRow; $row++) {
         $easychair_id = $sheet->getCellByColumnAndRow(0, $row)->getValue();
         $track_num = intval($sheet->getCellByColumnAndRow(1, $row)->getValue());
         $track_name = $sheet->getCellByColumnAndRow(2, $row)->getValue();
         $title = $sheet->getCellByColumnAndRow(3, $row)->getValue();
         $authors = $sheet->getCellByColumnAndRow(4, $row)->getValue();
         $decision = $sheet->getCellByColumnAndRow(5, $row)->getValue();
         $abstract = $sheet->getCellByColumnAndRow(6, $row)->getValue();
         $submission_num = $sheet->getCellByColumnAndRow(7, $row)->getValue();
         $organization = $sheet->getCellByColumnAndRow(8, $row)->getValue();
         if ($decision !== 'accept') {
             continue;
         }
         $post_data = array('post_type' => 'presentation', 'post_title' => $title, 'post_status' => 'publish', 'post_content' => $abstract);
         $post_id = wp_insert_post($post_data, true);
         update_field('presentation_author', $authors, $post_id);
         update_field('presentation_institution', $organization, $post_id);
         update_field('presentation_easychair_id', $easychair_id, $post_id);
         var_dump($track_num);
         if ($track_num === 1) {
             update_field('presentation_track', 'integration', $post_id);
         }
         if ($track_num === 2) {
             update_field('presentation_track', 'collaboration', $post_id);
         }
         if ($track_num === 3) {
             update_field('presentation_track', 'strategy', $post_id);
         }
         if ($track_num === 4) {
             update_field('presentation_track', 'research', $post_id);
         }
         if ($track_num === 5) {
             update_field('presentation_track', 'initiatives', $post_id);
         }
     }
     WP_CLI::success("Loaded {$filename}");
 }
/**
 *	Output custom classes based on Billboard Settings
 */
function eagle_billboard_classes()
{
    $object = get_queried_object();
    if ($object instanceof WP_Post) {
        $post_id = $object->ID;
    } else {
        $post_id = 0;
    }
    // fix pages/posts that don't have these ACF fields set
    $value = get_field('ts_billboard_setting_status', $post_id);
    if (empty($value) && 0 != $post_id) {
        update_field('ts_billboard_setting_status', 'active', $post_id);
        // the default value
    }
    if ('transparent' == get_field('ts_header_style', 'option') && 'active' == get_field('ts_billboard_setting_status')) {
        echo implode(' ', array('floating', get_field('ts_header_style', 'option'), get_field('ts_billboard_setting_status')));
    } else {
        echo 'non-floating';
    }
}
Exemplo n.º 21
0
 function update_fields($post_id)
 {
     $tmdb_id = $this->get_tmdb_id(get_the_title($post_id));
     // JSON array
     $tmdb_data = $this->get_tmdb_data($tmdb_id);
     // field-key reference
     $wpmt_film_fields_ref = get_wpmt_film_fields_ref();
     // if the tmdb_data title is a match
     if (get_the_title($post_id) == $tmdb_data['title']) {
         foreach ($this->associated_fields as $tmdb_field => $wpmt_field) {
             $tmdb_value = $tmdb_data[$tmdb_field];
             if (!empty($wpmt_field) && !get_field($wpmt_field)) {
                 $tmdb_value = $this->pre_process_data($wpmt_field, $tmdb_value, $post_id);
                 update_field($wpmt_film_fields_ref[$wpmt_field], $tmdb_value, $post_id);
             }
         }
         // end foreach
     }
     // end if
 }
Exemplo n.º 22
0
function psp_update_doc_fe()
{
    $project_id = $_POST["project_id"];
    $project_name = get_the_title($project_id);
    $doc_id = $_POST["doc_id"];
    $status = $_POST["status"];
    $filename = $_POST["filename"];
    $editor = $_POST["editor"];
    $users = $_POST["users"];
    $message = "<h3 style='font-size: 18px; font-weight: normal; font-family: Arial, Helvetica, San-serif;'>" . $project_name . "</h3>";
    $message .= "<p><strong>" . $filename . " status has been changed to " . $status . " by " . $editor . "</p>";
    $message .= $_POST["message"];
    $subject = $project_name . ": " . $filename . " status has been changed to " . $status . " by " . $editor;
    $docs = get_field('documents', $project_id);
    $docs[$doc_id]['status'] = $status;
    update_field('documents', $docs, $project_id);
    foreach ($users as $user) {
        psp_send_notification($user, $subject, $message, $project_id);
    }
}
 function __construct(TimberPost $post)
 {
     if (!property_exists($post, 'catfish_importer_url')) {
         return;
     }
     $this->post = $post;
     $take_live = !empty($post->instant_articles_is_preview);
     $permalink = get_permalink($this->post->id);
     $url = "{$permalink}/instant-articles?bypass";
     $instant_article = $this->build_article_object($url);
     $client = (new ClientProvider())->get_client_instance();
     try {
         $response = $client->importArticle($instant_article, $take_live);
         if ($id = $response->id) {
             update_field('instant_articles_status_id', $id, $post);
         }
     } catch (Exception $e) {
         echo 'Could not import the article: ' . $e->getMessage();
     }
 }
Exemplo n.º 24
0
function create_unit($data)
{
    $fields = array('unit_number', 'element', 'rarity', 'cost', 'hit_count', 'bb_hits', 'sbb_hits', 'bb_fill', 'sbb_fill', 'lord_hp', 'lord_atk', 'lord_def', 'lord_rec', 'anima_hp', 'anima_atk', 'anima_def', 'anima_rec', 'breaker_hp', 'breaker_atk', 'breaker_def', 'breaker_rec', 'guardian_hp', 'guardian_atk', 'guardian_def', 'guardian_rec', 'oracle_hp', 'oracle_atk', 'oracle_def', 'oracle_rec', 'leaders_skill_effect', 'brave_burst_effect', 'super_brave_burst_effect');
    $type = 'unit';
    $valid_type = function_exists('post_type_exists') && post_type_exists($type);
    if (!$valid_type) {
        //$this->log['error']["type-{$type}"] = sprintf('Unknown post type "%s".', $type);
    }
    $new_post = array('post_title' => convert_chars($data['unit_name']), 'post_content' => 'Not available', 'post_status' => 'publish', 'post_type' => $type, 'post_date' => parse_date(time()));
    // create!
    $id = wp_insert_post($new_post);
    //Now that we have a new post ID update the associated field data
    foreach ($fields as $field) {
        if (array_key_exists($field, $data)) {
            update_field($field, $data[$field], $id);
        } else {
            return "<b>The field {$field} does not exist.</b>";
        }
    }
    return $id;
}
Exemplo n.º 25
0
/**
 * Scans a location in S3 and updates the linked files in a post
 *
 * @param string $fieldKey acf field key
 * @param int $postId post id to link to
 * @param string $baseKey base key to scan in s3
 * @return string[] keys to the linked files
 */
function acf_s3_relink($fieldKey, $postId, $baseKey)
{
    $config = acf_s3_get_config();
    $s3 = acf_s3_get_client($config);
    $baseKey = trim($baseKey, '/') . '/';
    $data = $s3->listObjects(['Bucket' => $config['bucket'], 'Prefix' => $baseKey])->toArray();
    $contents = isset($data['Contents']) ? $data['Contents'] : [];
    // if directories have been created manually on S3, empty "ghost files" will
    // appear with the same key as the base key. Remove them.
    $contents = array_filter($contents, function ($it) use($baseKey) {
        return $it['Key'] !== $baseKey;
    });
    // if elements have been removed by the filter there might be holes in the array.
    // this can cause json_encode to return an object instead of an array.
    $contents = array_values($contents);
    $items = array_map(function ($it) {
        return $it['Key'];
    }, $contents);
    update_field($fieldKey, $items, $postId);
    return $items;
}
Exemplo n.º 26
0
 public static function getOptions()
 {
     $defaults = array('maxWidth' => 2000, 'maxHeight' => 2000, 'disableCropping' => true, 'sizeStep' => 200, 'offsetStep' => 50, 'embedAssets' => true, 'filterContent' => true, 'baseUrl' => 'di');
     $options = array();
     if (function_exists('get_field')) {
         $options['maxWidth'] = intval(get_field('max_width', 'di_options'));
         $options['maxHeight'] = intval(get_field('max_height', 'di_options'));
         $options['disableCropping'] = (bool) get_field('disable_cropping', 'di_options');
         $options['sizeStep'] = intval(get_field('size_step', 'di_options'));
         $options['offsetStep'] = intval(get_field('offset_step', 'di_options'));
         $options['embedAssets'] = (bool) get_field('embed_assets', 'di_options');
         $options['filterContent'] = (bool) get_field('filter_content', 'di_options');
         $options['baseUrl'] = get_field('base_url', 'di_options');
         // Can't not have a url set
         if (empty($options['baseUrl']) && function_exists('wp_generate_password')) {
             $options['baseUrl'] = 'di-' . \wp_generate_password(5, false);
             update_field('field_561ea193f9d8e', $options['baseUrl'], 'di_options');
         }
     }
     return apply_filters('DI.options', wp_parse_args($options, $defaults));
 }
function HookMeta_appendAllAfterpluploadfile()
{
    global $meta_append_field_ref, $meta_append_date_format, $ref, $userref;
    $found_meta_append_field = getval("metaappend", false);
    if ($found_meta_append_field && $found_meta_append_field == $meta_append_field_ref && $ref > 0) {
        $result = sql_query("select value from resource_data where resource={$ref} and resource_type_field={$meta_append_field_ref}");
        if (!isset($result[0]['value'])) {
            return;
        }
        $value_string = $result[0]['value'];
        $result = sql_query("select ref from resource where date(creation_date)=curdate() and created_by={$userref}");
        if (!isset($result[0])) {
            $count = 1;
        } else {
            $count = count($result);
        }
        $count_string = str_pad($count, 4, "0", STR_PAD_LEFT);
        $date_string = date($meta_append_date_format);
        $new_value_string = $value_string . $date_string . $count_string;
        update_field($ref, $meta_append_field_ref, $new_value_string);
    }
}
 public function promo_sync_times_to_posts($post_id, $post)
 {
     if (!$post || !isset($post->post_type) || $post->post_type !== 'promo') {
         return;
     }
     // Get start and end from promo.
     $start_time = get_field('start_time', $post->ID, false);
     $end_time = get_field('end_time', $post->ID, false);
     // Reverse query to find posts with this promo.
     $query_args = array('posts_per_page' => -1, 'post_status' => 'publish', 'meta_query' => array(array('key' => 'widgets_%_promo_post', 'value' => $post->ID)));
     // To accomodate ACF meta_key structure for widgets
     // (e.g. widgets_{index}_promo_post) we  need to manipulate
     // the SQL so that it is a LIKE comparison.
     \add_filter('posts_where', array($this, 'posts_where_widgets'));
     $posts = new \WP_Query($query_args);
     // Only needs to be applied in this context.
     \remove_filter('posts_where', array($this, 'posts_where_widgets'));
     foreach ($posts->posts as $p) {
         update_field('override_end_time', $end_time, $p->ID);
         update_field('override_start_time', $start_time, $p->ID);
     }
 }
Exemplo n.º 29
0
 public function updateResource()
 {
     $rid = $this->resourceId();
     // resource does not exist - create it
     if ($rid == 0) {
         $rid = create_resource($this->type);
     } else {
         update_resource_type($rid, $this->type);
     }
     foreach ($this->fields as $k => $v) {
         update_field($rid, $k, $v);
     }
     if (file_exists($this->filename)) {
         $extension = explode(".", $this->filename);
         if (count($extension) > 1) {
             $extension = trim(strtolower($extension[count($extension) - 1]));
         } else {
             $extension = "";
         }
         $path = get_resource_path($rid, true, "", true, $extension);
         copy($this->filename, $path);
         create_previews($rid, false, $extension);
         # add file extension
         sql_query("update resource set file_extension='" . escapeString($extension) . "' where ref='" . escapeString($rid) . "'");
     }
     # add resource to collection (if the collection exists)
     if ($this->collection != null) {
         $col_ref = sql_value("select ref as value from collection where name='" . escapeString($this->collection) . "'", 0);
         if (isset($col_ref)) {
             add_resource_to_collection($rid, $col_ref);
         }
     }
     # set access rights
     if ($this->access != null) {
         sql_query("update resource set access='" . escapeString($this->access) . "' where ref='" . escapeString($rid) . "'");
     }
 }
 /**
  * [import_csv read csv and parse them to database]
  * @return [type] [description]
  */
 public function import_csv()
 {
     global $wpdb;
     $file_src = "data/promise-service-point.csv";
     //Step 1: check action when we can import data & setup fields
     if (!isset($_GET["insert_sitepoint_posts"])) {
         return;
     }
     $arr_fields = array('address' => 'field_5645a37030278', 'address2' => 'field_5645a5f930279', 'tel' => 'field_5645a6483027a', 'fax' => 'field_5645a7093027b', 'category' => 'field_5645a7d0dae73', 'prefecture' => 'field_5645a933dae74', 'district' => 'field_5645a9efdae75', 'update_status' => 'field_564ad7bbe6140', 'pic_appearance' => 'field_5645aa88bd7c6', 'pic_map' => 'field_5645aac3bd7c7', 'type' => 'field_5645ab2f596df', 'lat' => 'field_5645ab7e596e0', 'lng' => 'field_5645abb3596e1', 'custom-post-type' => 'service-point');
     //Step 2: Get data from CSV and parse to array
     $posts = $this->parse_csv_to_array($file_src);
     //Step 3: Parse data to sql query and insert to database
     foreach ($posts as $post) {
         $post_exists = $this->check_post_exists($post["id"], $wpdb, $arr_fields);
         // If the post exists, skip and go to next
         if ($post_exists) {
             continue;
         }
         $post["id"] = wp_insert_post(array("post_title" => $post["id"], "post_type" => $arr_fields["custom-post-type"], "post_status" => "publish"));
         // Set attachment meta and insert URL to custom fields
         $attach_pic_appearance = $this->attach_to_media($post["pic_appearance"]);
         $attach_pic_map = $this->attach_to_media($post["pic_map"]);
         update_field($arr_fields["address"], $post["address"], $post["id"]);
         update_field($arr_fields["address2"], $post["address2"], $post["id"]);
         update_field($arr_fields["tel"], $post["tel"], $post["id"]);
         update_field($arr_fields["fax"], $post["fax"], $post["id"]);
         update_field($arr_fields["category"], $post["category"], $post["id"]);
         update_field($arr_fields["prefecture"], $post["prefecture"], $post["id"]);
         update_field($arr_fields["district"], $post["district"], $post["id"]);
         update_field($arr_fields["update_status"], $post["update_status"], $post["id"]);
         update_field($arr_fields["pic_appearance"], $attach_pic_appearance, $post["id"]);
         update_field($arr_fields["pic_map"], $attach_pic_map, $post["id"]);
         update_field($arr_fields["type"], $post["type"], $post["id"]);
         update_field($arr_fields["lat"], $post["lat"], $post["id"]);
         update_field($arr_fields["lng"], $post["lng"], $post["id"]);
     }
 }