golden hour
/home/godaofbq/hyperbarichelp.com/wp-content/plugins/woocommerce/src/Internal/Admin
⬆️ Go Up
Upload
File/Folder
Size
Actions
.htaccess
420 B
Del
OK
ActivityPanels.php
1.58 KB
Del
OK
Agentic
-
Del
OK
Analytics.php
24.59 KB
Del
OK
CategoryLookup.php
7.99 KB
Del
OK
Coupons.php
2.86 KB
Del
OK
CouponsMovedTrait.php
2.41 KB
Del
OK
CustomerEffortScoreTracks.php
17.65 KB
Del
OK
EmailImprovements
-
Del
OK
EmailPreview
-
Del
OK
Emails
-
Del
OK
Events.php
8.54 KB
Del
OK
FeaturePlugin.php
6.77 KB
Del
OK
Homescreen.php
8.7 KB
Del
OK
ImportExport
-
Del
OK
Loader.php
19.51 KB
Del
OK
Logging
-
Del
OK
Marketing
-
Del
OK
Marketing.php
6.29 KB
Del
OK
Marketplace.php
3.48 KB
Del
OK
MobileAppBanner.php
956 B
Del
OK
Notes
-
Del
OK
Onboarding
-
Del
OK
OrderMilestoneEasterEgg.php
13.98 KB
Del
OK
Orders
-
Del
OK
ProductForm
-
Del
OK
ProductReviews
-
Del
OK
RemoteFreeExtensions
-
Del
OK
RemoteInboxNotifications.php
932 B
Del
OK
Schedulers
-
Del
OK
Settings
-
Del
OK
Settings.php
16.16 KB
Del
OK
ShippingLabelBanner.php
4.67 KB
Del
OK
ShippingLabelBannerDisplayRules.php
3.63 KB
Del
OK
SiteHealth.php
25.3 KB
Del
OK
Suggestions
-
Del
OK
Survey.php
768 B
Del
OK
SystemStatusReport.php
5.85 KB
Del
OK
TaxSettingsRecommendations.php
3.56 KB
Del
OK
Translations.php
11.66 KB
Del
OK
WCAdminAssets.php
17.53 KB
Del
OK
WCAdminSharedSettings.php
2.08 KB
Del
OK
WCAdminUser.php
5.26 KB
Del
OK
WCPayPromotion
-
Del
OK
WcPayWelcomePage.php
6.33 KB
Del
OK
Edit: WCAdminUser.php
<?php namespace Automattic\WooCommerce\Internal\Admin; /** * WCAdminUser Class. */ class WCAdminUser { /** * Class instance. * * @var WCAdminUser instance */ protected static $instance = null; /** * Constructor. */ public function __construct() { add_action( 'rest_api_init', array( $this, 'register_user_data' ) ); } /** * Get class instance. * * @return object Instance. */ public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } /** * Registers WooCommerce specific user data to the WordPress user API. */ public function register_user_data() { register_rest_field( 'user', 'is_super_admin', array( 'get_callback' => function( $user ) { if ( ! isset( $user['id'] ) || 0 === $user['id'] ) { return false; } return is_super_admin( $user['id'] ); }, 'schema' => null, ) ); register_rest_field( 'user', 'woocommerce_meta', array( 'get_callback' => array( $this, 'get_user_data_values' ), 'update_callback' => array( $this, 'update_user_data_values' ), 'schema' => null, ) ); } /** * For all the registered user data fields ( Loader::get_user_data_fields ), fetch the data * for returning via the REST API. * * @param WP_User $user Current user. */ public function get_user_data_values( $user ) { $values = array(); foreach ( $this->get_user_data_fields() as $field ) { $values[ $field ] = self::get_user_data_field( $user['id'], $field ); } return $values; } /** * For all the registered user data fields ( Loader::get_user_data_fields ), update the data * for the REST API. * * @param array $values The new values for the meta. * @param WP_User $user The current user. * @param string $field_id The field id for the user meta. */ public function update_user_data_values( $values, $user, $field_id ) { if ( empty( $values ) || ! is_array( $values ) || 'woocommerce_meta' !== $field_id ) { return; } $fields = $this->get_user_data_fields(); $updates = array(); foreach ( $values as $field => $value ) { if ( in_array( $field, $fields, true ) ) { $updates[ $field ] = $value; self::update_user_data_field( $user->ID, $field, $value ); } } return $updates; } /** * We store some WooCommerce specific user meta attached to users endpoint, * so that we can track certain preferences or values such as the inbox activity panel last open time. * Additional fields can be added in the function below, and then used via wc-admin's currentUser data. * * @return array Fields to expose over the WP user endpoint. */ public function get_user_data_fields() { /** * Filter user data fields exposed over the WordPress user endpoint. * * @since 4.0.0 * @param array $fields Array of fields to expose over the WP user endpoint. */ return apply_filters( 'woocommerce_admin_get_user_data_fields', array( 'variable_product_tour_shown' ) ); } /** * Helper to update user data fields. * * @param int $user_id User ID. * @param string $field Field name. * @param mixed $value Field value. */ public static function update_user_data_field( $user_id, $field, $value ) { update_user_meta( $user_id, 'woocommerce_admin_' . $field, $value ); } /** * Helper to retrieve user data fields. * * Migrates old key prefixes as well. * * @param int $user_id User ID. * @param string $field Field name. * @return mixed The user field value. */ public static function get_user_data_field( $user_id, $field ) { $meta_value = get_user_meta( $user_id, 'woocommerce_admin_' . $field, true ); // Migrate old meta values (prefix changed from `wc_admin_` to `woocommerce_admin_`). if ( '' === $meta_value ) { $old_meta_value = get_user_meta( $user_id, 'wc_admin_' . $field, true ); if ( '' !== $old_meta_value ) { self::update_user_data_field( $user_id, $field, $old_meta_value ); delete_user_meta( $user_id, 'wc_admin_' . $field ); $meta_value = $old_meta_value; } } return $meta_value; } /** * Get the current user data. * * @return array User data. */ public static function get_user_data() { $user_controller = new \WP_REST_Users_Controller(); $request = new \WP_REST_Request(); $request->set_query_params( array( 'context' => 'edit' ) ); $user_response = $user_controller->get_current_item( $request ); $current_user_data = is_wp_error( $user_response ) ? (object) array() : $user_response->get_data(); $current_user_data = self::filter_user_capabilities( $current_user_data ); return $current_user_data; } /** * Filter user capabilities to respect file modification restrictions. * * @param array $user_data User data. * @return array Filtered user data. */ private static function filter_user_capabilities( $user_data ) { if ( ! is_array( $user_data ) || ! isset( $user_data['capabilities'] ) ) { return $user_data; } // If the user has install_plugins capability, check if file modifications are allowed. if ( isset( $user_data['capabilities']->install_plugins ) && $user_data['capabilities']->install_plugins ) { $user_data['capabilities']->install_plugins = wp_is_file_mod_allowed( 'woocommerce' ); } return $user_data; } }
Save