本文整理汇总了PHP中wpcf_unique_id函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_unique_id函数的具体用法?PHP wpcf_unique_id怎么用?PHP wpcf_unique_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_unique_id函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_fields_skype_meta_box_form
/**
* Form data for post edit page.
*
* @param type $field
*/
function wpcf_fields_skype_meta_box_form($field)
{
add_thickbox();
if (isset($field['value'])) {
$field['value'] = maybe_unserialize($field['value']);
}
$form = array();
add_filter('wpcf_fields_shortcode_slug_' . $field['slug'], 'wpcf_fields_skype_shortcode_filter', 10, 2);
$rand = wpcf_unique_id(serialize($field));
$form['skypename'] = array('#type' => 'textfield', '#value' => isset($field['value']['skypename']) ? $field['value']['skypename'] : '', '#name' => 'wpcf[' . $field['slug'] . '][skypename]', '#id' => 'wpcf-fields-skype-' . $field['slug'] . '-' . $rand . '-skypename', '#inline' => true, '#suffix' => ' ' . __('Skype name', 'wpcf'), '#description' => '', '#prefix' => !empty($field['description']) ? wpcf_translate('field ' . $field['id'] . ' description', $field['description']) . '<br /><br />' : '', '#attributes' => array('style' => 'width:60%;'), '#_validate_this' => true, '#before' => '<div class="wpcf-skype">');
$form['style'] = array('#type' => 'hidden', '#value' => isset($field['value']['style']) ? $field['value']['style'] : 'btn2', '#name' => 'wpcf[' . $field['slug'] . '][style]', '#id' => 'wpcf-fields-skype-' . $field['slug'] . '-' . $rand . '-style');
$preview_skypename = !empty($field['value']['skypename']) ? $field['value']['skypename'] : '--not--';
$preview_style = !empty($field['value']['style']) ? $field['value']['style'] : 'btn2';
$preview = wpcf_fields_skype_get_button_image($preview_skypename, $preview_style);
// Set button
// TODO WPML move
if (isset($field['disable']) || wpcf_wpml_field_is_copied($field)) {
$edit_button = '';
} else {
$edit_button = '' . '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&' . 'wpcf_action=insert_skype_button&_wpnonce=' . wp_create_nonce('insert_skype_button') . '&update=wpcf-fields-skype-' . $field['slug'] . '-' . $rand . '&skypename=' . $preview_skypename . '&button_style=' . $preview_style . '&keepThis=true&TB_iframe=true&width=500&height=500') . '"' . ' class="thickbox wpcf-fields-skype button-secondary"' . ' title="' . __('Edit Skype button', 'wpcf') . '"' . '>' . __('Edit Skype button', 'wpcf') . '</a>';
}
$form['markup'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-item">' . '<div id="wpcf-fields-skype-' . $field['slug'] . '-' . $rand . '-preview">' . $preview . '</div>' . $edit_button . '</div>');
$form['markup-close'] = array('#type' => 'markup', '#markup' => '</div>');
return $form;
}
示例2: wpcf_fields_checkboxes_meta_box_form
/**
* Form data for post edit page.
*
* @param type $field
*/
function wpcf_fields_checkboxes_meta_box_form($field, $data)
{
$options = array();
if (!empty($field['data']['options'])) {
global $pagenow;
foreach ($field['data']['options'] as $option_key => $option) {
// Set value
$options[$option_key] = array('#value' => $option['set_value'], '#title' => wpcf_translate('field ' . $field['id'] . ' option ' . $option_key . ' title', $option['title']), '#default_value' => !empty($data['#value'][$option_key]) || $pagenow == 'post-new.php' && !empty($option['checked']) ? 1 : 0, '#name' => 'wpcf[' . $field['id'] . '][' . $option_key . ']', '#id' => $option_key . '_' . wpcf_unique_id(serialize($field) . serialize($data)));
}
}
return array('#type' => 'checkboxes', '#options' => $options);
}
示例3: wpcf_fields_select_get_option
function wpcf_fields_select_get_option($parent_name = '', $form_data = array())
{
$id = isset($form_data['key']) ? $form_data['key'] : 'wpcf-fields-select-option-' . wpcf_unique_id(serialize($form_data));
$form = array();
$value = isset($_GET['count']) ? __('Option title', 'wpcf') . ' ' . intval($_GET['count']) : __('Option title', 'wpcf') . ' 1';
$value = isset($form_data['title']) ? $form_data['title'] : $value;
$form[$id . '-title'] = array('#type' => 'textfield', '#id' => $id . '-title', '#name' => $parent_name . '[options][' . $id . '][title]', '#value' => $value, '#inline' => true, '#attributes' => array('placeholder' => __('Title', 'wpcf')), '#before' => sprintf('<span class="js-types-sortable hndle"><i title="%s" class="js-types-sort-button fa fa-arrows-v"></i></span>', esc_attr__('Move this option', 'wpcf')), '#pattern' => '<tr><td class="num"><BEFORE></td><td><ELEMENT><AFTER></td>');
$value = isset($_GET['count']) ? intval($_GET['count']) : 1;
$value = isset($form_data['value']) ? $form_data['value'] : $value;
$form[$id . '-value'] = array('#type' => 'textfield', '#id' => $id . '-value', '#name' => $parent_name . '[options][' . $id . '][value]', '#value' => $value, '#inline' => true, '#attributes' => array('class' => 'wpcf-compare-unique-value', 'placeholder' => __('Value', 'wpcf')), '#pattern' => '<td><BEFORE><ELEMENT><AFTER></td>');
$form[$id . '-default'] = array('#type' => 'radio', '#id' => $id . '-default', '#inline' => true, '#title' => __('Default', 'wpcf'), '#after' => '</div>', '#name' => $parent_name . '[options][default]', '#value' => $id, '#default_value' => isset($form_data['default']) ? $form_data['default'] : false, '#pattern' => '<td class="num"><BEFORE><ELEMENT></td><td class="num"><AFTER></td></tr>', '#after' => sprintf('<span><a href="#" class="js-wpcf-button-delete" data-message-delete-confirm="%s" data-id="%s"><i title="%s" class="fa fa-trash"></i></span>', esc_attr__('Are you sure?', 'wpcf'), esc_attr(sprintf('%s-title-display-value-wrapper', $id)), esc_attr__('Delete this option', 'wpcf')));
return $form;
}
示例4: wpcf_fields_select_get_option
function wpcf_fields_select_get_option($parent_name = '', $form_data = array())
{
$id = isset($form_data['key']) ? $form_data['key'] : 'wpcf-fields-select-option-' . wpcf_unique_id(serialize($form_data));
$form = array();
$value = isset($_GET['count']) ? __('Option title', 'wpcf') . ' ' . intval($_GET['count']) : __('Option title', 'wpcf') . ' 1';
$value = isset($form_data['title']) ? $form_data['title'] : $value;
$form[$id . '-title'] = array('#type' => 'textfield', '#id' => $id . '-title', '#name' => $parent_name . '[options][' . $id . '][title]', '#value' => $value, '#inline' => true, '#attributes' => array('style' => 'width:80px;', 'placeholder' => __('Title', 'wpcf')), '#before' => '<div class="js-types-sortable"><img src="' . WPCF_RES_RELPATH . '/images/move.png" class="js-types-sort-button" alt="' . __('Move this option', 'wpcf') . '" /><img src="' . WPCF_RES_RELPATH . '/images/delete.png"' . ' class="wpcf-fields-select-delete-option wpcf-pointer"' . ' onclick="if (confirm(\'' . __('Are you sure?', 'wpcf') . '\')) { jQuery(this).parent().fadeOut(function(){jQuery(this).remove();}); }"' . 'alt="' . __('Delete this option', 'wpcf') . '" />');
$value = isset($_GET['count']) ? intval($_GET['count']) : 1;
$value = isset($form_data['value']) ? $form_data['value'] : $value;
$form[$id . '-value'] = array('#type' => 'textfield', '#id' => $id . '-value', '#name' => $parent_name . '[options][' . $id . '][value]', '#value' => $value, '#inline' => true, '#attributes' => array('style' => 'width:80px;', 'class' => 'wpcf-compare-unique-value', 'placeholder' => __('Value', 'wpcf')));
$form[$id . '-default'] = array('#type' => 'radio', '#id' => $id . '-default', '#inline' => true, '#title' => __('Default', 'wpcf'), '#after' => '</div>', '#name' => $parent_name . '[options][default]', '#value' => $id, '#default_value' => isset($form_data['default']) ? $form_data['default'] : false);
return $form;
}
示例5: wpcf_fields_radio_get_option
/**
* Returns form data for radio.
*
* @param type $parent_name Used for AJAX adding options
* @param type $form_data
* @return type
*/
function wpcf_fields_radio_get_option($parent_name = '', $form_data = array())
{
$id = isset($form_data['key']) ? $form_data['key'] : 'wpcf-fields-radio-option-' . wpcf_unique_id(serialize($form_data));
$form = array();
$value = isset($_GET['count']) ? __('Option title', 'wpcf') . ' ' . $_GET['count'] : __('Option title', 'wpcf') . ' 1';
$value = isset($form_data['title']) ? $form_data['title'] : $value;
$form[$id . '-id'] = $id;
$form[$id . '-title'] = array('#type' => 'textfield', '#id' => $id . '-title', '#name' => $parent_name . '[options][' . $id . '][title]', '#value' => $value, '#inline' => true, '#attributes' => array('style' => 'width:80px;', 'class' => 'wpcf-form-groups-radio-update-title-display-value'), '#before' => '<div class="wpcf-fields-radio-draggable"><img src="' . WPCF_RES_RELPATH . '/images/move.png" class="wpcf-fields-form-radio-move-field" alt="' . __('Move this option', 'wpcf') . '" /><img src="' . WPCF_RES_RELPATH . '/images/delete.png"' . ' class="wpcf-fields-radio-delete-option wpcf-pointer"' . ' onclick="if (confirm(\'' . __('Are you sure?', 'wpcf') . '\')) { jQuery(this).parent().fadeOut(function(){jQuery(this).remove(); ' . '}); ' . 'jQuery(\'#\'+jQuery(this).parent().find(\'input\').attr(\'id\')+\'' . '-display-value-wrapper\').fadeOut(function(){jQuery(this).remove();}); }"' . 'alt="' . __('Delete this option', 'wpcf') . '" />');
$value = isset($_GET['count']) ? $_GET['count'] : 1;
$value = isset($form_data['value']) ? $form_data['value'] : $value;
$form[$id . '-value'] = array('#type' => 'textfield', '#id' => $id . '-value', '#name' => $parent_name . '[options][' . $id . '][value]', '#value' => $value, '#inline' => true, '#attributes' => array('style' => 'width:80px;', 'class' => 'wpcf-compare-unique-value'));
$form[$id . '-default'] = array('#type' => 'radio', '#id' => $id . '-default', '#inline' => true, '#title' => __('Default', 'wpcf'), '#after' => '</div>', '#name' => $parent_name . '[options][default]', '#value' => $id, '#default_value' => isset($form_data['default']) ? $form_data['default'] : '');
return $form;
}
示例6: wpcf_fields_file_meta_box_form
/**
* Form data for post edit page.
*
* @global object $wpdb
*
* @param type $field
*/
function wpcf_fields_file_meta_box_form($field)
{
add_thickbox();
$button_text = sprintf(__('Select %s', 'wpcf'), $field['type']);
// Set ID
$element_id = 'wpcf-fields-' . wpcf_unique_id(serialize(func_get_args()));
$attachment_id = false;
// Get attachment by guid
global $wpdb;
if (!empty($field['value'])) {
$attachment_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM {$wpdb->posts} WHERE post_type = 'attachment' AND guid=%s", $field['value']));
}
// Set preview
$preview = '';
// TODO WPML move
if (!wpcf_wpml_field_is_copied($field)) {
if (!empty($attachment_id)) {
$preview = wp_get_attachment_image($attachment_id, 'thumbnail');
} else {
// If external image set preview
$file_path = parse_url($field['value']);
if ($file_path && isset($file_path['path'])) {
$file = pathinfo($file_path['path']);
} else {
$file = pathinfo($field['value']);
}
if (isset($file['extension']) && in_array(strtolower($file['extension']), array('jpg', 'jpeg', 'gif', 'png'))) {
$preview = '<img alt="" src="' . $field['value'] . '" />';
}
}
}
// Set button
// TODO WPML move
if (!wpcf_wpml_field_is_copied($field)) {
if (!empty($field['#attributes']['readonly']) || !empty($field['#attributes']['disabled'])) {
$button = '';
} else {
$button = '<a href="javascript:void(0);"' . ' class="wpcf-fields-' . ($field['type'] == 'image' ? 'image' : 'file') . '-upload-link button-secondary"' . ' id="' . $element_id . '-upload" ' . "data-types='{\"type\":\"{$field['type']}\",\"id\":\"{$field['id']}\"}'>" . $button_text . '</a>';
}
} else {
$button = '';
}
// Set form
$form = array('#type' => 'textfield', '#id' => $element_id . '-upload-holder', '#name' => 'wpcf[' . $field['slug'] . ']', '#suffix' => ' ' . $button, '#after' => '<div id="' . $element_id . '-upload-holder-preview"' . ' class="wpcf-fields-file-preview">' . $preview . '</div>', '#attributes' => array('class' => 'wpcf-fields-file-textfield'));
return $form;
}
示例7: set
/**
* Set current post and field.
*
* @param type $post
* @param type $cf
*/
function set($user_id, $cf)
{
global $wpcf;
/*
*
* Check if $cf is string
*/
if (is_string($cf)) {
WPCF_Loader::loadInclude('fields');
$cf = wpcf_admin_fields_get_field($this->__get_slug_no_prefix($cf));
if (empty($cf)) {
$this->_reset();
return false;
}
}
$this->currentUID = $user_id;
$this->ID = $cf['id'];
$this->cf = $cf;
$this->slug = wpcf_types_get_meta_prefix($this->cf) . $this->cf['slug'];
$this->meta = $this->_get_meta();
$this->config = $this->_get_config();
$this->unique_id = wpcf_unique_id(serialize((array) $this));
$this->cf['value'] = $this->meta;
// Debug
$wpcf->debug->fieds[$this->unique_id] = $this->cf;
$wpcf->debug->meta[$this->slug][] = $this->meta;
// Load files
if (isset($this->cf['type'])) {
$file = WPCF_EMBEDDED_INC_ABSPATH . '/fields/' . $this->cf['type'] . '.php';
if (file_exists($file)) {
include_once $file;
}
if (defined('WPCF_INC_ABSPATH')) {
$file = WPCF_INC_ABSPATH . '/fields/' . $this->cf['type'] . '.php';
if (file_exists($file)) {
include_once $file;
}
}
}
}
示例8: wpcf_admin_usermeta_form
//.........这里部分代码省略.........
$options[$role]['#inline'] = TRUE;
$options[$role]['#suffix'] = '<br />';
$options[$role]['#id'] = 'wpcf-form-groups-show-for-' . $role;
$options[$role]['#attributes'] = array('class' => 'wpcf-form-groups-support-post-type');
if ($update && !empty($update['show_for']) && in_array($role, $update['show_for'])) {
$users_currently_supported[] = ucwords($role);
}
}
if (empty($users_currently_supported)) {
$users_currently_supported[] = __('Displayed for all users roles', 'wpcf');
}
/*
* Show for FILTER
*/
$temp = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'wpcf[group][supports]', '#inline' => true);
/*
*
* Here we use unique function for all filters
* Since Types 1.1.4
*/
$form_users = _wpcf_filter_wrap('custom_post_types', __('Show For:', 'wpcf'), implode(', ', $users_currently_supported), __('Displayed for all users roles', 'wpcf'), $temp);
/*
* Now starting form
*/
$access_notification = '';
if (function_exists('wpcf_access_register_caps')) {
$access_notification = '<div class="message custom wpcf-notif"><span class="wpcf-notif-congrats">' . __('This groups visibility is also controlled by the Access plugin.', 'wpcf') . '</span></div>';
}
$form['supports-table-open'] = array('#type' => 'markup', '#markup' => '<table class="widefat"><thead><tr><th>' . __('Where to display this group', 'wpcf') . '</th></tr></thead><tbody><tr><td>' . '<p>' . __('Each usermeta group can display different fields for user roles.', 'wpcf') . $access_notification . '</p>');
/*
* Join filter forms
*/
// User Roles
$form['p_wrap_1_' . wpcf_unique_id(serialize($form_users))] = array('#type' => 'markup', '#markup' => '<p class="wpcf-filter-wrap">');
$form = $form + $form_users;
$form['supports-table-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table><br />');
/** Admin styles**/
$form['adminstyles-table-open'] = array('#type' => 'markup', '#markup' => '<table class="widefat" id="wpcf-admin-styles-box"><thead><tr><th>' . __('Styling Editor', 'wpcf') . '</th></tr></thead><tbody><tr><td>' . '<p>' . __('Customize Fields for admin panel.', 'wpcf') . '</p>');
$admin_styles_value = $preview_profile = $edit_profile = '';
if (isset($update['admin_styles'])) {
$admin_styles_value = $update['admin_styles'];
}
$temp = '';
if ($update) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
$user_id = wpcf_usermeta_get_user();
$preview_profile = wpcf_usermeta_preview_profile($user_id, $update, 1);
$group = $update;
$group['fields'] = wpcf_admin_usermeta_process_fields($user_id, $group['fields'], true, false);
$edit_profile = wpcf_admin_render_fields($group, $user_id, 1);
add_action('admin_enqueue_scripts', 'wpcf_admin_fields_form_fix_styles', PHP_INT_MAX);
}
$temp[] = array('#type' => 'radio', '#suffix' => '<br />', '#value' => 'edit_mode', '#title' => 'Edit mode', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#before' => '<div class="wpcf-admin-css-preview-style-edit">', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'editmode\')', 'checked' => 'checked'));
$temp[] = array('#type' => 'radio', '#title' => 'Read Only', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#after' => '</div>', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'readonly\')'));
$temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_html_preview]', '#inline' => true, '#value' => '', '#id' => 'wpcf-form-groups-admin-html-preview', '#before' => '<h3>Field group HTML</h3>');
$temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_styles]', '#inline' => true, '#value' => $admin_styles_value, '#default_value' => '', '#id' => 'wpcf-form-groups-css-fields-editor', '#after' => '
<div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
<h3>Field group preview</h3>
<div id="wpcf-update-preview-div">Preview here</div>
<script type="text/javascript">
var wpcfReadOnly = ' . json_encode($preview_profile) . ';
var wpcfEditMode = ' . json_encode($edit_profile) . ';
var wpcfDefaultCss = ' . json_encode($admin_styles_value) . ';
示例9: wpcf_admin_render_fields
function wpcf_admin_render_fields($group, $user_id, $echo = '')
{
global $wpcf;
$output = '<div class="wpcf-group-area wpcf-group-area_' . $group['slug'] . '">' . "\n\n";
$output .= '<h3>' . wpcf_translate('group ' . $group['id'] . ' name', $group['name']) . '</h3>' . "\n\n";
if (!empty($group['fields'])) {
// Display description
if (!empty($group['description'])) {
$output .= '<span>' . wpautop(wpcf_translate('group ' . $group['id'] . ' description', $group['description'])) . '</span>' . "\n\n";
}
$output .= '<div class="wpcf-profile-field-line">' . "\n\n";
foreach ($group['fields'] as $field_slug => $field) {
if (empty($field) || !is_array($field)) {
continue;
}
$field = $wpcf->usermeta_field->_parse_cf_form_element($field);
if (!isset($field['#id'])) {
$field['#id'] = wpcf_unique_id(serialize($field));
}
if (isset($field['wpcf-type'])) {
// May be ignored
$field = apply_filters('wpcf_fields_' . $field['wpcf-type'] . '_meta_box_form_value_display', $field);
}
// Render form elements
if (wpcf_compare_wp_version() && $field['#type'] == 'wysiwyg') {
$field['#editor_settings']['media_buttons'] = '';
if (!empty($echo)) {
$field['#editor_settings']['wpautop'] = true;
}
// Especially for WYSIWYG
$output .= "\n" . '<div class="wpcf-profile-field-line">' . "\n\n";
$output .= '<div class="wpcf-wysiwyg">' . "\n\n";
$output .= '<div id="wpcf-textarea-textarea-wrapper" class="form-item form-item-textarea wpcf-form-item wpcf-form-item-textarea">' . "\n\n";
$output .= isset($field['#before']) ? $field['#before'] : '';
$output .= '<label class="wpcf-form-label wpcf-form-textarea-label">' . $field['#title'] . '</label>' . "\n\n";
$output .= '<div class="description wpcf-form-description wpcf-form-description-textarea description-textarea">' . "\n\n" . wpautop($field['#description']) . '</div>' . "\n\n";
ob_start();
wp_editor($field['#value'], $field['#id'], $field['#editor_settings']);
$output .= ob_get_clean() . "\n\n";
$field['slug'] = str_replace(WPCF_META_PREFIX . 'wysiwyg-', '', $field_slug);
$field['type'] = 'wysiwyg';
$output .= '</div>' . "\n\n";
$output .= isset($field['#after']) ? $field['#after'] : '';
$output .= '</div>' . "\n\n";
$output .= '</div>' . "\n\n";
} else {
if ($field['#type'] == 'wysiwyg') {
$field['#type'] = 'textarea';
}
$field['#pattern'] = "\n" . '<div class="wpcf-profile-field-line">
<div class="wpcf-profile-line-left">
<LABEL><DESCRIPTION>
</div>
<div class="wpcf-profile-line-right"><BEFORE><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER></div>
</div>' . "\n\n";
if (isset($field['#name']) && (strpos($field['#name'], '[hour]') !== false || strpos($field['#name'], '[minute]') !== false)) {
if (isset($field['#attributes']) && $field['#attributes']['class'] == 'wpcf-repetitive') {
$field['#pattern'] = strpos($field['#name'], '[hour]') !== false ? __('Hour', 'wpcf') : __('Minute', 'wpcf');
$field['#pattern'] .= '<LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>' . "\n\n";
} else {
if (strpos($field['#name'], '[hour]') !== false) {
$field['#pattern'] = "\n" . '<div class="wpcf-profile-field-line">
<div class="wpcf-profile-line-left"> ' . __('Time', 'wpcf') . '</div>
<div class="wpcf-profile-line-right">
<LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER>' . "\n";
} else {
$field['#pattern'] = "\n" . '
<LABEL><DESCRIPTION><ERROR><PREFIX><ELEMENT><SUFFIX><AFTER></div>
</div>' . "\n\n";
}
}
}
if (!empty($echo)) {
$field['#validate'] = '';
}
$output .= wpcf_form_simple(array($field['#id'] => $field));
}
}
$output .= '</div>';
}
/*
* TODO Move to Conditional code
*
* This is already checked. Use hook to add wrapper DIVS and apply CSS.
*/
if (!empty($group['_conditional_display'])) {
$output .= '</div>';
}
$output .= "\n\n" . '</div>';
if (!empty($echo)) {
return $output;
} else {
echo $output;
}
}
示例10: wpcf_filds_checkboxes_relationship_form_filter
/**
* This marks child posts checkboxes.
*
* Because if all unchecked, on submit there won't be any data.
*
* @param string $form
* @param type $cf
* @return string
*/
function wpcf_filds_checkboxes_relationship_form_filter($form, $cf)
{
if ($cf->cf['type'] == 'checkboxes') {
$form[wpcf_unique_id(serialize($cf) . 'rel_child')] = array('#type' => 'hidden', '#name' => '_wpcf_check_checkboxes[' . $cf->post->ID . '][' . $cf->slug . ']', '#value' => '1');
}
return $form;
}
示例11: set
/**
* Set current post and field.
*
* @param type $post
* @param type $cf
*/
function set($post, $cf)
{
global $wpcf;
/*
*
* Check if $cf is string
*/
if (is_string($cf)) {
WPCF_Loader::loadInclude('fields');
$_cf = wpcf_admin_fields_get_field($this->__get_slug_no_prefix($cf));
// Check if found without prefix
if (empty($_cf)) {
$_cf = wpcf_admin_fields_get_field($cf);
}
if (empty($_cf)) {
/*
* TODO Check what happens if field is not found
*/
$this->_reset();
return false;
}
$cf = $_cf;
}
$this->post = is_integer($post) ? get_post($post) : $post;
// If empty post it is new
if (empty($this->post->ID)) {
$this->post = new stdClass();
$this->post->ID = 0;
}
$this->ID = $cf['id'];
$this->cf = $cf;
$this->slug = wpcf_types_get_meta_prefix($this->cf) . $this->cf['slug'];
$this->meta = $this->_get_meta();
$this->config = $this->_get_config();
$this->unique_id = wpcf_unique_id(serialize((array) $this));
$this->cf['value'] = $this->meta;
// Debug
$wpcf->debug->fields[$this->unique_id] = $this->cf;
$wpcf->debug->meta[$this->slug][] = $this->meta;
// Load files
$this->_include_file_by_field_type($this->cf['type']);
if (defined('WPCF_INC_ABSPATH')) {
$file = WPCF_INC_ABSPATH . '/fields/' . preg_replace('/[^\\w]+/', '', $this->cf['type']) . '.php';
if (file_exists($file)) {
include_once $file;
}
}
}
示例12: array
<?php
/*
* Child table taxonomy non-hierarchical form.
*/
$defaults = array('taxonomy' => 'category');
extract(wp_parse_args($data, $defaults), EXTR_SKIP);
$tax = get_taxonomy($taxonomy);
$html_id = "wpcf-reltax-{$taxonomy}-" . wpcf_unique_id($taxonomy);
?>
<div id="<?php
echo $html_id;
?>
" class="js-types-child-categorydiv types-child-categorydiv" data-types-reltax="<?php
echo $taxonomy;
?>
">
<!--<ul id="<?php
echo $html_id;
?>
-tabs" class="category-tabs">
<li class="tabs"><a href="#<?php
echo $taxonomy;
?>
-all"><?php
echo $tax->labels->all_items;
?>
</a></li>
<li class="hide-if-no-js"><a href="#<?php
echo $taxonomy;
示例13: add_admin_style
/**
* deprecated
*/
private function add_admin_style($form)
{
$admin_styles_value = $preview_profile = $edit_profile = '';
if (isset($this->update['admin_styles'])) {
$admin_styles_value = $this->update['admin_styles'];
}
$temp = '';
if ($this->update) {
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
// require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields-post.php';
require_once WPCF_EMBEDDED_INC_ABSPATH . '/usermeta-post.php';
//Get sample post
$post = query_posts('posts_per_page=1');
if (!empty($post) && count($post) != '') {
$post = $post[0];
}
$preview_profile = wpcf_admin_post_meta_box_preview($post, $this->update, 1);
$group = $this->update;
$group['fields'] = wpcf_admin_post_process_fields($post, $group['fields'], true, false);
$edit_profile = wpcf_admin_post_meta_box($post, $group, 1, true);
add_action('admin_enqueue_scripts', 'wpcf_admin_fields_form_fix_styles', PHP_INT_MAX);
}
$temp[] = array('#type' => 'radio', '#suffix' => '<br />', '#value' => 'edit_mode', '#title' => 'Edit mode', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#before' => '<div class="wpcf-admin-css-preview-style-edit">', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'editmode\')', 'checked' => 'checked'));
$temp[] = array('#type' => 'radio', '#title' => 'Read Only', '#name' => 'wpcf[group][preview]', '#default_value' => '', '#after' => '</div>', '#inline' => true, '#attributes' => array('onclick' => 'changePreviewHtml(\'readonly\')'));
$temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_html_preview]', '#inline' => true, '#id' => 'wpcf-form-groups-admin-html-preview', '#before' => '<h3>Field group HTML</h3>');
$temp[] = array('#type' => 'textarea', '#name' => 'wpcf[group][admin_styles]', '#inline' => true, '#value' => $admin_styles_value, '#default_value' => '', '#id' => 'wpcf-form-groups-css-fields-editor', '#after' => '
<div class="wpcf-update-preview-btn"><input type="button" value="Update preview" onclick="wpcfPreviewHtml()" style="float:right;" class="button-secondary"></div>
<h3>' . __('Field group preview', 'wpcf') . '</h3>
<div id="wpcf-update-preview-div">Preview here</div>
<script type="text/javascript">
var wpcfReadOnly = ' . json_encode(base64_encode($preview_profile)) . ';
var wpcfEditMode = ' . json_encode(base64_encode($edit_profile)) . ';
var wpcfDefaultCss = ' . json_encode(base64_encode($admin_styles_value)) . ';
</script>
', '#before' => sprintf('<h3>%s</h3>', __('Your CSS', 'wpcf')));
$admin_styles = _wpcf_filter_wrap('admin_styles', __('Admin styles for fields:', 'wpcf'), '', '', $temp, __('Open style editor', 'wpcf'));
$form['p_wrap_1_' . wpcf_unique_id(serialize($admin_styles))] = array('#type' => 'markup', '#markup' => '<p class="wpcf-filter-wrap">');
$form = $form + $admin_styles;
$form['adminstyles-table-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table><br />');
return $form;
}
示例14: pagination
/**
* Pagination
*/
function pagination()
{
global $wpcf;
// Pagination
$total_items = count($this->children);
$per_page = $wpcf->relationship->get_items_per_page($this->parent_post_type, $this->child_post_type);
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
$offset = $page == 1 ? 0 : ($page - 1) * $per_page;
$next = $total_items > $offset + $per_page;
$prev = $page == 1 ? false : true;
if ($total_items > $per_page) {
$this->children = array_splice($this->children, $offset, $per_page);
}
$this->pagination_top = wpcf_pr_admin_has_pagination($this->parent, $this->child_post_type, $page, $prev, $next, $per_page, $total_items);
/*
*
*
* Add pagination bottom
*/
$options = array(__('All', 'wpcf') => 'all', 5 => 5, 10 => 10, 15 => 15);
// Add sorting
$add_data = isset($_GET['sort']) && isset($_GET['field']) ? '&sort=' . sanitize_text_field($_GET['sort']) . '&field=' . sanitize_text_field($_GET['field']) : '';
if (isset($_GET['post_type_sort_parent'])) {
$add_data .= '&post_type_sort_parent=' . sanitize_text_field($_GET['post_type_sort_parent']);
}
$this->pagination_bottom = wpcf_form_simple(array('pagination' => array('#type' => 'select', '#before' => __('Show', 'wpcf'), '#after' => $this->child_post_type_object->labels->name, '#id' => 'wpcf_relationship_num_' . wpcf_unique_id(serialize($this->children)), '#name' => $wpcf->relationship->items_per_page_option_name, '#options' => $options, '#default_value' => $per_page, '#attributes' => array('class' => 'wpcf-relationship-items-per-page', 'data-action' => 'action=wpcf_ajax&wpcf_action=pr_pagination' . '&post_id=' . $this->parent->ID . '&post_type=' . $this->child_post_type . '&_wpnonce=' . wp_create_nonce('pr_pagination') . $add_data))));
}
示例15: wpcf_cd_fields_form_additional_filters
/**
* Group coditional display filter.
*
* @param type $filters
* @param type $update
* @return type
*/
function wpcf_cd_fields_form_additional_filters($filters, $update)
{
$data = array();
$data['id'] = !empty($update) && isset($update['name']) ? $update['name'] : wpcf_unique_id(serialize($filters));
$data['group_id'] = $update['id'];
if ($update) {
$data['data']['conditional_display'] = maybe_unserialize(get_post_meta($update['id'], '_wpcf_conditional_display', true));
} else {
$data['data']['conditional_display'] = array();
}
$data['meta_type'] = isset($update['meta_type']) ? $update['meta_type'] : 'unknown';
$filters = $filters + wpcf_cd_admin_form_filter(array(), $data, true);
return $filters;
}