/** * Receive some content, run a remote analysis task and return the results. The content is read from the body * input (php://input). * * @since 1.0.0 * * @uses wl_analyze_content() to analyze the provided content. */ function wl_ajax_analyze_action() { if ($analysis = wl_analyze_content(file_get_contents("php://input"))) { header('Content-Type: application/json; charset=' . get_option('blog_charset')); echo $analysis; wp_die(); } status_header(500); wp_send_json(__('An error occurred while request an analysis to the remote service. Please try again later.', 'wordlift')); }
/** * Analyze the post with the specified ID. The analysis will make use of the method *wl_ajax_analyze_action* * provided by the WordLift plugin. * * @since 3.0.0 * * @param int $post_id The post ID to analyze. * * @return string Returns null on failure, or the WP_Error, or a WP_Response with the response. */ function wl_analyze_post($post_id) { // Get the post contents. $post = wl_get_post($post_id); if (null === $post) { return null; } $content = $post->post_content; return wl_analyze_content($content); }
/** * Receive some content, run a remote analysis task and return the results. The content is read from the body * input (php://input). * * @since 1.0.0 * * @uses wl_analyze_content() to analyze the provided content. */ function wl_ajax_analyze_action() { echo wl_analyze_content(file_get_contents("php://input")); wp_die(); }