[a-zA-Z0-9-]+)', [ 'methods' => 'GET', 'callback' => function($request) { $slug = $request['slug']; if (!function_exists('get_coauthors')) { return new WP_Error('no_plugin', 'Co-Authors Plus not active', ['status' => 404]); } global $coauthors_plus; // Метод 1: Через объект плагина (работает всегда) if (isset($coauthors_plus) && method_exists($coauthors_plus, 'get_coauthor_by')) { $coauthor = $coauthors_plus->get_coauthor_by('user_nicename', $slug); if ($coauthor) { return [ 'id' => $coauthor->user_nicename, 'name' => $coauthor->display_name, 'firstName' => $coauthor->first_name ?? '', 'lastName' => $coauthor->last_name ?? '', 'description' => $coauthor->description ?? '', 'avatar' => get_avatar_url($coauthor->user_email, ['size' => 192]), 'url' => get_author_posts_url($coauthor->ID, $coauthor->user_nicename), 'type' => $coauthor->type ?? 'guest-author' ]; } } return new WP_Error('not_found', 'Author not found', ['status' => 404]); }, 'permission_callback' => '__return_true' ]); });