Requests::autoloader() WordPress Method

The Requests::autoloader() method is used to autoload the Requests classes when they are needed. This is useful for when you want to use the Requests classes in your own code, but don't want to have to include the files manually.

Requests::autoloader( string $class ) #

Autoloader for Requests


Description

Register this with register_autoloader() if you’d like to avoid having to create your own.

(You can also use spl_autoload_register directly if you’d prefer.)


Top ↑

Parameters

$class

(string)(Required)Class name to load


Top ↑

Source

File: wp-includes/class-requests.php

	public static function autoloader($class) {
		// Check that the class starts with "Requests"
		if (strpos($class, 'Requests') !== 0) {
			return;
		}

		$file = str_replace('_', '/', $class);
		if (file_exists(dirname(__FILE__) . '/' . $file . '.php')) {
			require_once dirname(__FILE__) . '/' . $file . '.php';
		}
	}

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.