本文整理汇总了PHP中wpcf_enqueue_scripts函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_enqueue_scripts函数的具体用法?PHP wpcf_enqueue_scripts怎么用?PHP wpcf_enqueue_scripts使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_enqueue_scripts函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: wpcf_pr_admin_post_init_action
/**
* Init function.
*
* Enqueues styles and scripts on post edit page.
*
* @param type $post_type
* @param type $post
* @param type $groups
* @param type $wpcf_active
*/
function wpcf_pr_admin_post_init_action($post_type, $post, $groups, $wpcf_active)
{
// See if any data
$has = wpcf_pr_admin_get_has($post_type);
$belongs = wpcf_pr_admin_get_belongs($post_type);
/*
* Enqueue styles and scripts
*/
if (!empty($has) || !empty($belongs)) {
$output = wpcf_pr_admin_post_meta_box_output($post, array('post_type' => $post_type, 'has' => $has, 'belongs' => $belongs));
add_meta_box('wpcf-post-relationship', __('Post Relationship', 'wpcf'), 'wpcf_pr_admin_post_meta_box', $post_type, 'normal', 'default', array('output' => $output));
if (!empty($output)) {
wp_enqueue_script('wpcf-post-relationship', WPCF_EMBEDDED_RELPATH . '/resources/js/post-relationship.js', array('jquery', 'select2'), WPCF_VERSION);
wp_enqueue_style('wpcf-post-relationship', WPCF_EMBEDDED_RELPATH . '/resources/css/post-relationship.css', array(), WPCF_VERSION);
if (!$wpcf_active) {
wpcf_enqueue_scripts();
wp_enqueue_style('wpcf-pr-post', WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css', array(), 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);
}
wpcf_admin_add_js_settings('wpcf_pr_del_warning', '\'' . __('Are you sure about deleting this post?', 'wpcf') . '\'');
wpcf_admin_add_js_settings('wpcf_pr_pagination_warning', '\'' . __('If you continue without saving your changes, they might get lost.', 'wpcf') . '\'');
}
}
}
示例2: ajax_header
/**
* Echoes AJAX HTML header.
*/
function ajax_header()
{
// Enqueue Types scripts
wpcf_enqueue_scripts();
/*
*
* TODO Resolve migration from Thickbox
* Since 1.2 we clone header and footer until we resolve future Thickbox
* handling.
*/
// include ABSPATH . '/wp-admin/admin-header.php';
include WPCF_EMBEDDED_ABSPATH . '/includes/ajax/admin-header.php';
}
示例3: wpcf_edit_post_screen_scripts
/**
* Load all scripts required on edit post screen.
*
* @since 1.2.1
* @todo Make loading JS more clear for all components.
*/
function wpcf_edit_post_screen_scripts()
{
wpcf_enqueue_scripts();
wp_enqueue_script('wpcf-fields-post', WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js', array('jquery'), WPCF_VERSION);
// TODO Switch to 1.11.1 jQuery Validation
// wp_enqueue_script( 'types-js-validation' );
if (!defined('WPTOOLSET_FORMS_ABSPATH')) {
wp_enqueue_script('wpcf-form-validation', WPCF_EMBEDDED_RES_RELPATH . '/js/' . 'jquery-form-validation/jquery.validate.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-fields-basic', 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-fields-basic'), WPCF_VERSION);
wp_enqueue_style('wpcf-usermeta', WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css', array('wpcf-fields-basic'), WPCF_VERSION);
wp_enqueue_script('toolset-colorbox');
wp_enqueue_style('toolset-colorbox');
wp_enqueue_style('toolset-font-awesome');
}
示例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'))) {
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);
}
示例5: wpcf_admin_usermeta_get_groups_fields
/**
* Gets all groups and fields for post.
*
* Core function. Works and stable. Do not move or change.
* If required, add hooks only.
*
* @param type $post_ID
* @return type
*/
function wpcf_admin_usermeta_get_groups_fields()
{
wpcf_enqueue_scripts();
$post = array();
// Filter groups
$groups = array();
$groups_all = wpcf_admin_fields_get_groups(TYPES_USER_META_FIELD_GROUP_CPT_NAME);
foreach ($groups_all as $temp_key => $temp_group) {
if (empty($temp_group['is_active'])) {
unset($groups_all[$temp_key]);
continue;
}
$passed = 1;
if (!$passed) {
unset($groups_all[$temp_key]);
} else {
$groups_all[$temp_key]['fields'] = wpcf_admin_fields_get_fields_by_group($temp_group['id'], 'slug', true, false, true, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
}
}
$groups = $groups_all;
return $groups;
}
示例6: 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 $upgrade
*/
function wpcf_admin_post_init($post = false)
{
global $wpcf;
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
if ($post) {
$post_type = get_post_type($post);
} else {
if (!isset($_GET['post_type'])) {
$post_type = 'post';
} else {
if (in_array($_GET['post_type'], get_post_types(array('show_ui' => true)))) {
$post_type = $_GET['post_type'];
} else {
return false;
}
}
}
// Set global $wpcf post object
// CHECKPOINT
$wpcf->post = $post;
$wpcf->post_types->set($post_type);
// Add items to View dropdown
if (in_array($post_type, array('view', 'view-template'))) {
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();
}
// Never show on 'Views' and 'View Templates'
// CRED should pass this check
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-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) {
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) {
if (!empty($group['fields'])) {
$wpcf_active = true;
// Process fields
$group['fields'] = wpcf_admin_post_process_fields($post, $group['fields'], true);
}
// Specially for CRED
/*
*
* TODO Setting some specific for CRED is wrong
* Use hooks
*/
if (!in_array($post_type, array('cred-form'))) {
// Add meta boxes
add_meta_box($group['slug'], wpcf_translate('group ' . $group['id'] . ' name', $group['name']), 'wpcf_admin_post_meta_box', $post_type, $group['meta_box_context'], 'high', $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-fields-basic', 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-fields-basic'), WPCF_VERSION);
wpcf_enqueue_scripts();
}
// Add validation
// TODO Move to wpcf_enqueue_scripts()
add_action('admin_footer', 'wpcf_admin_post_js_validation');
do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
示例7: 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-fields-basic', 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-fields-basic'), WPCF_VERSION);
wp_enqueue_style('wpcf-usermeta', WPCF_EMBEDDED_RES_RELPATH . '/css/usermeta.css', array('wpcf-fields-basic'), 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');
}
}
示例8: wpcf_admin_post_add_usermeta_to_editor_on_demand
public static function wpcf_admin_post_add_usermeta_to_editor_on_demand()
{
add_action('admin_footer', 'wpcf_admin_post_js_validation');
wpcf_enqueue_scripts();
wp_enqueue_script('toolset-colorbox');
wp_enqueue_style('toolset-colorbox');
add_filter('editor_addon_menus_wpv-views', 'wpcf_admin_post_add_usermeta_to_editor_js');
}
示例9: 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);
}
示例10: wpcf_edit_post_screen_scripts
/**
* Load all scripts required on edit post screen.
*
* @since 1.2.1
* @todo Make loading JS more clear for all components.
*/
function wpcf_edit_post_screen_scripts()
{
wpcf_enqueue_scripts();
wp_enqueue_script('wpcf-fields-post', WPCF_EMBEDDED_RES_RELPATH . '/js/fields-post.js', array('jquery'), WPCF_VERSION);
wp_enqueue_style('wpcf-fields-post', WPCF_EMBEDDED_RES_RELPATH . '/css/fields-post.css', array(), 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);
}