[A-Za-z0-9_:-]+)', array( 'methods' => \WP_REST_Server::READABLE, 'callback' => array( $this, 'show' ), 'permission_callback' => static function () { return current_user_can( 'edit_posts' ); }, 'args' => array( 'op_key' => OpKeys::schema( true ) ), ) ); } /** * Whether a write with the op key was applied, and its result. * * A write to a post the caller can't edit answers as if it was never * applied, so nothing about that post leaks. * * @param \WP_REST_Request $request Request. * @return \WP_REST_Response */ public function show( \WP_REST_Request $request ) { $op_key = (string) $request['op_key']; $found = OpKeys::find( $op_key ); if ( null === $found || ( $found['post_id'] && ! current_user_can( 'edit_post', $found['post_id'] ) ) ) { return rest_ensure_response( array( 'op_key' => $op_key, 'applied' => false, ) ); } return rest_ensure_response( array( 'op_key' => $op_key, 'applied' => true, 'kind' => $found['kind'], 'post_id' => $found['post_id'], 'result' => $found['result'], ) ); } }