/** * Process a single post ID (this is an AJAX handler) * * @SuppressWarnings(PHPMD.ExitExpression) * @SuppressWarnings(PHPMD.Superglobals) */ public static function ajax_process_post() { if (!wps_get_option('debug_mode')) { error_reporting(0); // Don't break the JSON result header('Content-type: application/json'); self::$post_id = intval($_REQUEST['id']); } $post = get_post(self::$post_id); if (!$post || !in_array($post->post_type, self::$post_types)) { die(json_encode(array('error' => sprintf(esc_html__('Failed Processing: %s is incorrect post type.', 'wordpress-starter'), esc_html(self::$post_id))))); } self::do_something(self::$post_id, $post); die(json_encode(array('success' => sprintf(__('"<a href="%1$s" target="_blank">%2$s</a>" Post ID %3$s was successfully processed in %4$s seconds.', 'wordpress-starter'), get_permalink(self::$post_id), esc_html(get_the_title(self::$post_id)), self::$post_id, timer_stop())))); }