ElggSite::isPublicPage PHP Method

isPublicPage() public method

Pages are registered to be public by {@elgg_plugin_hook public_pages walled_garden}.
Since: 1.8.0
public isPublicPage ( string $url = '' ) : boolean
$url string Defaults to the current URL.
return boolean
    public function isPublicPage($url = '')
    {
        global $CONFIG;
        if (empty($url)) {
            $url = current_page_url();
            // do not check against URL queries
            if ($pos = strpos($url, '?')) {
                $url = substr($url, 0, $pos);
            }
        }
        // always allow index page
        if ($url == _elgg_services()->config->getSiteUrl($this->guid)) {
            return true;
        }
        // default public pages
        $defaults = array('walled_garden/.*', 'action/.*', 'login', 'register', 'forgotpassword', 'changepassword', 'refresh_token', 'ajax/view/languages.js', 'upgrade\\.php', 'css/.*', 'js/.*', 'cache/[0-9]+/\\w+/.*', 'cron/.*', 'services/.*', 'serve-file/.*', 'robots.txt', 'favicon.ico');
        // include a hook for plugin authors to include public pages
        $plugins = _elgg_services()->hooks->trigger('public_pages', 'walled_garden', null, array());
        // allow public pages
        foreach (array_merge($defaults, $plugins) as $public) {
            $pattern = "`^{$CONFIG->url}{$public}/*\$`i";
            if (preg_match($pattern, $url)) {
                return true;
            }
        }
        // non-public page
        return false;
    }