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


PHP WPCF_Roles::user_can_edit方法代码示例

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


在下文中一共展示了WPCF_Roles::user_can_edit方法的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: 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

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

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

示例5: wpcf_admin_menu_edit_type

/**
 * Menu page display.
 */
function wpcf_admin_menu_edit_type()
{
    $post_type = current_filter();
    $title = __('View Post Type', 'wpcf');
    if (WPCF_Roles::user_can_edit('custom-post-type', array())) {
        if (isset($_GET['wpcf-post-type'])) {
            $title = __('Edit Post Type', 'wpcf');
            /**
             * add new CPT link
             */
            $title .= sprintf('<a href="%s" class="add-new-h2">%s</a>', esc_url(add_query_arg('page', 'wpcf-edit-type', admin_url('admin.php'))), __('Add New', 'wpcf'));
        } else {
            $title = __('Add New Post Type', 'wpcf');
        }
    }
    wpcf_add_admin_header($title);
    wpcf_wpml_warning();
    $form = wpcf_form('wpcf_form_types');
    echo '<form method="post" action="" class="wpcf-types-form wpcf-form-validate js-types-do-not-show-modal">';
    wpcf_admin_screen($post_type, $form->renderForm());
    echo '</form>';
    wpcf_add_admin_footer();
}
开发者ID:torch2424,项目名称:Team-No-Comply-Games-Wordpress,代码行数:26,代码来源:admin.php

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

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

示例8: form

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

示例9: wpcf_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

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

示例11: submitdiv

 /**
  * 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.
  */
 protected function submitdiv($button_text, $form = array(), $type = 'custom-post-type', $built_in = false)
 {
     if (WPCF_Roles::user_can_edit($type, $this->ct)) {
         $form['submit-div-open'] = array('#type' => 'markup', '#markup' => '<div class="submitbox" id="submitpost"><div id="major-publishing-actions">', '_builtin' => true);
         if ((isset($_GET['group_id']) || isset($_GET['wpcf-tax'])) && isset($_GET['page']) && !$built_in) {
             switch ($_GET['page']) {
                 case 'wpcf-edit':
                     // post fields
                     $action = 'delete_group';
                     break;
                 case 'wpcf-edit-usermeta':
                     // user fields
                     $action = 'delete_usermeta_group';
                     break;
                 case 'wpcf-termmeta-edit':
                     // term fields
                     $action = 'delete_term_group';
                     break;
                 case 'wpcf-edit-tax':
                     // taxonomy
                     $action = 'delete_taxonomy';
                     break;
             }
             if (isset($action)) {
                 $args = array('action' => 'wpcf_ajax', 'wpcf_action' => $action, '_wpnonce' => wp_create_nonce($action), 'wpcf_warning' => urlencode(__('Are you sure?', 'wpcf')));
                 if (isset($_GET['group_id'])) {
                     $args['group_id'] = sanitize_text_field($_GET['group_id']);
                     $args['wpcf_ajax_update'] = 'wpcf_list_ajax_response_' . sanitize_text_field($_GET['group_id']);
                     $delete_id_addition = sanitize_text_field($_GET['group_id']);
                 } else {
                     if (isset($_GET['wpcf-tax'])) {
                         $args['wpcf-tax'] = sanitize_text_field($_GET['wpcf-tax']);
                         $args['wpcf_ajax_update'] = 'wpcf_list_ajax_response_' . sanitize_text_field($_GET['wpcf-tax']);
                         $delete_id_addition = sanitize_text_field($_GET['wpcf-tax']);
                     }
                 }
                 $args['wpcf_ref'] = isset($_GET['ref']) ? $_GET['ref'] : 'list';
                 $form['delete'] = array('#type' => 'markup', '#markup' => sprintf('<div id="delete-action"><a href="%s" class="submitdelete wpcf-ajax-link wpcf-group-delete-link" id="wpcf-list-delete-%d"">%s</a></div>', esc_url(add_query_arg($args, admin_url('admin-ajax.php'))), $delete_id_addition, __('Delete', 'wpcf')));
             }
         }
         $form['submit-div-open-publish'] = array('#type' => 'markup', '#markup' => '<div id="publishing-action"><span class="spinner"></span>');
         $form['submit'] = array('#type' => 'submit', '#name' => 'wpcf-submit', '#value' => $button_text, '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'), '_builtin' => true);
         /**
          * add data attribute for _builtin post type
          */
         if (isset($this->ct['_builtin']) && $this->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);
     }
     return $form;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:69,代码来源:class.types.admin.page.php

示例12: submitdiv

 /**
  * 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.
  */
 protected function submitdiv($button_text, $form = array(), $type = 'custom-post-type')
 {
     if (WPCF_Roles::user_can_edit($type, $this->ct)) {
         $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' => 'wpcf-submit', '#value' => $button_text, '#attributes' => array('class' => 'button-primary wpcf-disabled-on-submit'), '_builtin' => true);
         /**
          * add data attribute for _builtin post type
          */
         if (isset($this->ct['_builtin']) && $this->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);
     }
     return $form;
 }
开发者ID:phuocdungit,项目名称:fundy,代码行数:32,代码来源:class.types.admin.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

 /**
  * 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

示例15: process_bulk_action

 function process_bulk_action()
 {
     global $wpdb;
     $action = $this->current_action();
     if (empty($action)) {
         return;
     }
     $nonce = wpcf_getpost('_wpnonce', null);
     if (!wp_verify_nonce($nonce, WPCF_Page_Listing_Termmeta::BULK_ACTION_NONCE)) {
         die('Security check');
     }
     $selected_field_group_ids = wpcf_getpost(self::BULK_ACTION_FIELD_NAME, array());
     if (empty($selected_field_group_ids)) {
         return;
     }
     foreach ($selected_field_group_ids as $field_group_id) {
         if (!WPCF_Roles::user_can_edit('term-field', array('id' => $field_group_id))) {
             continue;
         }
         switch ($action) {
             case 'delete':
                 $wpdb->delete($wpdb->posts, array('ID' => $field_group_id, 'post_type' => WPCF_Field_Group_Term::POST_TYPE), array('%d', '%s'));
                 break;
             case 'deactivate':
                 $wpdb->update($wpdb->posts, array('post_status' => 'draft'), array('ID' => $field_group_id, 'post_type' => WPCF_Field_Group_Term::POST_TYPE), array('%s'), array('%d', '%s'));
                 break;
             case 'activate':
                 $wpdb->update($wpdb->posts, array('post_status' => 'publish'), array('ID' => $field_group_id), array('%s'), array('%d'));
                 break;
         }
     }
     wp_cache_delete(md5('group::_get_group' . WPCF_Field_Group_Term::POST_TYPE), 'types_cache_groups');
 }
开发者ID:lytranuit,项目名称:wordpress,代码行数:33,代码来源:termmeta_table.php


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