Get plugin data filtered by plugin slug pattern.

@since 2.2.1

@param  string $pattern A regex pattern used to filter the plugin data array.
@return array
965175
public static function getFiltered( $pattern = '' ) {
		if ( ! function_exists( 'get_plugins' ) ) {
			require_once ABSPATH . 'wp-admin/includes/plugin.php';
		}

		$plugins = get_plugins();

		if ( empty( $pattern ) ) {
			return $plugins;
		}

		$filtered = array();

		foreach ( $plugins as $slug => $data ) {
			if ( preg_match( '#' . $pattern . '#', $slug ) ) {
				$filtered[ $slug ] = $data;
			}
		}

		return $filtered;
	}
975847
protected function matchesPattern($pattern)
	{
		trigger_error('Function ' . __METHOD__ . ' not implemented yet');

		$regexEncoding = $this->regexEncoding();
		$this->regexEncoding($this->encoding);

		$match = \mb_ereg_match($pattern, $this->str);
		$this->regexEncoding($regexEncoding);

		return $match;
	}
317910
public function getNonVariables($pattern) {
        $exp = explode('/',$pattern);
        $retorno = [];
        foreach($exp as $i => $v) {
            if(!preg_match('/^[\:]/i', $v)) {
                $retorno[$i] = $v;
            }
        }

        return $retorno;
    }
643872
public function filter($data)
    {
        // filtering and sorting
        if ($this->options['plugins-only']) {
            unset($data['themes']);
        }
        if ($this->options['themes-only']) {
            unset($data['plugins']);
        }

        $filter = [
            $this->options['filter'],
            $this->options['installed-only'],
            $this->options['updates-only'],
            $this->options['desc']
        ];

        if (\count(array_filter($filter))) {
            foreach ($data as $type => $packages) {
                foreach ($packages as $slug => $package) {
                    $filter = true;

                    // Filtering by string
                    if ($this->options['filter']) {
                        $filter = preg_grep('/(' . implode('|', $this->options['filter']) . ')/i', [$slug, $package->name]);
                    }

                    // Filtering updatables only
                    if ($filter && $this->options['installed-only']) {
                        $method = ucfirst(preg_replace('/s$/', '', $package->package_type));
                        $function = 'is' . $method . 'Installed';
                        $filter = $this->gpm->{$function}($package->slug);
                    }

                    // Filtering updatables only
                    if ($filter && $this->options['updates-only']) {
                        $method = ucfirst(preg_replace('/s$/', '', $package->package_type));
                        $function = 'is' . $method . 'Updatable';
                        $filter = $this->gpm->{$function}($package->slug);
                    }

                    if (!$filter) {
                        unset($data[$type][$slug]);
                    }
                }
            }
        }

        return $data;
    }
615852
protected function getRegExpForPattern(string $pattern) : string
    {
        $patternReplaced = str_replace(['*', '?'], ["\nA\n", "\nQ\n"], $pattern);
        $patternReplaced = preg_quote($patternReplaced, '/');
        $patternReplaced = str_replace(["\nA\n", "\nQ\n"], ['.*', '.'], $patternReplaced);

        return '/^' . $patternReplaced . '$/';
    }
933689
private function pattern_to_regex($pattern)
    {
        if (substr($pattern, -1) == '/') {
            $pattern .= '**';
        }

        $regex = '|^';
        foreach (explode('/', $pattern) as $i => $piece) {
            if ($i > 0) {
                $regex .= preg_quote('/', '|');
            }

            if ('**' == $piece) {
                $regex .= '.*';
            } else {
                $regex .= str_replace(array('?', '*'), array('[^/]', '[^/]*'), $piece);
            }
        }
        $regex .= '$|';

        return $regex;
    }
291688
public function rule($pattern)
    {
        $rewrite = $this->container->make(Rewrite::class);

        $rewrite->setPattern($pattern);

        return $this->hang($rewrite);
    }
364263
public static function filterArrayValuesWithPattern(array $values, $pattern)
    {
        return array_values(
            array_filter(
                array_map(function ($key) use ($pattern) {
                    if ((bool) preg_match('/'.$pattern.'/', $key)) {
                        return $key;
                    }
                }, $values)
            )
        );
    }
716084
public function pubSubChannels($pattern = null) {
        $payload = ['pubsub', 'channels'];

        if ($pattern !== null) {
            $payload[] = $pattern;
        }

        return $this->send($payload);
    }
1178960
public function parse($pattern, array $patterns = []) {
        return $this->matcher->parse(
            $pattern, $this->getPath(), $patterns
        );
    }
852972
public function GetFiles($pattern = "")
	{
		$files = Array();
		$dh = opendir($this->Path);

		while ($fname = readdir($dh)) 
		{
			if (is_file($this->Path.$fname))
			{
				if ($pattern == "" || preg_match($pattern,$fname) > 0)
				{
					$files[] = new FileHelper($this->Path.$fname);
				}
			}
		}
		
		closedir($dh);
	    
		return $files;
	}
339877
public function getCount( $pattern = NULL )
	{
		$count	= 0;
		$list	= $this->getList( $pattern );
		foreach( $list as $entry )
			$count++;
		return $count;
	}
783692
protected function replacePattern($pattern) {
    $replace = array(
      '$DIR' => dirname($this->configFile),
      '$CWD' => getcwd(),
    );
    return str_replace(array_keys($replace), array_values($replace), $pattern);
  }
1185729
public function matchUrl($pattern)
    {
        if ($this->matchValue($this->getUrl(), $pattern)) {
            return $this->getUrl();
        }

        return false;
    }
375024
protected function assertPattern($pattern)
    {
        if (strlen($pattern) == 0) return null;

        $pattern = '/^'. str_replace('/', '\\/', $pattern). '$/';
        if (@preg_match($pattern, null) === false) {
            throw new DefinitionException("invalid regular expression pattern");
        }

        return $pattern;
    }
96920
private function getFiles($pattern, $extension = '.log')
    {
        $pattern = $this->storagePath . DS . $pattern . $extension;
        $files   = array_map('realpath', glob($pattern, GLOB_BRACE));

        return array_filter($files);
    }
292280
protected function get_string_filters($context) {
        if (!isset($this->stringfilters[$context->id])) {
            $this->load_filters($context);
        }
        return $this->stringfilters[$context->id];
    }