maybe_upgrade(); add_filter('zadex/editor/can_edit', [Access::class, 'filter_can_edit'], 10, 2); add_filter('zadex/editor/config', [self::class, 'editor_config'], 10, 2); add_filter('zadex/documents/save_body', [ContentGuard::class, 'filter_save'], 10, 3); add_filter('rest_request_before_callbacks', [RestGuard::class, 'before_callbacks'], 10, 3); add_action('rest_api_init', static function (): void { (new NotesController())->routes(); }); add_action('deleted_post', static function ($post_id): void { (new Notes())->delete_for_post((int) $post_id); }); if (is_admin()) { (new RoleManagerPage())->register(); } } /** `zadex/editor/config`: the user's access mode and the notes settings. */ public static function editor_config(array $config, $post_id = 0): array { $config['user'] = is_array($config['user'] ?? null) ? $config['user'] : []; $config['user']['accessMode'] = Access::mode(); $config['notes'] = [ 'pollInterval' => (int) apply_filters('zadex/notes/poll_interval', 30), 'emails' => Mentions::emails_enabled(), ]; return $config; } }