Automattic\WooCommerce\Internal\Logging

SafeGlobalFunctionProxy::maybe_load_missing_function()private staticWC 1.0

Load missing function if we know where to find it. Modify this file to add more functions to the map.

Method of the class: SafeGlobalFunctionProxy{}

No Hooks.

Return

null. Nothing (null).

Usage

$result = SafeGlobalFunctionProxy::maybe_load_missing_function( $name );
$name(string) (required)
The name of the function to load.

SafeGlobalFunctionProxy::maybe_load_missing_function() code WC 9.6.0

private static function maybe_load_missing_function( $name ) {
	$function_map = array(
		'wp_parse_url'            => ABSPATH . WPINC . '/http.php',
		'home_url'                => ABSPATH . WPINC . '/link-template.php',
		'get_bloginfo'            => ABSPATH . WPINC . '/general-template.php',
		'get_option'              => ABSPATH . WPINC . '/option.php',
		'get_site_transient'      => ABSPATH . WPINC . '/option.php',
		'set_site_transient'      => ABSPATH . WPINC . '/option.php',
		'wp_safe_remote_post'     => ABSPATH . WPINC . '/http.php',
		'is_wp_error'             => ABSPATH . WPINC . '/load.php',
		'get_plugin_updates'      => array( ABSPATH . 'wp-admin/includes/update.php', ABSPATH . 'wp-admin/includes/plugin.php' ),
		'wp_get_environment_type' => ABSPATH . WPINC . '/load.php',
		'wp_json_encode'          => ABSPATH . WPINC . '/functions.php',
		'wc_get_logger'           => WC_ABSPATH . 'includes/class-wc-logger.php',
		'wc_print_r'              => WC_ABSPATH . 'includes/wc-core-functions.php',
	);

	if ( ! function_exists( $name ) ) {
		if ( isset( $function_map[ $name ] ) ) {
			$files = (array) $function_map[ $name ];
			foreach ( $files as $file ) {
				require_once $file;
			}
		} else {
			throw new \Exception( sprintf( 'Function %s does not exist and could not be loaded.', esc_html( $name ) ) );
		}
	}
}