wp_ajax_press_this_add_category()
云策文档标注
概述
wp_ajax_press_this_add_category() 是一个用于从 Press This 创建新类别的 Ajax 处理函数,已在 WordPress 4.9.0 版本中被弃用。
关键要点
- 该函数已被弃用,使用 _deprecated_function() 标记,建议开发者避免在新代码中使用。
- 函数检查 Press This 插件是否激活,若激活则调用 WP_Press_This_Plugin 类的 add_category() 方法,否则返回 JSON 错误响应。
- 相关函数包括 is_plugin_active()、__()、_deprecated_function() 和 wp_send_json_error(),用于插件状态检查、翻译、弃用标记和错误响应。
注意事项
自 WordPress 4.9.0 起,此函数已弃用,开发者应寻找替代方案或更新代码以避免兼容性问题。
原文内容
Ajax handler for creating new category from Press This.
Source
function wp_ajax_press_this_add_category() {
_deprecated_function( __FUNCTION__, '4.9.0' );
if ( is_plugin_active( 'press-this/press-this-plugin.php' ) ) {
include WP_PLUGIN_DIR . '/press-this/class-wp-press-this-plugin.php';
$wp_press_this = new WP_Press_This_Plugin();
$wp_press_this->add_category();
} else {
wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
}
}