[oik] plugins.com

WordPress plugins and themes

  • Home
  • About
    • lazy shortcodes
    • smart shortcodes
    • oik base plugin
      • oik – donate
      • oik PayPal buttons
      • oik installation
      • oik Button Shortcode button
      • oik changelog
      • oik FAQ
      • oik plugins on SVN
      • oik plugins on GitHub
  • Plugins
    • oik base plugin
    • FREE oik plugins
    • WordPress plugins
    • Premium oik plugins
    • Bespoke oik plugins
  • Shortcodes
    • Shortcode examples
  • Blocks
    • Block examples
  • APIs
    • ALL action and filter hooks
  • Blog

WP_UnitTestCase::go_to() – Modify WordPress’s query internals as if a given URL has been requested.

You appear to be a bot. Output may be restricted

Description

Modify WordPress's query internals as if a given URL has been requested.

Usage

WP_UnitTestCase::go_to( $url );

Parameters

$url
( string ) required – The URL for the request.

Returns

void

Source

File name: oik-batch/tests/testcase.php
Lines:
1 to 42 of 42
  function go_to( $url ) {
    // note: the WP and WP_Query classes like to silently fetch parameters
    // from all over the place (globals, GET, etc), which makes it tricky
    // to run them more than once without very carefully clearing everything
    $_GET = $_POST = array();
    foreach (array('query_string', 'id', 'postdata', 'authordata', 'day', 'currentmonth', 'page', 'pages', 'multipage', 'more', 'numpages', 'pagenow') as $v) {
      if ( isset( $GLOBALS[$v] ) ) unset( $GLOBALS[$v] );
    }
    $parts = parse_url($url);
    if (isset($parts['scheme'])) {
      $req = isset( $parts['path'] ) ? $parts['path'] : '';
      if (isset($parts['query'])) {
        $req .= '?' . $parts['query'];
        // parse the url query vars into $_GET
        parse_str($parts['query'], $_GET);
      }
    } else {
      $req = $url;
    }
    if ( ! isset( $parts['query'] ) ) {
      $parts['query'] = '';
    }

    $_SERVER['REQUEST_URI'] = $req;
    unset($_SERVER['PATH_INFO']);

    self::flush_cache();
    unset($GLOBALS['wp_query'], $GLOBALS['wp_the_query']);
    $GLOBALS['wp_the_query'] = new WP_Query();
    $GLOBALS['wp_query'] = $GLOBALS['wp_the_query'];

    $public_query_vars  = $GLOBALS['wp']->public_query_vars;
    $private_query_vars = $GLOBALS['wp']->private_query_vars;

    $GLOBALS['wp'] = new WP();
    $GLOBALS['wp']->public_query_vars  = $public_query_vars;
    $GLOBALS['wp']->private_query_vars = $private_query_vars;

    _cleanup_query_vars();

    $GLOBALS['wp']->main($parts['query']);
  }
 
 View on GitHub

Published: March 14, 2017 | Last updated: March 14, 2017

Information

Function name: WP_UnitTestCase::go_to
Class ref: WP_UnitTestCase
Plugin ref: oik-batch
Version: 1.0.0
Sourcefile: tests/testcase.php
File ref: tests/testcase.php
Deprecated?: No
API Letters: G,T,U,W

Recent plugin updates

slog v1.5.1 Update to slog v1.5.1 for support for PHP 8.1 and PHP 8.2 ...
oik-presentation v2.0.1 Update to oik-presentation v2.0.1 for support for PHP 8.1 and PHP 8.2. ...
oik-video v1.2.4 Update to oik-video v1.2.4 for support for PHP 8.1 and PHP 8.2 ...
oik-tunes v1.0.0 Update to oik-tunes v1.0.0 for support for PHP 8.1 and PHP 8.2 ...
oik-media v0.1.1 Update to oik-media v0.1.1 for support for PHP 8.1 and PHP 8.2 ...

Plugins

  • All Plugins
  • oik base plugin
  • FREE oik plugins
  • WordPress plugins
  • Premium oik plugins

Themes

  • FREE themes
  • Bespoke themes
  • Premium themes

Blocks

  • All Blocks
  • Block examples
  • About Blocks

Shortcodes

  • All Shortcodes
  • Shortcode examples
  • About Shortcodes

Reference

  • About APIs
  • All APIs
  • All Classes
  • All Files
  • All Hooks

Support

  • Contact
  • Cookies policy
  • Get API key
  • Privacy
  • Request support
  • Sitemap
  • Stay informed
  • Terms and Conditions
oik-plugins
Email: herb@bobbingwide.com

Weight shipping plugins

Find out which cart weight shipping plugin you need for your WooCommerce site.
Which cart weight based plugin do I need?

Site:  www.oik-plugins.com
© Copyright oik-plugins 2011-2023. All rights reserved.


Website designed and developed by Herb Miller of Bobbing Wide
Proudly powered by WordPress and oik-plugins
WordPress 6.4.1. PHP: 7.4.33. Memory limit: 768M