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

PHP wpcf_admin_fields_get_group函数代码示例

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

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



在下文中一共展示了wpcf_admin_fields_get_group函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: wpcf_module_inline_table_fields

/**
 * Fields table.
 */
function wpcf_module_inline_table_fields()
{
    // dont add module manager meta box on new post type form
    if (!defined('MODMAN_PLUGIN_NAME')) {
        _e('There is a problem with Module Manager', 'wpcf');
        return;
    }
    if (!isset($_GET['group_id'])) {
        _e('There is a problem with Module Manager', 'wpcf');
        return;
    }
    $group = wpcf_admin_fields_get_group($_GET['group_id']);
    if (empty($group)) {
        _e('Wrong group id.', 'wpcf');
        return;
    }
    do_action('wpmodules_inline_element_gui', array('id' => '12' . _GROUPS_MODULE_MANAGER_KEY_ . '21' . $group['id'], 'title' => $group['name'], 'section' => _GROUPS_MODULE_MANAGER_KEY_));
}
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:21,代码来源:module-manager.php


示例2: item_exists

 function item_exists($type, $item_id)
 {
     switch ($type) {
         case 'group':
             $check = wpcf_admin_fields_get_group($item_id);
             break;
         case 'field':
             $check = wpcf_admin_fields_get_field($item_id);
             break;
         case 'custom_post_type':
             $check = wpcf_get_custom_post_type_settings($item_id);
             break;
         case 'custom_taxonomy':
             $check = wpcf_get_custom_taxonomy_settings($item_id);
             break;
         default:
             return false;
             break;
     }
     return empty($check);
 }
开发者ID:adisonc,项目名称:MaineLearning,代码行数:21,代码来源:class.wpcf-import-export.php


示例3: group_condition_get

 /**
  * 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 boolean $return_form Description.
  * @return type Description.
  */
 public function group_condition_get($return_form = false)
 {
     if (!isset($_REQUEST['group_id']) && isset($_REQUEST['id'])) {
         $_REQUEST['group_id'] = $_REQUEST['id'];
     }
     /**
      * check nonce
      */
     if (!(isset($_REQUEST['id']) && $return_form === true) && !(isset($_REQUEST['group_id']) && isset($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], 'wpcf-conditional-get-' . $_REQUEST['group_id']))) {
         $this->verification_failed_and_die();
     }
     /**
      * get group definition
      */
     $group = wpcf_admin_fields_get_group($_REQUEST['group_id']);
     if (empty($group)) {
         __('Wrong group.', 'wpcf');
         die;
     }
     $group['meta_type'] = 'custom-fields-group';
     $group['data'] = array('conditional_display' => get_post_meta($group['id'], '_wpcf_conditional_display', true));
     /**
      * define conditional
      */
     require_once WPCF_INC_ABSPATH . '/classes/class.types.fields.conditional.php';
     new Types_Fields_Conditional();
     /**
      * get form data
      */
     /**
      * Summary.
      *
      * Description.
      *
      * @since x.x.x
      *
      * @param type  $var Description.
      * @param array $args {
      *     Short description about this hash.
      *
      *     @type type $var Description.
      *     @type type $var Description.
      * }
      * @param type  $var Description.
      */
     $form = $this->get_field_conditionals(array(), $group);
     if (empty($form)) {
         __('Wrong group.', 'wpcf');
         die;
     }
     /**
      * return form
      */
     if ($return_form) {
         return $form;
     }
     /**
      * produce form
      */
     echo wpcf_form_simple($form);
     die;
 }
开发者ID:lytranuit,项目名称:wordpress,代码行数:78,代码来源:class.types.fields.conditional.php


示例4: types_get_fields_by_group

/**
 * Get fields by group.
 * 
 * Returns array of fields and their values:
 * array( 'myfield' => 'some text' )
 * 
 * @global type $wpcf
 * @staticvar array $cache
 * @param type $group_id
 * @param type $active
 * @return array
 */
function types_get_fields_by_group($group, $only_active = 'only_active')
{
    static $cache = array();
    $cache_key = md5(serialize(func_get_args()));
    if (isset($cache[$cache_key])) {
        return $cache[$cache_key];
    }
    $results = array();
    $only_active = $only_active === 'only_active' || $only_active === true ? true : false;
    $group = wpcf_admin_fields_get_group($group);
    if (!empty($group['id'])) {
        if ($only_active && $group['is_active']) {
            $fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug');
            foreach ($fields as $field) {
                $results[$field['id']] = wpcf_api_field_meta_value($field);
            }
        }
    }
    $cache[$cache_key] = $results;
    return $cache[$cache_key];
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:33,代码来源:api.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_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();
    // 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($_REQUEST['group_id']);
            $update['post_types'] = wpcf_admin_get_post_types_by_group($_REQUEST['group_id']);
            $update['taxonomies'] = wpcf_admin_get_taxonomies_by_group($_REQUEST['group_id']);
            $update['templates'] = wpcf_admin_get_templates_by_group($_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">');
    $form['submit2'] = array('#type' => 'submit', '#name' => 'save', '#value' => __('Save', 'wpcf'), '#attributes' => array('class' => 'button-primary'));
    $form['fields'] = array('#type' => 'fieldset', '#title' => __('Available fields', 'wpcf'));
    // Get field types
    $fields_registered = wpcf_admin_fields_get_available_types();
    //    foreach (glob(WPCF_EMBEDDED_INC_ABSPATH . '/fields/*.php') as $filename) {
    foreach ($fields_registered as $filename => $data) {
        //        require_once $filename;
        //        if (function_exists('wpcf_fields_' . basename($filename, '.php'))) {
        //            $data = call_user_func('wpcf_fields_' . basename($filename, '.php'));
        //            if (isset($data['wp_version']) && wpcf_compare_wp_version($data['wp_version'],
        //                            '<')) {
        //                continue;
        //            }
        $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;_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;field=' . $field['id']) . '&amp;_wpnonce=' . wp_create_nonce('fields_insert_existing') . '" ' . 'class="wpcf-fields-add-ajax-link button-secondary" onclick="jQuery(this).parent().fadeOut();">' . 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'] : __('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']['onfocus'] = 'if (jQuery(this).val() == \'' . __('Enter group title', 'wpcf') . '\') { jQuery(this).val(\'\'); }';
        $form['title']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\'' . __('Enter group title', 'wpcf') . '\') }';
    }
    $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']['onfocus'] = 'if (jQuery(this).val() == \'' . __('Enter a description for this group', 'wpcf') . '\') { jQuery(this).val(\'\'); }';
        $form['description']['#attributes']['onblur'] = 'if (jQuery(this).val() == \'\') { jQuery(this).val(\'' . __('Enter a description for this group', 'wpcf') . '\') }';
    }
    // Support post types and taxonomies
    $post_types = get_post_types('', 'objects');
    $options = array();
    $post_types_currently_supported = array();
    $form_types = array();
//.........这里部分代码省略.........
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:101,代码来源:fields-form.php


示例7: wpcf_ajax_embedded


//.........这里部分代码省略.........
                 * Force empty values!
                 */
                $wpcf->repeater->cf['value'] = null;
                $wpcf->repeater->meta = null;
                $form = $wpcf->repeater->get_field_form(null, true);
                echo json_encode(array('output' => wpcf_form_simple($form) . wpcf_form_render_js_validation('#post', false)));
            } else {
                echo json_encode(array('output' => 'params missing'));
            }
            break;
        case 'repetitive_delete':
            if (current_user_can('edit_posts') && isset($_POST['post_id']) && isset($_POST['field_id'])) {
                require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
                $post_id = intval($_POST['post_id']);
                $parent_post = get_post($post_id);
                $field = wpcf_admin_fields_get_field(sanitize_text_field($_POST['field_id']));
                $meta_id = intval($_POST['meta_id']);
                if (!empty($field) && !empty($parent_post->ID) && !empty($meta_id)) {
                    /*
                     * 
                     * 
                     * Changed.
                     * Since Types 1.2
                     */
                    global $wpcf;
                    $wpcf->repeater->set($parent_post, $field);
                    $wpcf->repeater->delete($meta_id);
                    echo json_encode(array('output' => 'deleted'));
                } else {
                    echo json_encode(array('output' => 'field or post not found'));
                }
            } else {
                echo json_encode(array('output' => 'params missing'));
            }
            break;
        case 'cd_verify':
            if (!current_user_can('edit_posts') || empty($_POST['wpcf']) && empty($_POST['wpcf_post_relationship'])) {
                die;
            }
            WPCF_Loader::loadClass('helper.ajax');
            $js_execute = WPCF_Helper_Ajax::conditionalVerify($_POST);
            // Render JSON
            if (!empty($js_execute)) {
                echo json_encode(array('output' => '', 'execute' => $js_execute, 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
            }
            die;
            break;
        case 'cd_group_verify':
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
            $group = wpcf_admin_fields_get_group(sanitize_text_field($_POST['group_id']));
            if (!current_user_can('edit_posts') || empty($group)) {
                echo json_encode(array('output' => ''));
                die;
            }
            $execute = '';
            $group['conditional_display'] = get_post_meta($group['id'], '_wpcf_conditional_display', true);
            // Filter meta values (switch them with $_POST values)
            add_filter('get_post_metadata', 'wpcf_cd_meta_ajax_validation_filter', 10, 4);
            $parent_post = false;
            if (isset($_SERVER['HTTP_REFERER'])) {
                $split = explode('?', $_SERVER['HTTP_REFERER']);
                if (isset($split[1])) {
                    parse_str($split[1], $vars);
                    if (isset($vars['post'])) {
                        $parent_post = get_post($vars['post']);
                    }
                }
            }
            // Dummy post
            if (!$parent_post) {
                $parent_post = new stdClass();
                $parent_post->ID = 1;
            }
            if (!empty($group['conditional_display']['conditions'])) {
                $result = wpcf_cd_post_groups_filter(array(0 => $group), $parent_post, 'group');
                if (!empty($result)) {
                    $result = array_shift($result);
                    $passed = $result['_conditional_display'] == 'passed' ? true : false;
                } else {
                    $passed = false;
                }
                if (!$passed) {
                    $execute = 'jQuery("#wpcf-group-' . $group['slug'] . '").slideUp().find(".wpcf-cd-group")' . '.addClass(\'wpcf-cd-group-failed\')' . '.removeClass(\'wpcf-cd-group-passed\').hide();';
                } else {
                    $execute = 'jQuery("#wpcf-group-' . $group['slug'] . '").show().find(".wpcf-cd-group")' . '.addClass(\'wpcf-cd-group-passed\')' . '.removeClass(\'wpcf-cd-group-failed\').slideDown();';
                }
            }
            // Remove filter meta values (switch them with $_POST values)
            remove_filter('get_post_metadata', 'wpcf_cd_meta_ajax_validation_filter', 10, 4);
            echo json_encode(array('output' => '', 'execute' => $execute, 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
            break;
        default:
            break;
    }
    if (function_exists('wpcf_ajax')) {
        wpcf_ajax();
    }
    die;
}
开发者ID:KryvunRoman,项目名称:yobko,代码行数:101,代码来源:ajax.php


示例8: form

 /**
  * 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 form()
 {
     $this->save();
     global $wpcf;
     $this->current_user_can_edit = WPCF_Roles::user_can_create('user-meta-field');
     // If it's update, get data
     $this->update = false;
     if (isset($_REQUEST[$this->get_id])) {
         $this->update = wpcf_admin_fields_get_group(intval($_REQUEST[$this->get_id]), TYPES_USER_META_FIELD_GROUP_CPT_NAME);
         $this->current_user_can_edit = WPCF_Roles::user_can_edit('user-meta-field', $this->update);
         if (empty($this->update)) {
             $this->update = false;
             wpcf_admin_message(sprintf(__("Group with ID %d do not exist", 'wpcf'), intval($_REQUEST[$this->get_id])));
         } else {
             $this->update['fields'] = wpcf_admin_fields_get_fields_by_group(sanitize_text_field($_REQUEST[$this->get_id]), 'slug', false, true, false, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
             $this->update['show_for'] = wpcf_admin_get_groups_showfor_by_group(sanitize_text_field($_REQUEST[$this->get_id]));
             if (defined('TYPES_USE_STYLING_EDITOR') && TYPES_USE_STYLING_EDITOR) {
                 $this->update['admin_styles'] = wpcf_admin_get_groups_admin_styles_by_group(sanitize_text_field($_REQUEST[$this->get_id]));
             }
         }
     }
     /**
      * sanitize id
      */
     if (!isset($this->update['id'])) {
         $this->update['id'] = 0;
     }
     /**
      * setup meta type
      */
     $this->update['meta_type'] = 'custom_fields_group';
     /**
      * copy update to ct
      */
     $this->ct = $this->update;
     $form = $this->prepare_screen();
     $form['_wpnonce_wpcf'] = array('#type' => 'markup', '#markup' => wp_nonce_field('wpcf_form_fields', '_wpnonce_wpcf', true, false));
     /**
      * nonce depend on group id
      */
     $form['_wpnonce_' . $this->post_type] = array('#type' => 'markup', '#markup' => wp_nonce_field($this->get_nonce_action($this->update['id']), 'wpcf_save_group_nonce', true, false));
     $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="post-body-content" class="%s">', $this->current_user_can_edit ? '' : 'wpcf-types-read-only'));
     $form[$this->get_id] = array('#type' => 'hidden', '#name' => 'wpcf[group][id]', '#value' => $this->update['id']);
     $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat js-wpcf-slugize-container"><thead><tr><th colspan="2">' . __('Field Group name and description', 'wpcf') . '</th></tr></thead><tbody>');
     $table_row = '<tr><td><LABEL></td><td><ERROR><BEFORE><ELEMENT><AFTER></td></tr>';
     $form['title'] = array('#title' => sprintf('%s <b>(%s)</b>', __('Field Group name', 'wpcf'), __('required', 'wpcf')), '#type' => 'textfield', '#name' => 'wpcf[group][name]', '#id' => 'wpcf-group-name', '#value' => $this->update['id'] ? $this->update['name'] : '', '#inline' => true, '#attributes' => array('class' => 'large-text', 'placeholder' => __('Enter group title', 'wpcf')), '#validate' => array('required' => array('value' => true)), '#pattern' => $table_row);
     $form['description'] = array('#title' => __('Description', 'wpcf'), '#type' => 'textarea', '#id' => 'wpcf-group-description', '#name' => 'wpcf[group][description]', '#value' => $this->update['id'] ? $this->update['description'] : '', '#attributes' => array('placeholder' => __('Enter a description for this group', 'wpcf'), 'class' => 'hidden js-wpcf-description'), '#pattern' => $table_row, '#after' => sprintf('<a class="js-wpcf-toggle-description hidden" href="#">%s</a>', __('Add description', 'wpcf')), '#inline' => true);
     $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
     /**
      * fields
      */
     $form += $this->fields();
     $form['form-close'] = array('#type' => 'markup', '#markup' => '</div>', '_builtin' => true);
     /**
      * setup common setting for forms
      */
     $form = $this->common_form_setup($form);
     /**
      * return form if current_user_can edit
      */
     if ($this->current_user_can_edit) {
         return $form;
     }
     return wpcf_admin_common_only_show($form);
 }
开发者ID:phuocdungit,项目名称:fundy,代码行数:82,代码来源:class.types.admin.edit.meta.fields.group.php


示例9: wpcf_ajax_embedded


//.........这里部分代码省略.........
                $post->ID = 1;
            }
            // Filter meta values (switch them with $_POST values)
            add_filter('get_post_metadata', 'wpcf_cd_meta_ajax_validation_filter', 10, 4);
            foreach ($_POST['wpcf'] as $field_id => $field_value) {
                $element = array();
                $field = wpcf_admin_fields_get_field($field_id);
                if (!empty($field['data']['conditional_display']['conditions'])) {
                    $element = wpcf_cd_post_edit_field_filter($element, $field, $post, 'group');
                    if (isset($element['__wpcf_cd_status']) && $element['__wpcf_cd_status'] == 'passed') {
                        $passed_fields[] = 'wpcf[' . $field['id'] . ']';
                    } else {
                        $failed_fields[] = 'wpcf[' . $field['id'] . ']';
                    }
                }
            }
            // Remove filter meta values (switch them with $_POST values)
            remove_filter('get_post_metadata', 'wpcf_cd_meta_ajax_validation_filter', 10, 4);
            if (!empty($passed_fields) || !empty($failed_fields)) {
                $execute = '';
                foreach ($passed_fields as $field_name) {
                    $execute .= 'jQuery(\'[name^="' . $field_name . '"]\').parents(\'.wpcf-cd\').show().removeClass(\'wpcf-cd-failed\').addClass(\'wpcf-cd-passed\');' . " ";
                }
                foreach ($failed_fields as $field_name) {
                    $execute .= 'jQuery(\'[name^="' . $field_name . '"]\').parents(\'.wpcf-cd\').hide().addClass(\'wpcf-cd-failed\').removeClass(\'wpcf-cd-passed\');' . " ";
                }
                echo json_encode(array('output' => '', 'execute' => $execute, 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
            }
            die;
            break;
        case 'cd_group_verify':
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
            $group = wpcf_admin_fields_get_group($_POST['group_id']);
            if (empty($group)) {
                echo json_encode(array('output' => ''));
                die;
            }
            $execute = '';
            $group['conditional_display'] = get_post_meta($group['id'], '_wpcf_conditional_display', true);
            // Filter meta values (switch them with $_POST values)
            add_filter('get_post_metadata', 'wpcf_cd_meta_ajax_validation_filter', 10, 4);
            $post = false;
            if (isset($_SERVER['HTTP_REFERER'])) {
                $split = explode('?', $_SERVER['HTTP_REFERER']);
                if (isset($split[1])) {
                    parse_str($split[1], $vars);
                    if (isset($vars['post'])) {
                        $_POST['post_ID'] = $vars['post'];
                        $post = get_post($vars['post']);
                    }
                }
            }
            // Dummy post
            if (!$post) {
                $post = new stdClass();
                $post->ID = 1;
            }
            if (!empty($group['conditional_display']['conditions'])) {
                $result = wpcf_cd_post_groups_filter(array(0 => $group), $post, 'group');
                if (!empty($result)) {
                    $result = array_shift($result);
                    $passed = $result['_conditional_display'] == 'passed' ? true : false;
                } else {
                    $passed = false;
                }
开发者ID:sriram911,项目名称:pls,代码行数:67,代码来源:ajax.php


示例10: 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


示例11: wpcf_ajax_embedded


//.........这里部分代码省略.........
                    /*
                     * Since Types 1.2
                     * Moved to WPCF_Conditional class.
                     */
                    // Evaluate
                    $passed = $wpcf->conditional->evaluate();
                    if ($passed) {
                        $passed_fields[] = $name;
                    } else {
                        $failed_fields[] = $name;
                    }
                }
            }
            /*
             * 
             * 
             * Render JS
             */
            if (!empty($passed_fields) || !empty($failed_fields)) {
                $execute = '';
                foreach ($passed_fields as $field_name) {
                    $execute .= $wpcf->conditional->render_js_show($field_name);
                }
                foreach ($failed_fields as $field_name) {
                    $execute .= $wpcf->conditional->render_js_hide($field_name);
                }
                echo json_encode(array('output' => '', 'execute' => $execute, 'wpcf_nonce_ajax_callback' => wp_create_nonce('execute')));
            }
            die;
            break;
        case 'cd_group_verify':
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
            require_once WPCF_EMBEDDED_INC_ABSPATH . '/conditional-display.php';
            $group = wpcf_admin_fields_get_group($_POST['group_id']);
            if (empty($group)) {
                echo json_encode(array('output' => ''));
                die;
            }
            $execute = '';
            $group['conditional_display'] = get_post_meta($group['id'], '_wpcf_conditional_display', true);
            // Filter meta values (switch them with $_POST values)
            add_filter('get_post_metadata', 'wpcf_cd_meta_ajax_validation_filter', 10, 4);
            $post = false;
            if (isset($_SERVER['HTTP_REFERER'])) {
                $split = explode('?', $_SERVER['HTTP_REFERER']);
                if (isset($split[1])) {
                    parse_str($split[1], $vars);
                    if (isset($vars['post'])) {
                        $_POST['post_ID'] = $vars['post'];
                        $post = get_post($vars['post']);
                    }
                }
            }
            // Dummy post
            if (!$post) {
                $post = new stdClass();
                $post->ID = 1;
            }
            if (!empty($group['conditional_display']['conditions'])) {
                $result = wpcf_cd_post_groups_filter(array(0 => $group), $post, 'group');
                if (!empty($result)) {
                    $result = array_shift($result);
                    $passed = $result['_conditional_display'] == 'passed' ? true : false;
                } else {
                    $passed = false;
                }
开发者ID:pwillems,项目名称:mimosa-contents,代码行数:67,代码来源:ajax.php


示例12: form

 /**
  * Initialize and render the form.
  *
  * Determine if existing field group is being edited or if we're creating a new one.
  * If we're reloading the edit page after clicking Save button, save changes to database.
  * Generate an array with form field definitions (setup the form).
  * Fill $this->update with field group data.
  *
  * @return array
  */
 public function form()
 {
     $this->save();
     $this->current_user_can_edit = WPCF_Roles::user_can_create('term-field');
     $field_group_id = (int) wpcf_getarr($_REQUEST, $this->get_id, 0);
     // If it's update, get data
     if (0 != $field_group_id) {
         $this->update = wpcf_admin_fields_get_group($field_group_id, WPCF_Field_Group_Term::POST_TYPE);
         if (null == $this->get_field_group()) {
             $this->update = false;
             wpcf_admin_message(sprintf(__("Group with ID %d do not exist", 'wpcf'), $field_group_id));
         } else {
             $this->current_user_can_edit = WPCF_Roles::user_can_edit('custom-field', $this->update);
             $this->update['fields'] = wpcf_admin_fields_get_fields_by_group($field_group_id, 'slug', false, true, false, WPCF_Field_Group_Term::POST_TYPE, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
         }
     }
     // sanitize id
     $this->update['id'] = $this->get_field_group_id();
     // copy update to ct... dafuq is "ct"?
     $this->ct = $this->update;
     $form = $this->prepare_screen();
     $form['_wpnonce_wpcf'] = array('#type' => 'markup', '#markup' => wp_nonce_field('wpcf_form_fields', '_wpnonce_wpcf', true, false));
     // nonce depend on group id
     $nonce_name = $this->get_nonce_action($this->update['id']);
     $form['_wpnonce_' . $this->post_type] = array('#type' => 'markup', '#markup' => wp_nonce_field($nonce_name, 'wpcf_save_group_nonce', true, false));
     $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="post-body-content" class="%s">', 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wpcf_admin_fields_get_groups函数代码示例发布时间:2022-05-23
下一篇:
PHP wpcf_admin_fields_get_fields_by_group函数代码示例发布时间: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