• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wpcf_field_enqueue_scripts函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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&amp;wpcf_action=pr_sort&amp;field=' . '_wp_title&amp;sort=' . $title_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;_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&amp;wpcf_action=pr_sort&amp;field=' . '_wp_body&amp;sort=' . $body_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;_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&amp;wpcf_action=pr_sort&amp;field=' . $header . '&amp;sort=' . $field_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;_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&amp;wpcf_action=pr_sort&amp;field=' . '_wpcf_pr_parent&amp;sort=' . $parent_dir . '&amp;post_id=' . $post->ID . '&amp;post_type=' . $post_type . '&amp;post_type_sort_parent=' . $_parent . '&amp;_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;
 }
开发者ID:phuocdungit,项目名称:fundy,代码行数:77,代码来源:form-child.php


示例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'] .= '&#42;';
                        }
                        $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');
    }
}
开发者ID:sonvq,项目名称:passioninvestment,代码行数:101,代码来源:usermeta-post.php


示例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);
}
开发者ID:SpencerNeitzke,项目名称:types,代码行数:98,代码来源:fields-post.php


示例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);
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:95,代码来源:fields-post.php



注:本文中的wpcf_field_enqueue_scripts函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wpcf_fields_get_field_by_slug函数代码示例发布时间:2022-05-23
下一篇:
PHP wpcf_ensarr函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap