Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Blocks/Domain
File: Bootstrap.php
<?php
[0] Fix | Delete
namespace Automattic\WooCommerce\Blocks\Domain;
[1] Fix | Delete
[2] Fix | Delete
use Automattic\Jetpack\Constants;
[3] Fix | Delete
use Automattic\WooCommerce\Blocks\Assets\Api as AssetApi;
[4] Fix | Delete
use Automattic\WooCommerce\Blocks\Assets\AssetDataRegistry;
[5] Fix | Delete
use Automattic\WooCommerce\Blocks\AssetsController;
[6] Fix | Delete
use Automattic\WooCommerce\Blocks\BlockPatterns;
[7] Fix | Delete
use Automattic\WooCommerce\Blocks\BlockTemplatesRegistry;
[8] Fix | Delete
use Automattic\WooCommerce\Blocks\BlockTemplatesController;
[9] Fix | Delete
use Automattic\WooCommerce\Blocks\BlockTypesController;
[10] Fix | Delete
use Automattic\WooCommerce\Blocks\Patterns\AIPatterns;
[11] Fix | Delete
use Automattic\WooCommerce\Blocks\Patterns\PatternRegistry;
[12] Fix | Delete
use Automattic\WooCommerce\Blocks\Patterns\PTKClient;
[13] Fix | Delete
use Automattic\WooCommerce\Blocks\Patterns\PTKPatternsStore;
[14] Fix | Delete
use Automattic\WooCommerce\Blocks\QueryFilters;
[15] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\Notices;
[16] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\DraftOrders;
[17] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\GoogleAnalytics;
[18] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\Hydration;
[19] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFields;
[20] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFieldsAdmin;
[21] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutFieldsFrontend;
[22] Fix | Delete
use Automattic\WooCommerce\Blocks\Domain\Services\CheckoutLink;
[23] Fix | Delete
use Automattic\WooCommerce\Blocks\InboxNotifications;
[24] Fix | Delete
use Automattic\WooCommerce\Blocks\Installer;
[25] Fix | Delete
use Automattic\WooCommerce\Blocks\Payments\Api as PaymentsApi;
[26] Fix | Delete
use Automattic\WooCommerce\Blocks\Payments\Integrations\BankTransfer;
[27] Fix | Delete
use Automattic\WooCommerce\Blocks\Payments\Integrations\CashOnDelivery;
[28] Fix | Delete
use Automattic\WooCommerce\Blocks\Payments\Integrations\Cheque;
[29] Fix | Delete
use Automattic\WooCommerce\Blocks\Payments\Integrations\PayPal;
[30] Fix | Delete
use Automattic\WooCommerce\Blocks\Payments\PaymentMethodRegistry;
[31] Fix | Delete
use Automattic\WooCommerce\Blocks\Registry\Container;
[32] Fix | Delete
use Automattic\WooCommerce\Blocks\Templates\ClassicTemplatesCompatibility;
[33] Fix | Delete
use Automattic\WooCommerce\StoreApi\RoutesController;
[34] Fix | Delete
use Automattic\WooCommerce\StoreApi\SchemaController;
[35] Fix | Delete
use Automattic\WooCommerce\StoreApi\StoreApi;
[36] Fix | Delete
use Automattic\WooCommerce\Blocks\Shipping\ShippingController;
[37] Fix | Delete
use Automattic\WooCommerce\Blocks\TemplateOptions;
[38] Fix | Delete
[39] Fix | Delete
[40] Fix | Delete
/**
[41] Fix | Delete
* Takes care of bootstrapping the plugin.
[42] Fix | Delete
*
[43] Fix | Delete
* @since 2.5.0
[44] Fix | Delete
*/
[45] Fix | Delete
class Bootstrap {
[46] Fix | Delete
[47] Fix | Delete
/**
[48] Fix | Delete
* Holds the Dependency Injection Container
[49] Fix | Delete
*
[50] Fix | Delete
* @var Container
[51] Fix | Delete
*/
[52] Fix | Delete
private $container;
[53] Fix | Delete
[54] Fix | Delete
/**
[55] Fix | Delete
* Holds the Package instance
[56] Fix | Delete
*
[57] Fix | Delete
* @var Package
[58] Fix | Delete
*/
[59] Fix | Delete
private $package;
[60] Fix | Delete
[61] Fix | Delete
/**
[62] Fix | Delete
* Constructor
[63] Fix | Delete
*
[64] Fix | Delete
* @param Container $container The Dependency Injection Container.
[65] Fix | Delete
*/
[66] Fix | Delete
public function __construct( Container $container ) {
[67] Fix | Delete
$this->container = $container;
[68] Fix | Delete
$this->package = $container->get( Package::class );
[69] Fix | Delete
[70] Fix | Delete
$this->init();
[71] Fix | Delete
/**
[72] Fix | Delete
* Fires when the woocommerce blocks are loaded and ready to use.
[73] Fix | Delete
*
[74] Fix | Delete
* This hook is intended to be used as a safe event hook for when the plugin
[75] Fix | Delete
* has been loaded, and all dependency requirements have been met.
[76] Fix | Delete
*
[77] Fix | Delete
* To ensure blocks are initialized, you must use the `woocommerce_blocks_loaded`
[78] Fix | Delete
* hook instead of the `plugins_loaded` hook. This is because the functions
[79] Fix | Delete
* hooked into plugins_loaded on the same priority load in an inconsistent and unpredictable manner.
[80] Fix | Delete
*
[81] Fix | Delete
* @since 2.5.0
[82] Fix | Delete
*/
[83] Fix | Delete
do_action( 'woocommerce_blocks_loaded' );
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
/**
[87] Fix | Delete
* Init the package - load the blocks library and define constants.
[88] Fix | Delete
*/
[89] Fix | Delete
protected function init() {
[90] Fix | Delete
$this->register_dependencies();
[91] Fix | Delete
$this->register_payment_methods();
[92] Fix | Delete
[93] Fix | Delete
add_action(
[94] Fix | Delete
'admin_init',
[95] Fix | Delete
function () {
[96] Fix | Delete
// Delete this notification because the blocks are included in WC Core now. This will handle any sites
[97] Fix | Delete
// with lingering notices.
[98] Fix | Delete
InboxNotifications::delete_surface_cart_checkout_blocks_notification();
[99] Fix | Delete
},
[100] Fix | Delete
10,
[101] Fix | Delete
0
[102] Fix | Delete
);
[103] Fix | Delete
[104] Fix | Delete
// We need to initialize BlockTemplatesController and BlockTemplatesRegistry at the end of `after_setup_theme`
[105] Fix | Delete
// so themes had the opportunity to declare support for template parts.
[106] Fix | Delete
add_action(
[107] Fix | Delete
'after_setup_theme',
[108] Fix | Delete
function () {
[109] Fix | Delete
$is_store_api_request = wc()->is_store_api_request();
[110] Fix | Delete
[111] Fix | Delete
if ( ! $is_store_api_request && ( wp_is_block_theme() || current_theme_supports( 'block-template-parts' ) ) ) {
[112] Fix | Delete
$this->container->get( BlockTemplatesRegistry::class )->init();
[113] Fix | Delete
$this->container->get( BlockTemplatesController::class )->init();
[114] Fix | Delete
}
[115] Fix | Delete
},
[116] Fix | Delete
999
[117] Fix | Delete
);
[118] Fix | Delete
[119] Fix | Delete
$is_rest = wc()->is_rest_api_request();
[120] Fix | Delete
$is_store_api_request = wc()->is_store_api_request();
[121] Fix | Delete
[122] Fix | Delete
// Initialize Store API in non-admin context.
[123] Fix | Delete
if ( ! is_admin() ) {
[124] Fix | Delete
$this->container->get( StoreApi::class )->init();
[125] Fix | Delete
}
[126] Fix | Delete
[127] Fix | Delete
// Load and init assets.
[128] Fix | Delete
$this->container->get( PaymentsApi::class )->init();
[129] Fix | Delete
$this->container->get( DraftOrders::class )->init();
[130] Fix | Delete
$this->container->get( ShippingController::class )->init();
[131] Fix | Delete
$this->container->get( CheckoutFields::class )->init();
[132] Fix | Delete
$this->container->get( CheckoutLink::class )->init();
[133] Fix | Delete
[134] Fix | Delete
// Load assets in admin and on the frontend.
[135] Fix | Delete
if ( ! $is_rest ) {
[136] Fix | Delete
$this->add_build_notice();
[137] Fix | Delete
$this->container->get( AssetDataRegistry::class );
[138] Fix | Delete
$this->container->get( AssetsController::class );
[139] Fix | Delete
$this->container->get( Installer::class )->init();
[140] Fix | Delete
$this->container->get( GoogleAnalytics::class )->init();
[141] Fix | Delete
$this->container->get( is_admin() ? CheckoutFieldsAdmin::class : CheckoutFieldsFrontend::class )->init();
[142] Fix | Delete
}
[143] Fix | Delete
[144] Fix | Delete
// Load assets unless this is a request specifically for the store API.
[145] Fix | Delete
if ( ! $is_store_api_request ) {
[146] Fix | Delete
// Template related functionality. These won't be loaded for store API requests, but may be loaded for
[147] Fix | Delete
// regular rest requests to maintain compatibility with the store editor.
[148] Fix | Delete
$this->container->get( BlockPatterns::class );
[149] Fix | Delete
$this->container->get( BlockTypesController::class );
[150] Fix | Delete
$this->container->get( ClassicTemplatesCompatibility::class );
[151] Fix | Delete
$this->container->get( Notices::class )->init();
[152] Fix | Delete
[153] Fix | Delete
if ( is_admin() || $is_rest ) {
[154] Fix | Delete
$this->container->get( AIPatterns::class );
[155] Fix | Delete
$this->container->get( PTKPatternsStore::class );
[156] Fix | Delete
}
[157] Fix | Delete
[158] Fix | Delete
if ( is_admin() ) {
[159] Fix | Delete
$this->container->get( TemplateOptions::class )->init();
[160] Fix | Delete
}
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
$this->container->get( QueryFilters::class )->init();
[164] Fix | Delete
}
[165] Fix | Delete
[166] Fix | Delete
/**
[167] Fix | Delete
* See if files have been built or not.
[168] Fix | Delete
*
[169] Fix | Delete
* @return bool
[170] Fix | Delete
*/
[171] Fix | Delete
protected function is_built() {
[172] Fix | Delete
return file_exists(
[173] Fix | Delete
$this->package->get_path( 'assets/client/blocks/featured-product.js' )
[174] Fix | Delete
);
[175] Fix | Delete
}
[176] Fix | Delete
[177] Fix | Delete
/**
[178] Fix | Delete
* Add a notice stating that the build has not been done yet.
[179] Fix | Delete
*/
[180] Fix | Delete
protected function add_build_notice() {
[181] Fix | Delete
if ( $this->is_built() ) {
[182] Fix | Delete
return;
[183] Fix | Delete
}
[184] Fix | Delete
add_action(
[185] Fix | Delete
'admin_notices',
[186] Fix | Delete
function () {
[187] Fix | Delete
echo '<div class="error"><p>';
[188] Fix | Delete
printf(
[189] Fix | Delete
/* translators: %1$s is the node install command, %2$s is the install command, %3$s is the build command, %4$s is the watch command. */
[190] Fix | Delete
esc_html__( 'WooCommerce Blocks development mode requires files to be built. From the root directory, run %1$s to ensure your node version is aligned, run %2$s to install dependencies, %3$s to build the files or %4$s to build the files and watch for changes.', 'woocommerce' ),
[191] Fix | Delete
'<code>nvm use</code>',
[192] Fix | Delete
'<code>pnpm install</code>',
[193] Fix | Delete
'<code>pnpm --filter="@woocommerce/plugin-woocommerce" build</code>',
[194] Fix | Delete
'<code>pnpm --filter="@woocommerce/plugin-woocommerce" watch:build</code>'
[195] Fix | Delete
);
[196] Fix | Delete
echo '</p></div>';
[197] Fix | Delete
}
[198] Fix | Delete
);
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
/**
[202] Fix | Delete
* Register core dependencies with the container.
[203] Fix | Delete
*/
[204] Fix | Delete
protected function register_dependencies() {
[205] Fix | Delete
$this->container->register(
[206] Fix | Delete
AssetApi::class,
[207] Fix | Delete
function ( Container $container ) {
[208] Fix | Delete
return new AssetApi( $container->get( Package::class ) );
[209] Fix | Delete
}
[210] Fix | Delete
);
[211] Fix | Delete
$this->container->register(
[212] Fix | Delete
AssetDataRegistry::class,
[213] Fix | Delete
function ( Container $container ) {
[214] Fix | Delete
return new AssetDataRegistry( $container->get( AssetApi::class ) );
[215] Fix | Delete
}
[216] Fix | Delete
);
[217] Fix | Delete
$this->container->register(
[218] Fix | Delete
AssetsController::class,
[219] Fix | Delete
function ( Container $container ) {
[220] Fix | Delete
return new AssetsController( $container->get( AssetApi::class ) );
[221] Fix | Delete
}
[222] Fix | Delete
);
[223] Fix | Delete
$this->container->register(
[224] Fix | Delete
PaymentMethodRegistry::class,
[225] Fix | Delete
function () {
[226] Fix | Delete
return new PaymentMethodRegistry();
[227] Fix | Delete
}
[228] Fix | Delete
);
[229] Fix | Delete
$this->container->register(
[230] Fix | Delete
Installer::class,
[231] Fix | Delete
function () {
[232] Fix | Delete
return new Installer();
[233] Fix | Delete
}
[234] Fix | Delete
);
[235] Fix | Delete
$this->container->register(
[236] Fix | Delete
BlockTypesController::class,
[237] Fix | Delete
function ( Container $container ) {
[238] Fix | Delete
$asset_api = $container->get( AssetApi::class );
[239] Fix | Delete
$asset_data_registry = $container->get( AssetDataRegistry::class );
[240] Fix | Delete
return new BlockTypesController( $asset_api, $asset_data_registry );
[241] Fix | Delete
}
[242] Fix | Delete
);
[243] Fix | Delete
$this->container->register(
[244] Fix | Delete
ClassicTemplatesCompatibility::class,
[245] Fix | Delete
function ( Container $container ) {
[246] Fix | Delete
$asset_data_registry = $container->get( AssetDataRegistry::class );
[247] Fix | Delete
return new ClassicTemplatesCompatibility( $asset_data_registry );
[248] Fix | Delete
}
[249] Fix | Delete
);
[250] Fix | Delete
$this->container->register(
[251] Fix | Delete
DraftOrders::class,
[252] Fix | Delete
function ( Container $container ) {
[253] Fix | Delete
return new DraftOrders( $container->get( Package::class ) );
[254] Fix | Delete
}
[255] Fix | Delete
);
[256] Fix | Delete
$this->container->register(
[257] Fix | Delete
GoogleAnalytics::class,
[258] Fix | Delete
function ( Container $container ) {
[259] Fix | Delete
$asset_api = $container->get( AssetApi::class );
[260] Fix | Delete
return new GoogleAnalytics( $asset_api );
[261] Fix | Delete
}
[262] Fix | Delete
);
[263] Fix | Delete
$this->container->register(
[264] Fix | Delete
Notices::class,
[265] Fix | Delete
function ( Container $container ) {
[266] Fix | Delete
return new Notices( $container->get( Package::class ) );
[267] Fix | Delete
}
[268] Fix | Delete
);
[269] Fix | Delete
$this->container->register(
[270] Fix | Delete
Hydration::class,
[271] Fix | Delete
function ( Container $container ) {
[272] Fix | Delete
return new Hydration( $container->get( AssetDataRegistry::class ) );
[273] Fix | Delete
}
[274] Fix | Delete
);
[275] Fix | Delete
$this->container->register(
[276] Fix | Delete
CheckoutFields::class,
[277] Fix | Delete
function ( Container $container ) {
[278] Fix | Delete
return new CheckoutFields( $container->get( AssetDataRegistry::class ) );
[279] Fix | Delete
}
[280] Fix | Delete
);
[281] Fix | Delete
$this->container->register(
[282] Fix | Delete
CheckoutFieldsAdmin::class,
[283] Fix | Delete
function ( Container $container ) {
[284] Fix | Delete
$checkout_fields_controller = $container->get( CheckoutFields::class );
[285] Fix | Delete
return new CheckoutFieldsAdmin( $checkout_fields_controller );
[286] Fix | Delete
}
[287] Fix | Delete
);
[288] Fix | Delete
$this->container->register(
[289] Fix | Delete
CheckoutFieldsFrontend::class,
[290] Fix | Delete
function ( Container $container ) {
[291] Fix | Delete
$checkout_fields_controller = $container->get( CheckoutFields::class );
[292] Fix | Delete
return new CheckoutFieldsFrontend( $checkout_fields_controller );
[293] Fix | Delete
}
[294] Fix | Delete
);
[295] Fix | Delete
$this->container->register(
[296] Fix | Delete
PaymentsApi::class,
[297] Fix | Delete
function ( Container $container ) {
[298] Fix | Delete
$payment_method_registry = $container->get( PaymentMethodRegistry::class );
[299] Fix | Delete
$asset_data_registry = $container->get( AssetDataRegistry::class );
[300] Fix | Delete
return new PaymentsApi( $payment_method_registry, $asset_data_registry );
[301] Fix | Delete
}
[302] Fix | Delete
);
[303] Fix | Delete
$this->container->register(
[304] Fix | Delete
CheckoutLink::class,
[305] Fix | Delete
function () {
[306] Fix | Delete
return new CheckoutLink();
[307] Fix | Delete
}
[308] Fix | Delete
);
[309] Fix | Delete
$this->container->register(
[310] Fix | Delete
StoreApi::class,
[311] Fix | Delete
function () {
[312] Fix | Delete
return new StoreApi();
[313] Fix | Delete
}
[314] Fix | Delete
);
[315] Fix | Delete
$this->container->register(
[316] Fix | Delete
TemplateOptions::class,
[317] Fix | Delete
function () {
[318] Fix | Delete
return new TemplateOptions();
[319] Fix | Delete
}
[320] Fix | Delete
);
[321] Fix | Delete
// Maintains backwards compatibility with previous Store API namespace.
[322] Fix | Delete
$this->container->register(
[323] Fix | Delete
'Automattic\WooCommerce\Blocks\StoreApi\Formatters',
[324] Fix | Delete
function ( Container $container ) {
[325] Fix | Delete
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\Formatters', '6.4.0', 'Automattic\WooCommerce\StoreApi\Formatters', '6.5.0' );
[326] Fix | Delete
return $container->get( StoreApi::class )->container()->get( \Automattic\WooCommerce\StoreApi\Formatters::class );
[327] Fix | Delete
}
[328] Fix | Delete
);
[329] Fix | Delete
$this->container->register(
[330] Fix | Delete
'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi',
[331] Fix | Delete
function ( Container $container ) {
[332] Fix | Delete
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\Domain\Services\ExtendRestApi', '6.4.0', 'Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema', '6.5.0' );
[333] Fix | Delete
return $container->get( StoreApi::class )->container()->get( \Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::class );
[334] Fix | Delete
}
[335] Fix | Delete
);
[336] Fix | Delete
$this->container->register(
[337] Fix | Delete
'Automattic\WooCommerce\Blocks\StoreApi\SchemaController',
[338] Fix | Delete
function ( Container $container ) {
[339] Fix | Delete
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\SchemaController', '6.4.0', 'Automattic\WooCommerce\StoreApi\SchemaController', '6.5.0' );
[340] Fix | Delete
return $container->get( StoreApi::class )->container()->get( SchemaController::class );
[341] Fix | Delete
}
[342] Fix | Delete
);
[343] Fix | Delete
$this->container->register(
[344] Fix | Delete
'Automattic\WooCommerce\Blocks\StoreApi\RoutesController',
[345] Fix | Delete
function ( Container $container ) {
[346] Fix | Delete
$this->deprecated_dependency( 'Automattic\WooCommerce\Blocks\StoreApi\RoutesController', '6.4.0', 'Automattic\WooCommerce\StoreApi\RoutesController', '6.5.0' );
[347] Fix | Delete
return $container->get( StoreApi::class )->container()->get( RoutesController::class );
[348] Fix | Delete
}
[349] Fix | Delete
);
[350] Fix | Delete
$this->container->register(
[351] Fix | Delete
PTKClient::class,
[352] Fix | Delete
function () {
[353] Fix | Delete
return new PTKClient();
[354] Fix | Delete
}
[355] Fix | Delete
);
[356] Fix | Delete
$this->container->register(
[357] Fix | Delete
PTKPatternsStore::class,
[358] Fix | Delete
function () {
[359] Fix | Delete
return new PTKPatternsStore( $this->container->get( PTKClient::class ) );
[360] Fix | Delete
}
[361] Fix | Delete
);
[362] Fix | Delete
$this->container->register(
[363] Fix | Delete
BlockPatterns::class,
[364] Fix | Delete
function () {
[365] Fix | Delete
return new BlockPatterns(
[366] Fix | Delete
$this->package,
[367] Fix | Delete
new PatternRegistry(),
[368] Fix | Delete
$this->container->get( PTKPatternsStore::class )
[369] Fix | Delete
);
[370] Fix | Delete
}
[371] Fix | Delete
);
[372] Fix | Delete
$this->container->register(
[373] Fix | Delete
AIPatterns::class,
[374] Fix | Delete
function () {
[375] Fix | Delete
return new AIPatterns();
[376] Fix | Delete
}
[377] Fix | Delete
);
[378] Fix | Delete
$this->container->register(
[379] Fix | Delete
ShippingController::class,
[380] Fix | Delete
function ( $container ) {
[381] Fix | Delete
$asset_api = $container->get( AssetApi::class );
[382] Fix | Delete
$asset_data_registry = $container->get( AssetDataRegistry::class );
[383] Fix | Delete
return new ShippingController( $asset_api, $asset_data_registry );
[384] Fix | Delete
}
[385] Fix | Delete
);
[386] Fix | Delete
$this->container->register(
[387] Fix | Delete
QueryFilters::class,
[388] Fix | Delete
function () {
[389] Fix | Delete
return new QueryFilters();
[390] Fix | Delete
}
[391] Fix | Delete
);
[392] Fix | Delete
$this->container->register(
[393] Fix | Delete
BlockTemplatesRegistry::class,
[394] Fix | Delete
function () {
[395] Fix | Delete
return new BlockTemplatesRegistry();
[396] Fix | Delete
}
[397] Fix | Delete
);
[398] Fix | Delete
$this->container->register(
[399] Fix | Delete
BlockTemplatesController::class,
[400] Fix | Delete
function () {
[401] Fix | Delete
return new BlockTemplatesController();
[402] Fix | Delete
}
[403] Fix | Delete
);
[404] Fix | Delete
}
[405] Fix | Delete
[406] Fix | Delete
/**
[407] Fix | Delete
* Throws a deprecation notice for a dependency without breaking requests.
[408] Fix | Delete
*
[409] Fix | Delete
* @param string $function Class or function being deprecated.
[410] Fix | Delete
* @param string $version Version in which it was deprecated.
[411] Fix | Delete
* @param string $replacement Replacement class or function, if applicable.
[412] Fix | Delete
* @param string $trigger_error_version Optional version to start surfacing this as a PHP error rather than a log. Defaults to $version.
[413] Fix | Delete
*/
[414] Fix | Delete
protected function deprecated_dependency( $function, $version, $replacement = '', $trigger_error_version = '' ) {
[415] Fix | Delete
if ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) {
[416] Fix | Delete
return;
[417] Fix | Delete
}
[418] Fix | Delete
[419] Fix | Delete
$trigger_error_version = $trigger_error_version ? $trigger_error_version : $version;
[420] Fix | Delete
$error_message = $replacement ? sprintf(
[421] Fix | Delete
'%1$s is <strong>deprecated</strong> since version %2$s! Use %3$s instead.',
[422] Fix | Delete
$function,
[423] Fix | Delete
$version,
[424] Fix | Delete
$replacement
[425] Fix | Delete
) : sprintf(
[426] Fix | Delete
'%1$s is <strong>deprecated</strong> since version %2$s with no alternative available.',
[427] Fix | Delete
$function,
[428] Fix | Delete
$version
[429] Fix | Delete
);
[430] Fix | Delete
/**
[431] Fix | Delete
* Fires when a deprecated function is called.
[432] Fix | Delete
*
[433] Fix | Delete
* @since 7.3.0
[434] Fix | Delete
*/
[435] Fix | Delete
do_action( 'deprecated_function_run', $function, $replacement, $version );
[436] Fix | Delete
[437] Fix | Delete
$log_error = false;
[438] Fix | Delete
[439] Fix | Delete
// If headers have not been sent yet, log to avoid breaking the request.
[440] Fix | Delete
if ( ! headers_sent() ) {
[441] Fix | Delete
$log_error = true;
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
// If the $trigger_error_version was not yet reached, only log the error.
[445] Fix | Delete
if ( version_compare( Constants::get_constant( 'WC_VERSION' ), $trigger_error_version, '<' ) ) {
[446] Fix | Delete
$log_error = true;
[447] Fix | Delete
}
[448] Fix | Delete
[449] Fix | Delete
/**
[450] Fix | Delete
* Filters whether to trigger an error for deprecated functions. (Same as WP core)
[451] Fix | Delete
*
[452] Fix | Delete
* @since 7.3.0
[453] Fix | Delete
*
[454] Fix | Delete
* @param bool $trigger Whether to trigger the error for deprecated functions. Default true.
[455] Fix | Delete
*/
[456] Fix | Delete
if ( ! apply_filters( 'deprecated_function_trigger_error', true ) ) {
[457] Fix | Delete
$log_error = true;
[458] Fix | Delete
}
[459] Fix | Delete
[460] Fix | Delete
if ( $log_error ) {
[461] Fix | Delete
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
[462] Fix | Delete
error_log( $error_message );
[463] Fix | Delete
} else {
[464] Fix | Delete
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped, WordPress.PHP.DevelopmentFunctions.error_log_trigger_error
[465] Fix | Delete
trigger_error( $error_message, E_USER_DEPRECATED );
[466] Fix | Delete
}
[467] Fix | Delete
}
[468] Fix | Delete
[469] Fix | Delete
/**
[470] Fix | Delete
* Register payment method integrations with the container.
[471] Fix | Delete
*/
[472] Fix | Delete
protected function register_payment_methods() {
[473] Fix | Delete
$this->container->register(
[474] Fix | Delete
Cheque::class,
[475] Fix | Delete
function ( Container $container ) {
[476] Fix | Delete
$asset_api = $container->get( AssetApi::class );
[477] Fix | Delete
return new Cheque( $asset_api );
[478] Fix | Delete
}
[479] Fix | Delete
);
[480] Fix | Delete
$this->container->register(
[481] Fix | Delete
PayPal::class,
[482] Fix | Delete
function ( Container $container ) {
[483] Fix | Delete
$asset_api = $container->get( AssetApi::class );
[484] Fix | Delete
return new PayPal( $asset_api );
[485] Fix | Delete
}
[486] Fix | Delete
);
[487] Fix | Delete
$this->container->register(
[488] Fix | Delete
BankTransfer::class,
[489] Fix | Delete
function ( Container $container ) {
[490] Fix | Delete
$asset_api = $container->get( AssetApi::class );
[491] Fix | Delete
return new BankTransfer( $asset_api );
[492] Fix | Delete
}
[493] Fix | Delete
);
[494] Fix | Delete
$this->container->register(
[495] Fix | Delete
CashOnDelivery::class,
[496] Fix | Delete
function ( Container $container ) {
[497] Fix | Delete
$asset_api = $container->get( AssetApi::class );
[498] Fix | Delete
return new CashOnDelivery( $asset_api );
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function