当前位置: 首页>>代码示例>>PHP>>正文


PHP update_field函数代码示例

本文整理汇总了PHP中update_field函数的典型用法代码示例。如果您正苦于以下问题:PHP update_field函数的具体用法?PHP update_field怎么用?PHP update_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了update_field函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_user_meta

 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));
 }
开发者ID:brutalenemy666,项目名称:wp-utils,代码行数:7,代码来源:class-acf.php

示例2: exchange_attach_participant_to_collab

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;
    }
}
开发者ID:retrorism,项目名称:exchange-plugin,代码行数:28,代码来源:import_projects.php

示例3: modules_to_json

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');
    }
}
开发者ID:natsaros,项目名称:penySite,代码行数:25,代码来源:modules.php

示例4: removeOtherPosts

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');
        }
    }
}
开发者ID:surgemedia,项目名称:Snippet-Library,代码行数:33,代码来源:function-only-this-post.php

示例5: ocp_ajax_update_designs

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;
}
开发者ID:jhipwell6,项目名称:OCP-Snippets,代码行数:31,代码来源:ajax-example.php

示例6: update_item

 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));
 }
开发者ID:der-lukas,项目名称:acf-to-rest-api,代码行数:31,代码来源:class-acf-to-rest-api-controller.php

示例7: saveAcfImages

 /**
  * 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);
     }
 }
开发者ID:chuckhendo,项目名称:wp-faker,代码行数:13,代码来源:Post.php

示例8: _set_meta

 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);
     }
 }
开发者ID:brutalenemy666,项目名称:wp-utils,代码行数:8,代码来源:abstract-post.php

示例9: testACFGetFieldTermTag

 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)));
 }
开发者ID:Butterwell,项目名称:timber,代码行数:8,代码来源:test-timber-integrations.php

示例10: _set_meta

 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);
     }
 }
开发者ID:brutalenemy666,项目名称:wp-utils,代码行数:8,代码来源:abstract-user.php

示例11: set_longlived_vimeo_token

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;
}
开发者ID:aiganebraska,项目名称:The-Show,代码行数:8,代码来源:api_vimeo.php

示例12: save

 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);
     }
 }
开发者ID:solutionworks,项目名称:theme-setup,代码行数:10,代码来源:ACF.php

示例13: test_function

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);
}
开发者ID:rveitch,项目名称:funerals-compared,代码行数:11,代码来源:funerals-compared.php

示例14: check_post_value

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);
    }
}
开发者ID:ariniastari,项目名称:mhsd_dettol,代码行数:13,代码来源:functions.php

示例15: add_post

 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);
 }
开发者ID:johnleesw,项目名称:mustardseedwp,代码行数:14,代码来源:Class_Import_Page.php


注:本文中的update_field函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。