flag( self::OPT_GRANT_STUDIO ); } /** * Whether WordPress administrators implicitly hold the instructor * capabilities (manage their own availability and lessons). */ public function adminsAreInstructors(): bool { return $this->flag( self::OPT_GRANT_INSTRUCTOR ); } /** * Read a stored toggle, defaulting to on so a fresh install keeps the * single-account behaviour. */ private function flag( string $option ): bool { return '0' !== Val::string( get_option( $option, '1' ) ); } public function renderPage(): void { if ( ! current_user_can( 'manage_options' ) ) { wp_die( esc_html__( 'You do not have permission to manage access settings.', 'unsupervised-schedular' ) ); } if ( isset( $_POST['usc_action'] ) && check_admin_referer( 'usc_access_action' ) ) { $this->save(); } $adminsAreStudioAdmins = $this->adminsAreStudioAdmins(); $adminsAreInstructors = $this->adminsAreInstructors(); include USC_PLUGIN_DIR . 'templates/admin/access.php'; } private function save(): void { // Nonce is verified by the caller (renderPage) before this method runs. // phpcs:disable WordPress.Security.NonceVerification.Missing update_option( self::OPT_GRANT_STUDIO, isset( $_POST['grant_studio'] ) ? '1' : '0' ); update_option( self::OPT_GRANT_INSTRUCTOR, isset( $_POST['grant_instructor'] ) ? '1' : '0' ); // phpcs:enable WordPress.Security.NonceVerification.Missing } }