src/Providers/QueryServiceProvider.php
register accesses the super-global variable $GLOBALS. Open
Open
public function register()
{
$this->app->singleton('query', function () {
// main page query
return Query::instance($GLOBALS['wp_the_query']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}
Source
register accesses the super-global variable $GLOBALS. Open
Open
public function register()
{
$this->app->singleton('query', function () {
// main page query
return Query::instance($GLOBALS['wp_the_query']);
- Read upRead up
- Exclude checks
Superglobals
Since: 0.2
Accessing a super-global variable directly is considered a bad practice. These variables should be encapsulated in objects that are provided by a framework, for instance.
Example
class Foo {
public function bar() {
$name = $_POST['foo'];
}
}