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


PHP WPCF_Roles类代码示例

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


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

示例1: wpcf_admin_menu_edit_user_fields

/**
 * Add/Edit usermeta fields group
 *
 * @author Gen gen.i@icanlocalize.com
 * @since Types 1.3
 */
function wpcf_admin_menu_edit_user_fields()
{
    $title = __('View User Fields Group', 'wpcf');
    if (isset($_GET['group_id'])) {
        $item = wpcf_admin_get_user_field_group_by_id($_GET['group_id']);
        if (WPCF_Roles::user_can_edit('user-meta-field', $item)) {
            $title = __('Edit User Fields Group', 'wpcf');
        }
    } else {
        if (WPCF_Roles::user_can_create('user-meta-field')) {
            $title = __('Add New User Fields Group', 'wpcf');
        }
    }
    wpcf_add_admin_header($title);
    $form = wpcf_form('wpcf_form_fields');
    echo '<br /><form method="post" action="" class="wpcf-fields-form ' . 'wpcf-form-validate" onsubmit="';
    echo 'if (jQuery(\'#wpcf-group-name\').val() == \'' . __('Enter group title', 'wpcf') . '\') { jQuery(\'#wpcf-group-name\').val(\'\'); }';
    echo 'if (jQuery(\'#wpcf-group-description\').val() == \'' . __('Enter a description for this group', 'wpcf') . '\') { jQuery(\'#wpcf-group-description\').val(\'\'); }';
    echo 'jQuery(\'.wpcf-forms-set-legend\').each(function(){
        if (jQuery(this).val() == \'' . __('Enter field name', 'wpcf') . '\') {
            jQuery(this).val(\'\');
        }
        if (jQuery(this).next().val() == \'' . __('Enter field slug', 'wpcf') . '\') {
            jQuery(this).next().val(\'\');
        }
        if (jQuery(this).next().next().val() == \'' . __('Describe this field', 'wpcf') . '\') {
            jQuery(this).next().next().val(\'\');
        }
	});';
    echo '">';
    echo $form->renderForm();
    echo '</form>';
    wpcf_add_admin_footer();
}
开发者ID:olechka1505,项目名称:hungrylemur,代码行数:40,代码来源:usermeta-init.php

示例2: getInstance

 public static function getInstance()
 {
     if (!self::$instance) {
         self::$instance = new WPCF_Roles();
     }
     return self::$instance;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:7,代码来源:class.wpcf.roles.php

示例3: get_columns

 function get_columns()
 {
     $columns = array();
     if (WPCF_Roles::user_can_create('term-field')) {
         $columns['cb'] = '<input type="checkbox" />';
     }
     return array_merge($columns, array('name' => __('Term Field Name', 'wpcf'), 'groups' => __('Field Groups', 'wpcf'), 'slug' => __('Slug', 'wpcf'), 'field_type' => __('Type', 'wpcf')));
 }
开发者ID:lytranuit,项目名称:wordpress,代码行数:8,代码来源:termmeta_table.php

示例4: wpcf_admin_common_metabox_save

function wpcf_admin_common_metabox_save($ct, $button_text, $type = 'custom-post-type')
{
    $form = array();
    if (WPCF_Roles::user_can_edit($type, $ct)) {
        $form['submit-open'] = wpcf_admin_metabox_begin(__('Save', 'wpcf'), 'submitdiv', false, false, '_builtin');
        $form['submit-div-open'] = array('#type' => 'markup', '#markup' => '<div class="submitbox" id="submitpost"><div id="major-publishing-actions"><div id="publishing-action"><span class="spinner"></span>', '_builtin' => true);
        $form['submit'] = array('#type' => 'submit', '#name' => 'submit', '#value' => $button_text, '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'), '_builtin' => true);
        /**
         * add data attribute for _builtin post type
         */
        if (isset($ct['_builtin']) && $ct['_builtin']) {
            $form['submit']['#attributes']['data-post_type_is_builtin'] = '_builtin';
        }
        $form['submit-div-close'] = array('#type' => 'markup', '#markup' => '</div><div class="clear"></div></div></div>', '_builtin' => true);
        $form['submit-close'] = wpcf_admin_metabox_end(true, '_builtin');
    }
    return $form;
}
开发者ID:aarongillett,项目名称:B22-151217,代码行数:18,代码来源:common-functions.php

示例5: wpcf_admin_menu_edit_user_fields

/**
 * Add/Edit usermeta fields group
 *
 * @author Gen gen.i@icanlocalize.com
 * @since Types 1.3
 */
function wpcf_admin_menu_edit_user_fields()
{
    $add_new = false;
    $post_type = current_filter();
    $title = __('View User Field Group', 'wpcf');
    if (isset($_GET['group_id'])) {
        $item = wpcf_admin_get_user_field_group_by_id((int) $_GET['group_id']);
        if (WPCF_Roles::user_can_edit('user-meta-field', $item)) {
            $title = __('Edit User Field Group', 'wpcf');
            $add_new = array('page' => 'wpcf-edit-usermeta');
        }
    } else {
        if (WPCF_Roles::user_can_create('user-meta-field')) {
            $title = __('Add New User Field Group', 'wpcf');
        }
    }
    wpcf_add_admin_header($title, $add_new);
    $form = wpcf_form('wpcf_form_fields');
    echo '<form method="post" action="" class="wpcf-fields-form wpcf-form-validate js-types-show-modal">';
    wpcf_admin_screen($post_type, $form->renderForm());
    echo '</form>';
    wpcf_add_admin_footer();
    return;
    $form = wpcf_form('wpcf_form_fields');
    echo '<br /><form method="post" action="" class="wpcf-fields-form ' . 'wpcf-form-validate" onsubmit="';
    echo 'if (jQuery(\'#wpcf-group-name\').val() == \'' . __('Enter group title', 'wpcf') . '\') { jQuery(\'#wpcf-group-name\').val(\'\'); }';
    echo 'if (jQuery(\'#wpcf-group-description\').val() == \'' . __('Enter a description for this group', 'wpcf') . '\') { jQuery(\'#wpcf-group-description\').val(\'\'); }';
    echo 'jQuery(\'.wpcf-forms-set-legend\').each(function(){
        if (jQuery(this).val() == \'' . __('Enter field name', 'wpcf') . '\') {
            jQuery(this).val(\'\');
        }
        if (jQuery(this).next().val() == \'' . __('Enter field slug', 'wpcf') . '\') {
            jQuery(this).next().val(\'\');
        }
        if (jQuery(this).next().next().val() == \'' . __('Describe this field', 'wpcf') . '\') {
            jQuery(this).next().next().val(\'\');
        }
	});';
    echo '">';
    echo $form->renderForm();
    echo '</form>';
    wpcf_add_admin_footer();
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:49,代码来源:usermeta-init.php

示例6: wpcf_admin_usermeta_form

/**
 * Generates form data.
 */
function wpcf_admin_usermeta_form()
{
    /**
     * include common functions
     */
    include_once dirname(__FILE__) . '/common-functions.php';
    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();
    $current_user_can_edit = WPCF_Roles::user_can_create('user-meta-field');
    // If it's update, get data
    $update = false;
    if (isset($_REQUEST['group_id'])) {
        $update = wpcf_admin_fields_get_group(intval($_REQUEST['group_id']), TYPES_USER_META_FIELD_GROUP_CPT_NAME);
        $current_user_can_edit = WPCF_Roles::user_can_edit('user-meta-field', $update);
        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, false, TYPES_USER_META_FIELD_GROUP_CPT_NAME, 'wpcf-usermeta');
            $update['show_for'] = wpcf_admin_get_groups_showfor_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_usermeta_groups_submit');
    $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="poststuff" class="%s">', $current_user_can_edit ? '' : 'wpcf-types-read-only'));
    // Form sidebars
    if ($current_user_can_edit) {
        $form['open-sidebar'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-form-fields-align-right">');
        // Set help icon
        $form['help-icon'] = array('#type' => 'markup', '#markup' => '<div class="wpcf-admin-fields-help"><img src="' . WPCF_EMBEDDED_TOOLSET_RELPATH . '/toolset-common/res/images/question.png" style="position:relative;top:2px;" />&nbsp;<a href="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" class="wpcf-form-fields-main">');
    $form['title'] = array('#type' => 'textfield', '#name' => 'wpcf[group][name]', '#id' => 'wpcf-group-name', '#value' => $update ? wp_kses_post($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 ? wp_kses_post($update['description']) : '', '#attributes' => array('placeholder' => __('Enter a description for this group', 'wpcf')));
    // 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);
        $options[$role]['#default_value'] = $update && !empty($update['show_for']) && in_array($role, $update['show_for']) ? 1 : 0;
        $options[$role]['#value'] = $role;
        $options[$role]['#inline'] = TRUE;
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:usermeta-form.php

示例7: 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;
     $id = false;
     $update = false;
     $taxonomies = array();
     if (isset($_GET[$this->get_id])) {
         $id = sanitize_text_field($_GET[$this->get_id]);
     } elseif (isset($_POST[$this->get_id])) {
         $id = sanitize_text_field($_POST[$this->get_id]);
     }
     if ($id) {
         $taxonomies = $this->taxonomies->get();
         if (isset($taxonomies[$id])) {
             $this->ct = $taxonomies[$id];
             $update = true;
         } else {
             wpcf_admin_message(__('Wrong Taxonomy specified.', 'wpcf'), 'error');
             return false;
         }
     } else {
         $this->ct = wpcf_custom_taxonomies_default();
     }
     $current_user_can_edit = WPCF_Roles::user_can_edit('custom-taxonomy', $this->ct);
     /**
      * sanitize _builtin
      */
     if (!isset($this->ct['_builtin'])) {
         $this->ct['_builtin'] = false;
     }
     $form = $this->prepare_screen();
     if ($current_user_can_edit && $update) {
         $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-tax]');
     }
     /**
      * post icon field
      */
     $menu_icon = isset($this->ct['icon']) && !empty($this->ct['icon']) ? $this->ct['icon'] : 'admin-post';
     $form['icon'] = array('#type' => 'hidden', '#name' => 'ct[icon]', '#value' => $menu_icon, '#id' => 'wpcf-types-icon');
     $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="post-body-content" class="%s">', $current_user_can_edit ? '' : 'wpcf-types-read-only'), '_builtin' => true);
     $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">' . __('Taxonomy name and description', 'wpcf') . '</th></tr></thead><tbody>');
     $table_row = '<tr><td><LABEL></td><td><ERROR><BEFORE><ELEMENT><AFTER></td></tr>';
     $form['name'] = array('#type' => 'textfield', '#name' => 'ct[labels][name]', '#title' => __('Taxonomy name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($this->ct['labels']['name']) ? wp_kses_post($this->ct['labels']['name']) : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true, '#attributes' => array('placeholder' => __('Enter Taxonomy name plural', 'wpcf'), 'class' => 'widefat'));
     $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Taxonomy name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($this->ct['labels']['singular_name']) ? wp_kses_post($this->ct['labels']['singular_name']) : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true, '#attributes' => array('placeholder' => __('Enter Taxonomy name singular', 'wpcf'), 'class' => 'widefat js-wpcf-slugize-source'));
     /*
      *
      * IF isset $_POST['slug'] it means form is not submitted
      */
     $attributes = array();
     if (!empty($_POST['ct']['slug'])) {
         $reserved = wpcf_is_reserved_name(sanitize_text_field($_POST['ct']['slug']), 'taxonomy');
         if (is_wp_error($reserved)) {
             $attributes = array('class' => 'wpcf-form-error', 'onclick' => 'jQuery(this).removeClass(\'wpcf-form-error\');');
         }
     }
     $form['slug'] = array('#type' => 'textfield', '#name' => 'ct[slug]', '#title' => __('Slug', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . __('Machine readable name.', 'wpcf') . '<br />' . __('If not provided - will be created from singular name.', 'wpcf') . '<br />', '#value' => isset($this->ct['slug']) ? $this->ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => true), 'nospecialchars' => array('value' => true), 'maxlength' => array('value' => 30)), '#attributes' => $attributes + array('maxlength' => '30', 'placeholder' => __('Enter Taxonomy slug', 'wpcf'), 'class' => 'widefat js-wpcf-slugize'));
     $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($this->ct['description']) ? $this->ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60, 'placeholder' => __('Enter Taxonomy description', 'wpcf'), 'class' => 'hidden js-wpcf-description'), '#pattern' => $table_row, '#inline' => true, '#after' => $this->ct['_builtin'] ? __('This is built-in WordPress Taxonomy.', 'wpcf') : sprintf('<a class="js-wpcf-toggle-description hidden" href="#">%s</a>', __('Add description', 'wpcf')));
     $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
     $form['box-1-close'] = array('#type' => 'markup', '#markup' => '</div>', '_builtin' => true);
     if ($this->ct['_builtin']) {
         $form['name']['#attributes']['disabled'] = 'disabled';
         $form['name-singular']['#attributes']['disabled'] = 'disabled';
         $form['slug']['#attributes']['disabled'] = 'disabled';
         $form['description']['#attributes']['disabled'] = 'disabled';
     }
     /**
      * return form if current_user_can edit
      */
     if ($current_user_can_edit) {
         return $form;
     }
     return wpcf_admin_common_only_show($form);
 }
开发者ID:phuocdungit,项目名称:fundy,代码行数:91,代码来源:class.types.admin.edit.taxonomy.php

示例8: wpcf_add_admin_header

/**
 * Adds typical header on admin pages.
 *
 * @param string $title
 * @param string $icon_id Custom icon
 * @return string
 */
function wpcf_add_admin_header($title, $add_new = false, $add_new_title = false)
{
    echo '<div class="wrap">';
    echo '<h2>', $title;
    if (!$add_new_title) {
        $add_new_title = __('Add New', 'wpcf');
    }
    if (is_array($add_new) && isset($add_new['page'])) {
        $add_button = false;
        /**
         * check user can?
         */
        switch ($add_new['page']) {
            case 'wpcf-edit-type':
                $add_button = WPCF_Roles::user_can_create('custom-post-type');
                break;
            case 'wpcf-edit-tax':
                $add_button = WPCF_Roles::user_can_create('custom-taxonomy');
                break;
            case 'wpcf-edit':
                $add_button = WPCF_Roles::user_can_create('custom-field');
                break;
            case 'wpcf-edit-usermeta':
                $add_button = WPCF_Roles::user_can_create('user-meta-field');
                break;
            case WPCF_Page_Edit_Termmeta::PAGE_NAME:
                $add_button = WPCF_Roles::user_can_create('term-field');
                break;
        }
        if ($add_button) {
            printf(' <a href="%s" class="add-new-h2">%s</a>', esc_url(add_query_arg($add_new, admin_url('admin.php'))), $add_new_title);
        }
    }
    echo '</h2>';
    $current_page = sanitize_text_field($_GET['page']);
    do_action('wpcf_admin_header');
    do_action('wpcf_admin_header_' . $current_page);
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:45,代码来源:admin.php

示例9: process_bulk_action

 /** ************************************************************************
  * Optional. You can handle your bulk actions anywhere or anyhow you prefer.
  * For this example package, we will handle it in the class to keep things
  * clean and organized.
  *
  * @see $this->prepare_items()
  **************************************************************************/
 function process_bulk_action()
 {
     $action = $this->current_action();
     /**
      * check nounce
      */
     if (!empty($action)) {
         $nonce = '';
         if (isset($_REQUEST['_wpnonce'])) {
             $nonce = $_REQUEST['_wpnonce'];
         }
         if (!wp_verify_nonce($nonce, 'bulk-customtaxonomies')) {
             die('Security check');
         }
     }
     //Detect when a bulk action is being triggered...
     if (!empty($this->custom_taxonomies) && isset($_POST[$this->bulk_action_field_name]) && !empty($_POST[$this->bulk_action_field_name])) {
         $slugs_to_delete = array();
         foreach ($_POST[$this->bulk_action_field_name] as $key) {
             /**
              * do not process if there is no entry
              */
             if (!isset($this->custom_taxonomies[$key])) {
                 continue;
             }
             /**
              * check capability
              */
             if (!WPCF_Roles::user_can_edit('custom-taxonomy', $this->custom_taxonomies[$key])) {
                 continue;
             }
             /**
              * do it!
              */
             switch ($action) {
                 case 'delete':
                     unset($this->custom_taxonomies[$key]);
                     $slugs_to_delete[] = $key;
                     break;
                 case 'deactivate':
                     $this->custom_taxonomies[$key]['disabled'] = 1;
                     break;
                 case 'activate':
                     if (isset($this->custom_taxonomies[$key]['disabled'])) {
                         unset($this->custom_taxonomies[$key]['disabled']);
                     }
                     break;
             }
         }
         /**
          * update custom taxonomies
          */
         update_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, $this->custom_taxonomies);
         /**
          * update custom post types
          */
         if (count($slugs_to_delete)) {
             $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
             if (!empty($custom_types)) {
                 foreach ($slugs_to_delete as $slug) {
                     foreach ($custom_types as $custom_key => $data) {
                         if (!isset($data['taxonomies'])) {
                             continue;
                         }
                         if (isset($data['taxonomies'][$slug])) {
                             unset($custom_types[$custom_key]['taxonomies'][$slug]);
                         }
                     }
                 }
                 update_option(WPCF_OPTION_NAME_CUSTOM_TYPES, $custom_types);
             }
         }
     }
 }
开发者ID:aarongillett,项目名称:B22-151217,代码行数:81,代码来源:class.wpcf.custom.taxonomies.list.table.php

示例10: 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">', $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 Field Group name', '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 Field Group description', '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>');
     $form += $this->fields();
     $form['form-close'] = array('#type' => 'markup', '#markup' => '</div>', '_builtin' => true);
     // setup common setting for forms
     $form = $this->common_form_setup($form);
     if ($this->current_user_can_edit) {
         return $form;
     }
     return wpcf_admin_common_only_show($form);
 }
开发者ID:phuocdungit,项目名称:fundy,代码行数:51,代码来源:termmeta_form.php

示例11: wpcf_ajax

/**
 * All AJAX calls go here.
 *
 * @global object $wpdb
 *
 */
function wpcf_ajax()
{
    /**
     * check nounce
     */
    if (!(isset($_REQUEST['_wpnonce']) && wp_verify_nonce($_REQUEST['_wpnonce'], $_REQUEST['wpcf_action']))) {
        die;
    }
    require_once WPCF_INC_ABSPATH . '/classes/class.wpcf.roles.php';
    /**
     * check permissions
     */
    switch ($_REQUEST['wpcf_action']) {
        case 'deactivate_post_type':
        case 'activate_post_type':
        case 'delete_post_type':
        case 'duplicate_post_type':
            $post_type = wpcf_ajax_helper_get_post_type();
            if (empty($post_type)) {
                wpcf_ajax_helper_print_error_and_die();
            }
            if (!WPCF_Roles::user_can_edit_custom_post_by_slug($post_type)) {
                wpcf_ajax_helper_verification_failed_and_die();
            }
            break;
        case 'taxonomy_duplicate':
        case 'deactivate_taxonomy':
        case 'activate_taxonomy':
        case 'delete_taxonomy':
            $custom_taxonomy = wpcf_ajax_helper_get_taxonomy();
            if (empty($custom_taxonomy)) {
                wpcf_ajax_helper_print_error_and_die();
            }
            if (!WPCF_Roles::user_can_edit_custom_taxonomy_by_slug($custom_taxonomy)) {
                wpcf_ajax_helper_verification_failed_and_die();
            }
            break;
        case 'deactivate_group':
        case 'activate_group':
        case 'delete_group':
            if (!isset($_GET['group_id']) || empty($_GET['group_id'])) {
                wpcf_ajax_helper_print_error_and_die();
            }
            if (!WPCF_Roles::user_can_edit_custom_field_group_by_id($_GET['group_id'])) {
                wpcf_ajax_helper_verification_failed_and_die();
            }
            break;
        case 'deactivate_user_group':
        case 'activate_user_group':
        case 'delete_usermeta_group':
            if (!isset($_GET['group_id']) || empty($_GET['group_id'])) {
                wpcf_ajax_helper_print_error_and_die();
            }
            if (!WPCF_Roles::user_can_edit_usermeta_field_group_by_id($_GET['group_id'])) {
                wpcf_ajax_helper_verification_failed_and_die();
            }
            break;
        case 'deactivate_term_group':
        case 'activate_term_group':
        case 'delete_term_group':
            if (!isset($_GET['group_id']) || empty($_GET['group_id'])) {
                wpcf_ajax_helper_print_error_and_die();
            }
            if (!WPCF_Roles::user_can_edit_term_field_group_by_id($_GET['group_id'])) {
                wpcf_ajax_helper_verification_failed_and_die();
            }
            break;
        case 'usermeta_delete':
        case 'delete_usermeta':
        case 'remove_from_history2':
        case 'usermeta_insert_existing':
        case 'fields_insert':
        case 'fields_insert_existing':
        case 'remove_field_from_group':
        case 'add_radio_option':
        case 'add_select_option':
        case 'add_checkboxes_option':
        case 'group_form_collapsed':
        case 'form_fieldset_toggle':
        case 'fields_delete':
        case 'delete_field':
        case 'remove_from_history':
        case 'add_condition':
        case 'pt_edit_fields':
        case 'toggle':
        case 'cb_save_empty_migrate':
            if (!current_user_can('manage_options')) {
                wpcf_ajax_helper_verification_failed_and_die();
            }
            /**
             * do not check actions from other places
             */
            break;
        default:
//.........这里部分代码省略.........
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:101,代码来源:ajax.php

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

示例13: wpcf_admin_custom_taxonomies_form

/**
 * Add/edit form structure
 */
function wpcf_admin_custom_taxonomies_form()
{
    global $wpcf;
    include_once dirname(__FILE__) . '/common-functions.php';
    $ct = array();
    $id = false;
    $update = false;
    if (isset($_GET['wpcf-tax'])) {
        $id = sanitize_text_field($_GET['wpcf-tax']);
    } else {
        if (isset($_POST['wpcf-tax'])) {
            $id = sanitize_text_field($_POST['wpcf-tax']);
        }
    }
    if ($id) {
        $custom_taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
        if (isset($custom_taxonomies[$id])) {
            $ct = $custom_taxonomies[$id];
            $update = true;
            // Set rewrite if needed
            if (isset($_GET['wpcf-rewrite'])) {
                flush_rewrite_rules();
            }
        } else {
            wpcf_admin_message(__('Wrong custom taxonomy specified', 'wpcf'), 'error');
            return false;
        }
    } else {
        $ct = wpcf_custom_taxonomies_default();
    }
    $current_user_can_edit = WPCF_Roles::user_can_edit('custom-taxonomy', $ct);
    $form = array();
    /**
     * postbox-controll
     */
    $markup = wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false, false);
    $markup .= wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false, false);
    $form['postbox-controll'] = array('#type' => 'markup', '#markup' => $markup);
    /**
     * form setup
     */
    $form['#form']['callback'] = 'wpcf_admin_custom_taxonomies_form_submit';
    $form['#form']['redirection'] = false;
    if ($current_user_can_edit && $update) {
        $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-tax]');
    }
    /**
     * WP control for meta boxes
     */
    include_once ABSPATH . '/wp-admin/includes/meta-boxes.php';
    wp_enqueue_script('post');
    $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="poststuff" class="%s">', $current_user_can_edit ? '' : 'wpcf-types-read-only'));
    $form['form-metabox-holder-columns-2-open'] = array('#type' => 'markup', '#markup' => '<div id="post-body" class="metabox-holder columns-2">');
    $form['post-body-content-open'] = array('#type' => 'markup', '#markup' => '<div id="post-body-content">');
    $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">' . __('Name and description', 'wpcf') . '</th></tr></thead><tbody>');
    $table_row = '<tr><td><LABEL></td><td><ERROR><ELEMENT></td></tr>';
    $form['name'] = array('#type' => 'textfield', '#name' => 'ct[labels][name]', '#title' => __('Custom taxonomy name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($ct['labels']['name']) ? wp_kses_post($ct['labels']['name']) : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true, '#attributes' => array('placeholder' => __('Enter custom taxonomy name plural', 'wpcf')));
    $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Custom taxonomy name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($ct['labels']['singular_name']) ? wp_kses_post($ct['labels']['singular_name']) : '', '#validate' => array('required' => array('value' => true), 'maxlength' => array('value' => 30)), '#pattern' => $table_row, '#inline' => true, '#attributes' => array('placeholder' => __('Enter custom taxonomy name singular', 'wpcf'), 'class' => 'js-wpcf-slugize-source'));
    /*
     *
     * IF isset $_POST['slug'] it means form is not submitted
     */
    $attributes = array();
    if (!empty($_POST['ct']['slug'])) {
        $reserved = wpcf_is_reserved_name(sanitize_text_field($_POST['ct']['slug']), 'taxonomy');
        if (is_wp_error($reserved)) {
            $attributes = array('class' => 'wpcf-form-error', 'onclick' => 'jQuery(this).removeClass(\'wpcf-form-error\');');
        }
    }
    $form['slug'] = array('#type' => 'textfield', '#name' => 'ct[slug]', '#title' => __('Slug', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . __('Machine readable name.', 'wpcf') . '<br />' . __('If not provided - will be created from singular name.', 'wpcf') . '<br />', '#value' => isset($ct['slug']) ? $ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => true), 'nospecialchars' => array('value' => true), 'maxlength' => array('value' => 30)), '#attributes' => $attributes + array('maxlength' => '30', 'placeholder' => __('Enter custom taxonomy slug', 'wpcf'), 'class' => 'js-wpcf-slugize'));
    $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($ct['description']) ? $ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60, 'placeholder' => __('Enter custom taxonomy description', 'wpcf')), '#pattern' => $table_row, '#inline' => true);
    $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['post-body-content-close'] = array('#type' => 'markup', '#markup' => '</div>');
    /**
     * get box order
     */
    $meta_box_order_defaults = apply_filters('wpcf_meta_box_order_defaults', array('side' => array('submitdiv', 'wpcf_visibility', 'post_types'), 'normal' => array('labels', 'options')), 'taxonomy');
    $screen = get_current_screen();
    if (false == ($meta_box_order = get_user_option('meta-box-order_' . $screen->id))) {
        $meta_box_order = $meta_box_order_defaults;
    } else {
        if (isset($meta_box_order[0]) && !isset($meta_box_order['normal'])) {
            $meta_box_order['normal'] = $meta_box_order[0];
        }
    }
    $meta_boxes = array();
    foreach ($meta_box_order_defaults as $key => $value) {
        foreach ($value as $meta_box_key) {
            $meta_boxes[$meta_box_key] = $ct;
        }
    }
    if (!$current_user_can_edit) {
        $meta_boxes['submitdiv'] = false;
    }
    foreach ($meta_box_order as $key => $value) {
        if (is_array($value)) {
            continue;
//.........这里部分代码省略.........
开发者ID:aarongillett,项目名称:B22-151217,代码行数:101,代码来源:custom-taxonomies-form.php

示例14: form

 /**
  * Add/edit form
  */
 public function form()
 {
     $this->save();
     // Flush rewrite rules if we're asked to do so.
     //
     // This must be done after all post types and taxonomies are registered, and they can be registered properly
     // only on 'init'. So after making changes, we need to reload the page and THEN flush.
     if ('1' == wpcf_getget('flush', '0')) {
         flush_rewrite_rules();
     }
     global $wpcf;
     $id = false;
     $update = false;
     if (isset($_GET[$this->get_id])) {
         $id = sanitize_text_field($_GET[$this->get_id]);
     } elseif (isset($_POST[$this->get_id])) {
         $id = sanitize_text_field($_POST[$this->get_id]);
     }
     /**
      * get current post type
      */
     require_once WPCF_INC_ABSPATH . '/classes/class.types.admin.post-type.php';
     $wpcf_post_type = new Types_Admin_Post_Type();
     $custom_post_type = $wpcf_post_type->get_post_type($id);
     if (empty($custom_post_type)) {
         wpcf_admin_message(__('Please save new Post Type first.', 'wpcf'), 'error');
         die;
     }
     $this->ct = $custom_post_type;
     $current_user_can_edit = WPCF_Roles::user_can_edit('custom-post-type', $this->ct);
     /**
      * sanitize _builtin
      */
     if (!isset($this->ct['_builtin'])) {
         $this->ct['_builtin'] = false;
     }
     /**
      * fix taxonomies assigment for builitin post types
      */
     if ($this->ct['_builtin']) {
         $taxonomies = get_taxonomies('', 'objects');
         foreach ($taxonomies as $slug => $tax) {
             foreach ($tax->object_type as $post_slug) {
                 if ($this->ct['slug'] == $post_slug) {
                     $this->ct['taxonomies'][$slug] = 1;
                 }
             }
         }
     }
     $form = $this->prepare_screen();
     if ($current_user_can_edit && $this->ct['update']) {
         $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-post-type]', '_builtin' => true);
         /**
          * update Taxonomy too
          */
         $custom_taxonomies = get_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, array());
         foreach ($custom_taxonomies as $slug => $data) {
             if (!array_key_exists('supports', $data)) {
                 continue;
             }
             if (!array_key_exists($id, $data['supports'])) {
                 continue;
             }
             if (array_key_exists('taxonomies', $this->ct) && array_key_exists($slug, $this->ct['taxonomies'])) {
                 continue;
             }
             unset($custom_taxonomies[$slug]['supports'][$id]);
         }
         update_option(WPCF_OPTION_NAME_CUSTOM_TAXONOMIES, $custom_taxonomies);
     }
     /*
      * menu icon
      */
     switch ($this->ct['slug']) {
         case 'page':
             $menu_icon = 'admin-page';
             break;
         case 'attachment':
             $menu_icon = 'admin-media';
             break;
         default:
             $menu_icon = isset($this->ct['icon']) && !empty($this->ct['icon']) ? $this->ct['icon'] : 'admin-post';
             break;
     }
     /**
      * post icon field
      */
     $form['icon'] = array('#type' => 'hidden', '#name' => 'ct[icon]', '#value' => $menu_icon, '#id' => 'wpcf-types-icon');
     $form['form-open'] = array('#type' => 'markup', '#markup' => sprintf('<div id="post-body-content" class="%s">', $current_user_can_edit ? '' : 'wpcf-types-read-only'), '_builtin' => true);
     $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">' . __('Post Type name and description', 'wpcf') . '</th></tr></thead><tbody>', '_builtin' => true);
     $table_row = '<tr><td><LABEL></td><td><ERROR><BEFORE><ELEMENT><AFTER></td></tr>';
     $form['name'] = array('#type' => 'textfield', '#name' => 'ct[labels][name]', '#title' => __('Post Type name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($this->ct['labels']['name']) ? $this->ct['labels']['name'] : '', '#validate' => array('required' => array('value' => 'true')), '#pattern' => $table_row, '#inline' => true, '#id' => 'name-plural', '#attributes' => array('data-wpcf_warning_same_as_slug' => $wpcf->post_types->message('warning_singular_plural_match'), 'data-wpcf_warning_same_as_slug_ignore' => $wpcf->post_types->message('warning_singular_plural_match_ignore'), 'placeholder' => __('Enter Post Type name plural', 'wpcf'), 'class' => 'large-text'), '_builtin' => true);
     $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Post Type name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($this->ct['labels']['singular_name']) ? $this->ct['labels']['singular_name'] : '', '#validate' => array('required' => array('value' => 'true')), '#pattern' => $table_row, '#inline' => true, '#id' => 'name-singular', '#attributes' => array('placeholder' => __('Enter Post Type name singular', 'wpcf'), 'class' => 'js-wpcf-slugize-source large-text'), '_builtin' => true);
     /**
      * IF isset $_POST['slug'] it means form is not submitted
      */
     $attributes = array();
//.........这里部分代码省略.........
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:101,代码来源:class.types.admin.edit.post.type.php

示例15: _wpcf_filter_wrap

/**
 *
 * Use this to show filter item
 *
 * @since Types 1.2
 * @global type $wpcf_button_style
 * @global type $wpcf_button_style30
 * @param type $id
 * @param type $txt
 * @param type $txt_empty
 * @param type $e
 * @return string
 */
function _wpcf_filter_wrap($id, $title, $txt, $txt_empty, $e, $edit_button = '')
{
    global $wpcf_button_style;
    global $wpcf_button_style30;
    $form = array();
    $unique_id = wpcf_unique_id(serialize(func_get_args()));
    $query = 'jQuery(this), \'' . esc_js($id) . '\', \'' . esc_js($title) . '\', \'' . esc_js($txt) . '\', \'' . esc_js($txt_empty) . '\'';
    $group = array('id' => isset($_REQUEST['group_id']) ? intval($_REQUEST['group_id']) : 0);
    $current_user_can_edit = WPCF_Roles::user_can_edit('custom-field', $group);
    if (empty($edit_button)) {
        $edit = __('View', 'wpcf');
        if ($current_user_can_edit) {
            $edit = __('Edit', 'wpcf');
        }
    } else {
        $edit = $edit_button;
    }
    /*
     *
     * Title and Edit button
     */
    $form['filter_' . $unique_id . '_wrapper'] = array('#type' => 'markup', '#markup' => '<span class="wpcf-filter-ajax-response"' . ' style="font-style:italic;font-weight:bold;display:inline-block;">' . $title . ' ' . $txt . '</span>' . '&nbsp;&nbsp;<a href="javascript:void(0);" ' . $wpcf_button_style30 . ' ' . ' class="button-secondary wpcf-form-filter-edit" onclick="wpcfFilterEditClick(' . $query . ');">' . $edit . '</a><div class="hidden" id="wpcf-form-fields-' . $id . '">');
    /**
     * Form element as param
     * It may be single element or array of elements
     * Simply check if array has #type - indicates it is a form item
     */
    if (isset($e['#type'])) {
        $form['filter_' . $unique_id . '_items'] = $e;
    } else {
        /*
         * If array of elements just join
         */
        $form = $form + (array) $e;
    }
    /**
     * OK button
     */
    if ($current_user_can_edit) {
        $form['filter_' . $unique_id . '_ok'] = array('#type' => 'markup', '#markup' => '<a href="javascript:void(0);" ' . $wpcf_button_style . ' ' . 'class="button-primary  wpcf-form-filter-ok wpcf-groups-form-ajax-update-' . $id . '-ok"' . ' onclick="wpcfFilterOkClick(' . $query . ');">' . __('OK', 'wpcf') . '</a>&nbsp;');
    }
    /**
     * Cancel button
     */
    $button_cancel_text = __('Close', 'wpcf');
    if ($current_user_can_edit) {
        $button_cancel_text = __('Cancel', 'wpcf');
    }
    $form['filter_' . $unique_id . '_cancel'] = array('#type' => 'markup', '#markup' => sprintf('<a href="javascript:void(0);" %s class="button-secondary wpcf-form-filter-cancel wpcf-groups-form-ajax-update-%s-cancel" onclick="wpcfFilterCancelClick(%s);">%s</a>', $wpcf_button_style, $id, $query, $button_cancel_text));
    /**
     * Close wrapper
     */
    $form['filter_' . $unique_id . 'wrapper_close'] = array('#type' => 'markup', '#markup' => '</div>');
    return $form;
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:68,代码来源:fields-form.php


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