函数文档

wp_ajax_press_this_save_post()

💡 云策文档标注

概述

wp_ajax_press_this_save_post() 是一个用于从 Press This 保存文章的 Ajax 处理函数,自 WordPress 4.9.0 起已被弃用。

关键要点

  • 该函数是 Press This 插件保存文章的 Ajax 处理程序,但已标记为弃用。
  • 函数内部检查 Press This 插件是否激活,若激活则调用其 save_post() 方法,否则返回 JSON 错误响应。
  • 相关函数包括 is_plugin_active()、__()、_deprecated_function() 和 wp_send_json_error()。

代码示例

function wp_ajax_press_this_save_post() {
    _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->save_post();
    } else {
        wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
    }
}

注意事项

  • 此函数自 WordPress 4.9.0 版本起已弃用,开发者应避免在新代码中使用,并考虑替代方案。
  • 函数依赖于 Press This 插件,若插件未激活,会返回错误消息。

📄 原文内容

Ajax handler for saving a post from Press This.

Source

function wp_ajax_press_this_save_post() {
	_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->save_post();
	} else {
		wp_send_json_error( array( 'errorMessage' => __( 'The Press This plugin is required.' ) ) );
	}
}

Changelog

Version Description
4.9.0 Deprecated.
4.2.0 Introduced.