📜  自定义 api 端点 jwt 令牌 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:17.244000             🧑  作者: Mango

代码示例1
add_action('rest_api_init', function ($data) {
        register_rest_route('mladi-info/v1', '/user/favorites', 
            array(
                'methods' => 'GET',
                'callback' => 'mi_get_favorite_posts',
                'permission_callback' => function ($request) {
                        if (current_user_can('edit_others_posts'))
                        return true;
                 }
             )
        );
    });