当前位置: 首页>>代码示例>>PHP>>正文


PHP wpcf_admin_add_js_settings函数代码示例

本文整理汇总了PHP中wpcf_admin_add_js_settings函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_admin_add_js_settings函数的具体用法?PHP wpcf_admin_add_js_settings怎么用?PHP wpcf_admin_add_js_settings使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wpcf_admin_add_js_settings函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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') . '\'');
        }
    }
}
开发者ID:VanessaGarcia-Freelance,项目名称:CrowdsLine,代码行数:35,代码来源:post-relationship.php

示例2: wpcf_admin_post_init

/**
 * Init functions for post edit pages.
 * 
 * @param type $upgrade 
 */
function wpcf_admin_post_init($post = false)
{
    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;
            }
        }
    }
    // 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');
    }
    // Never show on 'Views' and 'View Templates'
    if (in_array($post_type, array('view', 'view-template'))) {
        return false;
    }
    // Get groups
    $groups = wpcf_admin_post_get_post_groups_fields($post);
    $wpcf_active = false;
    foreach ($groups as $key => $group) {
        if (!empty($group['fields'])) {
            $wpcf_active = true;
            // Process fields
            $group['fields'] = wpcf_admin_post_process_fields($post, $group['fields']);
        }
        // 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);
        add_action('admin_footer', 'wpcf_admin_post_js_validation');
    }
    do_action('wpcf_admin_post_init', $post_type, $post, $groups, $wpcf_active);
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:55,代码来源:fields-post.php

示例3: init_admin

 /**
  * Summary.
  *
  * Description.
  *
  * @since x.x.x
  * @access (for functions: only use if private)
  *
  * @see Function/method/class relied on
  * @link URL
  * @global type $varname Description.
  * @global type $varname Description.
  *
  * @param type $var Description.
  * @param type $var Optional. Description.
  *
  * @return type Description.
  */
 public function init_admin()
 {
     $this->post_type = TYPES_CUSTOM_FIELD_GROUP_CPT_NAME;
     $this->init_hooks();
     $this->boxes = array('submitdiv' => array('callback' => array($this, 'box_submitdiv'), 'title' => __('Save', 'wpcf'), 'default' => 'side', 'priority' => 'high'));
     /** Admin styles **/
     $this->current_user_can_edit = WPCF_Roles::user_can_create('custom-field');
     if (defined('TYPES_USE_STYLING_EDITOR') && TYPES_USE_STYLING_EDITOR && $this->current_user_can_edit) {
         $this->boxes['types_styling_editor'] = array('callback' => array($this, 'types_styling_editor'), 'title' => __('Fields Styling Editor'), 'default' => 'normal');
     }
     $this->boxes = apply_filters('wpcf_meta_box_order_defaults', $this->boxes, $this->post_type);
     $this->boxes = apply_filters('wpcf_meta_box_custom_field', $this->boxes, $this->post_type);
     wp_enqueue_script(__CLASS__, WPCF_RES_RELPATH . '/js/' . 'taxonomy-form.js', array('jquery', 'jquery-ui-dialog', 'jquery-ui-tabs'), WPCF_VERSION);
     wp_enqueue_style('wp-jquery-ui-dialog');
     wpcf_admin_add_js_settings('wpcfFormAlertOnlyPreview', sprintf("'%s'", __('Sorry, but this is only preview!', 'wpcf')));
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:34,代码来源:class.types.admin.edit.custom.fields.group.php

示例4: wpcf_admin_render_js_settings

/**
 * Renders JS settings.
 * 
 * @return type 
 */
function wpcf_admin_render_js_settings()
{
    $settings = wpcf_admin_add_js_settings('get');
    if (empty($settings)) {
        return '';
    }
    ?>
    <script type="text/javascript">
        //<![CDATA[
    <?php 
    foreach ($settings as $id => $setting) {
        echo 'var ' . $id . ' = ' . $setting . ';' . "\r\n";
    }
    ?>
        //]]>
    </script>
    <?php 
}
开发者ID:sriram911,项目名称:pls,代码行数:23,代码来源:admin.php

示例5: wpcf_admin_usermeta_form

/**
 * Generates form data.
 */
function wpcf_admin_usermeta_form()
{
    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') . '\'');
    $default = array();
    global $wpcf_button_style;
    global $wpcf_button_style30;
    // If it's update, get data
    $update = false;
    if (isset($_REQUEST['group_id'])) {
        $update = wpcf_admin_fields_get_group(intval($_REQUEST['group_id']), 'wp-types-user-group');
        if (empty($update)) {
            $update = false;
            wpcf_admin_message(sprintf(__("Group with ID %d do not exist", 'wpcf'), intval($_REQUEST['group_id'])));
        } else {
            $update['fields'] = wpcf_admin_fields_get_fields_by_group($_REQUEST['group_id'], 'slug', false, true, false, 'wp-types-user-group', 'wpcf-usermeta');
            $update['show_for'] = wpcf_admin_get_groups_showfor_by_group($_REQUEST['group_id']);
            $update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group($_REQUEST['group_id']);
        }
    }
    $form = array();
    $form['#form']['callback'] = array('wpcf_admin_save_usermeta_groups_submit');
    // Form sidebars
    $form['open-sidebar'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-fields-align-right">');
    // Set help icon
    $form['help-icon'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-admin-fields-help"><img src="' . WPCF_EMBEDDED_RELPATH . '/common/res/images/question.png" style="position:relative;top:2px;" />&nbsp;<a href="http://wp-types.com/documentation/user-guides/using-custom-fields/" target="_blank">' . __('Usermeta help', 'wpcf') . '</a></div>');
    $form['submit2'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
    $form['fields'] = array('#type' => 'fieldset', '#title' => __('Available fields', 'wpcf'));
    // Get field types
    $fields_registered = wpcf_admin_fields_get_available_types();
    foreach ($fields_registered as $filename => $data) {
        $form['fields'][basename($filename, '.php')] = array('#type' => 'markup', '#markup' => '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax&amp;wpcf_action=fields_insert' . '&amp;field=' . basename($filename, '.php') . '&amp;page=wpcf-edit-usermeta') . '&amp;_wpnonce=' . wp_create_nonce('fields_insert') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary">' . $data['title'] . '</a> ');
        // Process JS
        if (!empty($data['group_form_js'])) {
            foreach ($data['group_form_js'] as $handle => $script) {
                if (isset($script['inline'])) {
                    add_action('admin_footer', $script['inline']);
                    continue;
                }
                $deps = !empty($script['deps']) ? $script['deps'] : array();
                $in_footer = !empty($script['in_footer']) ? $script['in_footer'] : false;
                wp_register_script($handle, $script['src'], $deps, WPCF_VERSION, $in_footer);
                wp_enqueue_script($handle);
            }
        }
        // Process CSS
        if (!empty($data['group_form_css'])) {
            foreach ($data['group_form_css'] as $handle => $script) {
                if (isset($script['src'])) {
                    $deps = !empty($script['deps']) ? $script['deps'] : array();
                    wp_enqueue_style($handle, $script['src'], $deps, WPCF_VERSION);
                } else {
                    if (isset($script['inline'])) {
                        add_action('admin_head', $script['inline']);
                    }
                }
            }
        }
    }
    // Get fields created by user
    $fields = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
    if (!empty($fields)) {
        $form['fields-existing'] = array('#type' => 'fieldset', '#title' => __('User created fields', 'wpcf'), '#id' => 'wpcf-form-groups-user-fields');
        foreach ($fields as $key => $field) {
            if (isset($update['fields']) && array_key_exists($key, $update['fields'])) {
                continue;
            }
            if (!empty($field['data']['removed_from_history'])) {
                continue;
            }
            $form['fields-existing'][$key] = array('#type' => 'markup', '#markup' => '<div id="wpcf-user-created-fields-wrapper-' . $field['id'] . '" style="float:left; margin-right: 10px;"><a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;page=wpcf-edit' . '&amp;wpcf_action=usermeta_insert_existing' . '&amp;field=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('usermeta_insert_existing') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary" onclick="jQuery(this).parent().fadeOut();" ' . 'data-slug="' . $field['id'] . '">' . htmlspecialchars(stripslashes($field['name'])) . '</a>' . '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=remove_from_history2' . '&amp;field_id=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('remove_from_history2') . '&amp;wpcf_warning=' . sprintf(__('Are you sure that you want to remove field %s from history?', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '&amp;wpcf_ajax_update=wpcf-user-created-fields-wrapper-' . $field['id'] . '" title="' . sprintf(__('Remove field %s', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '" class="wpcf-ajax-link"><img src="' . WPCF_RES_RELPATH . '/images/delete-2.png" style="postion:absolute;margin-top:5px;margin-left:-4px;" /></a></div>');
        }
    }
    $form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
    // Group data
    $form['open-main'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-form-fields-main">');
    $form['title'] = array('#type' => 'textfield', '#name' => 'wpcf[group][name]', '#id' => 'wpcf-group-name', '#value' => $update ? $update['name'] : __('Enter group title', 'wpcf'), '#inline' => true, '#attributes' => array('style' => 'width:100%;margin-bottom:10px;'), '#validate' => array('required' => array('value' => true)));
    if (!$update) {
        $form['title']['#attributes']['data-label'] = addcslashes(__('Enter group title', 'wpcf'), '"');
        $form['title']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
        $form['title']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
    }
    $form['description'] = array('#type' => 'textarea', '#id' => 'wpcf-group-description', '#name' => 'wpcf[group][description]', '#value' => $update ? $update['description'] : __('Enter a description for this group', 'wpcf'));
    if (!$update) {
        $form['description']['#attributes']['data-label'] = addcslashes(__('Enter a description for this group', 'wpcf'), '"');
        $form['description']['#attributes']['onfocus'] = 'if (jQuery(this).val() == jQuery(this).data(\'label\')) { jQuery(this).val(\'\'); }';
        $form['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(jQuery(this).data(\'label\')) }';
    }
    // Show Fields for
    global $wp_roles;
    $options = array();
    $users_currently_supported = array();
    $form_types = array();
    foreach ($wp_roles->role_names as $role => $name) {
        $options[$role]['#name'] = 'wpcf[group][supports][' . $role . ']';
        $options[$role]['#title'] = ucwords($role);
//.........这里部分代码省略.........
开发者ID:sandum150,项目名称:cheltuieli,代码行数:101,代码来源:usermeta-form.php

示例6: wpcf_enqueue_scripts

/**
 * Basic scripts
 */
function wpcf_enqueue_scripts()
{
    if (!is_admin()) {
        return;
    }
    if (!wpcf_is_embedded()) {
        /**
         * Basic JS
         */
        wp_register_script('wpcf-js', WPCF_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs', 'toolset-colorbox'), WPCF_VERSION);
        wp_localize_script('wpcf-js', 'wpcf_js', array('close' => __('Close', 'wpcf')));
        wp_enqueue_script('wpcf-js');
        if (function_exists('wpcf_admin_add_js_settings')) {
            wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
        }
    }
    /**
     * Basic JS
     */
    wp_enqueue_script('wpcf-js-embedded', WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs', 'select2'), WPCF_VERSION);
    wp_localize_script('wpcf-js-embedded', 'WPCF_basic', array('field_already_in_use' => sprintf(__('%s This field is locked because the same field is added multiple times to this post. %s%s%s you can set the value%s', 'wpcf'), '<small style="display: block;">', '<a href="#" class="focus_correct_field" data-field-slug="##DATA-FIELD-ID##" >', 'Here', '</a>', '</small>')));
    /*
     *
     * Basic CSS
     */
    wp_enqueue_style('wpcf-css-embedded');
    /*
     *
     * Other components
     */
    if (!defined('WPTOOLSET_FORMS_ABSPATH')) {
        // Repetitive
        wp_enqueue_script('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/js/repetitive.js', array('wpcf-js-embedded'), WPCF_VERSION);
        wp_enqueue_style('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/css/repetitive.css', array('wpcf-css-embedded'), WPCF_VERSION);
    }
    // Conditional
    wp_enqueue_script('types-conditional');
    // RTL
    if (is_rtl()) {
        wp_enqueue_style('wpcf-rtl', WPCF_EMBEDDED_RES_RELPATH . '/css/rtl.css', array('wpcf-css-embedded'), WPCF_VERSION);
    }
    /**
     * select2
     */
    $select2_version = '3.5.2';
    if (!wp_script_is('select2', 'registered')) {
        wp_register_script('select2', WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/res/lib/select2/select2.min.js', array('jquery'), $select2_version);
    }
    if (!wp_style_is('select2', 'registered')) {
        wp_register_style('select2', WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/res/lib/select2/select2.css', array(), $select2_version);
    }
    if (!wp_style_is('select2')) {
        wp_enqueue_style('select2');
    }
    // Add JS settings
    wpcf_admin_add_js_settings('wpcfFormUniqueValuesCheckText', '\'' . __('Warning: same values selected', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueNamesCheckText', '\'' . __('Warning: field name already used', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueSlugsCheckText', '\'' . __('Warning: field slug already used', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUsedOrReservedSlug', '\'' . __('You cannot use this slug because it is already used or a reserved word. Please choose a different slug.', 'wpcf') . '\'');
}
开发者ID:studiopengpeng,项目名称:ASCOMETAL,代码行数:63,代码来源:functions.php

示例7: wpcf_enqueue_scripts

/**
 * Basic scripts
 */
function wpcf_enqueue_scripts()
{
    if (!is_admin()) {
        return;
    }
    if (!wpcf_is_embedded()) {
        /**
         * Basic JS
         */
        wp_register_script('wpcf-js', WPCF_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs', 'toolset-colorbox'), WPCF_VERSION);
        wp_localize_script('wpcf-js', 'wpcf_js', array('close' => __('Close', 'wpcf')));
        wp_enqueue_script('wpcf-js');
        if (function_exists('wpcf_admin_add_js_settings')) {
            wpcf_admin_add_js_settings('wpcf_nonce_toggle_group', '\'' . wp_create_nonce('group_form_collapsed') . '\'');
        }
    }
    /**
     * Basic JS
     */
    wp_enqueue_script('wpcf-js-embedded', WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs', 'select2'), WPCF_VERSION);
    /*
     *
     * Basic CSS
     */
    wp_enqueue_style('wpcf-css-embedded');
    /*
     *
     * Other components
     */
    if (!defined('WPTOOLSET_FORMS_ABSPATH')) {
        // Repetitive
        wp_enqueue_script('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/js/repetitive.js', array('wpcf-js-embedded'), WPCF_VERSION);
        wp_enqueue_style('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/css/repetitive.css', array('wpcf-css-embedded'), WPCF_VERSION);
    }
    // Conditional
    wp_enqueue_script('types-conditional');
    // RTL
    if (is_rtl()) {
        wp_enqueue_style('wpcf-rtl', WPCF_EMBEDDED_RES_RELPATH . '/css/rtl.css', array('wpcf-css-embedded'), WPCF_VERSION);
    }
    /**
     * select2
     */
    $select2_version = '3.5.2';
    if (!wp_script_is('select2', 'registered')) {
        wp_register_script('select2', WPCF_EMBEDDED_RELPATH . '/toolset/toolset-common/utility/js/select2.min.js', array('jquery'), $select2_version);
    }
    if (!wp_style_is('select2', 'registered')) {
        wp_register_style('select2', WPCF_EMBEDDED_RELPATH . '/toolset/toolset-common/utility/css/select2/select2.css', array(), $select2_version);
    }
    if (!wp_style_is('select2')) {
        wp_enqueue_style('select2');
    }
    // Add JS settings
    wpcf_admin_add_js_settings('wpcfFormUniqueValuesCheckText', '\'' . __('Warning: same values selected', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueNamesCheckText', '\'' . __('Warning: field name already used', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUniqueSlugsCheckText', '\'' . __('Warning: field slug already used', 'wpcf') . '\'');
    wpcf_admin_add_js_settings('wpcfFormUsedOrReservedSlug', '\'' . __('You cannot use this slug because it is already used or a reserved word. Please choose a different slug.', 'wpcf') . '\'');
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:62,代码来源:functions.php

示例8: wpcf_admin_fields_form

/**
 * Generates form data.
 * 
 * @deprecated Possibly deprecated, no usage found in Types. Possibly identical code in Types_Admin_Edit_Fields::get_field_form_data()
 */
function wpcf_admin_fields_form()
{
    /**
     * include common functions
     */
    include_once dirname(__FILE__) . '/common-functions.php';
    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') . '\'');
    $default = array();
    global $wpcf_button_style;
    global $wpcf_button_style30;
    global $wpcf;
    $form = array();
    $form['#form']['callback'] = array('wpcf_admin_save_fields_groups_submit');
    // Form sidebars
    if ($current_user_can_edit) {
        $form['open-sidebar'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-fields-align-right">');
        // Set help icon
        $form['help-icon'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-admin-fields-help"><img src="' . WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/res/images/question.png" style="position:relative;top:2px;" />&nbsp;<a href="' . Types_Helper_Url::get_url('using-post-fields', 'fields-editor', 'fields-help', Types_Helper_Url::UTM_MEDIUM_HELP) . '" target="_blank">' . __('Custom fields help', 'wpcf') . '</a></div>');
        $form['submit2'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
        $form['fields'] = array('#type' => 'fieldset', '#title' => __('Available fields', 'wpcf'));
        // Get field types
        $fields_registered = wpcf_admin_fields_get_available_types();
        foreach ($fields_registered as $filename => $data) {
            $form['fields'][basename($filename, '.php')] = array('#type' => 'markup', '#markup' => '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax&amp;wpcf_action=fields_insert' . '&amp;field=' . basename($filename, '.php') . '&amp;page=wpcf-edit') . '&amp;_wpnonce=' . wp_create_nonce('fields_insert') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary">' . $data['title'] . '</a> ');
            // Process JS
            if (!empty($data['group_form_js'])) {
                foreach ($data['group_form_js'] as $handle => $script) {
                    if (isset($script['inline'])) {
                        add_action('admin_footer', $script['inline']);
                        continue;
                    }
                    $deps = !empty($script['deps']) ? $script['deps'] : array();
                    $in_footer = !empty($script['in_footer']) ? $script['in_footer'] : false;
                    wp_register_script($handle, $script['src'], $deps, WPCF_VERSION, $in_footer);
                    wp_enqueue_script($handle);
                }
            }
            // Process CSS
            if (!empty($data['group_form_css'])) {
                foreach ($data['group_form_css'] as $handle => $script) {
                    if (isset($script['src'])) {
                        $deps = !empty($script['deps']) ? $script['deps'] : array();
                        wp_enqueue_style($handle, $script['src'], $deps, WPCF_VERSION);
                    } else {
                        if (isset($script['inline'])) {
                            add_action('admin_head', $script['inline']);
                        }
                    }
                }
            }
        }
        // Get fields created by user
        $fields = wpcf_admin_fields_get_fields(true, true);
        if (!empty($fields)) {
            $form['fields-existing'] = array('#type' => 'fieldset', '#title' => __('User created fields', 'wpcf'), '#id' => 'wpcf-form-groups-user-fields');
            foreach ($fields as $key => $field) {
                if (isset($update['fields']) && array_key_exists($key, $update['fields'])) {
                    continue;
                }
                if (!empty($field['data']['removed_from_history'])) {
                    continue;
                }
                $form['fields-existing'][$key] = array('#type' => 'markup', '#markup' => '<div id="wpcf-user-created-fields-wrapper-' . $field['id'] . '" style="float:left; margin-right: 10px;"><a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=fields_insert_existing' . '&amp;page=wpcf-edit' . '&amp;field=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('fields_insert_existing') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary" onclick="jQuery(this).parent().fadeOut();" ' . ' data-slug="' . $field['id'] . '">' . htmlspecialchars(stripslashes($field['name'])) . '</a>' . '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=remove_from_history' . '&amp;field_id=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('remove_from_history') . '&amp;wpcf_warning=' . sprintf(__('Are you sure that you want to remove field %s from history?', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '&amp;wpcf_ajax_update=wpcf-user-created-fields-wrapper-' . $field['id'] . '" title="' . sprintf(__('Remove field %s', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '" class="wpcf-ajax-link"><img src="' . WPCF_RES_RELPATH . '/images/delete-2.png" style="postion:absolute;margin-top:5px;margin-left:-4px;" /></a></div>');
            }
        }
        $form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
    }
    // Group data
    $form['open-main'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-form-fields-main" class="wpcf-form-fields-main">');
    /**
     * Now starting form
     */
    /** End admin Styles * */
    // Group fields
    $form['fields_title'] = array('#type' => 'markup', '#markup' => '<h2>' . __('Fields', 'wpcf') . '</h2>');
    $show_under_title = true;
    $form['ajax-response-open'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-fields-sortable" class="ui-sortable">');
    // If it's update, display existing fields
    $existing_fields = array();
    if ($update && isset($update['fields'])) {
        foreach ($update['fields'] as $slug => $field) {
            $field['submitted_key'] = $slug;
            $field['group_id'] = $update['id'];
            $form_field = wpcf_fields_get_field_form_data($field['type'], $field);
            if (is_array($form_field)) {
                $form['draggable-open-' . rand()] = array('#type' => 'markup', '#markup' => '<div class="ui-draggable">');
                $form = $form + $form_field;
                $form['draggable-close-' . rand()] = array('#type' => 'markup', '#markup' => '</div>');
            }
            $existing_fields[] = $slug;
            $show_under_title = false;
        }
    }
    // Any new fields submitted but failed? (Don't double it)
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:fields-form.php

示例9: wpcf_admin_load_collapsible

/**
 * Collapsible scripts. 
 */
function wpcf_admin_load_collapsible()
{
    wp_enqueue_script('wpcf-collapsible', WPCF_RES_RELPATH . '/js/collapsible.js', array('jquery'), WPCF_VERSION);
    wp_enqueue_style('wpcf-collapsible', WPCF_RES_RELPATH . '/css/collapsible.css', array(), WPCF_VERSION);
    $option = get_option('wpcf_toggle', array());
    if (!empty($option)) {
        $setting = 'new Array("' . implode('", "', array_keys($option)) . '")';
        wpcf_admin_add_js_settings('wpcf_collapsed', $setting);
    }
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:13,代码来源:admin.php

示例10: wpcf_enqueue_scripts

/**
 * Basic scripts
 */
function wpcf_enqueue_scripts()
{
    if (!wpcf_is_embedded()) {
        /*
         * 
         * Basic JS
         */
        wp_enqueue_script('wpcf-js', WPCF_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'), WPCF_VERSION);
        /*
         * 
         * Basic CSS
         */
        wp_enqueue_style('wpcf-css', WPCF_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
    }
    /*
     * 
     * Basic JS
     */
    wp_enqueue_script('wpcf-js-embedded', WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'), WPCF_VERSION);
    /*
     * 
     * Basic CSS
     */
    wp_enqueue_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
    /*
     * 
     * Other components
     */
    if (!defined('WPTOOLSET_FORMS_ABSPATH')) {
        // Repetitive
        wp_enqueue_script('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/js/repetitive.js', array('wpcf-js-embedded'), WPCF_VERSION);
        wp_enqueue_style('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/css/repetitive.css', array('wpcf-css-embedded'), WPCF_VERSION);
    }
    // Conditional
    wp_enqueue_script('types-conditional');
    wpcf_admin_add_js_settings('wpcfConditionalVerify_nonce', wp_create_nonce('cd_verify'));
    wpcf_admin_add_js_settings('wpcfConditionalVerifyGroup', wp_create_nonce('cd_group_verify'));
    // RTL
    if (is_rtl()) {
        wp_enqueue_style('wpcf-rtl', WPCF_EMBEDDED_RES_RELPATH . '/css/rtl.css', array('wpcf-css-embedded'), WPCF_VERSION);
    }
}
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:45,代码来源:functions.php

示例11: add_js

 /**
  * Enqueues scripts. 
  */
 function add_js()
 {
     wp_enqueue_script('wpcf-conditional', WPCF_EMBEDDED_RES_RELPATH . '/js/conditional.js', array('jquery'), WPCF_VERSION);
     wpcf_admin_add_js_settings('wpcfConditionalVerify_nonce', wp_create_nonce('cd_verify'));
 }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:8,代码来源:conditional.php

示例12: wpcf_admin_fields_form

/**
 * Generates form data.
 */
function wpcf_admin_fields_form()
{
    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') . '\'');
    $default = array();
    global $wpcf_button_style;
    global $wpcf_button_style30;
    global $wpcf;
    // If it's update, get data
    $update = false;
    if (isset($_REQUEST['group_id'])) {
        $update = wpcf_admin_fields_get_group(intval($_REQUEST['group_id']));
        if (empty($update)) {
            $update = false;
            wpcf_admin_message(sprintf(__("Group with ID %d do not exist", 'wpcf'), intval($_REQUEST['group_id'])));
        } else {
            $update['fields'] = wpcf_admin_fields_get_fields_by_group(sanitize_text_field($_REQUEST['group_id']), 'slug', false, true);
            $update['post_types'] = wpcf_admin_get_post_types_by_group(sanitize_text_field($_REQUEST['group_id']));
            $update['taxonomies'] = wpcf_admin_get_taxonomies_by_group(sanitize_text_field($_REQUEST['group_id']));
            $update['templates'] = wpcf_admin_get_templates_by_group(sanitize_text_field($_REQUEST['group_id']));
            $update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group(sanitize_text_field($_REQUEST['group_id']));
        }
    }
    $form = array();
    $form['#form']['callback'] = array('wpcf_admin_save_fields_groups_submit');
    // Form sidebars
    $form['open-sidebar'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-fields-align-right">');
    // Set help icon
    $form['help-icon'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-admin-fields-help"><img src="' . WPCF_EMBEDDED_RELPATH . '/common/res/images/question.png" style="position:relative;top:2px;" />&nbsp;<a href="http://wp-types.com/documentation/user-guides/using-custom-fields/?utm_source=typesplugin&utm_medium=help&utm_term=fields-help&utm_content=fields-editor&utm_campaign=types" target="_blank">' . __('Custom fields help', 'wpcf') . '</a></div>');
    $form['submit2'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'));
    $form['fields'] = array('#type' => 'fieldset', '#title' => __('Available fields', 'wpcf'));
    // Get field types
    $fields_registered = wpcf_admin_fields_get_available_types();
    foreach ($fields_registered as $filename => $data) {
        $form['fields'][basename($filename, '.php')] = array('#type' => 'markup', '#markup' => '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax&amp;wpcf_action=fields_insert' . '&amp;field=' . basename($filename, '.php') . '&amp;page=wpcf-edit') . '&amp;_wpnonce=' . wp_create_nonce('fields_insert') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary">' . $data['title'] . '</a> ');
        // Process JS
        if (!empty($data['group_form_js'])) {
            foreach ($data['group_form_js'] as $handle => $script) {
                if (isset($script['inline'])) {
                    add_action('admin_footer', $script['inline']);
                    continue;
                }
                $deps = !empty($script['deps']) ? $script['deps'] : array();
                $in_footer = !empty($script['in_footer']) ? $script['in_footer'] : false;
                wp_register_script($handle, $script['src'], $deps, WPCF_VERSION, $in_footer);
                wp_enqueue_script($handle);
            }
        }
        // Process CSS
        if (!empty($data['group_form_css'])) {
            foreach ($data['group_form_css'] as $handle => $script) {
                if (isset($script['src'])) {
                    $deps = !empty($script['deps']) ? $script['deps'] : array();
                    wp_enqueue_style($handle, $script['src'], $deps, WPCF_VERSION);
                } else {
                    if (isset($script['inline'])) {
                        add_action('admin_head', $script['inline']);
                    }
                }
            }
        }
    }
    // Get fields created by user
    $fields = wpcf_admin_fields_get_fields(true, true);
    if (!empty($fields)) {
        $form['fields-existing'] = array('#type' => 'fieldset', '#title' => __('User created fields', 'wpcf'), '#id' => 'wpcf-form-groups-user-fields');
        foreach ($fields as $key => $field) {
            if (isset($update['fields']) && array_key_exists($key, $update['fields'])) {
                continue;
            }
            if (!empty($field['data']['removed_from_history'])) {
                continue;
            }
            $form['fields-existing'][$key] = array('#type' => 'markup', '#markup' => '<div id="wpcf-user-created-fields-wrapper-' . $field['id'] . '" style="float:left; margin-right: 10px;"><a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=fields_insert_existing' . '&amp;page=wpcf-edit' . '&amp;field=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('fields_insert_existing') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary" onclick="jQuery(this).parent().fadeOut();" ' . ' data-slug="' . $field['id'] . '">' . htmlspecialchars(stripslashes($field['name'])) . '</a>' . '<a href="' . admin_url('admin-ajax.php' . '?action=wpcf_ajax' . '&amp;wpcf_action=remove_from_history' . '&amp;field_id=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('remove_from_history') . '&amp;wpcf_warning=' . sprintf(__('Are you sure that you want to remove field %s from history?', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '&amp;wpcf_ajax_update=wpcf-user-created-fields-wrapper-' . $field['id'] . '" title="' . sprintf(__('Remove field %s', 'wpcf'), htmlspecialchars(stripslashes($field['name']))) . '" class="wpcf-ajax-link"><img src="' . WPCF_RES_RELPATH . '/images/delete-2.png" style="postion:absolute;margin-top:5px;margin-left:-4px;" /></a></div>');
        }
    }
    $form['close-sidebar'] = array('#type' => 'markup', '#markup' => '</div>');
    // Group data
    $form['open-main'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-form-fields-main">');
    $form['title'] = array('#type' => 'textfield', '#name' => 'wpcf[group][name]', '#id' => 'wpcf-group-name', '#value' => $update ? $update['name'] : '', '#inline' => true, '#attributes' => array('style' => 'width:100%;margin-bottom:10px;', 'placeholder' => __('Enter group title', 'wpcf')), '#validate' => array('required' => array('value' => true)));
    $form['description'] = array('#type' => 'textarea', '#id' => 'wpcf-group-description', '#name' => 'wpcf[group][description]', '#value' => $update ? $update['description'] : '', '#attributes' => array('placeholder' => __('Enter a description for this group', 'wpcf')));
    /**
     *
     * FILTER BOX
     * Since Types 1.2 we moved JS to /embedded/resources/js/custom-fields-form-filter.js
     *
     */
    // Support post types and taxonomies
    $post_types = get_post_types('', 'objects');
    $options = array();
    $post_types_currently_supported = array();
    $form_types = array();
    foreach ($post_types as $post_type_slug => $post_type) {
        if (in_array($post_type_slug, $wpcf->excluded_post_types) || !$post_type->show_ui) {
            continue;
        }
        $options[$post_type_slug]['#name'] = 'wpcf[group][supports][' . $post_type_slug . ']';
//.........这里部分代码省略.........
开发者ID:chrismathers,项目名称:premierplacement,代码行数:101,代码来源:fields-form.php

示例13: add_filter

 * 
 * These hooks check if conditional failed
 * but form allowed to be saved
 * Since Types 1.2
 */
add_filter('wpcf_post_form_error', 'wpcf_conditional_post_form_error_filter', 10, 2);
/*
 * Logger
 */
if (!function_exists('wplogger')) {
    require_once WPCF_EMBEDDED_ABSPATH . '/common/wplogger.php';
}
if (!function_exists('wpv_filter_parse_date')) {
    require_once WPCF_EMBEDDED_ABSPATH . '/common/wpv-filter-date-embedded.php';
}
wpcf_admin_add_js_settings('wpcfConditionalVerifyGroup', wp_create_nonce('cd_group_verify'));
/*
 * since Types 1.2 Filter validation JS
 */
add_filter('wpcf_validation_js_invalid_handler', 'wpcf_conditional_validation_js_invalid_handler_filter', 10, 3);
/**
 * Filters groups on post edit page.
 * 
 * @param type $groups
 * @param type $post
 * @return type 
 */
function wpcf_cd_post_groups_filter($groups, $post, $context)
{
    if ($context != 'group') {
        return $groups;
开发者ID:adisonc,项目名称:MaineLearning,代码行数:31,代码来源:conditional-display.php

示例14: wpcf_enqueue_scripts

/**
 * Basic scripts
 */
function wpcf_enqueue_scripts()
{
    if (!wpcf_is_embedded()) {
        /*
         * 
         * Basic JS
         */
        wp_enqueue_script('wpcf-js', WPCF_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'), WPCF_VERSION);
        /*
         * 
         * Basic CSS
         */
        wp_enqueue_style('wpcf-css', WPCF_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
        /*
         * Settings
         */
        // _nonce for editor callback
        wpcf_admin_add_js_settings('wpcfEditorCallbackNonce', wp_create_nonce('editor_callback'));
        // Thickbox generic title
        wpcf_admin_add_js_settings('wpcfEditorTbTitle', esc_js(__('Insert field', 'wpcf')));
    }
    /*
     * 
     * Basic JS
     */
    wp_enqueue_script('wpcf-js-embedded', WPCF_EMBEDDED_RES_RELPATH . '/js/basic.js', array('jquery', 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-tabs'), WPCF_VERSION);
    /*
     * 
     * Basic CSS
     */
    wp_enqueue_style('wpcf-css-embedded', WPCF_EMBEDDED_RES_RELPATH . '/css/basic.css', array(), WPCF_VERSION);
    /*
     * 
     * Other components
     */
    // Repetitive
    wp_enqueue_script('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/js/repetitive.js', array('wpcf-js-embedded'), WPCF_VERSION);
    wp_enqueue_style('wpcf-repeater', WPCF_EMBEDDED_RES_RELPATH . '/css/repetitive.css', array('wpcf-css-embedded'), WPCF_VERSION);
    // Conditional
    wp_enqueue_script('wpcf-conditional', WPCF_EMBEDDED_RES_RELPATH . '/js/conditional.js', array('wpcf-js-embedded'), WPCF_VERSION);
    wpcf_admin_add_js_settings('wpcfConditionalVerify_nonce', wp_create_nonce('cd_verify'));
    wpcf_admin_add_js_settings('wpcfConditionalVerifyGroup', wp_create_nonce('cd_group_verify'));
    // RTL
    if (is_rtl()) {
        wp_enqueue_style('wpcf-rtl', WPCF_EMBEDDED_RES_RELPATH . '/css/rtl.css', array('wpcf-css-embedded'), WPCF_VERSION);
    }
}
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:50,代码来源:functions.php

示例15: wpcf_admin_post_process_repetitive_field_skype

/**
 * Processes repetitive Skype field.
 * 
 * @staticvar array $repetitive_started
 * @staticvar array $repetitive_index
 * @param type $post
 * @param string $field
 * @param type $skype_element
 * @return string 
 */
function wpcf_admin_post_process_repetitive_field_skype($post, $field, $skype_element)
{
    static $repetitive_started = array();
    static $repetitive_index = array();
    $repetitive_form = '';
    if (defined('DOING_AJAX')) {
        $field['value'] = '__wpcf_repetitive_new_field';
    }
    if (!isset($repetitive_index[$field['id']])) {
        if (defined('DOING_AJAX') && isset($_POST['count'])) {
            $repetitive_index[$field['id']] = $_POST['count'];
        } else {
            $repetitive_index[$field['id']] = 1;
        }
    }
    foreach ($skype_element as $element_key_temp => &$element) {
        $element_key = $element['__element_key'];
        if (!isset($field['value'][$element_key])) {
            $field['value'][$element_key] = '';
        }
        if ($element_key == 'skypename') {
            // Add hidden fields old_value and mark field repetitive
            $repetitive_form .= '<input type="hidden" name="wpcf_repetitive[' . $field['id'] . ']" value="1" />';
            $repetitive_form .= '<input type="hidden" name="wpcf[' . $field['slug'] . '][' . $repetitive_index[$field['id']] . '][old_value]" value="' . base64_encode(serialize($field['value'])) . '" />';
        }
        if ($element_key != 'markup') {
            // Alter element name
            $element['#name'] = 'wpcf[' . $field['slug'] . '][' . $repetitive_index[$field['id']] . '][' . $element_key . ']';
        }
        if ($element_key == 'skypename' && !isset($repetitive_started[$field['id']]) && !defined('DOING_AJAX')) {
            // Add 'Add' button
            $repetitive_form .= '<div class="wpcf-repetitive-buttons" style="margin-top:10px;">';
            $repetitive_form .= '<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=repetitive_add&amp;_wpnonce=' . wp_create_nonce('repetitive_add')) . '&amp;field_id=' . $field['id'] . '&amp;field_id_md5=' . md5($field['id']) . '" class="wpcf-repetitive-add button-primary">Add Another Field</a>';
            $repetitive_form .= '</div>';
        } else {
            if ($element_key == 'skypename') {
                $repetitive_form .= '<div class="wpcf-repetitive-buttons" style="margin-top:10px;">';
                // Add 'Delete' button
                if ($post || !defined('DOING_AJAX')) {
                    $repetitive_form .= '&nbsp;<a href="' . admin_url('admin-ajax.php?action=wpcf_ajax&amp;wpcf_action=repetitive_delete&amp;_wpnonce=' . wp_create_nonce('repetitive_delete') . '&amp;post_id=' . $post->ID . '&amp;field_id=' . $field['id'] . '&amp;field_id_md5=' . md5($field['id']) . '&amp;old_value=' . base64_encode(serialize($field['value']))) . '&amp;wpcf_warning=' . __('Are you sure?', 'wpcf') . '" class="wpcf-repetitive-delete button-secondary">Delete Field</a>';
                } else {
                    $repetitive_form .= '&nbsp;<a href="javascript:void(0);" onclick="jQuery(this).parent().parent().fadeOut(function(){jQuery(this).remove();});" class="wpcf-repetitive-delete button-secondary">Delete Field</a>';
                }
                $repetitive_form .= '</div>';
            }
        }
        // Prepend to form element
        if ($element_key == 'skypename' && isset($element['#before'])) {
            $element['#before'] .= $repetitive_form;
        } else {
            if ($element_key == 'skypename') {
                $element['#before'] = $repetitive_form;
            }
        }
        // Append AJAX response area to element
        if ($element_key == 'markup' && !isset($repetitive_started[$field['id']]) && !defined('DOING_AJAX')) {
            $element['#markup'] .= '<div class="wpcf-repetitive-response"></div>';
        }
        if ($element_key == 'skypename') {
            $main_element = $element;
        }
    }
    // Mark that first repetitive field is processed
    $repetitive_started[$field['id']] = true;
    $repetitive_index[$field['id']] += 1;
    // Set JS var for counting repetitive fields
    wpcf_admin_add_js_settings('wpcf_repetitive_count_' . md5($field['id']), $repetitive_index[$field['id']]);
    return array($main_element, $skype_element);
}
开发者ID:sriram911,项目名称:pls,代码行数:79,代码来源:fields-post.php


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