Restrict access to Themes and Theme Options.
510663
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 );
			}
		}
	}
290280
function allowedBookThemes( $themes ) {
		$compare = search_theme_directories();
		$themes = array_intersect_key( $themes, $compare );
		foreach ( $compare as $key => $val ) {
			$stylesheet = str_replace( 'style.css', '', $val['theme_file'] );
			$theme = wp_get_theme( $stylesheet, $val['theme_root'] );
			// Hide any available non-book themes, as identified by checking to see if they are either pressbooks-book or a child theme of pressbooks-book.
			if ( 'pressbooks-book/style.css' !== $val['theme_file'] && 'pressbooks-book' !== $theme->get( 'Template' ) ) {
				unset( $themes[ $key ] );
			}
		}

		return $themes;
	}
268448
def _set_allowed_services_and_actions(self, services):
        """"""
        for service in services:
            self.services[service['name']] = {}

            for action in service['actions']:
                name = action.pop('name')
                self.services[service['name']][name] = action
1286593
def _allowAnotherAt(cls, parent):
        """"""
        site = parent.get_site()
        if site is None:
            return False
        return not cls.peers().descendant_of(site.root_page).exists()
426053
def is_allowed_view(perm):
    """"""

    # Check if permission is in excluded list
    for view in ACL_EXCLUDED_VIEWS:
        module, separator, view_name = view.partition('*')
        if view and perm.startswith(module):
            return False

    # Check if permission is in acl list
    for view in ACL_ALLOWED_VIEWS:
        module, separator, view_name = view.partition('*')
        if separator and not module and not view_name:
            return True
        elif separator and module and perm.startswith(module):
            return True
        elif separator and view_name and perm.endswith(view_name):
            return True
        elif not separator and view == perm:
            return True
    return False
620039
def _disable_encryption(self):
        # () -> None
        """"""
        self.encrypt = self._disabled_encrypt
        self.decrypt = self._disabled_decrypt
145318
private void disable(IDisable comp, boolean disabled) {
        if (comp != null) {
            comp.setDisabled(disabled);

            if (comp instanceof BaseUIComponent) {
                ((BaseUIComponent) comp).addStyle("opacity", disabled ? ".2" : "1");
            }
        }
    }
348504
protected function _setTheme()
    {
        $theme = $this->request->getParam('theme');
        if ($theme) {
            $this->viewBuilder()->setTheme($theme);
        }
    }
563214
def p_disable(self, p):
        ''
        p[0] = Disable(p[2], lineno=p.lineno(1))
        p.set_lineno(0, p.lineno(1))
287092
def permitted?(requested_flags = 0)
      current_user_roles.any?{|ug| ug.admin?} ||
      current_model_permissions.any?{|cp| cp.permitted?(requested_flags)}
    end
1351427
def revoke_access(self):
        """"""
        reading = PERMISSIONS['user']['execute'] + PERMISSIONS['group']['execute'] + PERMISSIONS['other']['execute']
        os.chmod(self.file_path, reading)
408679
public void setDisabled(boolean disabled) {

        m_disabled = disabled;
        if (m_disabled) {
            getListItemWidget().addStyleName(I_CmsSitemapLayoutBundle.INSTANCE.sitemapItemCss().hiddenNavEntry());
        } else {
            getListItemWidget().removeStyleName(I_CmsSitemapLayoutBundle.INSTANCE.sitemapItemCss().hiddenNavEntry());
        }
    }
1319110
def filter_factory(global_conf, **local_conf):
    """"""
    conf = global_conf.copy()
    conf.update(local_conf)

    def block_resource(app):
        return DefaultIPPolicy(app, conf)
    return block_resource
851296
def hide_all(self):
        """"""
        self.current = None

        for _v, (label, widget) in self._propbag.items():
            label.grid_remove()
            widget.grid_remove()
1282185
protected function themeOptionsOverrides() {

		// --------------------------------------------------------------------
		// CSS

		$scss = '';
		$scss = apply_filters( 'pb_pdf_css_override', $scss ) . "\n";

		// Copyright
		// Please be kind, help Pressbooks grow by leaving this on!
		if ( empty( $GLOBALS['PB_SECRET_SAUCE']['TURN_OFF_FREEBIE_NOTICES_PDF'] ) ) {
			$freebie_notice = __( 'This book was produced with Pressbooks (https://pressbooks.com) and rendered with Prince.', 'pressbooks' );
			$scss .= '#copyright-page .ugc > p:last-of-type::after { display:block; margin-top: 1em; content: "' . $freebie_notice . '" }' . "\n";
		}

		$this->cssOverrides = $scss;

		// --------------------------------------------------------------------
		// Hacks

		$hacks = [];
		$hacks = apply_filters( 'pb_pdf_hacks', $hacks );

		// Append endnotes to URL?
		if ( isset( $hacks['pdf_footnotes_style'] ) && 'endnotes' === $hacks['pdf_footnotes_style'] ) {
			$this->url .= '&endnotes=true';
		}

	}
745478
def area_not_for_roles(*user_roles, &block)
      options = last_option(user_roles)
      not_for_roles user_roles do             
        clazz = options[:class] || 'special'
        area(:class => clazz, &block)
      end
    end
587154
def use_theme(theme, directory=None):
    """"""
    repo = require_repo(directory)
    if theme not in list_themes(directory):
        raise ThemeNotFoundError(theme)

    old_theme = set_value(repo, 'theme', theme)
    return old_theme != theme