本文整理汇总了PHP中wpcf_custom_types_default函数的典型用法代码示例。如果您正苦于以下问题:PHP wpcf_custom_types_default函数的具体用法?PHP wpcf_custom_types_default怎么用?PHP wpcf_custom_types_default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wpcf_custom_types_default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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];
}
示例3: 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']);
}
//.........这里部分代码省略.........
示例4: 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;
}
示例5: 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);
}
}
}