本文整理汇总了PHP中disp_boolean函数的典型用法代码示例。如果您正苦于以下问题:PHP disp_boolean函数的具体用法?PHP disp_boolean怎么用?PHP disp_boolean使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了disp_boolean函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cptui_update_taxonomy
/**
* Add to or update our CPTUI option with new data.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data to update.
*
* @return bool|string False on failure, string on success.
*/
function cptui_update_taxonomy($data = array())
{
/**
* Fires before a taxonomy is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data we are updating.
*/
do_action('cptui_before_update_taxonomy', $data);
# They need to provide a name
if (empty($data['cpt_custom_tax']['name'])) {
return cptui_admin_notices('error', '', false, __('Please provide a taxonomy name', 'cpt-plugin'));
}
foreach ($data as $key => $value) {
if (is_string($value)) {
$data[$key] = sanitize_text_field($value);
} else {
array_map('sanitize_text_field', $data[$key]);
}
}
if (false !== strpos($data['cpt_custom_tax']['name'], '\'') || false !== strpos($data['cpt_custom_tax']['name'], '\\"') || false !== strpos($data['cpt_custom_tax']['rewrite_slug'], '\'') || false !== strpos($data['cpt_custom_tax']['rewrite_slug'], '\\"')) {
return cptui_admin_notices('error', '', false, __('Please do not use quotes in taxonomy names or rewrite slugs', 'cpt-plugin'));
}
$taxonomies = get_option('cptui_taxonomies', array());
if ('new' == $data['cpt_tax_status'] && array_key_exists(strtolower($data['cpt_custom_tax']['name']), $taxonomies)) {
return cptui_admin_notices('error', '', false, sprintf(__('Please choose a different taxonomy name. %s is already used.', 'cpt-plugin'), $data['cpt_custom_tax']['name']));
}
if (empty($data['cpt_post_types']) || !is_array($data['cpt_post_types'])) {
$data['cpt_post_types'] = '';
}
foreach ($data['cpt_tax_labels'] as $key => $label) {
if (empty($label)) {
unset($data['cpt_tax_labels'][$key]);
}
$label = str_replace('"', '', htmlspecialchars_decode($label));
$label = htmlspecialchars($label, ENT_QUOTES);
$data['cpt_tax_labels'][$key] = stripslashes_deep($label);
}
$label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_tax']['label']));
$label = htmlspecialchars(stripslashes($label), ENT_QUOTES);
$singular_label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_tax']['singular_label']));
$singular_label = htmlspecialchars(stripslashes($singular_label));
$taxonomies[$data['cpt_custom_tax']['name']] = array('name' => $data['cpt_custom_tax']['name'], 'label' => $label, 'singular_label' => $singular_label, 'hierarchical' => disp_boolean($data['cpt_custom_tax']['hierarchical']), 'show_ui' => disp_boolean($data['cpt_custom_tax']['show_ui']), 'query_var' => disp_boolean($data['cpt_custom_tax']['query_var']), 'query_var_slug' => $data['cpt_custom_tax']['query_var_slug'], 'rewrite' => disp_boolean($data['cpt_custom_tax']['rewrite']), 'rewrite_slug' => $data['cpt_custom_tax']['rewrite_slug'], 'rewrite_withfront' => $data['cpt_custom_tax']['rewrite_withfront'], 'rewrite_hierarchical' => $data['cpt_custom_tax']['rewrite_hierarchical'], 'show_admin_column' => disp_boolean($data['cpt_custom_tax']['show_admin_column']), 'labels' => $data['cpt_tax_labels']);
$taxonomies[$data['cpt_custom_tax']['name']]['object_types'] = $data['cpt_post_types'];
$success = update_option('cptui_taxonomies', $taxonomies);
/**
* Fires after a taxonomy is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data that was updated.
*/
do_action('cptui_after_update_taxonomy', $data);
flush_rewrite_rules();
if (isset($success)) {
if ('new' == $data['cpt_tax_status']) {
return cptui_admin_notices('add', $data['cpt_custom_tax']['name'], $success);
}
}
return cptui_admin_notices('update', $data['cpt_custom_tax']['name'], true);
}
示例2: cpt_manage_taxonomies
//.........这里部分代码省略.........
_e('Edit', 'cpt-plugin');
?>
</a> / <a href="#" class="comment_button" id="<?php
echo $thecounter;
?>
"><?php
_e('Get Code', 'cpt-plugin');
?>
</a></td>
<td valign="top"><?php
echo stripslashes($cpt_tax_type["name"]);
?>
</td>
<td valign="top"><?php
echo stripslashes($cpt_tax_type["label"]);
?>
</td>
<td valign="top"><?php
echo stripslashes($cpt_tax_type["singular_label"]);
?>
</td>
<td valign="top">
<?php
if (isset($cpt_tax_type["cpt_name"])) {
echo stripslashes($cpt_tax_type["cpt_name"]);
} elseif (is_array($cpt_tax_type[1])) {
foreach ($cpt_tax_type[1] as $cpt_post_types) {
echo $cpt_post_types . '<br />';
}
}
?>
</td>
<td valign="top"><?php
echo disp_boolean($cpt_tax_type["hierarchical"]);
?>
</td>
<td valign="top"><?php
echo disp_boolean($cpt_tax_type["show_ui"]);
?>
</td>
<td valign="top"><?php
echo disp_boolean($cpt_tax_type["rewrite"]);
?>
</td>
<td valign="top"><?php
echo $rewrite_slug;
?>
</td>
</tr>
<tr>
<td colspan="10">
<div style="display:none;" id="slidepanel<?php
echo $thecounter;
?>
">
<?php
$cpt_tax_sanitized_name = str_replace('-', '_', $cpt_tax_type['name']);
//display register_taxonomy code
$custom_tax = '';
$custom_tax = "add_action('init', 'cptui_register_my_taxes_" . $cpt_tax_sanitized_name . "');\n";
$custom_tax .= "function cptui_register_my_taxes_" . $cpt_tax_sanitized_name . "() {\n";
if (!$cpt_tax_type["label"]) {
$cpt_label = esc_html($cpt_tax_type["name"]);
} else {
$cpt_label = esc_html($cpt_tax_type["label"]);
}
示例3: cptui_register_single_taxonomy
/**
* Helper function to register the actual taxonomy.
*
* @param array $taxonomy Taxonomy array to register.
*
* @return null Result of register_taxonomy.
*/
function cptui_register_single_taxonomy($taxonomy = array())
{
$labels = array('name' => $taxonomy['label'], 'singular_name' => $taxonomy['singular_label']);
$preserved = cptui_get_preserved_keys('taxonomies');
foreach ($taxonomy['labels'] as $key => $label) {
if (!empty($label)) {
$labels[$key] = $label;
} elseif (empty($label) && in_array($key, $preserved)) {
$labels[$key] = cptui_get_preserved_label('taxonomies', $key, $taxonomy['label'], $taxonomy['singular_label']);
}
}
$rewrite = get_disp_boolean($taxonomy['rewrite']);
if (false !== get_disp_boolean($taxonomy['rewrite'])) {
$rewrite = array();
$rewrite['slug'] = !empty($taxonomy['rewrite_slug']) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
$rewrite['with_front'] = 'false' === disp_boolean($taxonomy['rewrite_withfront']) ? false : true;
$rewrite['hierarchical'] = 'true' === disp_boolean($taxonomy['rewrite_hierarchical']) ? true : false;
}
if (in_array($taxonomy['query_var'], array('true', 'false', '0', '1'))) {
$taxonomy['query_var'] = get_disp_boolean($taxonomy['query_var']);
}
if (true === $taxonomy['query_var'] && !empty($taxonomy['query_var_slug'])) {
$taxonomy['query_var'] = $taxonomy['query_var_slug'];
}
$show_admin_column = !empty($taxonomy['show_admin_column']) && false !== get_disp_boolean($taxonomy['show_admin_column']) ? true : false;
$args = array('labels' => $labels, 'label' => $taxonomy['label'], 'hierarchical' => get_disp_boolean($taxonomy['hierarchical']), 'show_ui' => get_disp_boolean($taxonomy['show_ui']), 'query_var' => $taxonomy['query_var'], 'rewrite' => $rewrite, 'show_admin_column' => $show_admin_column);
$object_type = !empty($taxonomy['object_types']) ? $taxonomy['object_types'] : '';
/**
* Filters the arguments used for a taxonomy right before registering.
*
* @since 1.0.0
*
* @param array $args Array of arguments to use for registering taxonomy.
* @param string $value Taxonomy slug to be registered.
*/
$args = apply_filters('cptui_pre_register_taxonomy', $args, $taxonomy['name']);
return register_taxonomy($taxonomy['name'], $object_type, $args);
}
示例4: cptui_update_post_type
/**
* Add to or update our CPTUI option with new data.
*
* @since 1.0.0
*
* @param array $data Array of post type data to update.
*
* @return bool|string False on failure, string on success.
*/
function cptui_update_post_type($data = array())
{
/**
* Fires before a post_type is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of post_type data we are updating.
*/
do_action('cptui_before_update_post_type', $data);
# They need to provide a name
if (empty($data['cpt_custom_post_type']['name'])) {
return cptui_admin_notices('error', '', false, __('Please provide a post type name', 'cpt-plugin'));
}
# clean up $_POST data
foreach ($data as $key => $value) {
if (is_string($value)) {
$data[$key] = sanitize_text_field($value);
} else {
array_map('sanitize_text_field', $data[$key]);
}
}
# Check if they didn't put quotes in the name or rewrite slug.
if (false !== strpos($data['cpt_custom_post_type']['name'], '\'') || false !== strpos($data['cpt_custom_post_type']['name'], '\\"') || false !== strpos($data['cpt_custom_post_type']['rewrite_slug'], '\'') || false !== strpos($data['cpt_custom_post_type']['rewrite_slug'], '\\"')) {
return cptui_admin_notices('error', '', false, __('Please do not use quotes in post type names or rewrite slugs', 'cpt-plugin'));
}
$post_types = get_option('cptui_post_types', array());
# Check if we already have a post type of that name.
if ('new' == $data['cpt_type_status'] && (array_key_exists(strtolower($data['cpt_custom_post_type']['name']), $post_types) || in_array($data['cpt_custom_post_type']['name'], cptui_reserved_post_types()))) {
return cptui_admin_notices('error', '', false, sprintf(__('Please choose a different post type name. %s is already registered.', 'cpt-plugin'), $data['cpt_custom_post_type']['name']));
}
if (empty($data['cpt_addon_taxes']) || !is_array($data['cpt_addon_taxes'])) {
$data['cpt_addon_taxes'] = array();
}
if (empty($data['cpt_supports']) || !is_array($data['cpt_supports'])) {
$data['cpt_supports'] = array();
}
foreach ($data['cpt_labels'] as $key => $label) {
if (empty($label)) {
unset($data['cpt_labels'][$key]);
}
$label = str_replace('"', '', htmlspecialchars_decode($label));
$label = htmlspecialchars($label, ENT_QUOTES);
$data['cpt_labels'][$key] = stripslashes_deep($label);
}
if (empty($data['cpt_custom_post_type']['menu_icon'])) {
$data['cpt_custom_post_type']['menu_icon'] = null;
}
$label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_post_type']['label']));
$label = htmlspecialchars(stripslashes($label), ENT_QUOTES);
$singular_label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_post_type']['singular_label']));
$singular_label = htmlspecialchars(stripslashes($singular_label), ENT_QUOTES);
$description = stripslashes_deep($data['cpt_custom_post_type']['description']);
$post_types[$data['cpt_custom_post_type']['name']] = array('name' => $data['cpt_custom_post_type']['name'], 'label' => $label, 'singular_label' => $singular_label, 'description' => $description, 'public' => disp_boolean($data['cpt_custom_post_type']['public']), 'show_ui' => disp_boolean($data['cpt_custom_post_type']['show_ui']), 'has_archive' => disp_boolean($data['cpt_custom_post_type']['has_archive']), 'has_archive_string' => $data['cpt_custom_post_type']['has_archive_string'], 'exclude_from_search' => disp_boolean($data['cpt_custom_post_type']['exclude_from_search']), 'capability_type' => $data['cpt_custom_post_type']['capability_type'], 'hierarchical' => disp_boolean($data['cpt_custom_post_type']['hierarchical']), 'rewrite' => disp_boolean($data['cpt_custom_post_type']['rewrite']), 'rewrite_slug' => $data['cpt_custom_post_type']['rewrite_slug'], 'rewrite_withfront' => disp_boolean($data['cpt_custom_post_type']['rewrite_withfront']), 'query_var' => disp_boolean($data['cpt_custom_post_type']['query_var']), 'menu_position' => $data['cpt_custom_post_type']['menu_position'], 'show_in_menu' => disp_boolean($data['cpt_custom_post_type']['show_in_menu']), 'show_in_menu_string' => $data['cpt_custom_post_type']['show_in_menu_string'], 'menu_icon' => $data['cpt_custom_post_type']['menu_icon'], 'supports' => $data['cpt_supports'], 'taxonomies' => $data['cpt_addon_taxes'], 'labels' => $data['cpt_labels']);
$success = update_option('cptui_post_types', $post_types);
/**
* Fires after a post type is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of post type data that was updated.
*/
do_action('cptui_after_update_post_type', $data);
flush_rewrite_rules();
if (isset($success)) {
if ('new' == $data['cpt_type_status']) {
return cptui_admin_notices('add', $data['cpt_custom_post_type']['name'], $success);
}
}
return cptui_admin_notices('update', $data['cpt_custom_post_type']['name'], true);
}
示例5: cptui_register_single_taxonomy
/**
* Helper function to register the actual taxonomy.
*
* @since 1.0.0
*
* @internal
*
* @param array $taxonomy Taxonomy array to register.
* @return null Result of register_taxonomy.
*/
function cptui_register_single_taxonomy($taxonomy = array())
{
$labels = array('name' => $taxonomy['label'], 'singular_name' => $taxonomy['singular_label']);
$description = '';
if (!empty($taxonomy['description'])) {
$description = $taxonomy['description'];
}
$preserved = cptui_get_preserved_keys('taxonomies');
foreach ($taxonomy['labels'] as $key => $label) {
if (!empty($label)) {
$labels[$key] = $label;
} elseif (empty($label) && in_array($key, $preserved)) {
$labels[$key] = cptui_get_preserved_label('taxonomies', $key, $taxonomy['label'], $taxonomy['singular_label']);
}
}
$rewrite = get_disp_boolean($taxonomy['rewrite']);
if (false !== get_disp_boolean($taxonomy['rewrite'])) {
$rewrite = array();
$rewrite['slug'] = !empty($taxonomy['rewrite_slug']) ? $taxonomy['rewrite_slug'] : $taxonomy['name'];
$rewrite['with_front'] = 'false' === disp_boolean($taxonomy['rewrite_withfront']) ? false : true;
$rewrite['hierarchical'] = 'true' === disp_boolean($taxonomy['rewrite_hierarchical']) ? true : false;
}
if (in_array($taxonomy['query_var'], array('true', 'false', '0', '1'))) {
$taxonomy['query_var'] = get_disp_boolean($taxonomy['query_var']);
}
if (true === $taxonomy['query_var'] && !empty($taxonomy['query_var_slug'])) {
$taxonomy['query_var'] = $taxonomy['query_var_slug'];
}
$public = !empty($taxonomy['public']) && false === get_disp_boolean($taxonomy['public']) ? false : true;
$show_admin_column = !empty($taxonomy['show_admin_column']) && false !== get_disp_boolean($taxonomy['show_admin_column']) ? true : false;
$show_in_menu = !empty($taxonomy['show_in_menu']) && false !== get_disp_boolean($taxonomy['show_in_menu']) ? true : false;
if (empty($taxonomy['show_in_menu'])) {
$show_in_menu = get_disp_boolean($taxonomy['show_ui']);
}
$show_in_nav_menus = !empty($taxonomy['show_in_nav_menus']) && false !== get_disp_boolean($taxonomy['show_in_nav_menus']) ? true : false;
if (empty($taxonomy['show_in_nav_menus'])) {
$show_in_nav_menus = $public;
}
$show_in_rest = !empty($taxonomy['show_in_rest']) && false !== get_disp_boolean($taxonomy['show_in_rest']) ? true : false;
$show_in_quick_edit = !empty($taxonomy['show_in_quick_edit']) && false !== get_disp_boolean($taxonomy['show_in_quick_edit']) ? true : false;
$rest_base = null;
if (!empty($taxonomy['rest_base'])) {
$rest_base = $taxonomy['rest_base'];
}
$args = array('labels' => $labels, 'label' => $taxonomy['label'], 'description' => $description, 'public' => $public, 'hierarchical' => get_disp_boolean($taxonomy['hierarchical']), 'show_ui' => get_disp_boolean($taxonomy['show_ui']), 'show_in_menu' => $show_in_menu, 'show_in_nav_menus' => $show_in_nav_menus, 'query_var' => $taxonomy['query_var'], 'rewrite' => $rewrite, 'show_admin_column' => $show_admin_column, 'show_in_rest' => $show_in_rest, 'rest_base' => $rest_base, 'show_in_quick_edit' => $show_in_quick_edit);
$object_type = !empty($taxonomy['object_types']) ? $taxonomy['object_types'] : '';
/**
* Filters the arguments used for a taxonomy right before registering.
*
* @since 1.0.0
* @since 1.3.0 Added original passed in values array
*
* @param array $args Array of arguments to use for registering taxonomy.
* @param string $value Taxonomy slug to be registered.
* @param array $taxonomy Original passed in values for taxonomy.
*/
$args = apply_filters('cptui_pre_register_taxonomy', $args, $taxonomy['name'], $taxonomy);
return register_taxonomy($taxonomy['name'], $object_type, $args);
}
示例6: cptui_get_single_post_type_registery
/**
* Create output for single post type to be ready for copy/paste from Get Code.
*
* @since 1.0.0
*
* @param array $post_type Post type data to output.
*
* @return string Copy/paste ready "php" code.
*/
function cptui_get_single_post_type_registery($post_type = array())
{
/** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
$post_type['map_meta_cap'] = apply_filters('cptui_map_meta_cap', 'true', $post_type['name'], $post_type);
$user_supports_params = apply_filters('cptui_user_supports_params', array(), $post_type['name'], $post_type);
if (is_array($user_supports_params)) {
$post_type['supports'] = array_merge($post_type['supports'], $user_supports_params);
}
$rewrite = get_disp_boolean($post_type['rewrite']);
if (false !== $rewrite) {
$rewrite = disp_boolean($post_type['rewrite']);
$rewrite_slug = ' "slug" => "' . $post_type['name'] . '",';
if (!empty($post_type['rewrite_slug'])) {
$rewrite_slug = ' "slug" => "' . $post_type['rewrite_slug'] . '",';
}
$withfront = disp_boolean($post_type['rewrite_withfront']);
if (!empty($withfront)) {
$rewrite_withfront = ' "with_front" => ' . $withfront . ' ';
}
if (!empty($post_type['rewrite_slug']) || !empty($post_type['rewrite_withfront'])) {
$rewrite_start = 'array(';
$rewrite_end = ')';
$rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
}
} else {
$rewrite = disp_boolean($post_type['rewrite']);
}
$supports = '';
# Do a little bit of php work to get these into strings.
if (!empty($post_type['supports']) && is_array($post_type['supports'])) {
$supports = 'array( "' . implode('", "', $post_type['supports']) . '" )';
}
if (in_array('none', $post_type['supports'])) {
$supports = 'false';
}
$taxonomies = '';
if (!empty($post_type['taxonomies']) && is_array($post_type['taxonomies'])) {
$taxonomies = 'array( "' . implode('", "', $post_type['taxonomies']) . '" )';
}
if (in_array($post_type['query_var'], array('true', 'false', '0', '1'))) {
$post_type['query_var'] = get_disp_boolean($post_type['query_var']);
}
$post_type['description'] = addslashes($post_type['description']);
?>
$labels = array(
"name" => "<?php
echo $post_type['label'];
?>
",
"singular_name" => "<?php
echo $post_type['singular_label'];
?>
",
<?php
foreach ($post_type['labels'] as $key => $label) {
if (!empty($label)) {
echo '"' . $key . '" => "' . $label . '",' . "\n\t\t";
}
}
?>
);
$args = array(
"labels" => $labels,
"description" => "<?php
echo $post_type['description'];
?>
",
"public" => <?php
echo disp_boolean($post_type['public']);
?>
,
"show_ui" => <?php
echo disp_boolean($post_type['show_ui']);
?>
,
"has_archive" => <?php
echo disp_boolean($post_type['has_archive']);
?>
,
"show_in_menu" => <?php
echo disp_boolean($post_type['show_in_menu']);
?>
,
"exclude_from_search" => <?php
echo disp_boolean($post_type['exclude_from_search']);
?>
,
"capability_type" => "<?php
echo $post_type['capability_type'];
?>
//.........这里部分代码省略.........
示例7: cpt_manage_taxonomies
function cpt_manage_taxonomies() {
global $CPT_URL;
$MANAGE_URL = cpt_check_return( 'add' );
//flush rewrite rules
flush_rewrite_rules();
?>
<div class="wrap">
<?php
//check for success/error messages
If (isset($_GET['cpt_msg']) && $_GET['cpt_msg']=='del') { ?>
<div id="message" class="updated">
<?php _e('Custom taxonomy deleted successfully', 'cpt-plugin'); ?>
</div>
<?php
}
?>
<h2><?php _e('Manage Custom Taxonomies', 'cpt-plugin') ?></h2>
<p><?php _e('Deleting custom taxonomies does <strong>NOT</strong> delete any content added to those taxonomies. You can easily recreate your taxonomies and the content will still exist.', 'cpt-plugin') ?></p>
<?php
$cpt_tax_types = get_option('cpt_custom_tax_types');
If (is_array($cpt_tax_types)) {
?>
<table width="100%">
<tr>
<td><strong><?php _e('Action', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Name', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Label', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Singular Label', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Attached Post Types', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Hierarchical', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Show UI', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Rewrite', 'cpt-plugin');?></strong></td>
<td><strong><?php _e('Rewrite Slug', 'cpt-plugin');?></strong></td>
</tr>
<?php
$thecounter=0;
foreach ($cpt_tax_types as $cpt_tax_type) {
$del_url = cpt_check_return( 'cpt' ) .'&deltax=' .$thecounter .'&return=tax';
$del_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($del_url, 'cpt_delete_tax') : $del_url;
$edit_url = $MANAGE_URL .'&edittax=' .$thecounter .'&return=tax';
$edit_url = ( function_exists('wp_nonce_url') ) ? wp_nonce_url($edit_url, 'cpt_edit_tax') : $edit_url;
$rewrite_slug = ( $cpt_tax_type["rewrite_slug"] ) ? $cpt_tax_type["rewrite_slug"] : $cpt_tax_type["name"];
?>
<tr>
<td valign="top"><a href="<?php echo $del_url; ?>">Delete</a> / <a href="<?php echo $edit_url; ?>">Edit</a><!-- / <a href="#" class="comment_button" id="<?php echo $thecounter; ?>">Get Code</a>--></td>
<td valign="top"><?php echo stripslashes($cpt_tax_type["name"]); ?></td>
<td valign="top"><?php echo stripslashes($cpt_tax_type["label"]); ?></td>
<td valign="top"><?php echo stripslashes($cpt_tax_type["singular_label"]); ?></td>
<td valign="top">
<?php
if ( isset( $cpt_tax_type["cpt_name"] ) ) {
echo stripslashes($cpt_tax_type["cpt_name"]);
}elseif ( is_array( $cpt_tax_type[1] ) ) {
foreach ($cpt_tax_type[1] as $cpt_post_types) {
echo $cpt_post_types .'<br />';
}
}
?>
</td>
<td valign="top"><?php echo disp_boolean($cpt_tax_type["hierarchical"]); ?></td>
<td valign="top"><?php echo disp_boolean($cpt_tax_type["show_ui"]); ?></td>
<td valign="top"><?php echo disp_boolean($cpt_tax_type["rewrite"]); ?></td>
<td valign="top"><?php echo $rewrite_slug; ?></td>
</tr>
<tr>
<td colspan="10">
<div style="display:none;" id="slidepanel<?php echo $thecounter; ?>">
<?php
//display register_taxonomy code
$cpt_tax_types = get_option('cpt_custom_tax_types');
$custom_tax = '';
//check if option value is an Array before proceeding
If (is_array($cpt_tax_types)) {
//foreach ($cpt_tax_types as $cpt_tax_type) {
If (!$cpt_tax_type["label"]) {
$cpt_label = esc_html($cpt_tax_type["name"]);
}Else{
$cpt_label = esc_html($cpt_tax_type["label"]);
}
//check if singular label was filled out
If (!$cpt_tax_type["singular_label"]) {
$cpt_singular_label = esc_html($cpt_tax_type["name"]);
}Else{
$cpt_singular_label = esc_html($cpt_tax_type["singular_label"]);
}
//register our custom taxonomies
$custom_tax = 'register_taxonomy(\'' .$cpt_tax_type["name"]. '\',';
$custom_tax .= '\''.$cpt_tax_type["cpt_name"] .'\',';
$custom_tax .= 'array( \'hierarchical\' => '.disp_boolean($cpt_tax_type["hierarchical"]).', ';
$custom_tax .= '\'label\' => \''.$cpt_label.'\',';
//.........这里部分代码省略.........
示例8: cptui_listings
function cptui_listings()
{
?>
<div class="wrap">
<h1><?php
_e('Post Types and Taxonomies registered by Custom Post Type UI.', 'custom-post-type-ui');
?>
</h1>
<?php
$post_types = get_option('cptui_post_types');
echo '<h2>' . __('Post Types', 'custom-post-type-ui') . '</h2>';
if (!empty($post_types)) {
?>
<p><?php
printf(__('Total count: %d', 'custom-post-type-ui'), count($post_types));
?>
</p>
<?php
$post_type_table_heads = array(__('Post Type', 'custom-post-type-ui'), __('Settings', 'custom-post-type-ui'), __('Supports', 'custom-post-type-ui'), __('Taxonomies', 'custom-post-type-ui'), __('Labels', 'custom-post-type-ui'), __('Template Hierarchy', 'custom-post-type-ui'));
/**
* Fires before the listing of registered post type data.
*
* @since 1.1.0
*/
do_action('cptui_before_post_type_listing');
?>
<table class="wp-list-table widefat">
<tr>
<?php
foreach ($post_type_table_heads as $head) {
echo '<th>' . $head . '</th>';
}
?>
</tr>
<?php
$counter = 1;
foreach ($post_types as $post_type => $post_type_settings) {
$rowclass = $counter % 2 == 0 ? '' : 'alternate';
$strings = array();
$supports = array();
$taxonomies = array();
$archive = '';
foreach ($post_type_settings as $settings_key => $settings_value) {
if ('labels' == $settings_key) {
continue;
}
if (is_string($settings_value)) {
$strings[$settings_key] = $settings_value;
} else {
if ('supports' === $settings_key) {
$supports[$settings_key] = $settings_value;
}
if ('taxonomies' === $settings_key) {
$taxonomies[$settings_key] = $settings_value;
# In case they are not associated from the post type settings
if (empty($taxonomies['taxonomies'])) {
$taxonomies['taxonomies'] = get_object_taxonomies($post_type);
}
}
}
$archive = get_post_type_archive_link($post_type);
}
?>
<tr class="<?php
echo $rowclass;
?>
">
<?php
$post_type_link_url = admin_url('admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type);
?>
<td><a href="<?php
echo $post_type_link_url;
?>
"><?php
printf(__('Edit %s', 'custom-post-type-ui'), $post_type);
?>
</a>
<?php
if ($archive) {
?>
|
<a href="<?php
echo get_post_type_archive_link($post_type);
?>
"><?php
_e('View frontend archive', 'custom-post-type-ui');
?>
</a>
<?php
}
?>
</td>
<td>
<?php
foreach ($strings as $key => $value) {
printf('<strong>%s:</strong> ', $key);
if (in_array($value, array('1', '0'))) {
echo disp_boolean($value);
//.........这里部分代码省略.........
示例9: cptui_update_post_type
//.........这里部分代码省略.........
foreach ($data as $key => $value) {
if (is_string($value)) {
$data[$key] = sanitize_text_field($value);
} else {
array_map('sanitize_text_field', $data[$key]);
}
}
// Check if they didn't put quotes in the name or rewrite slug.
if (false !== strpos($data['cpt_custom_post_type']['name'], '\'') || false !== strpos($data['cpt_custom_post_type']['name'], '\\"') || false !== strpos($data['cpt_custom_post_type']['rewrite_slug'], '\'') || false !== strpos($data['cpt_custom_post_type']['rewrite_slug'], '\\"')) {
return cptui_admin_notices('error', '', false, __('Please do not use quotes in post type names or rewrite slugs', 'custom-post-type-ui'));
}
$post_types = cptui_get_post_type_data();
/**
* Check if we already have a post type of that name.
*
* @since 1.3.0
*
* @param bool $value Assume we have no conflict by default.
* @param string $value Post type slug being saved.
* @param array $post_types Array of existing post types from CPTUI.
*/
$slug_exists = apply_filters('cptui_post_type_slug_exists', false, $data['cpt_custom_post_type']['name'], $post_types);
$slug_as_page = cptui_check_page_slugs($data['cpt_custom_post_type']['name']);
if ('new' == $data['cpt_type_status']) {
if (true === $slug_exists) {
return cptui_admin_notices('error', '', false, sprintf(__('Please choose a different post type name. %s is already registered.', 'custom-post-type-ui'), $data['cpt_custom_post_type']['name']));
}
if (true === $slug_as_page) {
return cptui_admin_notices('error', '', false, sprintf(__('Please choose a different post type name. %s matches an existing page slug, which can cause conflicts.', 'custom-post-type-ui'), $data['cpt_custom_post_type']['name']));
}
}
if (empty($data['cpt_addon_taxes']) || !is_array($data['cpt_addon_taxes'])) {
$data['cpt_addon_taxes'] = array();
}
if (empty($data['cpt_supports']) || !is_array($data['cpt_supports'])) {
$data['cpt_supports'] = array();
}
foreach ($data['cpt_labels'] as $key => $label) {
if (empty($label)) {
unset($data['cpt_labels'][$key]);
}
$label = str_replace('"', '', htmlspecialchars_decode($label));
$label = htmlspecialchars($label, ENT_QUOTES);
$label = trim($label);
$data['cpt_labels'][$key] = stripslashes_deep($label);
}
if (empty($data['cpt_custom_post_type']['menu_icon'])) {
$data['cpt_custom_post_type']['menu_icon'] = null;
}
$label = ucwords(str_replace('_', ' ', $data['cpt_custom_post_type']['name']));
if (!empty($data['cpt_custom_post_type']['label'])) {
$label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_post_type']['label']));
$label = htmlspecialchars(stripslashes($label), ENT_QUOTES);
}
$singular_label = ucwords(str_replace('_', ' ', $data['cpt_custom_post_type']['name']));
if (!empty($data['cpt_custom_post_type']['singular_label'])) {
$singular_label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_post_type']['singular_label']));
$singular_label = htmlspecialchars(stripslashes($singular_label), ENT_QUOTES);
}
$name = trim($data['cpt_custom_post_type']['name']);
$description = stripslashes_deep($data['cpt_custom_post_type']['description']);
$rest_base = trim($data['cpt_custom_post_type']['rest_base']);
$has_archive_string = trim($data['cpt_custom_post_type']['has_archive_string']);
$capability_type = trim($data['cpt_custom_post_type']['capability_type']);
$rewrite_slug = trim($data['cpt_custom_post_type']['rewrite_slug']);
$query_var_slug = trim($data['cpt_custom_post_type']['query_var_slug']);
$menu_position = trim($data['cpt_custom_post_type']['menu_position']);
$show_in_menu_string = trim($data['cpt_custom_post_type']['show_in_menu_string']);
$menu_icon = trim($data['cpt_custom_post_type']['menu_icon']);
$custom_supports = trim($data['cpt_custom_post_type']['custom_supports']);
$post_types[$data['cpt_custom_post_type']['name']] = array('name' => $name, 'label' => $label, 'singular_label' => $singular_label, 'description' => $description, 'public' => disp_boolean($data['cpt_custom_post_type']['public']), 'show_ui' => disp_boolean($data['cpt_custom_post_type']['show_ui']), 'show_in_nav_menus' => disp_boolean($data['cpt_custom_post_type']['show_in_nav_menus']), 'show_in_rest' => disp_boolean($data['cpt_custom_post_type']['show_in_rest']), 'rest_base' => $rest_base, 'has_archive' => disp_boolean($data['cpt_custom_post_type']['has_archive']), 'has_archive_string' => $has_archive_string, 'exclude_from_search' => disp_boolean($data['cpt_custom_post_type']['exclude_from_search']), 'capability_type' => $capability_type, 'hierarchical' => disp_boolean($data['cpt_custom_post_type']['hierarchical']), 'rewrite' => disp_boolean($data['cpt_custom_post_type']['rewrite']), 'rewrite_slug' => $rewrite_slug, 'rewrite_withfront' => disp_boolean($data['cpt_custom_post_type']['rewrite_withfront']), 'query_var' => disp_boolean($data['cpt_custom_post_type']['query_var']), 'query_var_slug' => $query_var_slug, 'menu_position' => $menu_position, 'show_in_menu' => disp_boolean($data['cpt_custom_post_type']['show_in_menu']), 'show_in_menu_string' => $show_in_menu_string, 'menu_icon' => $menu_icon, 'supports' => $data['cpt_supports'], 'taxonomies' => $data['cpt_addon_taxes'], 'labels' => $data['cpt_labels'], 'custom_supports' => $custom_supports);
/**
* Filters whether or not 3rd party options were saved successfully within post type add/update.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else saved successfully. Default false.
* @param array $post_types Array of our updated post types data.
* @param array $data Array of submitted post type to update.
*/
if (false === ($success = apply_filters('cptui_post_type_update_save', false, $post_types, $data))) {
$success = update_option('cptui_post_types', $post_types);
}
/**
* Fires after a post type is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of post type data that was updated.
*/
do_action('cptui_after_update_post_type', $data);
// Used to help flush rewrite rules on init.
set_transient('cptui_flush_rewrite_rules', 'true', 5 * 60);
if (isset($success)) {
if ('new' == $data['cpt_type_status']) {
return cptui_admin_notices('add', $data['cpt_custom_post_type']['name'], $success);
}
}
return cptui_admin_notices('update', $data['cpt_custom_post_type']['name'], true);
}
示例10: get_select_input
/**
* Return a populated `<select>` input.
*
* @since 1.0.0
*
* @param array $args Arguments to use with the `<select>` input.
* @return string $value Complete <select> input with options and selected attribute.
*/
public function get_select_input($args = array())
{
$defaults = $this->get_default_input_parameters(array('selections' => array()));
$args = wp_parse_args($args, $defaults);
$value = '';
if ($args['wrap']) {
$value = $this->get_tr_start();
$value .= $this->get_th_start();
$value .= $this->get_label($args['name'], $args['labeltext']);
if ($args['required']) {
$value .= $this->get_required_span();
}
if (!empty($args['helptext'])) {
$value .= $this->get_help($args['helptext']);
}
$value .= $this->get_th_end();
$value .= $this->get_td_start();
}
$value .= '<select id="' . $args['name'] . '" name="' . $args['namearray'] . '[' . $args['name'] . ']">';
if (!empty($args['selections']['options']) && is_array($args['selections']['options'])) {
foreach ($args['selections']['options'] as $val) {
$result = '';
$bool = disp_boolean($val['attr']);
if (is_numeric($args['selections']['selected'])) {
$selected = disp_boolean($args['selections']['selected']);
} elseif (in_array($args['selections']['selected'], array('true', 'false'))) {
$selected = $args['selections']['selected'];
}
if (!empty($selected) && $selected === $bool) {
$result = ' selected="selected"';
} else {
if (array_key_exists('default', $val) && !empty($val['default'])) {
if (empty($selected)) {
$result = ' selected="selected"';
}
}
}
if (!is_numeric($args['selections']['selected']) && (!empty($args['selections']['selected']) && $args['selections']['selected'] === $val['attr'])) {
$result = ' selected="selected"';
}
$value .= '<option value="' . $val['attr'] . '"' . $result . '>' . $val['text'] . '</option>';
}
}
$value .= '</select>';
if (!empty($args['aftertext'])) {
$value .= ' ' . $this->get_description($args['aftertext']);
}
if ($args['wrap']) {
$value .= $this->get_td_end();
$value .= $this->get_tr_end();
}
return $value;
}
示例11: test_disp_boolean
public function test_disp_boolean()
{
$this->assertEquals('false', disp_boolean(0));
$this->assertEquals('false', disp_boolean('0'));
$this->assertEquals('false', disp_boolean(false));
$this->assertEquals('false', disp_boolean('false'));
$this->assertEquals('false', disp_boolean(''));
$this->assertEquals('false', disp_boolean(null));
$this->assertEquals('true', disp_boolean(1));
$this->assertEquals('true', disp_boolean('1'));
$this->assertEquals('true', disp_boolean(true));
$this->assertEquals('true', disp_boolean('true'));
$this->assertEquals('true', disp_boolean('abcd'));
$this->assertEquals('true', disp_boolean(1235));
}
示例12: cptui_listings
//.........这里部分代码省略.........
}
$archive = get_post_type_archive_link($post_type);
}
?>
<tr class="<?php
echo esc_attr($rowclass);
?>
">
<?php
$edit_path = 'admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type;
$post_type_link_url = is_network_admin() ? network_admin_url($edit_path) : admin_url($edit_path);
?>
<td>
<?php
printf('<a href="%s">%s</a> | <a href="%s">%s</a><br/>', esc_attr($post_type_link_url), sprintf(esc_html__('Edit %s', 'custom-post-type-ui'), esc_html($post_type)), esc_attr(admin_url('admin.php?page=cptui_importexport&action=get_code#' . $post_type)), esc_html__('Get code', 'custom-post-type-ui'));
if ($archive) {
?>
<a href="<?php
echo esc_attr(get_post_type_archive_link($post_type));
?>
"><?php
esc_html_e('View frontend archive', 'custom-post-type-ui');
?>
</a>
<?php
}
?>
</td>
<td>
<?php
foreach ($strings as $key => $value) {
printf('<strong>%s:</strong> ', esc_html($key));
if (in_array($value, array('1', '0'))) {
echo esc_html(disp_boolean($value));
} else {
echo esc_html($value);
}
echo '<br/>';
}
?>
</td>
<td>
<?php
foreach ($supports['supports'] as $support) {
echo esc_html($support) . '<br/>';
}
?>
</td>
<td>
<?php
foreach ($taxonomies['taxonomies'] as $taxonomy) {
echo esc_html($taxonomy) . '<br/>';
}
?>
</td>
<td>
<?php
$maybe_empty = array_filter($post_type_settings['labels']);
if (!empty($maybe_empty)) {
foreach ($post_type_settings['labels'] as $key => $value) {
if ('parent' === $key && array_key_exists('parent_item_colon', $post_type_settings['labels'])) {
continue;
}
printf('%s: %s<br/>', esc_html($key), esc_html($value));
}
} else {
示例13: cptui_update_taxonomy
/**
* Add to or update our CPTUI option with new data.
*
* @since 1.0.0
*
* @internal
*
* @param array $data Array of taxonomy data to update.
* @return bool|string False on failure, string on success.
*/
function cptui_update_taxonomy($data = array())
{
/**
* Fires before a taxonomy is updated to our saved options.
*
* @since 1.0.0
*
* @param array $data Array of taxonomy data we are updating.
*/
do_action('cptui_before_update_taxonomy', $data);
// They need to provide a name.
if (empty($data['cpt_custom_tax']['name'])) {
return cptui_admin_notices('error', '', false, __('Please provide a taxonomy name', 'custom-post-type-ui'));
}
if (empty($data['cpt_post_types'])) {
return cptui_admin_notices('error', '', false, __('Please provide a post type to attach to.', 'custom-post-type-ui'));
}
if (!empty($data['tax_original']) && $data['tax_original'] != $data['cpt_custom_tax']['name']) {
if (!empty($data['update_taxonomy'])) {
cptui_convert_taxonomy_terms($data['tax_original'], $data['cpt_custom_tax']['name']);
}
}
foreach ($data as $key => $value) {
if (is_string($value)) {
$data[$key] = sanitize_text_field($value);
} else {
array_map('sanitize_text_field', $data[$key]);
}
}
if (false !== strpos($data['cpt_custom_tax']['name'], '\'') || false !== strpos($data['cpt_custom_tax']['name'], '\\"') || false !== strpos($data['cpt_custom_tax']['rewrite_slug'], '\'') || false !== strpos($data['cpt_custom_tax']['rewrite_slug'], '\\"')) {
return cptui_admin_notices('error', '', false, __('Please do not use quotes in taxonomy names or rewrite slugs', 'custom-post-type-ui'));
}
$taxonomies = cptui_get_taxonomy_data();
/**
* Check if we already have a post type of that name.
*
* @since 1.3.0
*
* @param bool $value Assume we have no conflict by default.
* @param string $value Post type slug being saved.
* @param array $post_types Array of existing post types from CPTUI.
*/
$slug_exists = apply_filters('cptui_taxonomy_slug_exists', false, $data['cpt_custom_tax']['name'], $taxonomies);
if ('new' == $data['cpt_tax_status']) {
if (true === $slug_exists) {
return cptui_admin_notices('error', '', false, sprintf(__('Please choose a different taxonomy name. %s is already registered.', 'custom-post-type-ui'), $data['cpt_custom_tax']['name']));
}
}
foreach ($data['cpt_tax_labels'] as $key => $label) {
if (empty($label)) {
unset($data['cpt_tax_labels'][$key]);
}
$label = str_replace('"', '', htmlspecialchars_decode($label));
$label = htmlspecialchars($label, ENT_QUOTES);
$label = trim($label);
$data['cpt_tax_labels'][$key] = stripslashes_deep($label);
}
$label = ucwords(str_replace('_', ' ', $data['cpt_custom_tax']['name']));
if (!empty($data['cpt_custom_tax']['label'])) {
$label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_tax']['label']));
$label = htmlspecialchars(stripslashes($label), ENT_QUOTES);
}
$name = trim($data['cpt_custom_tax']['name']);
$singular_label = ucwords(str_replace('_', ' ', $data['cpt_custom_tax']['name']));
if (!empty($data['cpt_custom_tax']['singular_label'])) {
$singular_label = str_replace('"', '', htmlspecialchars_decode($data['cpt_custom_tax']['singular_label']));
$singular_label = htmlspecialchars(stripslashes($singular_label));
}
$description = stripslashes_deep($data['cpt_custom_tax']['description']);
$query_var_slug = trim($data['cpt_custom_tax']['query_var_slug']);
$rewrite_slug = trim($data['cpt_custom_tax']['rewrite_slug']);
$rest_base = trim($data['cpt_custom_tax']['rest_base']);
$show_quickpanel_bulk = !empty($data['cpt_custom_tax']['show_in_quick_edit']) ? disp_boolean($data['cpt_custom_tax']['show_in_quick_edit']) : '';
$taxonomies[$data['cpt_custom_tax']['name']] = array('name' => $name, 'label' => $label, 'singular_label' => $singular_label, 'description' => $description, 'public' => disp_boolean($data['cpt_custom_tax']['public']), 'hierarchical' => disp_boolean($data['cpt_custom_tax']['hierarchical']), 'show_ui' => disp_boolean($data['cpt_custom_tax']['show_ui']), 'query_var' => disp_boolean($data['cpt_custom_tax']['query_var']), 'query_var_slug' => $query_var_slug, 'rewrite' => disp_boolean($data['cpt_custom_tax']['rewrite']), 'rewrite_slug' => $rewrite_slug, 'rewrite_withfront' => $data['cpt_custom_tax']['rewrite_withfront'], 'rewrite_hierarchical' => $data['cpt_custom_tax']['rewrite_hierarchical'], 'show_admin_column' => disp_boolean($data['cpt_custom_tax']['show_admin_column']), 'show_in_rest' => disp_boolean($data['cpt_custom_tax']['show_in_rest']), 'show_in_quick_edit' => $show_quickpanel_bulk, 'rest_base' => $rest_base, 'labels' => $data['cpt_tax_labels']);
$taxonomies[$data['cpt_custom_tax']['name']]['object_types'] = $data['cpt_post_types'];
/**
* Filters whether or not 3rd party options were saved successfully within taxonomy add/update.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else saved successfully. Default false.
* @param array $taxonomies Array of our updated taxonomies data.
* @param array $data Array of submitted taxonomy to update.
*/
if (false === ($success = apply_filters('cptui_taxonomy_update_save', false, $taxonomies, $data))) {
$success = update_option('cptui_taxonomies', $taxonomies);
}
/**
* Fires after a taxonomy is updated to our saved options.
*
//.........这里部分代码省略.........
示例14: cptui_listings
//.........这里部分代码省略.........
echo admin_url('admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type);
?>
"><?php
echo $post_type;
?>
</a><br/><hr/>
<a href="<?php
echo admin_url('admin.php?page=cptui_manage_post_types&action=edit&cptui_post_type=' . $post_type);
?>
"><?php
_e('Edit', 'cpt-plugin');
?>
</a>
<?php
if ($archive) {
?>
|
<a href="<?php
echo get_post_type_archive_link($post_type);
?>
"><?php
_e('View frontend archive', 'cpt-plugin');
?>
</a>
<?php
}
?>
</td>
<td>
<?php
foreach ($strings as $key => $value) {
printf('<strong>%s:</strong> ', $key);
if (in_array($value, array('1', '0'))) {
echo disp_boolean($value);
} else {
echo $value;
}
echo '<br/>';
}
?>
</td>
<td>
<?php
foreach ($supports['supports'] as $support) {
echo $support . '<br/>';
}
?>
</td>
<td>
<?php
foreach ($taxonomies['taxonomies'] as $taxonomy) {
echo $taxonomy . '<br/>';
}
?>
</td>
<td>
<?php
$maybe_empty = array_filter($post_type_settings['labels']);
if (!empty($maybe_empty)) {
foreach ($post_type_settings['labels'] as $key => $value) {
echo $key . ': ' . $value . '<br/>';
}
} else {
_e('No custom labels to display', 'cpt-plugin');
}
?>
示例15: cptui_get_single_post_type_registery
/**
* Create output for single post type to be ready for copy/paste from Get Code.
*
* @since 1.0.0
*
* @param array $post_type Post type data to output.
* @return string Copy/paste ready "php" code.
*/
function cptui_get_single_post_type_registery($post_type = array())
{
/** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
$post_type['map_meta_cap'] = apply_filters('cptui_map_meta_cap', 'true', $post_type['name'], $post_type);
/** This filter is documented in custom-post-type-ui/custom-post-type-ui.php */
$user_supports_params = apply_filters('cptui_user_supports_params', array(), $post_type['name'], $post_type);
if (is_array($user_supports_params)) {
$post_type['supports'] = array_merge($post_type['supports'], $user_supports_params);
}
$yarpp = false;
// Prevent notices.
if (!empty($post_type['custom_supports'])) {
$custom = explode(',', $post_type['custom_supports']);
foreach ($custom as $part) {
// We'll handle YARPP separately.
if (in_array($part, array('YARPP', 'yarpp'))) {
$yarpp = true;
continue;
}
$post_type['supports'][] = $part;
}
}
$rewrite_withfront = '';
$rewrite = get_disp_boolean($post_type['rewrite']);
if (false !== $rewrite) {
$rewrite = disp_boolean($post_type['rewrite']);
$rewrite_slug = ' "slug" => "' . $post_type['name'] . '",';
if (!empty($post_type['rewrite_slug'])) {
$rewrite_slug = ' "slug" => "' . $post_type['rewrite_slug'] . '",';
}
$withfront = disp_boolean($post_type['rewrite_withfront']);
if (!empty($withfront)) {
$rewrite_withfront = ' "with_front" => ' . $withfront . ' ';
}
if (!empty($post_type['rewrite_slug']) || !empty($post_type['rewrite_withfront'])) {
$rewrite_start = 'array(';
$rewrite_end = ')';
$rewrite = $rewrite_start . $rewrite_slug . $rewrite_withfront . $rewrite_end;
}
} else {
$rewrite = disp_boolean($post_type['rewrite']);
}
$supports = '';
// Do a little bit of php work to get these into strings.
if (!empty($post_type['supports']) && is_array($post_type['supports'])) {
$supports = 'array( "' . implode('", "', $post_type['supports']) . '" )';
}
if (in_array('none', $post_type['supports'])) {
$supports = 'false';
}
$taxonomies = '';
if (!empty($post_type['taxonomies']) && is_array($post_type['taxonomies'])) {
$taxonomies = 'array( "' . implode('", "', $post_type['taxonomies']) . '" )';
}
if (in_array($post_type['query_var'], array('true', 'false', '0', '1'))) {
$post_type['query_var'] = disp_boolean($post_type['query_var']);
}
if (!empty($post_type['query_var_slug'])) {
$post_type['query_var'] = '"' . $post_type['query_var_slug'] . '"';
}
if (empty($post_type['show_in_rest'])) {
$post_type['show_in_rest'] = 'false';
}
$post_type['description'] = addslashes($post_type['description']);
$my_theme = wp_get_theme();
$textdomain = $my_theme->get('TextDomain');
?>
$labels = array(
"name" => __( '<?php
echo $post_type['label'];
?>
', '<?php
echo $textdomain;
?>
' ),
"singular_name" => __( '<?php
echo $post_type['singular_label'];
?>
', '<?php
echo $textdomain;
?>
' ),
<?php
foreach ($post_type['labels'] as $key => $label) {
if (!empty($label)) {
echo '"' . $key . '" => __( \'' . $label . '\', \'' . $textdomain . '\' ),' . "\n\t\t";
}
}
?>
);
$args = array(
//.........这里部分代码省略.........