public function restrictThemeManagement() {
		$locked = $this->isLocked();
		if ( $locked ) {
			$data = $this->getLockData();

			// Redirect and notify users of theme lock status.

			$check_against_url = wp_parse_url( ( is_ssl() ? 'http://' : 'https://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], PHP_URL_PATH );
			$redirect_url = get_site_url( get_current_blog_id(), '/wp-admin/' );

			// ---------------------------------------------------------------------------------------------------------------
			// Don't let user go to theme (options) page, under any circumstance

			$restricted = [
				'themes',
			];

			$expr = '~/wp-admin/(' . implode( '|', $restricted ) . ')\.php$~';
			if ( preg_match( $expr, $check_against_url ) ) {
				$_SESSION['pb_errors'][] = sprintf(
					__( 'Your book&rsquo;s theme, %1$s, was locked in its current state as of %2$s at %3$s. To select a new theme or change your theme options, please %4$s.', 'pressbooks' ),
					$data['name'],
					strftime( '%x', $data['timestamp'] ),
					strftime( '%X', $data['timestamp'] ),
					sprintf(
						'<a href="%s">%s</a>',
						admin_url( 'options-general.php?page=pressbooks_export_options' ),
						'unlock your theme'
					)
				);
				\Pressbooks\Redirect\location( $redirect_url );
			}
		}
	}
public function restrictThemeManagement() {
		$locked = $this->isLocked();
		if ( $locked ) {
			$data = $this->getLockData();

			// Redirect and notify users of theme lock status.

			$check_against_url = wp_parse_url( ( is_ssl() ? 'http://' : 'https://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'], PHP_URL_PATH );
			$redirect_url = get_site_url( get_current_blog_id(), '/wp-admin/' );

			// ---------------------------------------------------------------------------------------------------------------
			// Don't let user go to theme (options) page, under any circumstance

			$restricted = [
				'themes',
			];

			$expr = '~/wp-admin/(' . implode( '|', $restricted ) . ')\.php$~';
			if ( preg_match( $expr, $check_against_url ) ) {
				$_SESSION['pb_errors'][] = sprintf(
					__( 'Your book&rsquo;s theme, %1$s, was locked in its current state as of %2$s at %3$s. To select a new theme or change your theme options, please %4$s.', 'pressbooks' ),
					$data['name'],
					strftime( '%x', $data['timestamp'] ),
					strftime( '%X', $data['timestamp'] ),
					sprintf(
						'<a href="%s">%s</a>',
						admin_url( 'options-general.php?page=pressbooks_export_options' ),
						'unlock your theme'
					)
				);
				\Pressbooks\Redirect\location( $redirect_url );
			}
		}
	}
public function restrictThemeManagement ( ) { $ locked = $ this -> isLocked ( ) ; if ( $ locked ) { $ data = $ this -> getLockData ( ) ; // Redirect and notify users of theme lock status. $ check_against_url = wp_parse_url ( ( is_ssl ( ) ? 'http://' : 'https://' ) . $ _SERVER [ 'HTTP_HOST' ] . $ _SERVER [ 'REQUEST_URI' ] , PHP_URL_PATH ) ; $ redirect_url = get_site_url ( get_current_blog_id ( ) , '/wp-admin/' ) ; // --------------------------------------------------------------------------------------------------------------- // Don't let user go to theme (options) page, under any circumstance $ restricted = [ 'themes' , ] ; $ expr = '~/wp-admin/(' . implode ( '|' , $ restricted ) . ')\.php$~' ; if ( preg_match ( $ expr , $ check_against_url ) ) { $ _SESSION [ 'pb_errors' ] [ ] = sprintf ( __ ( 'Your book&rsquo;s theme, %1$s, was locked in its current state as of %2$s at %3$s. To select a new theme or change your theme options, please %4$s.' , 'pressbooks' ) , $ data [ 'name' ] , strftime ( '%x' , $ data [ 'timestamp' ] ) , strftime ( '%X' , $ data [ 'timestamp' ] ) , sprintf ( '<a href="%s">%s</a>' , admin_url ( 'options-general.php?page=pressbooks_export_options' ) , 'unlock your theme' ) ) ; \ Pressbooks \ Redirect \ location ( $ redirect_url ) ; } } }
Restrict access to Themes and Theme Options.
Restrict access to Themes and Theme Options .