edit-form-ajax-cat.php

来自「php 开发的内容管理系统」· PHP 代码 · 共 38 行

PHP
38
字号
<?phprequire_once('../wp-config.php');require_once('admin-functions.php');require_once('admin-db.php');if ( !current_user_can('manage_categories') )	die('-1');if ( !check_ajax_referer() )	die('-1');function get_out_now() { exit; }add_action('shutdown', 'get_out_now', -1);$names = explode(',', rawurldecode($_POST['ajaxnewcat']) );$ids   = array();foreach ($names as $cat_name) {	$cat_name = trim( $cat_name );		if ( !$category_nicename = sanitize_title($cat_name) )		continue;	if ( $already = category_exists($cat_name) ) {		$ids[] = (string) $already;		continue;	}		$new_cat_id = wp_create_category($cat_name);		$ids[] = (string) $new_cat_id;}$return = join(',', $ids);die( (string) $return );?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?