本文整理汇总了PHP中wpcf_field_enqueue_scripts函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_field_enqueue_scripts函数的具体用法?PHP wpcf_field_enqueue_scripts怎么用?PHP wpcf_field_enqueue_scripts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_field_enqueue_scripts函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: headers
/**
* Header HTML formatted output.
*
* Each header <th> is array element. Sortable.
*
* @return array 'header_id' => html
*/
function headers()
{
// Sorting
$dir = isset($_GET['sort']) && $_GET['sort'] == 'ASC' ? 'DESC' : 'ASC';
$dir_default = 'ASC';
$sort_field = isset($_GET['field']) ? sanitize_text_field($_GET['field']) : '';
// Set values
$post = $this->parent;
$post_type = $this->child_post_type;
$parent_post_type = $this->parent_post_type;
$data = $this->data;
$wpcf_fields = wpcf_admin_fields_get_fields(true);
$headers = array();
foreach ($this->headers as $k => $header) {
if ($k === '__parents' || $k === '__taxonomies') {
continue;
}
if ($header == '_wp_title') {
if ($this->child_supports['title']) {
$title_dir = $sort_field == '_wp_title' ? $dir : 'ASC';
$headers[$header] = '';
$headers[$header] .= $sort_field == '_wp_title' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
$headers[$header] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=pr_sort&field=' . '_wp_title&sort=' . $title_dir . '&post_id=' . $post->ID . '&post_type=' . $post_type . '&_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . __('Post Title', 'wpcf') . '</a>';
} else {
$headers[$header] = 'ID';
}
} else {
if ($header == '_wp_body') {
$body_dir = $sort_field == '_wp_body' ? $dir : $dir_default;
$headers[$header] = '';
$headers[$header] .= $sort_field == '_wp_body' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
$headers[$header] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=pr_sort&field=' . '_wp_body&sort=' . $body_dir . '&post_id=' . $post->ID . '&post_type=' . $post_type . '&_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . __('Post Body', 'wpcf') . '</a>';
} else {
if ($header == '_wp_excerpt' || $header == '_wp_featured_image') {
$headers[$header] = $this->get_header($header);
} else {
$link_text = $this->get_header($header);
if (strpos($header, WPCF_META_PREFIX) === 0 && isset($wpcf_fields[str_replace(WPCF_META_PREFIX, '', $header)])) {
wpcf_field_enqueue_scripts($wpcf_fields[str_replace(WPCF_META_PREFIX, '', $header)]['type']);
$link_text = stripslashes($wpcf_fields[str_replace(WPCF_META_PREFIX, '', $header)]['name']);
}
$field_dir = $sort_field == $header ? $dir : $dir_default;
$headers[$header] = '';
$headers[$header] .= $sort_field == $header ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
$headers[$header] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=pr_sort&field=' . $header . '&sort=' . $field_dir . '&post_id=' . $post->ID . '&post_type=' . $post_type . '&_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . $link_text . '</a>';
}
}
}
}
if (!empty($this->headers['__parents'])) {
foreach ($this->headers['__parents'] as $_parent => $data) {
if ($_parent == $parent_post_type) {
continue;
}
$temp_parent_type = get_post_type_object($_parent);
if (empty($temp_parent_type)) {
continue;
}
$parent_dir = $sort_field == '_wpcf_pr_parent' ? $dir : $dir_default;
$headers['_wpcf_pr_parent_' . $_parent] = $sort_field == '_wpcf_pr_parent' ? '<div class="wpcf-pr-sort-' . $dir . '"></div>' : '';
$headers['_wpcf_pr_parent_' . $_parent] .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&wpcf_action=pr_sort&field=' . '_wpcf_pr_parent&sort=' . $parent_dir . '&post_id=' . $post->ID . '&post_type=' . $post_type . '&post_type_sort_parent=' . $_parent . '&_wpnonce=' . wp_create_nonce('pr_sort')) . '">' . $temp_parent_type->label . '</a>';
}
}
if (!empty($this->headers['__taxonomies'])) {
foreach ($this->headers['__taxonomies'] as $tax_id => $taxonomy) {
$headers["_wpcf_pr_taxonomy_{$tax_id}"] = $taxonomy;
}
}
return $headers;
}
示例2: wpcf_admin_userprofile_init
//.........这里部分代码省略.........
continue;
} else {
//If Access plugin activated
if (function_exists('wpcf_access_register_caps')) {
//If user can't view own profile fields
if (!current_user_can('view_own_in_profile_' . $group['slug'])) {
continue;
}
//If user can modify current group in own profile
if (!current_user_can('modify_own_' . $group['slug'])) {
$profile_only_preview = 1;
}
}
}
} else {
if (function_exists('wpcf_access_register_caps')) {
if (!current_user_can('view_own_in_profile_' . $group['slug'])) {
continue;
}
if (!current_user_can('modify_own_' . $group['slug'])) {
$profile_only_preview = 1;
}
}
}
// Process fields
if (empty($profile_only_preview)) {
if (defined('WPTOOLSET_FORMS_VERSION')) {
$errors = get_user_meta($user_id->ID, '__wpcf-invalid-fields', true);
// OLD
delete_post_meta($user_id->ID, 'wpcf-invalid-fields');
delete_post_meta($user_id->ID, '__wpcf-invalid-fields');
if (empty($group['fields'])) {
continue;
}
$output = '<div class="wpcf-group-area wpcf-group-area_' . $group['slug'] . '">' . "\n\n" . '<h3>' . wpcf_translate('group ' . $group['id'] . ' name', $group['name']) . '</h3>' . "\n\n";
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) {
$config = wptoolset_form_filter_types_field($field, $user_id->ID);
$config = array_map('fix_fields_config_output_for_display', $config);
$meta = get_user_meta($user_id->ID, $field['meta_key']);
if ($errors) {
$config['validate'] = true;
}
if (isset($config['validation']['required'])) {
$config['title'] .= '*';
}
$config['_title'] = $config['title'];
$output .= '
<div class="wpcf-profile-field-line">
<div class="wpcf-profile-line-left">
' . $config['title'] . '
</div>
<div class="wpcf-profile-line-right">
';
$description = false;
if (!empty($config['description'])) {
$description = sprintf('<span class="description">%s</span>', $config['description']);
}
$config['title'] = $config['description'] = '';
$form_name = $user_id->ID ? 'your-profile' : 'createuser';
$output .= wptoolset_form_field($form_name, $config, $meta);
if ($description) {
$output .= $description;
}
$output .= '
</div>
</div>';
}
$output .= '</div></div>';
echo $output;
} else {
$group['fields'] = wpcf_admin_usermeta_process_fields($user_id, $group['fields'], true);
wpcf_admin_render_fields($group, $user_id);
}
} else {
// Render profile fields (text only)
wpcf_usermeta_preview_profile($user_id, $group);
}
}
}
// Activate scripts
if ($wpcf_active) {
wp_enqueue_script('wpcf-fields-post', WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js', array('jquery'), WPCF_VERSION);
wp_enqueue_script('wpcf-form-validation', WPCF_EMBEDDED_RES_RELPATH . '/js/' . 'jquery-form-validation/jquery.validate.min.js', array('jquery'), WPCF_VERSION);
wp_enqueue_script('wpcf-form-validation-additional', WPCF_EMBEDDED_RES_RELPATH . '/js/' . 'jquery-form-validation/additional-methods.min.js', array('jquery'), WPCF_VERSION);
wp_enqueue_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
wp_enqueue_style('wpcf-fields-post', WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css', array('wpcf-css-embedded'), WPCF_VERSION);
wp_enqueue_style('wpcf-usermeta', WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css', array('wpcf-css-embedded'), WPCF_VERSION);
wpcf_enqueue_scripts();
wpcf_field_enqueue_scripts('date');
wpcf_field_enqueue_scripts('image');
wpcf_field_enqueue_scripts('file');
wpcf_field_enqueue_scripts('skype');
wpcf_field_enqueue_scripts('numeric');
add_action('admin_footer', 'wpcf_admin_profile_js_validation');
}
}
示例3: wpcf_admin_post_init
/**
* Init functions for post edit pages.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @param type $post
*/
function wpcf_admin_post_init($post)
{
add_action('admin_footer', 'wpcf_admin_fields_postfields_styles');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
// Get post_type
$post_type = wpcf_admin_get_edited_post_type($post);
/*
*
* This is left to maintain compatibility with older versions
* TODO Remove
*/
// Add items to View dropdown
if (in_array($post_type, array('view', 'view-template', 'cred-form'))) {
add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_editor_addon_menus_filter');
add_action('admin_footer', 'wpcf_admin_post_js_validation');
wpcf_enqueue_scripts();
wp_enqueue_script('toolset-colorbox');
wp_enqueue_style('toolset-colorbox');
}
// Never show on 'Views' and 'View Templates'
if (in_array($post_type, array('view', 'view-template'))) {
return false;
}
// Add marketing box
if (!in_array($post_type, array('post', 'page', 'cred-form')) && !defined('WPCF_RUNNING_EMBEDDED')) {
$hide_help_box = true;
$help_box = wpcf_get_settings('help_box');
$custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
if ($help_box != 'no') {
if ($help_box == 'by_types' && array_key_exists($post_type, $custom_types)) {
$hide_help_box = false;
}
if (function_exists('wprc_is_logged_to_repo') && wprc_is_logged_to_repo(WPCF_REPOSITORY)) {
$hide_help_box = true;
}
if ($help_box == 'all') {
$hide_help_box = false;
}
if (!$hide_help_box && !defined('WPV_VERSION')) {
add_meta_box('wpcf-marketing', __('Display Custom Content', 'wpcf'), 'wpcf_admin_post_marketing_meta_box', $post_type, 'side', 'high');
}
}
}
// Are Types active?
$wpcf_active = false;
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($post);
foreach ($groups as $group) {
$only_preview = '';
//If Access plugin activated
if (function_exists('wpcf_access_register_caps')) {
//If user can't view own profile fields
if (!current_user_can('view_fields_in_edit_page_' . $group['slug'])) {
continue;
}
//If user can modify current group in own profile
if (!current_user_can('modify_fields_in_edit_page_' . $group['slug'])) {
$only_preview = 1;
}
}
if (!empty($group['fields']) && empty($only_preview)) {
$wpcf_active = true;
break;
}
}
// Activate scripts
if ($wpcf_active) {
add_action('admin_head', 'wpcf_post_preview_warning');
wpcf_edit_post_screen_scripts();
}
// Add validation
add_action('admin_footer', 'wpcf_admin_post_js_validation');
/*
* TODO Review
* This is forced because of various Child cases
* and when field are rendered via AJAX but not registered yet.
*
* Basically all fields that require additional JS should be added here.
*
* This is a must for now.
* These fields need init JS in various cases.
*/
wpcf_field_enqueue_scripts('date');
wpcf_field_enqueue_scripts('image');
wpcf_field_enqueue_scripts('file');
wpcf_field_enqueue_scripts('skype');
wpcf_field_enqueue_scripts('numeric');
do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
示例4: wpcf_admin_post_init
/**
* Init functions for post edit pages.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @param type $post
*/
function wpcf_admin_post_init($post)
{
add_action('admin_footer', 'wpcf_admin_fields_postfields_styles');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
wpcf_admin_add_js_settings('wpcf_nonce_toggle_fieldset', '\'' . wp_create_nonce('form_fieldset_toggle') . '\'');
// Get post_type
$post_type = wpcf_admin_get_edited_post_type($post);
/*
*
* This is left to maintain compatibility with older versions
* TODO Remove
*/
// Add items to View dropdown
if (in_array($post_type, array('view', 'view-template', 'cred-form', 'cred-user-form'))) {
add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_editor_addon_menus_filter');
add_action('admin_footer', 'wpcf_admin_post_js_validation');
wpcf_enqueue_scripts();
wp_enqueue_script('toolset-colorbox');
wp_enqueue_style('toolset-colorbox');
}
// Never show on 'Views' and 'Content Templates'
if (in_array($post_type, array('view', 'view-template'))) {
return false;
}
/**
* remove custom field WordPress metabox
*/
if ('hide' == wpcf_get_settings('hide_standard_custom_fields_metabox')) {
foreach (array('normal', 'advanced', 'side') as $context) {
remove_meta_box('postcustom', $post_type, $context);
}
}
// Add marketing box
if (!wpcf_is_client() && !in_array($post_type, array('post', 'page', 'cred-form', 'cred-user-form')) && !defined('WPCF_RUNNING_EMBEDDED')) {
$settings_help_box = wpcf_get_settings('help_box');
$custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
if ($settings_help_box == 'all' || array_key_exists($post_type, $custom_types)) {
$displaying_custom_content = (include WPCF_ABSPATH . '/marketing/displaying-custom-content/title-content.php');
add_meta_box('add_box_howto', $displaying_custom_content['title'], 'wpcf_admin_post_marketing_displaying_custom_content', $post_type, 'side', 'high');
}
}
// Are Types active?
$wpcf_active = false;
// Get groups
$groups = wpcf_admin_post_get_post_groups_fields($post);
foreach ($groups as $group) {
$only_preview = '';
//If Access plugin activated
if (function_exists('wpcf_access_register_caps')) {
//If user can't view own profile fields
if (!current_user_can('view_fields_in_edit_page_' . $group['slug'])) {
continue;
}
//If user can modify current group in own profile
if (!current_user_can('modify_fields_in_edit_page_' . $group['slug'])) {
$only_preview = 1;
}
}
if (!empty($group['fields']) && empty($only_preview)) {
$wpcf_active = true;
break;
}
}
// Activate scripts
if ($wpcf_active) {
add_action('admin_head', 'wpcf_post_preview_warning');
wpcf_edit_post_screen_scripts();
}
// Add validation
add_action('admin_footer', 'wpcf_admin_post_js_validation');
/*
* TODO Review
* This is forced because of various Child cases
* and when field are rendered via AJAX but not registered yet.
*
* Basically all fields that require additional JS should be added here.
*
* This is a must for now.
* These fields need init JS in various cases.
*/
wpcf_field_enqueue_scripts('date');
wpcf_field_enqueue_scripts('image');
wpcf_field_enqueue_scripts('file');
wpcf_field_enqueue_scripts('skype');
wpcf_field_enqueue_scripts('numeric');
do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}