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

PHP wpcf_admin_fields_get_fields函数代码示例

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

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



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

示例1: wpcf_admin_menu_summary

/**
 * Menu page display.
 */
function wpcf_admin_menu_summary()
{
    echo wpcf_add_admin_header(__('Custom Fields', 'wpcf'));
    require_once WPCF_INC_ABSPATH . '/fields.php';
    require_once WPCF_INC_ABSPATH . '/fields-list.php';
    wpcf_admin_fields_list();
    $to_display = wpcf_admin_fields_get_fields();
    if (!empty($to_display)) {
        $promotional_text = '<div class="message updated" style="padding: 5px 20px;"><h3>' . __('Want to display custom content easily?', 'wpcf') . '</h3>';
        $promotional_text .= '<p style="font-size: 110%;">' . __('<a href="http://wp-types.com">Views</a> plugin let\'s you create dynamic templates for single pages and complex content lists. It queries content from the database, filters it and displays in any way you choose.', 'wpcf') . '</p>';
        if (defined('WPV_VERSION')) {
            // Views active
            $promotional_text .= '<ul style="list-style-type:disc; list-style-position: inside; font-size: 110%;"><li><a href="' . admin_url('edit.php?post_type=view-template') . '">' . __('Create <strong>View Templates</strong> for single pages', 'wpcf') . '</a></li>';
            $promotional_text .= '<li><a href="' . admin_url('edit.php?post_type=view') . '">' . __('Create <strong>Views</strong> for content lists', 'wpcf') . '</a></li>';
            $promotional_text .= '<li><a href="http://wp-types.com">' . __('Find <strong>documentation</strong> and <strong>help</strong>', 'wpcf') . '</a></li></ul>';
        } else {
            $promotional_text .= '<p style="font-size: 110%;">' . __('Learn more:', 'wpcf') . '</p>';
            $promotional_text .= '<ul style="list-style-type:disc; list-style-position: inside; font-size: 110%;"><li><a href="http://wp-types.com/documentation/user-guides/view-templates/">' . __('Creating dynamic templates', 'wpcf') . '</a></li>';
            $promotional_text .= '<li><a href="http://wp-types.com/documentation/user-guides/views/">' . __('Query content and display it', 'wpcf') . '</a></li>';
            $promotional_text .= '</ul><p style="font-size: 110%;">' . __('Get Views:', 'wpcf') . '</p><ul>';
            $promotional_text .= '<li style="font-size: 110%;"><a href="http://wp-types.com/buy/">' . __('Buy and download Views', 'wpcf') . '</a></li>';
            $promotional_text .= '</ul>';
        }
        $promotional_text .= '</div>';
        echo '<br />' . $promotional_text;
    }
    echo wpcf_add_admin_footer();
}
开发者ID:nuevomediagroup,项目名称:nmg-code,代码行数:31,代码来源:admin.php


示例2: wpv_filters_add_filter_usermeta_field

 static function wpv_filters_add_filter_usermeta_field($filters)
 {
     $basic = array(array(__('First Name', 'wpv-views'), 'first_name', 'Basic', ''), array(__('Last Name', 'wpv-views'), 'last_name', 'Basic', ''), array(__('Nickname', 'wpv-views'), 'nickname', 'Basic', ''), array(__('Description', 'wpv-views'), 'description', 'Basic', ''), array(__('Yahoo IM', 'wpv-views'), 'yim', 'Basic', ''), array(__('Jabber', 'wpv-views'), 'jabber', 'Basic', ''), array(__('AIM', 'wpv-views'), 'aim', 'Basic', ''));
     foreach ($basic as $b_filter) {
         $filters['usermeta-field-basic-' . str_replace(' ', '_', $b_filter[1])] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $b_filter[0]), 'present' => 'usermeta-field-' . $b_filter[1] . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $b_filter[1]), 'group' => __('User data', 'wpv-views'));
     }
     // @todo review this for gods sake!!!!!!!!!!!!!!!!!!!!!!!!
     if (function_exists('wpcf_admin_fields_get_groups')) {
         $groups = wpcf_admin_fields_get_groups('wp-types-user-group');
         $user_id = wpcf_usermeta_get_user();
         $add = array();
         if (!empty($groups)) {
             foreach ($groups as $group_id => $group) {
                 if (empty($group['is_active'])) {
                     continue;
                 }
                 $fields = wpcf_admin_fields_get_fields_by_group($group['id'], 'slug', true, false, true, 'wp-types-user-group', 'wpcf-usermeta');
                 if (!empty($fields)) {
                     foreach ($fields as $field_id => $field) {
                         $add[] = $field['meta_key'];
                         $filters['usermeta-field-' . str_replace(' ', '_', $field['meta_key'])] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $field['name']), 'present' => 'usermeta-field-' . $field['meta_key'] . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $field['meta_key']));
                     }
                 }
             }
         }
         $cf_types = wpcf_admin_fields_get_fields(true, true, false, 'wpcf-usermeta');
         foreach ($cf_types as $cf_id => $cf) {
             if (!in_array($cf['meta_key'], $add)) {
                 $filters['usermeta-field-' . str_replace(' ', '_', $cf['meta_key'])] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $cf['name']), 'present' => 'usermeta-field-' . $cf['meta_key'] . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $cf['meta_key']));
             }
         }
     }
     $meta_keys = get_user_meta_keys();
     foreach ($meta_keys as $key) {
         $key_nicename = '';
         if (stripos($key, 'wpcf-') === 0) {
             if (function_exists('wpcf_admin_fields_get_groups')) {
                 continue;
             }
         } else {
             $key_nicename = $key;
         }
         $filters['usermeta-field-' . str_replace(' ', '_', $key)] = array('name' => sprintf(__('User field - %s', 'wpv-views'), $key_nicename), 'present' => 'usermeta-field-' . $key . '_compare', 'callback' => array('WPV_Usermeta_Field_Filter', 'wpv_add_new_filter_usermeta_field_list_item'), 'args' => array('name' => 'usermeta-field-' . $key));
     }
     return $filters;
 }
开发者ID:supahseppe,项目名称:path-of-gaming,代码行数:46,代码来源:wpv-filter-user-field.php


示例3: wpv_shortcode_wpv_control

/**
 * 
 * Views-Shortcode: wpv-control
 *
 * Description: Add filters for View
 *
 * Parameters:
 * type: type of retrieved field layout (radio, checkbox, select, textfield, checkboxes, datepicker)
 * url_param: the URL parameter passed as an argument
 * values: Optional. a list of supplied values
 * display_values: Optional. A list of values to display for the corresponding values
 * auto_fill: Optional. When set to a "field-slug" the control will be populated with custom field values from the database.
 * auto_fill_default: Optional. Used to set the default, unselected, value of the control. eg Ignore or Don't care
 * auto_fill_sort: Optional. 'asc', 'desc', 'ascnum', 'descnum', 'none'. Defaults to ascending.
 * field: Optional. a Types field to retrieve values from
 * title: Optional. Use for the checkbox title
 * taxonomy: Optional. Use when a taxonomy control should be displayed.
 * default_label: Optional. Use when a taxonomy control should be displayed using select input type.
 * date_format: Optional. Used for a datepicker control
 *
 * Example usage:
 *
 * Link:
 * More details about this shortcode here: <a href="http://wp-types.com/documentation/wpv-control-fields-in-front-end-filters/" title="wpv-control – Displaying fields in front-end filters">http://wp-types.com/documentation/wpv-control-fields-in-front-end-filters/</a>
 *
 * Note:
 *
 */
function wpv_shortcode_wpv_control($atts)
{
    if (!isset($atts['url_param'])) {
        return __('The url_param is missing from the wpv-control shortcode argument.', 'wpv-views');
    }
    if ((!isset($atts['type']) || $atts == '') && !isset($atts['field'])) {
        return __('The "type" or "field" needs to be set in the wpv-control shortcode argument.', 'wpv-views');
    }
    extract(shortcode_atts(array('type' => '', 'values' => array(), 'display_values' => array(), 'field' => '', 'url_param' => '', 'title' => '', 'taxonomy' => '', 'default_label' => '', 'auto_fill' => '', 'auto_fill_default' => '', 'auto_fill_sort' => '', 'date_format' => ''), $atts));
    if ($taxonomy != '') {
        // pass the new shortcode attribute $default_label
        return _wpv_render_taxonomy_control($taxonomy, $type, $url_param, $default_label);
    }
    if ($auto_fill != '') {
        // See if we should handle types checkboxes
        $types_checkboxes_field = false;
        if (_wpv_is_field_of_type($auto_fill, 'checkboxes')) {
            if (!function_exists('wpcf_admin_fields_get_fields')) {
                if (defined('WPCF_EMBEDDED_ABSPATH')) {
                    include WPCF_EMBEDDED_ABSPATH . '/includes/fields.php';
                }
            }
            if (function_exists('wpcf_admin_fields_get_fields')) {
                $fields = wpcf_admin_fields_get_fields();
                $field_name = substr($auto_fill, 5);
                if (isset($fields[$field_name])) {
                    $types_checkboxes_field = true;
                    $db_values = array();
                    $options = $fields[$field_name]['data']['options'];
                    foreach ($options as $option) {
                        $db_values[] = $option['title'];
                    }
                    switch (strtolower($auto_fill_sort)) {
                        case 'desc':
                            sort($db_values);
                            $db_values = array_reverse($db_values);
                            break;
                        case 'descnum':
                            sort($db_values, SORT_NUMERIC);
                            $db_values = array_reverse($db_values);
                            break;
                        case 'none':
                            break;
                        case 'ascnum':
                            sort($db_values, SORT_NUMERIC);
                            break;
                        default:
                            sort($db_values);
                            break;
                    }
                }
            }
        }
        if (!$types_checkboxes_field) {
            if (!function_exists('wpcf_admin_fields_get_fields')) {
                if (defined('WPCF_EMBEDDED_ABSPATH')) {
                    include WPCF_EMBEDDED_ABSPATH . '/includes/fields.php';
                }
            }
            if (function_exists('wpcf_admin_fields_get_fields')) {
                $fields = wpcf_admin_fields_get_fields();
            }
            $field_name = substr($auto_fill, 5);
            if (isset($fields) && isset($fields[$field_name]) && isset($fields[$field_name]['data']['options'])) {
                $display_text = array();
                $options = $fields[$field_name]['data']['options'];
                if (isset($options['default'])) {
                    unset($options['default']);
                }
                // remove the default option from the array
                if (isset($fields[$field_name]['data']['display'])) {
                    $display_option = $fields[$field_name]['data']['display'];
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:wpv-filter-embedded.php


示例4: wpcf_cd_admin_form_single_filter

/**
 * Single condition form elements.
 *
 * @param type $data
 * @param type $condition
 * @param type $key
 * @return string
 */
function wpcf_cd_admin_form_single_filter($data, $condition, $key = null, $group = false, $force_multi = false)
{
    global $wpcf;
    if ($group) {
        $name = 'wpcf[group][conditional_display]';
    } else {
        $name = 'wpcf[fields][' . $data['id'] . '][conditional_display]';
    }
    $group_id = isset($_GET['group_id']) ? intval($_GET['group_id']) : false;
    /*
     *
     *
     * TODO Review this allowing fields from same group as conditional (self loop)
     * I do not remember allowing fields from same group as conditional (self loop)
     * on Group Fields edit screen.
     */
    //    if ( $group_id && !$group ) {// Allow group to use other fields
    //        $fields = wpcf_admin_fields_get_fields_by_group( $group_id );
    //    } else {
    $fields = wpcf_admin_fields_get_fields(true, false, true);
    ksort($fields, SORT_STRING);
    //    }
    if ($group) {
        $_distinct = wpcf_admin_fields_get_fields_by_group($group_id);
        foreach ($_distinct as $_field_id => $_field) {
            if (isset($fields[$_field_id])) {
                unset($fields[$_field_id]);
            }
        }
    }
    $options = array();
    $ignore_field_type_array = array('audio', 'checkboxes', 'embed', 'file', 'image', 'video', 'wysiwyg');
    $flag_repetitive = false;
    foreach ($fields as $field_id => $field) {
        if (!$group && $data['id'] == $field_id) {
            continue;
        }
        // WE DO NOT ALLOW repetitive fields to be compared.
        if (wpcf_admin_is_repetitive($field)) {
            $flag_repetitive = true;
            continue;
        }
        /**
         * Skip some files
         */
        if (in_array($field['type'], $ignore_field_type_array)) {
            continue;
        }
        /**
         * build options
         */
        $options[$field_id] = array('#value' => $field_id, '#title' => stripslashes($field['name']), '#attributes' => array('class' => 'wpcf-conditional-select-' . $field['type']));
    }
    /*
     * Special case
     * https://icanlocalize.basecamphq.com/projects/7393061-wp-views/todo_items/153565054/comments
     *
     * When field is new and only one diff field in list - that
     * means one field is saved but other not yet.
     */
    $is_new = isset($data['id']) && isset($fields[$data['id']]) ? false : true;
    $special_stop = false;
    if ($is_new) {
        if (count($options) == 1) {
            $special_stop = true;
        }
    }
    /*
     *
     * This means all fields are repetitive and no one left to compare with.
     * WE DO NOT ALLOW repetitive fields to be compared.
     */
    if (!$group && empty($options) && $flag_repetitive) {
        return array('cd' => array('#type' => 'markup', '#markup' => '<p class="wpcf-error">' . __('Conditional display is only working based on non-repeating fields. All fields in this group are repeating, so you cannot set their display based on other fields.', 'wpcf') . '</p>' . wpcf_conditional_disable_add_js($data['id'])));
    } else {
        if (!$group && (empty($options) || $special_stop)) {
            return array('cd' => array('#type' => 'markup', '#markup' => '<p>' . __('You will be able to set conditional field display when you save more fields.', 'wpcf') . '</p>'));
        }
    }
    $id = !is_null($key) ? $key : strval('condition_' . wpcf_unique_id(serialize($data) . serialize($condition) . $key . $group));
    $form = array();
    $before = '<div class="wpcf-cd-entry"><br />';
    $form['cd']['field_' . $id] = array('#type' => 'select', '#name' => $name . '[conditions][' . $id . '][field]', '#options' => $options, '#inline' => true, '#before' => $before, '#default_value' => isset($condition['field']) ? $condition['field'] : null, '#attributes' => array('class' => 'wpcf-cd-field'));
    $form['cd']['operation_' . $id] = array('#type' => 'select', '#name' => $name . '[conditions][' . $id . '][operation]', '#options' => array_flip(wpcf_cd_admin_operations()), '#inline' => true, '#default_value' => isset($condition['operation']) ? $condition['operation'] : null, '#attributes' => array('class' => 'wpcf-cd-operation'));
    $form['cd']['value_' . $id] = array('#type' => 'textfield', '#name' => $name . '[conditions][' . $id . '][value]', '#inline' => true, '#value' => isset($condition['value']) ? $condition['value'] : '', '#attributes' => array('class' => 'wpcf-cd-value'));
    /*
     *
     * Adjust for date
     */
    if (!empty($condition['value'])) {
        WPCF_Loader::loadInclude('fields/date/functions.php');
        $timestamp = wpcf_fields_date_convert_datepicker_to_timestamp($condition['value']);
//.........这里部分代码省略.........
开发者ID:CrankMaster336,项目名称:FFW-TR,代码行数:101,代码来源:conditional-display.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_custom_fields_control_bulk_actions

/**
 * Submitted Bulk actions.
 */
function wpcf_admin_custom_fields_control_bulk_actions($action = '')
{
    if (!isset($_POST['_wpnonce']) || !wp_verify_nonce($_POST['_wpnonce'], 'custom_fields_control_bulk')) {
        return;
    }
    switch ($action) {
        case 'wpcf-change-type-bulk':
            if (true && isset($_POST['wpcf-id']) && isset($_POST['fields'])) {
                wpcf_admin_custom_fields_change_type($_POST['fields'], $_POST['wpcf-id'], TYPES_CUSTOM_FIELD_GROUP_CPT_NAME);
            }
            break;
        case 'wpcf-deactivate-bulk':
            $fields = wpcf_admin_fields_get_fields(false, true);
            foreach ($_POST['fields'] as $field_id) {
                $field_id = sanitize_text_field($field_id);
                if (isset($fields[$field_id])) {
                    $fields[$field_id]['data']['disabled'] = 1;
                    wpcf_admin_message_store(sprintf(__('Removed from Types control: %s', 'wpcf'), $fields[$field_id]['name']));
                }
            }
            wpcf_admin_fields_save_fields($fields);
            break;
        case 'wpcf-activate-bulk':
            $fields = wpcf_admin_fields_get_fields(false, true);
            $fields_bulk = wpcf_types_cf_under_control('add', array('fields' => $_POST['fields']));
            foreach ($fields_bulk as $field_id) {
                if (isset($fields[$field_id])) {
                    $fields[$field_id]['data']['disabled'] = 0;
                }
                wpcf_admin_message_store(sprintf(__('Added to Types control: %s', 'wpcf'), $field_id));
            }
            wpcf_admin_fields_save_fields($fields);
            break;
        case 'wpcf-delete-bulk':
            require_once WPCF_INC_ABSPATH . '/fields.php';
            $failed = array();
            $success = array();
            foreach ($_POST['fields'] as $field_id) {
                $field_id = sanitize_text_field($field_id);
                $response = wpcf_admin_fields_delete_field($field_id);
                if (!$response) {
                    $failed[] = str_replace('_' . md5('wpcf_not_controlled'), '', $field_id);
                } else {
                    $success[] = $field_id;
                }
            }
            if (!empty($success)) {
                wpcf_admin_message_store(sprintf(__('Fields %s have been deleted.', 'wpcf'), implode(', ', $success)));
            }
            if (!empty($failed)) {
                wpcf_admin_message_store(sprintf(__('Fields %s are not Types fields. Types wont delete these fields.', 'wpcf'), implode(', ', $failed)), 'error');
            }
            break;
        case 'wpcf-add-to-group-bulk':
        case 'wpcf-remove-from-group-bulk':
            if (true && isset($_POST['wpcf-id']) && isset($_POST['fields'])) {
                $fields = array_values((array) $_POST['fields']);
                if (!empty($fields)) {
                    $groups = explode(',', $_POST['wpcf-id']);
                    foreach ($groups as $group_id) {
                        switch ($action) {
                            case 'wpcf-add-to-group-bulk':
                                wpcf_admin_fields_save_group_fields($group_id, $fields, true);
                                break;
                            case 'wpcf-remove-from-group-bulk':
                                wpcf_admin_fields_remove_field_from_group_bulk($group_id, $fields);
                                break;
                        }
                    }
                }
            }
            break;
    }
    wp_safe_redirect(esc_url_raw(add_query_arg(array('page' => 'wpcf-custom-fields-control'), admin_url('admin.php'))));
    die;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:79,代码来源:fields-control.php


示例7: wpcf_admin_menu_summary

/**
 * Menu page display.
 */
function wpcf_admin_menu_summary()
{
    echo wpcf_add_admin_header(__('Custom Fields', 'wpcf'));
    require_once WPCF_INC_ABSPATH . '/fields.php';
    require_once WPCF_INC_ABSPATH . '/fields-list.php';
    $to_display = wpcf_admin_fields_get_fields();
    if (!empty($to_display)) {
        add_action('wpcf_groups_list_table_after', 'wpcf_admin_promotional_text');
    }
    wpcf_admin_fields_list();
    echo wpcf_add_admin_footer();
}
开发者ID:par-orillonsoft,项目名称:Wishmagnet,代码行数:15,代码来源:admin.php


示例8: wpcf_admin_import_data_from_xmlstring


//.........这里部分代码省略.........
                            if (!$_checksum) {
                                $result['updated'] += 1;
                            } else {
                            }
                        }
                    } else {
                        $errors[] = new WP_Error('group_update_failed', sprintf(__('Group "%s" update failed', 'wpcf'), $group['post_title']));
                    }
                } else {
                    // Insert
                    $group_wp_id = wp_insert_post($post, true);
                    if (is_wp_error($group_wp_id)) {
                        $errors[] = new WP_Error('group_insert_failed', sprintf(__('Group "%s" insert failed', 'wpcf'), $group['post_title']));
                        $result['errors'][] = sprintf(__('Group %s insert failed', 'wpcf'), $group['post_title']);
                        $result['failed'] += 1;
                    } else {
                        $result['new'] += 1;
                    }
                }
                // Update meta
                if (!empty($group['meta'])) {
                    foreach ($group['meta'] as $meta_key => $meta_value) {
                        update_post_meta($group_wp_id, $meta_key, maybe_unserialize($meta_value));
                    }
                }
                $group_check[] = $group_wp_id;
                if (!empty($post_to_update)) {
                    $group_check[] = $post_to_update;
                }
            }
        }
        // Process fields
        if (!empty($data->fields)) {
            $fields_existing = wpcf_admin_fields_get_fields();
            $fields = array();
            $fields_check = array();
            // Set insert data from XML
            foreach ($data->fields->field as $field) {
                $field = wpcf_admin_import_export_simplexml2array($field);
                $fields[$field['id']] = $field;
            }
            // Insert fields
            foreach ($fields as $field_id => $field) {
                // If Types check if exists in $_POST
                // TODO Regular import do not have structure like this
                if ($context == 'types' || $context == 'modman') {
                    if (!isset($_POST['items']['groups']['__fields__' . $field['slug']])) {
                        continue;
                    }
                }
                if (isset($field['add']) && !$field['add'] && !$overwrite_fields) {
                    continue;
                }
                if (empty($field['id']) || empty($field['name']) || empty($field['slug'])) {
                    continue;
                }
                $_new_field = !isset($fields_existing[$field_id]);
                if ($_new_field) {
                    $result['new'] += 1;
                } else {
                    $_checksum = $wpcf->import->checksum('field', $fields_existing[$field_id]['slug'], $field['checksum']);
                    if (!$_checksum) {
                        $result['updated'] += 1;
                    }
                }
                $field_data = array();
开发者ID:MiquelAdell,项目名称:miqueladell,代码行数:67,代码来源:module-manager.php


示例9: wpv_shortcode_wpv_control

/**
 * 
 * Views-Shortcode: wpv-control
 *
 * Description: Add filters for View
 *
 * Parameters:
 * type: type of retrieved field layout (radio, checkbox, select, textfield, checkboxes, datepicker)
 * url_param: the URL parameter passed as an argument
 * values: Optional. a list of supplied values
 * display_values: Optional. A list of values to display for the corresponding values
 * auto_fill: Optional. When set to a "field-slug" the control will be populated with custom field values from the database.
 * auto_fill_default: Optional. Used to set the default, unselected, value of the control. eg Ignore or Don't care
 * auto_fill_sort: Optional. 'asc', 'desc', 'ascnum', 'descnum', 'none'. Defaults to ascending.
 * field: Optional. a Types field to retrieve values from
 * title: Optional. Use for the checkbox title
 * taxonomy: Optional. Use when a taxonomy control should be displayed.
 * default_label: Optional. Use when a taxonomy control should be displayed using select input type.
 * date_format: Optional. Used for a datepicker control
 *
 * Example usage:
 *
 * Link:
 * More details about this shortcode here: <a href="http://wp-types.com/documentation/wpv-control-fields-in-front-end-filters/" title="wpv-control – Displaying fields in front-end filters">http://wp-types.com/documentation/wpv-control-fields-in-front-end-filters/</a>
 *
 * Note:
 *
 */
function wpv_shortcode_wpv_control($atts)
{
    global $WP_Views;
    $aux_array = $WP_Views->view_used_ids;
    $view_name = get_post_field('post_name', end($aux_array));
    if (!isset($atts['url_param'])) {
        return __('The url_param is missing from the wpv-control shortcode argument.', 'wpv-views');
    }
    if ((!isset($atts['type']) || $atts == '') && !isset($atts['field'])) {
        return __('The "type" or "field" needs to be set in the wpv-control shortcode argument.', 'wpv-views');
    }
    extract(shortcode_atts(array('type' => '', 'values' => array(), 'display_values' => array(), 'field' => '', 'url_param' => '', 'title' => '', 'taxonomy' => '', 'taxonomy_orderby' => 'name', 'taxonomy_order' => 'ASC', 'format' => false, 'default_label' => '', 'hide_empty' => 'false', 'auto_fill' => '', 'auto_fill_default' => '', 'auto_fill_sort' => '', 'date_format' => '', 'default_date' => ''), $atts));
    if ($taxonomy != '') {
        // pass the new shortcode attribute $default_label
        $default_label = wpv_translate($url_param . '_default_label', $default_label, false, 'View ' . $view_name);
        return _wpv_render_taxonomy_control($taxonomy, $type, $url_param, $default_label, $taxonomy_orderby, $taxonomy_order, $format, $hide_empty);
    }
    $multi = '';
    $display_values_trans = false;
    if ($type == 'multi-select') {
        $type = 'select';
        $multi = 'multiple';
    }
    if ($auto_fill != '') {
        // See if we should handle types checkboxes
        $types_checkboxes_field = false;
        $auto_fill_default_trans = false;
        $display_values_traans = false;
        if (_wpv_is_field_of_type($auto_fill, 'checkboxes')) {
            if (!function_exists('wpcf_admin_fields_get_fields')) {
                if (defined('WPCF_EMBEDDED_ABSPATH')) {
                    include WPCF_EMBEDDED_ABSPATH . '/includes/fields.php';
                }
            }
            if (function_exists('wpcf_admin_fields_get_fields')) {
                $fields = wpcf_admin_fields_get_fields();
                $field_name = substr($auto_fill, 5);
                if (isset($fields[$field_name])) {
                    $types_checkboxes_field = true;
                    $db_values = array();
                    $options = $fields[$field_name]['data']['options'];
                    foreach ($options as $field_key => $option) {
                        $db_values[] = $option['title'];
                        $display_text[$option['title']] = wpv_translate('field ' . $fields[$field_name]['id'] . ' option ' . $field_key . ' title', $option['title'], false, 'plugin Types');
                    }
                    switch (strtolower($auto_fill_sort)) {
                        case 'desc':
                            sort($db_values);
                            $db_values = array_reverse($db_values);
                            break;
                        case 'descnum':
                            sort($db_values, SORT_NUMERIC);
                            $db_values = array_reverse($db_values);
                            break;
                        case 'none':
                            break;
                        case 'ascnum':
                            sort($db_values, SORT_NUMERIC);
                            break;
                        default:
                            sort($db_values);
                            break;
                    }
                }
            }
        }
        if (!$types_checkboxes_field) {
            if (!function_exists('wpcf_admin_fields_get_fields')) {
                if (defined('WPCF_EMBEDDED_ABSPATH')) {
                    include WPCF_EMBEDDED_ABSPATH . '/includes/fields.php';
                }
            }
//.........这里部分代码省略.........
开发者ID:javierdlahoz,项目名称:paella-development,代码行数:101,代码来源:wpv-filter-embedded.php


示例10: wpcf_get_post_meta_field_names

/**
 * wpcf_get_fields
 *
 * returns the fields handled by types
 *
 */
function wpcf_get_post_meta_field_names()
{
    require_once WPCF_EMBEDDED_INC_ABSPATH . '/fields.php';
    $fields = wpcf_admin_fields_get_fields();
    $field_names = array();
    foreach ($fields as $field) {
        $field_names[] = wpcf_types_get_meta_prefix($field) . $field['slug'];
    }
    return $field_names;
}
开发者ID:lytranuit,项目名称:wordpress,代码行数:16,代码来源:admin.php


示例11: manage_posts_columns_common

 /**
  * Add custom fields column helper.
  *
  * Add custom fields as a sortable columns on custom post admin list
  *
  * @since 1.7
  *
  * @param array $columns Hashtable of columns;
  * @param string $mode Work Mode.
  *
  * @return array Hashtable of columns;
  */
 private function manage_posts_columns_common($columns, $mode = 'normal')
 {
     $screen = get_current_screen();
     if (!isset($screen->post_type)) {
         return $columns;
     }
     $custom_post_types = wpcf_get_active_custom_types();
     if (!isset($custom_post_types[$screen->post_type]) || !$this->check_has_custom_fields($custom_post_types[$screen->post_type]) || !isset($custom_post_types[$screen->post_type]['custom_fields']) || empty($custom_post_types[$screen->post_type]['custom_fields'])) {
         return $columns;
     }
     $fields = wpcf_admin_fields_get_fields();
     foreach (array_keys($custom_post_types[$screen->post_type]['custom_fields']) as $full_id) {
         $data = array();
         $key = null;
         foreach ($fields as $field_key => $field_data) {
             if (!isset($field_data['meta_key'])) {
                 continue;
             }
             if ($full_id != $field_data['meta_key']) {
                 continue;
             }
             $key = $field_key;
             $data = $field_data;
         }
         if (!isset($data['meta_key'])) {
             continue;
         }
         if (isset($custom_post_types[$screen->post_type]['custom_fields'][$data['meta_key']])) {
             switch ($mode) {
                 case 'sortable':
                     switch ($data['type']) {
                         /**
                          * turn of sorting for complex data
                          */
                         case 'skype':
                             $columns[$data['meta_key']] = false;
                             break;
                         default:
                             $columns[$data['meta_key']] = $data['meta_key'];
                             break;
                     }
                     break;
                 case 'normal':
                 default:
                     $columns[$data['meta_key']] = $data['name'];
                     break;
             }
         }
     }
     return $columns;
 }
开发者ID:lytranuit,项目名称:wordpress,代码行数:63,代码来源:class.wpcf-post-types.php


示例12: process_bulk_action

 private function process_bulk_action()
 {
     $action = $this->current_action();
     if (false == $action) {
         return;
     }
     if (!wp_verify_nonce(wpcf_getpost('_wpnonce'), WPCF_Page_Control_Termmeta::BULK_ACTION_NONCE)) {
         wp_die(__('Invalid nonce.', 'wpcf'));
     }
     $selected_field_definitions = wpcf_getpost(self::INPUT_SLUGS, array());
     if (is_string($selected_field_definitions)) {
         $selected_field_definitions = array($selected_field_definitions);
     }
     if (!is_array($selected_field_definitions) || empty($selected_field_definitions)) {
         // Nothing to do here
         return;
     }
     $factory = WPCF_Field_Term_Definition_Factory::get_instance();
     switch ($action) {
         case self::BULK_ACTION_ADD_TO_GROUP:
             $group_ids = $this->read_group_ids();
             foreach ($group_ids as $group_id) {
                 wpcf_admin_fields_save_group_fields($group_id, $selected_field_definitions, true, WPCF_Field_Group_Term::POST_TYPE, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
             }
             break;
         case self::BULK_ACTION_REMOVE_FROM_TO_GROUP:
             $group_ids = $this->read_group_ids();
             foreach ($group_ids as $group_id) {
                 wpcf_admin_fields_remove_field_from_group_bulk($group_id, $selected_field_definitions);
             }
             break;
         case self::BULK_ACTION_CHANGE_TYPE:
             $field_type_slug = wpcf_getpost('wpcf-id');
             if (!empty($field_type_slug)) {
                 wpcf_admin_custom_fields_change_type($selected_field_definitions, $field_type_slug, WPCF_Field_Group_Term::POST_TYPE, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
             }
             break;
         case self::BULK_ACTION_ACTIVATE:
             $fields = wpcf_admin_fields_get_fields(false, true, false, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
             $fields_bulk = wpcf_types_cf_under_control('add', array('fields' => $selected_field_definitions), WPCF_Field_Group_Term::POST_TYPE, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
             foreach ($fields_bulk as $field_id) {
                 if (isset($fields[$field_id])) {
                     $fields[$field_id]['data']['disabled'] = 0;
                 }
                 wpcf_admin_message(sprintf(__('Added to Types control: %s', 'wpcf'), esc_html($field_id)), 'updated', 'echo');
             }
             wpcf_admin_fields_save_fields($fields, false, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
             break;
         case self::BULK_ACTION_DEACTIVATE:
             $fields = wpcf_admin_fields_get_fields(false, true, false, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
             foreach ($selected_field_definitions as $field_id) {
                 $field_id = sanitize_text_field($field_id);
                 if (isset($fields[$field_id])) {
                     $fields[$field_id]['data']['disabled'] = 1;
                     wpcf_admin_message(sprintf(__('Removed from Types control: %s', 'wpcf'), $fields[$field_id]['name']), 'updated', 'echo');
                 }
             }
             wpcf_admin_fields_save_fields($fields, false, WPCF_Field_Term_Definition_Factory::FIELD_DEFINITIONS_OPTION);
             break;
         case self::BULK_ACTION_DELETE:
             $failed = array();
             $success = array();
             foreach ($selected_field_definitions as $field_id) {
                 $field_id = sanitize_text_field($field_id);
                 // Permanently single field definition and field data.
                 $field_definition = $factory->load_field_definition($field_id);
                 if (null == $field_definition) {
                     $response = false;
                 } else {
                     $response = $factory->delete_definition($field_definition);
                 }
                 if (!$response) {
                     $failed[] = str_replace('_' . md5('wpcf_not_controlled'), '', $field_id);
                 } else {
                     $success[] = $field_id;
                 }
             }
             if (!empty($success)) {
                 wpcf_admin_message(sprintf(__('Fields %s have been deleted.', 'wpcf'), esc_html(implode(', ', $success))), 'updated', 'echo');
             }
             if (!empty($failed)) {
                 wpcf_admin_message(sprintf(__('Fields %s are not Types fields. Types wont delete these fields.', 'wpcf'), esc_html(implode(', ', $failed))), 'error', 'echo');
             }
             break;
     }
     // We made changes to field definitions and now the listing table is going to be rendered.
     $factory->clear_definition_storage();
 }
开发者ID:lytranuit,项目名称:wordpress,代码行数:88,代码来源:termmeta_table.php


示例13: wpv_register_typesfields_func

 /**
  * Auto-register the computed values as Types fields.
  * This method automatically creates the Woocommerce Views filter custom fields and group.
  * Hooked to wp_loaded
  * @access public
  * @return void
  */
 public function wpv_register_typesfields_func()
 {
     //Define WC Views canonical custom field array
     $wc_views_custom_fields_array = array('views_woo_price', 'views_woo_on_sale', 'views_woo_in_stock');
     //Preparation to Types control
     $wc_views_fields_array = array();
     $string_wpcf_not_controlled = md5('wpcf_not_controlled');
     foreach ($wc_views_custom_fields_array as $k 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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