pterotype/inc/api.php

19 lines
447 B
PHP
Raw Normal View History

2018-08-21 13:17:07 +00:00
<?php
2018-08-21 21:52:56 +00:00
namespace api;
require_once plugin_dir_path( __FILE__ ) . '/actors.php';
2018-08-21 13:17:07 +00:00
2018-08-22 12:33:06 +00:00
function get_user_actor( $data ) {
2018-08-21 13:17:07 +00:00
$handle = $data["handle"];
$id = get_user_by( 'slug', $handle );
2018-08-22 12:33:06 +00:00
return \actors\user_to_actor( $id );
2018-08-21 13:17:07 +00:00
}
2018-08-21 21:52:56 +00:00
function register_routes() {
2018-08-22 12:33:06 +00:00
register_rest_route( 'activitypub/v1', '/actor/(?P<handle>[a-zA-Z0-9-]+)', array(
2018-08-21 13:17:07 +00:00
'methods' => 'GET',
2018-08-22 12:33:06 +00:00
'callback' => __NAMESPACE__ . '\get_user_actor',
2018-08-21 13:17:07 +00:00
) );
2018-08-21 21:52:56 +00:00
}
2018-08-21 13:17:07 +00:00
?>