Load route definition files depending on the current request.

@codeCoverageIgnore
@param  string $web
@param  string $admin
@param  string $ajax
@return void
437779
protected function loadRoutes( $web = '', $admin = '', $ajax = '' ) {
		if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
			$this->loadRoutesFile( $ajax, [
				'namespace' => '\\App\\Controllers\\Ajax\\',
				'middleware' => ['ajax'],
			] );
			return;
		}

		if ( is_admin() ) {
			$this->loadRoutesFile( $admin, [
				'namespace' => '\\App\\Controllers\\Admin\\',
				'middleware' => ['admin'],
			] );
			return;
		}

		$this->loadRoutesFile( $web, [
			'namespace' => '\\App\\Controllers\\Web\\',
			'handler' => '\\WPEmerge\\Controllers\\WordPressController@handle',
			'middleware' => ['web'],
		] );
	}
159358
public function admin_ajax() {

		if ( false === headers_sent() ) {
			pods_session_start();

			header( 'Content-Type: text/html; charset=' . get_bloginfo( 'charset' ) );
		}

		// Sanitize input @codingStandardsIgnoreLine
		$params = pods_unslash( (array) $_POST );

		foreach ( $params as $key => $value ) {
			if ( 'action' === $key ) {
				continue;
			}

			unset( $params[ $key ] );

			$params[ str_replace( '_podsfix_', '', $key ) ] = $value;
		}

		$params = (object) $params;

		$component = $params->component;
		$method    = $params->method;

		if ( ! isset( $component ) || ! isset( $this->components[ $component ] ) || ! isset( $this->settings['components'][ $component ] ) ) {
			pods_error( 'Invalid AJAX request', $this );
		}

		if ( ! isset( $params->_wpnonce ) || false === wp_verify_nonce( $params->_wpnonce, 'pods-component-' . $component . '-' . $method ) ) {
			pods_error( 'Unauthorized request', $this );
		}

		// Cleaning up $params
		unset( $params->action, $params->component, $params->method, $params->_wpnonce );

		$params = (object) apply_filters( "pods_component_ajax_{$component}_{$method}", $params, $component, $method );

		$output = false;

		// Component init
		if ( isset( $this->components[ $component ]['object'] ) && method_exists( $this->components[ $component ]['object'], 'init' ) ) {
			$this->components[ $component ]['object']->init( $this->settings['components'][ $component ], $component );
		}

		if ( isset( $this->components[ $component ]['object'] ) && ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) && method_exists( $this, 'admin_ajax_' . $method ) ) {
			// Handle internal methods
			$output = call_user_func( array( $this, 'admin_ajax_' . $method ), $component, $params );
		} elseif ( ! isset( $this->components[ $component ]['object'] ) || ! method_exists( $this->components[ $component ]['object'], 'ajax_' . $method ) ) {
			// Make sure method exists
			pods_error( 'API method does not exist', $this );
		} else {
			// Dynamically call the component method
			$output = call_user_func( array( $this->components[ $component ]['object'], 'ajax_' . $method ), $params );
		}

		if ( ! is_bool( $output ) ) {
			// @codingStandardsIgnoreLine
			echo $output;
		}

		die();
		// KBAI!
	}
204431
public function renderAjaxBlock(
        \Twig_Environment $environment,
        $controllerName,
        array $controllerParams = array(),
        array $options = array())
    {
        $routeParams = array('_ajaxController' => $controllerName) + $controllerParams;
        $controllerParams[AjaxBlockControllerEventListener::JGP_AJAX_BLOCK_TAG] = true;
        $options = array_merge($this->defaultOptions, $options);

        $variables = array(
            'controllerName' => $controllerName,
            'controllerParams' => $controllerParams,
            'routeName' => 'jgp_ajax_block',
            'routeParams' => $routeParams,
            'autoload' => isset($options['autoload']) && $options['autoload'],
        );

        $template = 'AjaxBlocksBundle::ajax_block.html.twig';
        return $environment->render($template, $variables);
    }
654899
protected function loadRoutes()
    {
        $builder = Router::createRouteBuilder('/');

        if ($this->app instanceof HttpApplicationInterface) {
            $this->app->routes($builder);
        }
        if ($this->app instanceof PluginApplicationInterface) {
            $this->app->pluginRoutes($builder);
        }
    }
1269505
protected function loadJs($file, array $properties = [])
    {
        if (!isset($this->loaded_js[$file])) {
            $this->loaded_js[$file] = true;

            $properties = array_merge($properties, [
                'type' => 'text/javascript',
                'src' => $file,
            ]);

            echo $this->buildElement('script', $properties);
        }
    }
890452
protected function prepRoutes(ServerRequestInterface $request) : void
    {
        $this->processGroups($request);
        $this->buildNameIndex();

        $routes = array_merge(array_values($this->routes), array_values($this->namedRoutes));

        foreach ($routes as $key => $route) {
            // check for scheme condition
            if (! is_null($route->getScheme()) && $route->getScheme() !== $request->getUri()->getScheme()) {
                continue;
            }

            // check for domain condition
            if (! is_null($route->getHost()) && $route->getHost() !== $request->getUri()->getHost()) {
                continue;
            }

            // check for port condition
            if (! is_null($route->getPort()) && $route->getPort() !== $request->getUri()->getPort()) {
                continue;
            }

            if (is_null($route->getStrategy())) {
                $route->setStrategy($this->getStrategy());
            }

            $this->addRoute($route->getMethod(), $this->parseRoutePath($route->getPath()), $route);
        }
    }
287581
public function show()
    {
        if ($this->plugin['request']->ajax()) {
            $this->plugin['response']->setContent(html_entity_decode($this->attributes['messages'][0]))->send();
            exit;
        } else {
            print $this->plugin->view('admin.framework.settings', $this->attributes);
        }
    }
365843
protected function mapWebRoutes(): void
    {
        $file = $this->basePath.'routes/web.php';

        if (file_exists($file)) {
            $this->loadRoutesFrom(
                Route::middleware('web')
                ->group($file));
        }
    }
358815
public function generateUrl(AdminInterface $admin, $action, $params = [])
    {
        $routeName = $this->getRouteName($admin, $action);

        return $this->router->generate($routeName, $params);
    }
849111
public function run_ajax() {
    global $wp_query;

    if ( $wp_query->get("no-admin-ajax") ) {
      // Constant for plugins to know that we are on an AJAX request
      define("DOING_AJAX", true);

      // If we don't have an action, do nothing
      if ( ! isset( $_REQUEST["action"] ) ) {
          die(0);
      }

      // Escape the parameter to prevent disastrous things
      $action = esc_attr( $_REQUEST["action"] );

      // Run customized no-admin-ajax methods with action "no-admin-ajax/before"
      do_action( "no-admin-ajax/before" );

      // Run customized no-admin-ajax methods for specific ajax actions with "no-admin-ajax/before/{action}"
      do_action( "no-admin-ajax/before/". $action );

      // Same headers as WordPress normal AJAX routine sends
      $default_headers = array(
        "Content-Type: text/html; charset=" . get_option( "blog_charset" ),
        "X-Robots-Tag: noindex"
      );

      // Filter to customize the headers sent by ajax calls
      $headers = apply_filters( "no-admin-ajax/headers", $default_headers );

      // Send the headers to the user
      if ( is_array( $headers ) && count( $headers ) > 0 ) {
        foreach ( $headers as $header ) {
          @header( $header );
        }
      }

      send_nosniff_header();
      nocache_headers();

      // Run the actions
      if(is_user_logged_in()) {
          do_action( "wp_ajax_" . $action );
      }
      else {
          do_action( "wp_ajax_nopriv_" . $action );
      }

      die(0);
    }
  }
850881
public function onKernelRequest(GetResponseEvent $event): void
    {
        if (!$event->isMasterRequest()) {
            return;
        }

        $request = $event->getRequest();
        $currentRoute = $request->attributes->get('_route', '');
        if (mb_stripos($currentRoute, self::ADMIN_ROUTE_PREFIX) !== 0) {
            return;
        }

        $request->attributes->set(self::ADMIN_FLAG_NAME, true);

        $adminEvent = new AdminMatchEvent($event->getRequest(), $event->getRequestType());
        $this->eventDispatcher->dispatch($adminEvent, BlockManagerAdminEvents::ADMIN_MATCH);
    }
854061
public function admin_init(){
        if( !AjaxBase::is_ajax() && current_user_can('manage_options') ){
            if( !empty($this->classes) ){
                $rewrites = '';
                foreach( $this->classes as $class_name ){
                   $rewrites .= $this->get_prefix($class_name);
                }
                $rewrites = md5($rewrites);
                if( get_option('rewrite_rules') && $this->rewrite_md5 != $rewrites ){
                    flush_rewrite_rules();
                    $last_updated = current_time('timestamp');
                    update_option($this->option_name, $last_updated);
                    update_option($this->rewrite_md5_name, $rewrites);
                    $message = sprintf($this->__('Rewrite rules updated. Last modified date is %s'), date_i18n(get_option('date_format').' '.get_option('time_format'), $last_updated));
                    add_action('admin_notices', function() use ($message){
                        printf('<div class="updated"><p>%s</p></div>', $message);
                    });
                }
            }
        }
    }
20810
protected function loadRoutes(string $filename='')
  {
    # If no filename given, default to "app/Config/routes.json"
    if (empty($filename)) {
      $filename = $this->appPath . \DIRECTORY_SEPARATOR . 'Config' . \DIRECTORY_SEPARATOR . 'routes-' . $this->getEnvironment() . '.json';
    }

    if ( \file_exists($filename) ) {
      $routesFile = \json_decode( \file_get_contents($filename), true );

      if ($routesFile) {

        # Take the GROUPS section
        $routeGroups = $routesFile['groups'] ?? [];

        # Add each RouteGroup
        foreach ($routeGroups as $routeGroupDef)
        {
          # Create new Route Group
          $routeGroup = new RouteGroup($routeGroupDef);

          # Add to list
          $this->routeGroups[] = $routeGroup;
        }

        # Common Middlewares
        $this->beforeMiddleware = ($routesFile['common']['before'] ?? []);
        $this->afterMiddleware = ($routesFile['common']['after'] ?? []);

        # Error controllers
        $this->errorControllers = $routesFile['errors'] ?? [];

      } else {
        throw new SpinException('Invalid routes file "'.$filename.'"');

      }

      # Debug log
      $this->getLogger()->debug('Loaded routes',['file'=>$filename]);

      return true; // routes loaded

    } else {
      # Log
      $this->getLogger()->error('Routes file not found',['file'=>$filename]);

    }

    return false;
  }
581575
protected function getBaseTemplate(Request $request, AbstractAdmin $admin)
    {
        if ($request->isXmlHttpRequest()) {
            return $admin->getTemplate('ajax');
        }

        return $admin->getTemplate('layout');
    }
1350141
public function route()
	{
		$content = $this->_controller->{$this->_actionMethod}();

		if ($this->_controller->isJson()) {
			Request::setHeader(Request::HEADER_JSON);
			echo json_encode($content);
		} else {
			echo $content;
		}
	}
273201
private function load()
	{
		if ($this->isLoaded())
		{
			return;
		}

		$path = sprintf('%s/../../lang/%s.php', __DIR__, $this->locale);

		if (file_exists($path))
		{
			$this->loaded[$this->locale] = require $path;
		}
	}
535282
protected function load(string $file): void
	{
		$this->configuration[$file] = $this->loader->load($file, $this->environment);
	}