本文整理汇总了PHP中update_field函数的典型用法代码示例。如果您正苦于以下问题:PHP update_field函数的具体用法?PHP update_field怎么用?PHP update_field使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了update_field函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: update_acf_fields
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);
}
}
}
开发者ID:thetmkay,项目名称:stage-craft,代码行数:15,代码来源:stage-post.php
示例17: _insert_events
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();
}
}
}
开发者ID:noudr93,项目名称:mediavilla,代码行数:17,代码来源:meetup-api.php
示例18: presentations
/**
* 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}");
}
开发者ID:ocwc,项目名称:conf2015,代码行数:58,代码来源:cli-importer.php
示例19: eagle_billboard_classes
/**
* 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';
}
}
开发者ID:WebBirdWebIntegrators,项目名称:eagle-wp-theme,代码行数:23,代码来源:functions.php
示例20: update_fields
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
}
开发者ID:chipete,项目名称:wp-movie-theater,代码行数:20,代码来源:class-wpmt-tmdb.php
注:本文中的update_field函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论