本文整理汇总了PHP中FrmField::maybe_get_field方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmField::maybe_get_field方法的具体用法?PHP FrmField::maybe_get_field怎么用?PHP FrmField::maybe_get_field使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmField
的用法示例。
在下文中一共展示了FrmField::maybe_get_field方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_single_field
/**
* @since 2.0.11
*/
public static function update_single_field($atts)
{
if (empty($atts['entry_id'])) {
return;
}
$field = $atts['field_id'];
FrmField::maybe_get_field($field);
if (!$field) {
return;
}
if (isset($field->field_options['post_field']) && !empty($field->field_options['post_field'])) {
$post_id = FrmDb::get_var('frm_items', array('id' => $atts['entry_id']), 'post_id');
} else {
$post_id = false;
}
global $wpdb;
if (!$post_id) {
$updated = FrmEntryMeta::update_entry_meta($atts['entry_id'], $field->id, null, $atts['value']);
if (!$updated) {
$wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->prefix}frm_item_metas WHERE item_id = %d and field_id = %d", $atts['entry_id'], $field->id));
$updated = FrmEntryMeta::add_entry_meta($atts['entry_id'], $field->id, '', $atts['value']);
}
wp_cache_delete($atts['entry_id'], 'frm_entry');
} else {
switch ($field->field_options['post_field']) {
case 'post_custom':
$updated = update_post_meta($post_id, $field->field_options['custom_field'], maybe_serialize($atts['value']));
break;
case 'post_category':
$taxonomy = !FrmField::is_option_empty($field, 'taxonomy') ? $field->field_options['taxonomy'] : 'category';
$updated = wp_set_post_terms($post_id, $atts['value'], $taxonomy);
break;
default:
$post = get_post($post_id, ARRAY_A);
$post[$field->field_options['post_field']] = maybe_serialize($atts['value']);
$updated = wp_insert_post($post);
break;
}
}
if ($updated) {
// set updated_at time
$wpdb->update($wpdb->prefix . 'frm_items', array('updated_at' => current_time('mysql', 1), 'updated_by' => get_current_user_id()), array('id' => $atts['entry_id']));
}
$atts['field_id'] = $field->id;
$atts['field'] = $field;
do_action('frm_after_update_field', $atts);
return $updated;
}
示例2: maybe_get_field
public static function maybe_get_field(&$field)
{
_deprecated_function(__FUNCTION__, '2.0.9', 'FrmField::maybe_get_field');
FrmField::maybe_get_field($field);
}
示例3: update_field_ajax
public static function update_field_ajax()
{
//check_ajax_referer( 'frm_ajax', 'nonce' );
$entry_id = FrmAppHelper::get_param('entry_id', 0, 'post', 'absint');
$field_id = FrmAppHelper::get_param('field_id', 0, 'post', 'sanitize_title');
$value = FrmAppHelper::get_param('value');
FrmField::maybe_get_field($field_id);
if ($field_id && FrmProEntriesHelper::user_can_edit($entry_id, $field_id->form_id)) {
$updated = FrmProEntryMeta::update_single_field(compact('entry_id', 'field_id', 'value'));
echo $updated;
}
wp_die();
}