User may set default filter, find it
@return void
338722
public function findDefaultFilter()
	{
		if (!empty($this->filter)) {
			return;
		}

		if ($this->getSessionData('_grid_has_filtered')) {
			return;
		}

		if (!empty($this->default_filter)) {
			$this->filter = $this->default_filter;
		}

		foreach ($this->filter as $key => $value) {
			$this->saveSessionData($key, $value);
		}
	}
393242
protected function setup_filters() {
        $readers = $this->get_readers();

        // Set up filters.
        $filter = new \stdClass();
        if (!empty($this->course)) {
            $filter->courseid = $this->course->id;
        } else {
            $filter->courseid = 0;
        }
        $filter->logreader = $readers[$this->selectedlogreader];
        $filter->date = $this->date;
        $filter->orderby = $this->order;
        $filter->anonymous = 0;

        return $filter;
    }
1080326
protected function set_defaults()
	{
		$this->options   = $this->default_options;
		$this->params    = $this->default_params;
		return $this;
	}
104528
public function setFilter($filter)
    {
        parent::setFilter($filter);

        $this->userOptions['value'] = $this->validator->arrayGet($filter, 'value', '');

        //if it isn't null, we have to check the 'true'/'false' string
        if ($this->userOptions['value'] !== '') {
            $this->userOptions['value'] = $this->userOptions['value'] === 'false' || !$this->userOptions['value'] ? 0 : 1;
        }
    }
793037
protected function setParamsFilters()
    {
        if ($this->arParams['IBLOCK_TYPE'])
        {
            $this->filterParams['IBLOCK_TYPE'] = $this->arParams['IBLOCK_TYPE'];
        }

        if ($this->arParams['IBLOCK_ID'])
        {
            $this->filterParams['IBLOCK_ID'] = $this->arParams['IBLOCK_ID'];
        }

        if ($this->arParams['SECTION_CODE'])
        {
            $this->filterParams['SECTION_CODE'] = $this->arParams['SECTION_CODE'];
        }
        elseif ($this->arParams['SECTION_ID'])
        {
            $this->filterParams['SECTION_ID'] = $this->arParams['SECTION_ID'];
        }

        if ($this->arParams['INCLUDE_SUBSECTIONS'] === 'Y')
        {
            $this->filterParams['INCLUDE_SUBSECTIONS'] = 'Y';
        }

        if ($this->arParams['ELEMENT_CODE'])
        {
            $this->filterParams['CODE'] = $this->arParams['ELEMENT_CODE'];
        }
        elseif ($this->arParams['ELEMENT_ID'])
        {
            $this->filterParams['ID'] = $this->arParams['ELEMENT_ID'];
        }

        if ($this->arParams['CHECK_PERMISSIONS'])
        {
            $this->filterParams['CHECK_PERMISSIONS'] = $this->arParams['CHECK_PERMISSIONS'];
        }

        if (!isset($this->filterParams['ACTIVE']))
        {
            $this->filterParams['ACTIVE'] = 'Y';
        }

        if (strlen($this->arParams['EX_FILTER_NAME']) > 0
            && preg_match("/^[A-Za-z_][A-Za-z01-9_]*$/", $this->arParams['EX_FILTER_NAME'])
            && is_array($GLOBALS[$this->arParams['EX_FILTER_NAME']])
        )
        {
            $this->filterParams = array_merge_recursive($this->filterParams, $GLOBALS[$this->arParams['EX_FILTER_NAME']]);

            $this->addCacheAdditionalId($GLOBALS[$this->arParams['EX_FILTER_NAME']]);
        }
    }
1111625
private function _setDefaults()
    {
        if (!isset(self::$_template))
            self::_initializeDefaults();
        foreach (self::$_template as $k=>$v) {
            if ($k[0] != '_')
                $this->$k = $v;
        }
        return $this;
    }
1166766
protected function setDefault()
    {
        if (strpos($this->input, '=')) {
            list($this->input, $this->default) = explode('=', $this->input);

            $this->modeArray[] = 'OPTIONAL';
        }

        return $this;
    }
776247
protected function get_filter_value($filtername, $default = null) {
        if ($values = $this->get_filter_values($filtername)) {
            $value = reset($values);
            return $value;
        }
        return $default;
    }
1217630
public static function addDefault()
    {
        static::$methods['null'] = function ($str) {
            return $str === null || $str === '';
        };
        static::$methods['len'] = function ($str, $min, $max = null) {
            $len = strlen($str);
            return null === $max ? $len === $min : $len >= $min && $len <= $max;
        };
        static::$methods['int'] = function ($str) {
            return (string)$str === ((string)(int)$str);
        };
        static::$methods['float'] = function ($str) {
            return (string)$str === ((string)(float)$str);
        };
        static::$methods['email'] = function ($str) {
            return filter_var($str, FILTER_VALIDATE_EMAIL) !== false;
        };
        static::$methods['url'] = function ($str) {
            return filter_var($str, FILTER_VALIDATE_URL) !== false;
        };
        static::$methods['ip'] = function ($str) {
            return filter_var($str, FILTER_VALIDATE_IP) !== false;
        };
        static::$methods['remoteip'] = function ($str) {
            return filter_var($str, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false;
        };
        static::$methods['alnum'] = function ($str) {
            return ctype_alnum($str);
        };
        static::$methods['alpha'] = function ($str) {
            return ctype_alpha($str);
        };
        static::$methods['contains'] = function ($str, $needle) {
            return strpos($str, $needle) !== false;
        };
        static::$methods['regex'] = function ($str, $pattern) {
            return preg_match($pattern, $str);
        };
        static::$methods['chars'] = function ($str, $chars) {
            return preg_match("/^[$chars]++$/i", $str);
        };

        static::$default_added = true;
    }
1298635
public function getFiltersMode()
    {
        if (null === $this->filtersMode) {
            $this->filtersMode = $this->getGenerator()->getFromYaml('builders.list.params.filtersMode', 'default');
        }

        return $this->filtersMode;
    }
1142712
public function resetFilters()
    {
        $this->filters = [];

        if ($this->endDate !== null) {
            $this->filters[] = [static::END_DATE_FILTER, null];
        }

        if ($this->recurrences !== null) {
            $this->filters[] = [static::RECURRENCES_FILTER, null];
        }

        $this->handleChangedParameters();

        return $this;
    }
145855
protected function set_defaults()
	{
		parent::set_defaults();
		$this->headers = array();

		if ( ! empty($this->preserve_resource))
		{
			$this->resource = $this->preserve_resource;
			$this->preserve_resource = null;
		}

		return $this;
	}
595674
static function filterDefaults( $defaults ) {

		// SASS => WP
		$overrides = [
			'examples-header-color' => 'edu_textbox_examples_header_color',
			'examples-header-background' => 'edu_textbox_examples_header_background',
			'examples-background' => 'edu_textbox_examples_background',
			'exercises-header-color' => 'edu_textbox_exercises_header_color',
			'exercises-header-background' => 'edu_textbox_exercises_header_background',
			'exercises-background' => 'edu_textbox_exercises_background',
			'learning-objectives-header-color' => 'edu_textbox_objectives_header_color',
			'learning-objectives-header-background' => 'edu_textbox_objectives_header_background',
			'learning-objectives-background' => 'edu_textbox_objectives_background',
			'key-takeaways-header-color' => 'edu_textbox_takeaways_header_color',
			'key-takeaways-header-background' => 'edu_textbox_takeaways_header_background',
			'key-takeaways-background' => 'edu_textbox_takeaways_background',
		];

		$transient_name = 'pressbooks_theme_options_global_parsed_sass_variables';
		$parsed_sass_variables = get_transient( $transient_name );
		if ( $parsed_sass_variables === false ) {
			// Order of files matter. If a variable is duplicated in other files then the last one takes precedence
			$parsed_sass_variables = [];
			$sass = Container::get( 'Sass' );
			$path_to_global = $sass->pathToGlobals();
			$path_to_theme = get_stylesheet_directory();
			$files = [
				$path_to_global . '/variables/_specials.scss',
				$path_to_theme . '/assets/styles/components/_specials.scss',
			];
			foreach ( $files as $file ) {
				if ( file_exists( $file ) ) {
					$parsed_sass_variables[] = $sass->parseVariables( \Pressbooks\Utility\get_contents( $file ) );
				}
			}
			set_transient( $transient_name, $parsed_sass_variables );
		}

		foreach ( $parsed_sass_variables as $parsed_variables ) {
			foreach ( $overrides as $sass_var => $wp_option ) {
				if ( isset( $parsed_variables[ $sass_var ] ) ) {
					if ( ! empty( $parsed_variables[ $sass_var ] ) ) {
						$defaults[ $wp_option ] = $parsed_variables[ $sass_var ]; // Override default with new value
					}
				}
			}
		}

		return $defaults;
	}
944119
private static function setDefaults() {
            if (!self::$defaults) {
                self::$defaults =
                    [self::CFG_CSS_PATH           => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' .
                                                     DIRECTORY_SEPARATOR . 'error.min.css',
                     self::CFG_TRACE_MAX_DEPTH    => 50,
                     self::CFG_BACKGROUND         => 'default',
                     self::CFG_FOREGROUND_NOTICE  => 'cyan',
                     self::CFG_FOREGROUND_WARNING => 'yellow',
                     self::CFG_FOREGROUND_ERROR   => 'red',
                     self::CFG_FORCE_HTML         => false];
            }
        }
897461
public function getSearchDefaults()
    {
        if (! $this->defaultSearchData) {
            $inFormat = \MUtil_Model_Bridge_FormBridge::getFixedOption('date', 'dateFormat');
            $now      = new \MUtil_Date();
            $today    = $now->toString($inFormat);

            $this->defaultSearchData = array(
                'datefrom'    => $today,
                'dateused'    => '_gto_valid_from gto_valid_until',
                'dateuntil'   => $today,
                'main_filter' => '',
            );
        }

        return parent::getSearchDefaults();
    }
1097709
final public function isDefaultFilter($name)
    {
        $filter = $this->getFilterParameters();
        $default = $this->getDefaultFilterValues();

        if (!\array_key_exists($name, $filter) || !\array_key_exists($name, $default)) {
            return false;
        }

        return $filter[$name] === $default[$name];
    }
52825
public function getCurrentFilters()
    {
        $sessionValues = $this->session->get(Configuration::SESSION_PREFIX.'filters', null);

        return $sessionValues !== null ? $sessionValues : $this->getDefaultFilters();
    }