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

PHP wpcf_custom_types_default函数代码示例

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

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



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

示例1: get_post_type

 /**
  * 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 get_post_type($post_type_slug)
 {
     if (empty($post_type_slug)) {
         return wpcf_custom_types_default();
     }
     $post_type = array();
     $custom_types = get_option(WPCF_OPTION_NAME_CUSTOM_TYPES, array());
     if (isset($custom_types[$post_type_slug])) {
         $post_type = $custom_types[$post_type_slug];
         $post_type['update'] = true;
     } else {
         $buildin_post_types = wpcf_get_builtin_in_post_types();
         if (isset($buildin_post_types[$post_type_slug])) {
             $post_type = get_object_vars(get_post_type_object($post_type_slug));
             $post_type['labels'] = get_object_vars($post_type['labels']);
             $post_type['slug'] = esc_attr($post_type_slug);
             $post_type['_builtin'] = true;
         } else {
             return false;
         }
     }
     if (!isset($post_type['update'])) {
         $post_type['update'] = false;
     }
     return $post_type;
 }
开发者ID:axeljohansson1988,项目名称:oddcv,代码行数:43,代码来源:class.types.admin.post-type.php


示例2: wpcf_admin_migrate_get_cfui_type_data

/**
 * Gets types data.
 * 
 * @param type $cfui_type
 * @return type 
 */
function wpcf_admin_migrate_get_cfui_type_data($cfui_type)
{
    $cfui_types_migrated = array();
    $supports = array();
    if (!empty($cfui_type[0])) {
        foreach ($cfui_type[0] as $temp_key => $support) {
            $supports[$support] = 1;
        }
    }
    $taxonomies = array();
    if (!empty($cfui_type[1])) {
        foreach ($cfui_type[1] as $key => $tax) {
            $taxonomies[$tax] = 1;
        }
    }
    $wpcf_types_defaults = wpcf_custom_types_default();
    $slug = $id = sanitize_title($cfui_type['name']);
    // Set labels
    $labels = isset($cfui_type[2]) ? $cfui_type[2] : array();
    $labels['name'] = !empty($cfui_type['label']) ? $cfui_type['label'] : $slug;
    $labels['singular_name'] = !empty($cfui_type['singular_label']) ? $cfui_type['singular_label'] : $slug;
    foreach ($wpcf_types_defaults['labels'] as $label_id => $label_text) {
        if (empty($labels[$label_id])) {
            $labels[$label_id] = $label_text;
        }
    }
    foreach ($labels as $label_id => $label_text) {
        if (!isset($wpcf_types_defaults['labels'][$label_id])) {
            unset($labels[$label_id]);
        }
    }
    // Force menu_name label
    if (empty($labels['menu_name'])) {
        $labels['menu_name'] = $labels['name'];
    }
    // Set rewrite
    $rewrite = empty($cfui_type['rewrite']) ? 0 : array();
    if (is_array($rewrite)) {
        $rewrite = array('enabled' => 1, 'custom' => !empty($cfui_type['rewrite_slug']) ? 'custom' : 'normal', 'slug' => !empty($cfui_type['rewrite_slug']) ? $cfui_type['rewrite_slug'] : '', 'with_front' => 1, 'feeds' => 1, 'pages' => 1);
    }
    $cfui_types_migrated[$slug] = array('labels' => $labels, 'supports' => $supports, 'slug' => $slug, 'rewrite' => $rewrite, 'slug' => $slug, 'id' => $id, 'public' => empty($cfui_type['public']) ? 'hidden' : 'public', 'publicly_queryable' => empty($cfui_type['public']) ? false : true, 'query_var_enabled' => (bool) $cfui_type['query_var'], 'query_var' => '', 'show_in_menu' => (bool) $cfui_type['show_in_menu'], 'show_in_menu_page' => $cfui_type['show_in_menu_string'], 'has_archive' => (bool) $cfui_type['has_archive'], 'taxonomies' => $taxonomies, 'can_export' => true, 'show_in_nav_menus' => true);
    unset($cfui_type[0], $cfui_type[1], $cfui_type[2], $cfui_type['public'], $cfui_type['rewrite'], $cfui_type['name'], $cfui_type['label'], $cfui_type['singular_label'], $cfui_type['capability_type'], $cfui_type['rewrite_slug'], $cfui_type['show_in_menu'], $cfui_type['show_in_menu_string'], $cfui_type['publicly_queryable'], $cfui_type['capabilities'], $cfui_type['has_archive'], $cfui_type['show_in_nav_menus']);
    $cfui_types_migrated[$slug] = array_merge($cfui_type, $cfui_types_migrated[$slug]);
    return $cfui_types_migrated[$slug];
}
开发者ID:adisonc,项目名称:MaineLearning,代码行数:51,代码来源:migration.php


示例3: wpcf_admin_custom_types_form

/**
 * Add/edit form
 */
function wpcf_admin_custom_types_form()
{
    global $wpcf;
    $ct = array();
    $id = false;
    $update = false;
    if (isset($_GET['wpcf-post-type'])) {
        $id = $_GET['wpcf-post-type'];
    } else {
        if (isset($_POST['wpcf-post-type'])) {
            $id = $_POST['wpcf-post-type'];
        }
    }
    if ($id) {
        $custom_types = get_option('wpcf-custom-types', array());
        if (isset($custom_types[$id])) {
            $ct = $custom_types[$id];
            $update = true;
            // Set rewrite if needed
            if (isset($_GET['wpcf-rewrite'])) {
                flush_rewrite_rules();
            }
        } else {
            wpcf_admin_message(__('Wrong custom post type specified', 'wpcf'), 'error');
            return false;
        }
    } else {
        $ct = wpcf_custom_types_default();
    }
    $form = array();
    $form['#form']['callback'] = 'wpcf_admin_custom_types_form_submit';
    $form['#form']['redirection'] = false;
    if ($update) {
        $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-post-type]');
    }
    $form['table-1-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-name-table" class="wpcf-types-form-table widefat"><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 post type name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($ct['labels']['name']) ? $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')));
    $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Custom post type name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($ct['labels']['singular_name']) ? $ct['labels']['singular_name'] : '', '#validate' => array('required' => array('value' => 'true')), '#pattern' => $table_row, '#inline' => true, '#id' => 'name-singular');
    /*
     * 
     * IF isset $_POST['slug'] it means form is not submitted
     */
    $attributes = array();
    if (!empty($_POST['ct']['slug'])) {
        $reserved = wpcf_is_reserved_name($_POST['ct']['slug']);
        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>)', '#value' => isset($ct['slug']) ? $ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => 'true'), 'nospecialchars' => array('value' => 'true'), 'maxlength' => array('value' => '20')), '#attributes' => $attributes + array('maxlength' => '20'), '#id' => 'slug');
    $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($ct['description']) ? $ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60), '#pattern' => $table_row, '#inline' => true);
    $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    global $sitepress;
    if ($update && isset($sitepress) && version_compare(ICL_SITEPRESS_VERSION, '2.6.2', '>=') && function_exists('wpml_custom_post_translation_options')) {
        $form['table-1-close']['#markup'] .= wpml_custom_post_translation_options($ct['slug']);
    }
    $form['table-2-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-visibility-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Visibility', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['public'] = array('#type' => 'radios', '#name' => 'ct[public]', '#options' => array(__('Make this type public (will appear in the WordPress Admin menu)', 'wpcf') => 'public', __('Hidden - users cannot directly edit data in this type', 'wpcf') => 'hidden'), '#default_value' => isset($ct['public']) && strval($ct['public']) == 'hidden' ? 'hidden' : 'public', '#inline' => true);
    $hidden = isset($ct['public']) && strval($ct['public']) == 'hidden' ? ' class="hidden"' : '';
    $form['menu_position'] = array('#type' => 'textfield', '#name' => 'ct[menu_position]', '#title' => __('Menu position', 'wpcf'), '#value' => isset($ct['menu_position']) ? $ct['menu_position'] : '', '#validate' => array('number' => array('value' => true)), '#inline' => true, '#pattern' => '<div' . $hidden . ' id="wpcf-types-form-visiblity-toggle"><table><tr><td><LABEL></td><td><ELEMENT><ERROR></td></tr>');
    $form['menu_icon'] = array('#type' => 'textfield', '#name' => 'ct[menu_icon]', '#title' => __('Menu icon', 'wpcf'), '#description' => __('The url to the icon to be used for this menu. Default: null - defaults to the posts icon.', 'wpcf'), '#value' => isset($ct['menu_icon']) ? $ct['menu_icon'] : '', '#inline' => true, '#pattern' => '<tr><td><LABEL></td><td><ELEMENT><ERROR></td></tr></table></div>');
    $form['table-2-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $taxonomies = get_taxonomies('', 'objects');
    $options = array();
    foreach ($taxonomies as $category_slug => $category) {
        if ($category_slug == 'nav_menu' || $category_slug == 'link_category' || $category_slug == 'post_format') {
            continue;
        }
        $options[$category_slug]['#name'] = 'ct[taxonomies][' . $category_slug . ']';
        $options[$category_slug]['#title'] = $category->labels->name;
        $options[$category_slug]['#default_value'] = !empty($ct['taxonomies'][$category_slug]);
        $options[$category_slug]['#inline'] = true;
        $options[$category_slug]['#after'] = '&nbsp;&nbsp;';
    }
    $form['table-3-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-taxonomies-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Select Taxonomies', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['taxonomies'] = array('#type' => 'checkboxes', '#options' => $options, '#description' => __('Registered taxonomies that will be used with this post type.', 'wpcf'), '#name' => 'ct[taxonomies]', '#inline' => true);
    $form['table-3-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $form['table-4-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-labels-table" class="wpcf-types-form-table widefat"><thead><tr><th colspan="3">' . __('Labels', 'wpcf') . '</th></tr></thead><tbody>');
    $labels = array('add_new' => array('title' => __('Add New', 'wpcf'), 'description' => __('The add new text. The default is Add New for both hierarchical and non-hierarchical types.', 'wpcf')), 'add_new_item' => array('title' => __('Add New %s', 'wpcf'), 'description' => __('The add new item text. Default is Add New Post/Add New Page.', 'wpcf')), 'edit_item' => array('title' => __('Edit %s', 'wpcf'), 'description' => __('The edit item text. Default is Edit Post/Edit Page.', 'wpcf')), 'new_item' => array('title' => __('New %s', 'wpcf'), 'description' => __('The view item text. Default is View Post/View Page.', 'wpcf')), 'view_item' => array('title' => __('View %s', 'wpcf'), 'description' => __('The view item text. Default is View Post/View Page.', 'wpcf')), 'search_items' => array('title' => __('Search %s', 'wpcf'), 'description' => __('The search items text. Default is Search Posts/Search Pages.', 'wpcf')), 'not_found' => array('title' => __('No %s found', 'wpcf'), 'description' => __('The not found text. Default is No posts found/No pages found.', 'wpcf')), 'not_found_in_trash' => array('title' => __('No %s found in Trash', 'wpcf'), 'description' => __('The not found in trash text. Default is No posts found in Trash/No pages found in Trash.', 'wpcf')), 'parent_item_colon' => array('title' => __('Parent text', 'wpcf'), 'description' => __("The parent text. This string isn't used on non-hierarchical types. In hierarchical ones the default is Parent Page.", 'wpcf')), 'all_items' => array('title' => __('All items', 'wpcf'), 'description' => __('The all items text used in the menu. Default is the Name label.', 'wpcf')));
    foreach ($labels as $name => $data) {
        $form['labels-' . $name] = array('#type' => 'textfield', '#name' => 'ct[labels][' . $name . ']', '#title' => ucwords(str_replace('_', ' ', $name)), '#description' => $data['description'], '#value' => isset($ct['labels'][$name]) ? $ct['labels'][$name] : '', '#inline' => true, '#pattern' => '<tr><td><LABEL></td><td><ELEMENT></td><td><DESCRIPTION></td>');
    }
    $form['table-4-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    $form['table-5-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-supports-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Display Sections', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['title-editor-warning'] = array('#type' => 'markup', '#markup' => '<div id="wpcf-types-title-editor-warning" class="wpcf-form-error" style="display:none;">' . __('WordPress does not allow disabling both the title and the editor. Please enable at least one of these.', 'wpcf') . '</div>');
    $options = array('title' => array('#name' => 'ct[supports][title]', '#default_value' => !empty($ct['supports']['title']), '#title' => __('Title', 'wpcf'), '#description' => __('Text input field to create a post title.', 'wpcf'), '#inline' => true, '#id' => 'wpcf-supports-title', '#attributes' => array('onclick' => 'wpcfTitleEditorCheck();')), 'editor' => array('#name' => 'ct[supports][editor]', '#default_value' => !empty($ct['supports']['editor']), '#title' => __('Editor', 'wpcf'), '#description' => __('Content input box for writing.', 'wpcf'), '#inline' => true, '#id' => 'wpcf-supports-editor', '#attributes' => array('onclick' => 'wpcfTitleEditorCheck();')), 'comments' => array('#name' => 'ct[supports][comments]', '#default_value' => !empty($ct['supports']['comments']), '#title' => __('Comments', 'wpcf'), '#description' => __('Ability to turn comments on/off.', 'wpcf'), '#inline' => true), 'trackbacks' => array('#name' => 'ct[supports][trackbacks]', '#default_value' => !empty($ct['supports']['trackbacks']), '#title' => __('Trackbacks', 'wpcf'), '#description' => __('Ability to turn trackbacks and pingbacks on/off.', 'wpcf'), '#inline' => true), 'revisions' => array('#name' => 'ct[supports][revisions]', '#default_value' => !empty($ct['supports']['revisions']), '#title' => __('Revisions', 'wpcf'), '#description' => __('Allows revisions to be made of your post.', 'wpcf'), '#inline' => true), 'author' => array('#name' => 'ct[supports][author]', '#default_value' => !empty($ct['supports']['author']), '#title' => __('Author', 'wpcf'), '#description' => __('Displays a dropdown menu for changing the post author.', 'wpcf'), '#inline' => true), 'excerpt' => array('#name' => 'ct[supports][excerpt]', '#default_value' => !empty($ct['supports']['excerpt']), '#title' => __('Excerpt', 'wpcf'), '#description' => __('A text area for writing a custom excerpt.', 'wpcf'), '#inline' => true), 'thumbnail' => array('#name' => 'ct[supports][thumbnail]', '#default_value' => !empty($ct['supports']['thumbnail']), '#title' => __('Thumbnail', 'wpcf'), '#description' => __('Add a box for uploading a featured image.', 'wpcf'), '#inline' => true), 'custom-fields' => array('#name' => 'ct[supports][custom-fields]', '#default_value' => !empty($ct['supports']['custom-fields']), '#title' => __('custom-fields', 'wpcf'), '#description' => __('Custom fields input area.', 'wpcf'), '#inline' => true), 'page-attributes' => array('#name' => 'ct[supports][page-attributes]', '#default_value' => !empty($ct['supports']['page-attributes']), '#title' => __('page-attributes', 'wpcf'), '#description' => __('Menu order, hierarchical must be true to show Parent option', 'wpcf'), '#inline' => true), 'post-formats' => array('#name' => 'ct[supports][post-formats]', '#default_value' => !empty($ct['supports']['post-formats']), '#title' => __('post-formats', 'wpcf'), '#description' => sprintf(__('Add post formats, see %sPost Formats%s', 'wpcf'), '<a href="http://codex.wordpress.org/Post_Formats" title="Post Formats" target="_blank">', '</a>'), '#inline' => true));
    $form['supports'] = array('#type' => 'checkboxes', '#options' => $options, '#name' => 'ct[supports]', '#inline' => true);
    $form['table-5-close'] = array('#type' => 'markup', '#markup' => '</td></tr></tbody></table>');
    $form['table-6-open'] = array('#type' => 'markup', '#markup' => '<table id="wpcf-types-form-supports-table" class="wpcf-types-form-table widefat"><thead><tr><th>' . __('Advanced', 'wpcf') . '</th></tr></thead><tbody><tr><td>');
    $form['rewrite-enabled'] = array('#type' => 'checkbox', '#title' => __('Rewrite', 'wpcf'), '#name' => 'ct[rewrite][enabled]', '#description' => __('Rewrite permalinks with this format. False to prevent rewrite. Default: true and use post type as slug.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['enabled']), '#inline' => true);
    $form['rewrite-custom'] = array('#type' => 'radios', '#name' => 'ct[rewrite][custom]', '#options' => array(__('Use the normal WordPress URL logic', 'wpcf') => 'normal', __('Use a custom URL format', 'wpcf') => 'custom'), '#default_value' => empty($ct['rewrite']['custom']) || $ct['rewrite']['custom'] != 'custom' ? 'normal' : 'custom', '#inline' => true, '#after' => '<br />');
    $hidden = empty($ct['rewrite']['custom']) || $ct['rewrite']['custom'] != 'custom' ? ' class="hidden"' : '';
    $form['rewrite-slug'] = array('#type' => 'textfield', '#name' => 'ct[rewrite][slug]', '#description' => __('Optional.', 'wpcf') . ' ' . __("Prepend posts with this slug - defaults to post type's name.", 'wpcf'), '#value' => isset($ct['rewrite']['slug']) ? $ct['rewrite']['slug'] : '', '#inline' => true, '#before' => '<div id="wpcf-types-form-rewrite-toggle"' . $hidden . '>', '#after' => '</div>', '#validate' => array('rewriteslug' => array('value' => 'true')));
    $form['rewrite-with_front'] = array('#type' => 'checkbox', '#title' => __('Allow permalinks to be prepended with front base', 'wpcf'), '#name' => 'ct[rewrite][with_front]', '#description' => __('Example: if your permalink structure is /blog/, then your links will be: false->/news/, true->/blog/news/.', 'wpcf') . ' ' . __('Defaults to true.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['with_front']), '#inline' => true);
    $form['rewrite-feeds'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][feeds]', '#title' => __('Feeds', 'wpcf'), '#description' => __('Defaults to has_archive value.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['feeds']), '#value' => 1, '#inline' => true);
    $form['rewrite-pages'] = array('#type' => 'checkbox', '#name' => 'ct[rewrite][pages]', '#title' => __('Pages', 'wpcf'), '#description' => __('Defaults to true.', 'wpcf'), '#default_value' => !empty($ct['rewrite']['pages']), '#value' => 1, '#inline' => true);
//.........这里部分代码省略.........
开发者ID:adisonc,项目名称:MaineLearning,代码行数:101,代码来源:custom-types-form.php


示例4: wpcf_admin_custom_types_form

/**
 * Add/edit form
 */
function wpcf_admin_custom_types_form()
{
    global $wpcf;
    include_once dirname(__FILE__) . '/common-functions.php';
    $ct = array();
    $id = false;
    $update = false;
    if (isset($_GET['wpcf-post-type'])) {
        $id = $_GET['wpcf-post-type'];
    } elseif (isset($_POST['wpcf-post-type'])) {
        $id = $_POST['wpcf-post-type'];
    }
    if ($id) {
        $custom_types = get_option('wpcf-custom-types', array());
        if (isset($custom_types[$id])) {
            $ct = $custom_types[$id];
            $update = true;
            // Set rewrite if needed
            if (isset($_GET['wpcf-rewrite'])) {
                flush_rewrite_rules();
            }
        } else {
            wpcf_admin_message(__('Wrong custom post type specified', 'wpcf'), 'error');
            return false;
        }
    } else {
        $ct = wpcf_custom_types_default();
    }
    $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_types_form_submit';
    $form['#form']['redirection'] = false;
    if ($update) {
        $form['id'] = array('#type' => 'hidden', '#value' => $id, '#name' => 'ct[wpcf-post-type]');
        /**
         * update taxonomy too
         */
        $custom_taxonomies = get_option('wpcf-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', $ct) && array_key_exists($slug, $ct['taxonomies'])) {
                continue;
            }
            unset($custom_taxonomies[$slug]['supports'][$id]);
        }
        update_option('wpcf-custom-taxonomies', $custom_taxonomies);
    }
    /**
     * 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' => '<div id="poststuff">');
    $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"><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 post type name plural', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in plural!', 'wpcf') . '.', '#value' => isset($ct['labels']['name']) ? $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')));
    $form['name-singular'] = array('#type' => 'textfield', '#name' => 'ct[labels][singular_name]', '#title' => __('Custom post type name singular', 'wpcf') . ' (<strong>' . __('required', 'wpcf') . '</strong>)', '#description' => '<strong>' . __('Enter in singular!', 'wpcf') . '</strong><br />' . '.', '#value' => isset($ct['labels']['singular_name']) ? $ct['labels']['singular_name'] : '', '#validate' => array('required' => array('value' => 'true')), '#pattern' => $table_row, '#inline' => true, '#id' => 'name-singular');
    /*
     *
     * IF isset $_POST['slug'] it means form is not submitted
     */
    $attributes = array();
    if (!empty($_POST['ct']['slug'])) {
        $reserved = wpcf_is_reserved_name($_POST['ct']['slug'], 'post_type');
        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>)', '#value' => isset($ct['slug']) ? $ct['slug'] : '', '#pattern' => $table_row, '#inline' => true, '#validate' => array('required' => array('value' => 'true'), 'nospecialchars' => array('value' => 'true'), 'maxlength' => array('value' => '20')), '#attributes' => $attributes + array('maxlength' => '20'), '#id' => 'slug');
    $form['description'] = array('#type' => 'textarea', '#name' => 'ct[description]', '#title' => __('Description', 'wpcf'), '#value' => isset($ct['description']) ? $ct['description'] : '', '#attributes' => array('rows' => 4, 'cols' => 60), '#pattern' => $table_row, '#inline' => true);
    /**
     * icons only for version 3.8 up
     */
    global $wp_version;
    if (version_compare('3.8', $wp_version) < 1) {
        $form['icon'] = array('#type' => 'select', '#name' => 'ct[icon]', '#title' => __('Icon', 'wpcf'), '#default_value' => isset($ct['icon']) ? $ct['icon'] : 'admin-post', '#pattern' => $table_row, '#inline' => true, '#id' => 'wpcf-types-icon', '#options' => array('admin appearance' => 'admin-appearance', 'admin collapse' => 'admin-collapse', 'admin comments' => 'admin-comments', 'admin generic' => 'admin-generic', 'admin home' => 'admin-home', 'admin links' => 'admin-links', 'admin media' => 'admin-media', 'admin network' => 'admin-network', 'admin page' => 'admin-page', 'admin plugins' => 'admin-plugins', 'admin post' => 'admin-post', 'admin settings' => 'admin-settings', 'admin site' => 'admin-site', 'admin tools' => 'admin-tools', 'admin users' => 'admin-users', 'align center' => 'align-center', 'align left' => 'align-left', 'align none' => 'align-none', 'align right' => 'align-right', 'analytics' => 'analytics', 'archive' => 'archive', 'arrow down' => 'arrow-down', 'arrow down alt' => 'arrow-down-alt', 'arrow down alt2' => 'arrow-down-alt2', 'arrow left' => 'arrow-left', 'arrow left alt' => 'arrow-left-alt', 'arrow left alt2' => 'arrow-left-alt2', 'arrow right' => 'arrow-right', 'arrow right alt' => 'arrow-right-alt', 'arrow right alt2' => 'arrow-right-alt2', 'arrow up' => 'arrow-up', 'arrow up alt' => 'arrow-up-alt', 'arrow up alt2' => 'arrow-up-alt2', 'art' => 'art', 'awards' => 'awards', 'backup' => 'backup', 'book' => 'book', 'book alt' => 'book-alt', 'businessman' => 'businessman', 'calendar' => 'calendar', 'camera' => 'camera', 'cart' => 'cart', 'category' => 'category', 'chart area' => 'chart-area', 'chart bar' => 'chart-bar', 'chart line' => 'chart-line', 'chart pie' => 'chart-pie', 'clipboard' => 'clipboard', 'clock' => 'clock', 'cloud' => 'cloud', 'dashboard' => 'dashboard', 'desktop' => 'desktop', 'dismiss' => 'dismiss', 'download' => 'download', 'edit' => 'edit', 'editor aligncenter' => 'editor-aligncenter', 'editor alignleft' => 'editor-alignleft', 'editor alignright' => 'editor-alignright', 'editor bold' => 'editor-bold', 'editor break' => 'editor-break', 'editor code' => 'editor-code', 'editor contract' => 'editor-contract', 'editor customchar' => 'editor-customchar', 'editor expand' => 'editor-expand', 'editor help' => 'editor-help', 'editor indent' => 'editor-indent', 'editor insertmore' => 'editor-insertmore', 'editor italic' => 'editor-italic', 'editor justify' => 'editor-justify', 'editor kitchensink' => 'editor-kitchensink', 'editor ol' => 'editor-ol', 'editor outdent' => 'editor-outdent', 'editor paragraph' => 'editor-paragraph', 'editor paste text' => 'editor-paste-text', 'editor paste word' => 'editor-paste-word', 'editor quote' => 'editor-quote', 'editor removeformatting' => 'editor-removeformatting', 'editor rtl' => 'editor-rtl', 'editor spellcheck' => 'editor-spellcheck', 'editor strikethrough' => 'editor-strikethrough', 'editor textcolor' => 'editor-textcolor', 'editor ul' => 'editor-ul', 'editor underline' => 'editor-underline', 'editor unlink' => 'editor-unlink', 'editor video' => 'editor-video', 'email' => 'email', 'email alt' => 'email-alt', 'exerpt view' => 'exerpt-view', 'external' => 'external', 'facebook' => 'facebook', 'facebook alt' => 'facebook-alt', 'feedback' => 'feedback', 'flag' => 'flag', 'format aside' => 'format-aside', 'format audio' => 'format-audio', 'format chat' => 'format-chat', 'format gallery' => 'format-gallery', 'format image' => 'format-image', 'format quote' => 'format-quote', 'format status' => 'format-status', 'format video' => 'format-video', 'forms' => 'forms', 'googleplus' => 'googleplus', 'groups' => 'groups', 'hammer' => 'hammer', 'heart' => 'heart', 'id' => 'id', 'id alt' => 'id-alt', 'image crop' => 'image-crop', 'image flip horizontal' => 'image-flip-horizontal', 'image flip vertical' => 'image-flip-vertical', 'image rotate left' => 'image-rotate-left', 'image rotate right' => 'image-rotate-right', 'images alt' => 'images-alt', 'images alt2' => 'images-alt2', 'info' => 'info', 'leftright' => 'leftright', 'lightbulb' => 'lightbulb', 'list view' => 'list-view', 'location' => 'location', 'location alt' => 'location-alt', 'lock' => 'lock', 'marker' => 'marker', 'media archive' => 'media-archive', 'media audio' => 'media-audio', 'media code' => 'media-code', 'media default' => 'media-default', 'media document' => 'media-document', 'media interactive' => 'media-interactive', 'media spreadsheet' => 'media-spreadsheet', 'media text' => 'media-text', 'media video' => 'media-video', 'megaphone' => 'megaphone', 'menu' => 'menu', 'microphone' => 'microphone', 'migrate' => 'migrate', 'minus' => 'minus', 'nametag' => 'nametag', 'networking' => 'networking', 'no' => 'no', 'no alt' => 'no-alt', 'performance' => 'performance', 'playlist audio' => 'playlist-audio', 'playlist video' => 'playlist-video', 'plus' => 'plus', 'plus alt' => 'plus-alt', 'portfolio' => 'portfolio', 'post status' => 'post-status', 'pressthis' => 'pressthis', 'products' => 'products', 'randomize' => 'randomize', 'redo' => 'redo', 'rss' => 'rss', 'schedule' => 'schedule', 'screenoptions' => 'screenoptions', 'search' => 'search', 'share' => 'share', 'share alt' => 'share-alt', 'share alt2' => 'share-alt2', 'shield' => 'shield', 'shield alt' => 'shield-alt', 'slides' => 'slides', 'smartphone' => 'smartphone', 'smiley' => 'smiley', 'sort' => 'sort', 'sos' => 'sos', 'star empty' => 'star-empty', 'star filled' => 'star-filled', 'star half' => 'star-half', 'tablet' => 'tablet', 'tag' => 'tag', 'tagcloud' => 'tagcloud', 'testimonial' => 'testimonial', 'text' => 'text', 'tickets' => 'tickets', 'translation' => 'translation', 'trash' => 'trash', 'twitter' => 'twitter', 'undo' => 'undo', 'universal access' => 'universal-access', 'universal access alt' => 'universal-access-alt', 'update' => 'update', 'upload' => 'upload', 'vault' => 'vault', 'video alt' => 'video-alt', 'video alt2' => 'video-alt2', 'video alt3' => 'video-alt3', 'visibility' => 'visibility', 'welcome add page' => 'welcome-add-page', 'welcome comments' => 'welcome-comments', 'welcome learn more' => 'welcome-learn-more', 'welcome view site' => 'welcome-view-site', 'welcome widgets menus' => 'welcome-widgets-menus', 'welcome write blog' => 'welcome-write-blog', 'wordpress' => 'wordpress', 'wordpress alt' => 'wordpress-alt', 'yes' => 'yes'));
    }
    $form['table-1-close'] = array('#type' => 'markup', '#markup' => '</tbody></table>');
    global $sitepress;
    if ($update && isset($sitepress) && version_compare(ICL_SITEPRESS_VERSION, '2.6.2', '>=') && function_exists('wpml_custom_post_translation_options')) {
        $form['table-1-close']['#markup'] .= wpml_custom_post_translation_options($ct['slug']);
    }
//.........这里部分代码省略.........
开发者ID:sandum150,项目名称:cheltuieli,代码行数:101,代码来源:custom-types-form.php


示例5: wpcf_wpml_post_types_translate

/**
 * Translates data.
 *
 * @param type $post_type
 * @param type $data
 */
function wpcf_wpml_post_types_translate($data, $post_type)
{
    if (!function_exists('icl_t')) {
        return $data;
    }
    $default = wpcf_custom_types_default();
    if (!empty($data['description'])) {
        $data['description'] = wpcf_translate($post_type . ' description', $data['description'], 'Types-CPT');
    }
    foreach ($data['labels'] as $label => $string) {
        if ($label == 'name' || $label == 'singular_name') {
            $data['labels'][$label] = wpcf_translate($post_type . ' ' . $label, $string, 'Types-CPT');
            continue;
        }
        if (!isset($default['labels'][$label]) || $string !== $default['labels'][$label]) {
            $data['labels'][$label] = wpcf_translate($post_type . ' ' . $label, $string, 'Types-CPT');
        } else {
            $data['labels'][$label] = wpcf_translate($label, $string, 'Types-CPT');
        }
    }
    return $data;
}
开发者ID:evdant,项目名称:firstwp,代码行数:28,代码来源:wpml.php


示例6: wpcf_custom_types_register_translation

/**
 * Registers translation data.
 * 
 * @param type $post_type
 * @param type $data 
 */
function wpcf_custom_types_register_translation($post_type, $data)
{
    if (!function_exists('icl_register_string')) {
        return $data;
    }
    $default = wpcf_custom_types_default();
    if (isset($data['description'])) {
        icl_register_string('Types-CPT', $post_type . ' description', $data['description']);
    }
    foreach ($data['labels'] as $label => $string) {
        if ($label == 'name' || $label == 'singular_name') {
            icl_register_string('Types-CPT', $post_type . ' ' . $label, $string);
            continue;
        }
        if (!isset($default['labels'][$label]) || $string !== $default['labels'][$label]) {
            icl_register_string('Types-CPT', $post_type . ' ' . $label, $string);
        }
    }
}
开发者ID:Netsoro,项目名称:gdnlteamgroup,代码行数:25,代码来源:custom-types-form.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP wpcf_custom_types_register_translation函数代码示例发布时间:2022-05-23
下一篇:
PHP wpcf_custom_taxonomies_default函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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