本文整理汇总了PHP中cptui_admin_notices函数的典型用法代码示例。如果您正苦于以下问题:PHP cptui_admin_notices函数的具体用法?PHP cptui_admin_notices怎么用?PHP cptui_admin_notices使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cptui_admin_notices函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
示例2: 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);
}
示例3: cptui_import_types_taxes_settings
/**
* Import the posted JSON data from a separate export.
*
* @since 1.0.0
*
* @param array $postdata $_POST data as json.
*
* @return mixed false on nothing to do, otherwise void.
*/
function cptui_import_types_taxes_settings($postdata = array())
{
if (!isset($postdata['cptui_post_import']) && !isset($postdata['cptui_tax_import'])) {
return false;
}
$success = false;
if (!empty($postdata['cptui_post_import'])) {
$data = stripslashes_deep(trim($postdata['cptui_post_import']));
$settings = json_decode($data, true);
if ($settings) {
if (false !== get_option('cptui_post_types')) {
delete_option('cptui_post_types');
}
$success = update_option('cptui_post_types', $settings);
}
return cptui_admin_notices('import', __('Post types', 'cpt-plugin'), $success);
} elseif (!empty($postdata['cptui_tax_import'])) {
$data = stripslashes_deep(trim($postdata['cptui_tax_import']));
$settings = json_decode($data, true);
if ($settings) {
if (false !== get_option('cptui_taxonomies')) {
delete_option('cptui_taxonomies');
}
$success = update_option('cptui_taxonomies', $settings);
}
return cptui_admin_notices('import', __('Taxonomies', 'cpt-plugin'), $success);
}
flush_rewrite_rules();
return $success;
}
示例4: cptui_update_post_type
/**
* Add to or update our CPTUI option with new data.
*
* @since 1.0.0
*
* @internal
*
* @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', 'custom-post-type-ui'));
}
if (!empty($data['cpt_original']) && $data['cpt_original'] != $data['cpt_custom_post_type']['name']) {
if (!empty($data['update_post_types'])) {
cptui_convert_post_type_posts($data['cpt_original'], $data['cpt_custom_post_type']['name']);
}
}
// 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', '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']);
//.........这里部分代码省略.........
示例5: 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.
*
//.........这里部分代码省略.........
示例6: cptui_import_types_taxes_settings
/**
* Import the posted JSON data from a separate export.
*
* @since 1.0.0
*
* @internal
*
* @param array $postdata $_POST data as json.
* @return mixed false on nothing to do, otherwise void.
*/
function cptui_import_types_taxes_settings($postdata = array())
{
if (!isset($postdata['cptui_post_import']) && !isset($postdata['cptui_tax_import'])) {
return false;
}
$success = false;
/**
* Filters the post type data to import.
*
* Allows third parties to provide their own data dump and import instead of going through our UI.
*
* @since 1.2.0
*
* @param bool $value Default to no data.
*/
$third_party_post_type_data = apply_filters('cptui_third_party_post_type_import', false);
/**
* Filters the taxonomy data to import.
*
* Allows third parties to provide their own data dump and import instead of going through our UI.
*
* @since 1.2.0
*
* @param bool $value Default to no data.
*/
$third_party_taxonomy_data = apply_filters('cptui_third_party_taxonomy_import', false);
if (false !== $third_party_post_type_data) {
$postdata['cptui_post_import'] = $third_party_post_type_data;
}
if (false !== $third_party_taxonomy_data) {
$postdata['cptui_tax_import'] = $third_party_taxonomy_data;
}
if (!empty($postdata['cptui_post_import'])) {
$cpt_data = stripslashes_deep(trim($postdata['cptui_post_import']));
$settings = json_decode($cpt_data, true);
// Add support to delete settings outright, without accessing database.
// Doing double check to protect.
if (is_null($settings) && '{""}' === $cpt_data) {
/**
* Filters whether or not 3rd party options were deleted successfully within post type import.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else deleted successfully. Default false.
* @param array $postdata Post type data.
*/
if (false === ($success = apply_filters('cptui_post_type_import_delete_save', false, $postdata))) {
delete_option('cptui_post_types');
}
// We're technically successful in a sense. Importing nothing.
$success = true;
}
if ($settings) {
if (false !== cptui_get_post_type_data()) {
/** This filter is documented in /inc/import-export.php */
if (false === ($success = apply_filters('cptui_post_type_import_delete_save', false, $postdata))) {
delete_option('cptui_post_types');
}
}
/**
* Filters whether or not 3rd party options were updated successfully within the post type import.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else updated successfully. Default false.
* @param array $postdata Post type data.
*/
if (false === ($success = apply_filters('cptui_post_type_import_update_save', false, $postdata))) {
$success = update_option('cptui_post_types', $settings);
}
}
// Used to help flush rewrite rules on init.
set_transient('cptui_flush_rewrite_rules', 'true', 5 * 60);
return cptui_admin_notices('import', __('Post types', 'custom-post-type-ui'), $success);
} elseif (!empty($postdata['cptui_tax_import'])) {
$tax_data = stripslashes_deep(trim($postdata['cptui_tax_import']));
$settings = json_decode($tax_data, true);
// Add support to delete settings outright, without accessing database.
// Doing double check to protect.
if (is_null($settings) && '{""}' === $tax_data) {
/**
* Filters whether or not 3rd party options were deleted successfully within taxonomy import.
*
* @since 1.3.0
*
* @param bool $value Whether or not someone else deleted successfully. Default false.
* @param array $postdata Taxonomy data
*/
if (false === ($success = apply_filters('cptui_taxonomy_import_delete_save', false, $postdata))) {
delete_option('cptui_taxonomies');
//.........这里部分代码省略.........
示例7: cptui_import_types_taxes_settings
/**
* Import the posted JSON data from a separate export.
*
* @since 1.0.0
*
* @param array $postdata $_POST data as json.
*
* @return mixed false on nothing to do, otherwise void.
*/
function cptui_import_types_taxes_settings($postdata = array())
{
if (!isset($postdata['cptui_post_import']) && !isset($postdata['cptui_tax_import'])) {
return false;
}
$success = false;
/**
* Filters the post type data to import.
*
* Allows third parties to provide their own data dump and import instead of going through our UI.
*
* @since 1.2.0
*
* @param bool $value Default to no data.
*/
$third_party_post_type_data = apply_filters('cptui_third_party_post_type_import', false);
/**
* Filters the taxonomy data to import.
*
* Allows third parties to provide their own data dump and import instead of going through our UI.
*
* @since 1.2.0
*
* @param bool $value Default to no data.
*/
$third_party_taxonomy_data = apply_filters('cptui_third_party_taxonomy_import', false);
if (false !== $third_party_post_type_data) {
$postdata['cptui_post_import'] = $third_party_post_type_data;
}
if (false !== $third_party_taxonomy_data) {
$postdata['cptui_tax_import'] = $third_party_taxonomy_data;
}
if (!empty($postdata['cptui_post_import'])) {
$cpt_data = stripslashes_deep(trim($postdata['cptui_post_import']));
$settings = json_decode($cpt_data, true);
# Add support to delete settings outright, without accessing database.
# Doing double check to protect.
if (is_null($settings) && '{""}' === $cpt_data) {
delete_option('cptui_post_types');
# We're technically successful in a sense. Importing nothing.
$success = true;
}
if ($settings) {
if (false !== get_option('cptui_post_types')) {
delete_option('cptui_post_types');
}
$success = update_option('cptui_post_types', $settings);
}
return cptui_admin_notices('import', __('Post types', 'custom-post-type-ui'), $success);
} elseif (!empty($postdata['cptui_tax_import'])) {
$tax_data = stripslashes_deep(trim($postdata['cptui_tax_import']));
$settings = json_decode($tax_data, true);
# Add support to delete settings outright, without accessing database.
# Doing double check to protect.
if (is_null($settings) && '{""}' === $tax_data) {
delete_option('cptui_taxonomies');
# We're technically successful in a sense. Importing nothing.
$success = true;
}
if ($settings) {
if (false !== get_option('cptui_taxonomies')) {
delete_option('cptui_taxonomies');
}
$success = update_option('cptui_taxonomies', $settings);
}
return cptui_admin_notices('import', __('Taxonomies', 'custom-post-type-ui'), $success);
}
flush_rewrite_rules();
return $success;
}