Roots\StageSwitcher\StageSwitcher::admin_bar_stage_switcher PHP Метод

admin_bar_stage_switcher() публичный Метод

public admin_bar_stage_switcher ( $admin_bar )
    public function admin_bar_stage_switcher($admin_bar)
    {
        if (!defined('ENVIRONMENTS') && !defined('WP_ENV') && !apply_filters('bedrock/stage_switcher_visibility', is_super_admin())) {
            return;
        }
        $stages = unserialize(ENVIRONMENTS);
        $current_stage = WP_ENV;
        foreach ($stages as $stage => $url) {
            if ($stage === $current_stage) {
                continue;
            }
            if (is_multisite() && defined('SUBDOMAIN_INSTALL') && SUBDOMAIN_INSTALL && !is_main_site()) {
                $url = $this->multisite_url($url) . $_SERVER['REQUEST_URI'];
            } else {
                $url .= $_SERVER['REQUEST_URI'];
            }
            $admin_bar->add_menu(['id' => 'environment', 'parent' => 'top-secondary', 'title' => ucwords($current_stage), 'href' => '#']);
            $admin_bar->add_menu(['id' => "stage_{$stage}", 'parent' => 'environment', 'title' => ucwords($stage), 'href' => $url]);
        }
    }