Edit File by line
/home/zeestwma/richards.../wp-conte.../plugins/woocomme.../src/Internal/Admin
File: FeaturePlugin.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* WooCommerce Admin: Feature plugin main class.
[2] Fix | Delete
*/
[3] Fix | Delete
[4] Fix | Delete
namespace Automattic\WooCommerce\Internal\Admin;
[5] Fix | Delete
[6] Fix | Delete
defined( 'ABSPATH' ) || exit;
[7] Fix | Delete
[8] Fix | Delete
use Automattic\WooCommerce\Admin\API;
[9] Fix | Delete
use Automattic\WooCommerce\Admin\Notes\Notes;
[10] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\OrderMilestones;
[11] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\WooSubscriptionsNotes;
[12] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\TrackingOptIn;
[13] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\WooCommercePayments;
[14] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\InstallJPAndWCSPlugins;
[15] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\SellingOnlineCourses;
[16] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\MagentoMigration;
[17] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Notes\ScheduledUpdatesPromotion;
[18] Fix | Delete
use Automattic\WooCommerce\Admin\Features\Features;
[19] Fix | Delete
use Automattic\WooCommerce\Admin\PluginsHelper;
[20] Fix | Delete
use Automattic\WooCommerce\Admin\PluginsInstaller;
[21] Fix | Delete
use Automattic\WooCommerce\Admin\ReportExporter;
[22] Fix | Delete
use Automattic\WooCommerce\Admin\ReportsSync;
[23] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\CategoryLookup;
[24] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Events;
[25] Fix | Delete
use Automattic\WooCommerce\Internal\Admin\Onboarding\Onboarding;
[26] Fix | Delete
[27] Fix | Delete
/**
[28] Fix | Delete
* Feature plugin main class.
[29] Fix | Delete
*
[30] Fix | Delete
* @internal This file will not be bundled with woo core, only the feature plugin.
[31] Fix | Delete
* @internal Note this is not called WC_Admin due to a class already existing in core with that name.
[32] Fix | Delete
*/
[33] Fix | Delete
class FeaturePlugin {
[34] Fix | Delete
/**
[35] Fix | Delete
* The single instance of the class.
[36] Fix | Delete
*
[37] Fix | Delete
* @var object
[38] Fix | Delete
*/
[39] Fix | Delete
protected static $instance = null;
[40] Fix | Delete
[41] Fix | Delete
/**
[42] Fix | Delete
* Indicates if init has been invoked already.
[43] Fix | Delete
*
[44] Fix | Delete
* @var bool
[45] Fix | Delete
*/
[46] Fix | Delete
private bool $initialized = false;
[47] Fix | Delete
[48] Fix | Delete
/**
[49] Fix | Delete
* Constructor
[50] Fix | Delete
*
[51] Fix | Delete
* @return void
[52] Fix | Delete
*/
[53] Fix | Delete
protected function __construct() {}
[54] Fix | Delete
[55] Fix | Delete
/**
[56] Fix | Delete
* Get class instance.
[57] Fix | Delete
*
[58] Fix | Delete
* @return object Instance.
[59] Fix | Delete
*/
[60] Fix | Delete
final public static function instance() {
[61] Fix | Delete
if ( null === static::$instance ) {
[62] Fix | Delete
static::$instance = new static();
[63] Fix | Delete
}
[64] Fix | Delete
return static::$instance;
[65] Fix | Delete
}
[66] Fix | Delete
[67] Fix | Delete
/**
[68] Fix | Delete
* Init the feature plugin, only if we can detect both Gutenberg and WooCommerce.
[69] Fix | Delete
*/
[70] Fix | Delete
public function init() {
[71] Fix | Delete
// Bail if WC isn't initialized (This can be called from WCAdmin's entrypoint).
[72] Fix | Delete
if ( ! defined( 'WC_ABSPATH' ) ) {
[73] Fix | Delete
return;
[74] Fix | Delete
}
[75] Fix | Delete
[76] Fix | Delete
if ( $this->initialized ) {
[77] Fix | Delete
return;
[78] Fix | Delete
}
[79] Fix | Delete
$this->initialized = true;
[80] Fix | Delete
[81] Fix | Delete
// Load the page controller functions file first to prevent fatal errors when disabling WooCommerce Admin.
[82] Fix | Delete
$this->define_constants();
[83] Fix | Delete
require_once WC_ADMIN_ABSPATH . '/includes/react-admin/page-controller-functions.php';
[84] Fix | Delete
require_once WC_ADMIN_ABSPATH . '/src/Admin/Notes/DeprecatedNotes.php';
[85] Fix | Delete
require_once WC_ADMIN_ABSPATH . '/includes/react-admin/core-functions.php';
[86] Fix | Delete
require_once WC_ADMIN_ABSPATH . '/includes/react-admin/feature-config.php';
[87] Fix | Delete
require_once WC_ADMIN_ABSPATH . '/includes/react-admin/wc-admin-update-functions.php';
[88] Fix | Delete
require_once WC_ADMIN_ABSPATH . '/includes/react-admin/class-experimental-abtest.php';
[89] Fix | Delete
[90] Fix | Delete
if ( did_action( 'plugins_loaded' ) ) {
[91] Fix | Delete
self::on_plugins_loaded();
[92] Fix | Delete
} else {
[93] Fix | Delete
// Make sure we hook into `plugins_loaded` before core's Automattic\WooCommerce\Package::init().
[94] Fix | Delete
// If core is network activated but we aren't, the packaged version of WooCommerce Admin will
[95] Fix | Delete
// attempt to use a data store that hasn't been loaded yet - because we've defined our constants here.
[96] Fix | Delete
// See: https://github.com/woocommerce/woocommerce-admin/issues/3869.
[97] Fix | Delete
add_action( 'plugins_loaded', array( $this, 'on_plugins_loaded' ), 9 );
[98] Fix | Delete
}
[99] Fix | Delete
}
[100] Fix | Delete
[101] Fix | Delete
/**
[102] Fix | Delete
* Setup plugin once all other plugins are loaded.
[103] Fix | Delete
*
[104] Fix | Delete
* @return void
[105] Fix | Delete
*/
[106] Fix | Delete
public function on_plugins_loaded() {
[107] Fix | Delete
$this->hooks();
[108] Fix | Delete
$this->includes();
[109] Fix | Delete
}
[110] Fix | Delete
[111] Fix | Delete
/**
[112] Fix | Delete
* Define Constants.
[113] Fix | Delete
*
[114] Fix | Delete
* IMPORTANT: When adding new constants here, also add them to
[115] Fix | Delete
* php-stubs/wc-constants.php for PHPStan static analysis.
[116] Fix | Delete
*/
[117] Fix | Delete
protected function define_constants() {
[118] Fix | Delete
$this->define( 'WC_ADMIN_APP', 'wc-admin-app' );
[119] Fix | Delete
$this->define( 'WC_ADMIN_ABSPATH', WC_ABSPATH );
[120] Fix | Delete
$this->define( 'WC_ADMIN_DIST_JS_FOLDER', 'assets/client/admin/' );
[121] Fix | Delete
$this->define( 'WC_ADMIN_DIST_CSS_FOLDER', 'assets/client/admin/' );
[122] Fix | Delete
$this->define( 'WC_ADMIN_PLUGIN_FILE', WC_PLUGIN_FILE );
[123] Fix | Delete
[124] Fix | Delete
/**
[125] Fix | Delete
* Define the WC Admin Images Folder URL.
[126] Fix | Delete
*
[127] Fix | Delete
* @deprecated 6.7.0
[128] Fix | Delete
* @var string
[129] Fix | Delete
*/
[130] Fix | Delete
if ( ! defined( 'WC_ADMIN_IMAGES_FOLDER_URL' ) ) {
[131] Fix | Delete
/**
[132] Fix | Delete
* Define the WC Admin Images Folder URL.
[133] Fix | Delete
*
[134] Fix | Delete
* @deprecated 6.7.0
[135] Fix | Delete
* @var string
[136] Fix | Delete
*/
[137] Fix | Delete
define( 'WC_ADMIN_IMAGES_FOLDER_URL', plugins_url( 'assets/images', WC_PLUGIN_FILE ) );
[138] Fix | Delete
}
[139] Fix | Delete
[140] Fix | Delete
/**
[141] Fix | Delete
* Define the current WC Admin version.
[142] Fix | Delete
*
[143] Fix | Delete
* @deprecated 6.4.0
[144] Fix | Delete
* @var string
[145] Fix | Delete
*/
[146] Fix | Delete
if ( ! defined( 'WC_ADMIN_VERSION_NUMBER' ) ) {
[147] Fix | Delete
/**
[148] Fix | Delete
* Define the current WC Admin version.
[149] Fix | Delete
*
[150] Fix | Delete
* @deprecated 6.4.0
[151] Fix | Delete
* @var string
[152] Fix | Delete
*/
[153] Fix | Delete
define( 'WC_ADMIN_VERSION_NUMBER', '3.3.0' );
[154] Fix | Delete
}
[155] Fix | Delete
}
[156] Fix | Delete
[157] Fix | Delete
/**
[158] Fix | Delete
* Include WC Admin classes.
[159] Fix | Delete
*/
[160] Fix | Delete
public function includes() {
[161] Fix | Delete
// Initialize Database updates, option migrations, and Notes.
[162] Fix | Delete
Events::instance()->init();
[163] Fix | Delete
Notes::init();
[164] Fix | Delete
[165] Fix | Delete
// Initialize Plugins Installer.
[166] Fix | Delete
PluginsInstaller::init();
[167] Fix | Delete
PluginsHelper::init();
[168] Fix | Delete
[169] Fix | Delete
// Initialize API.
[170] Fix | Delete
API\Init::instance();
[171] Fix | Delete
[172] Fix | Delete
if ( Features::is_enabled( 'onboarding' ) ) {
[173] Fix | Delete
Onboarding::init();
[174] Fix | Delete
}
[175] Fix | Delete
[176] Fix | Delete
if ( Features::is_enabled( 'analytics' ) ) {
[177] Fix | Delete
// Initialize Reports syncing.
[178] Fix | Delete
ReportsSync::init();
[179] Fix | Delete
CategoryLookup::instance()->init();
[180] Fix | Delete
[181] Fix | Delete
// Initialize Reports exporter.
[182] Fix | Delete
ReportExporter::init();
[183] Fix | Delete
}
[184] Fix | Delete
[185] Fix | Delete
// Admin note providers.
[186] Fix | Delete
// @todo These should be bundled in the features/ folder, but loading them from there currently has a load order issue.
[187] Fix | Delete
new WooSubscriptionsNotes();
[188] Fix | Delete
new OrderMilestones();
[189] Fix | Delete
new TrackingOptIn();
[190] Fix | Delete
new WooCommercePayments();
[191] Fix | Delete
new InstallJPAndWCSPlugins();
[192] Fix | Delete
new SellingOnlineCourses();
[193] Fix | Delete
new MagentoMigration();
[194] Fix | Delete
new ScheduledUpdatesPromotion();
[195] Fix | Delete
}
[196] Fix | Delete
[197] Fix | Delete
/**
[198] Fix | Delete
* Set up our admin hooks and plugin loader.
[199] Fix | Delete
*/
[200] Fix | Delete
protected function hooks() {
[201] Fix | Delete
add_filter( 'woocommerce_admin_features', array( $this, 'replace_supported_features' ), 0 );
[202] Fix | Delete
[203] Fix | Delete
Loader::get_instance();
[204] Fix | Delete
WCAdminAssets::get_instance();
[205] Fix | Delete
}
[206] Fix | Delete
[207] Fix | Delete
[208] Fix | Delete
/**
[209] Fix | Delete
* Overwrites the allowed features array using a local `feature-config.php` file.
[210] Fix | Delete
*
[211] Fix | Delete
* @param array $features Array of feature slugs.
[212] Fix | Delete
*/
[213] Fix | Delete
public function replace_supported_features( $features ) {
[214] Fix | Delete
/**
[215] Fix | Delete
* Get additional feature config
[216] Fix | Delete
*
[217] Fix | Delete
* @since 6.5.0
[218] Fix | Delete
*/
[219] Fix | Delete
$feature_config = apply_filters( 'woocommerce_admin_get_feature_config', wc_admin_get_feature_config() );
[220] Fix | Delete
$features = array_keys( array_filter( $feature_config ) );
[221] Fix | Delete
return $features;
[222] Fix | Delete
}
[223] Fix | Delete
[224] Fix | Delete
/**
[225] Fix | Delete
* Define constant if not already set.
[226] Fix | Delete
*
[227] Fix | Delete
* @param string $name Constant name.
[228] Fix | Delete
* @param string|bool $value Constant value.
[229] Fix | Delete
*/
[230] Fix | Delete
protected function define( $name, $value ) {
[231] Fix | Delete
if ( ! defined( $name ) ) {
[232] Fix | Delete
define( $name, $value );
[233] Fix | Delete
}
[234] Fix | Delete
}
[235] Fix | Delete
[236] Fix | Delete
/**
[237] Fix | Delete
* Prevent cloning.
[238] Fix | Delete
*/
[239] Fix | Delete
private function __clone() {}
[240] Fix | Delete
[241] Fix | Delete
/**
[242] Fix | Delete
* Prevent unserializing.
[243] Fix | Delete
*/
[244] Fix | Delete
public function __wakeup() {
[245] Fix | Delete
die();
[246] Fix | Delete
}
[247] Fix | Delete
}
[248] Fix | Delete
[249] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function