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