WC_Helper_Admin::add_marketplace_settingspublic staticWC 1.0

Pushes settings onto the WooCommerce Admin global settings object (wcSettings).

Метод класса: WC_Helper_Admin{}

Хуков нет.

Возвращает

Разное. $settings

Использование

$result = WC_Helper_Admin::add_marketplace_settings( $settings );
$settings(разное) (обязательный)
The settings object we're amending.

Код WC_Helper_Admin::add_marketplace_settings() WC 10.3.4

public static function add_marketplace_settings( $settings ) {
	if ( ! WC_Helper::is_site_connected() && isset( $_GET['connect'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		wp_safe_redirect( self::get_connection_url() );
		exit;
	}

	$auth_user_data  = WC_Helper_Options::get( 'auth_user_data', array() );
	$auth_user_email = isset( $auth_user_data['email'] ) ? $auth_user_data['email'] : '';

	// Get the all installed themes and plugins. Knowing this will help us decide to show Add to Store button on product cards.
	$installed_products = array_merge( WC_Helper::get_local_plugins(), WC_Helper::get_local_themes() );
	$installed_products = array_map(
		function ( $product ) {
			return $product['slug'];
		},
		$installed_products
	);

	$blog_name = get_bloginfo( 'name' );

	$settings['wccomHelper'] = array(
		'isConnected'                => WC_Helper::is_site_connected(),
		'connectURL'                 => self::get_connection_url(),
		'reConnectURL'               => self::get_connection_url( true ),
		'userEmail'                  => $auth_user_email,
		'userAvatar'                 => get_avatar_url( $auth_user_email, array( 'size' => '48' ) ),
		'storeCountry'               => wc_get_base_location()['country'],
		'storeName'                  => $blog_name ? $blog_name : '',
		'inAppPurchaseURLParams'     => WC_Admin_Addons::get_in_app_purchase_url_params(),
		'installedProducts'          => $installed_products,
		'mySubscriptionsTabLoaded'   => WC_Helper_Options::get( 'my_subscriptions_tab_loaded' ),
		'wooUpdateManagerInstalled'  => WC_Woo_Update_Manager_Plugin::is_plugin_installed(),
		'wooUpdateManagerActive'     => WC_Woo_Update_Manager_Plugin::is_plugin_active(),
		'wooUpdateManagerInstallUrl' => WC_Woo_Update_Manager_Plugin::generate_install_url(),
		'wooUpdateManagerPluginSlug' => WC_Woo_Update_Manager_Plugin::WOO_UPDATE_MANAGER_SLUG,
		'dismissNoticeNonce'         => wp_create_nonce( 'dismiss_notice' ),
		'trackingAllowed'            => 'yes' === get_option( 'woocommerce_allow_tracking' ),
	);

	// This data is only used in the `Extensions` screen, so only populate it there.
	// More specifically, it's used in `My Subscriptions`, however, switching tabs doesn't require
	// a page reload, so we just check for `path` (/extensions), rather than `tab` (my-subscriptions).
	if ( ! empty( $_GET['path'] ) && '/extensions' === $_GET['path'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
		$settings['wccomHelper']['wooUpdateCount']          = WC_Helper_Updater::get_updates_count_based_on_site_status();
		$settings['wccomHelper']['connected_notice']        = PluginsHelper::get_wccom_connected_notice( $auth_user_email );
		$settings['wccomHelper']['woocomConnectNoticeType'] = WC_Helper_Updater::get_woo_connect_notice_type();

		if ( WC_Helper::is_site_connected() ) {
			$settings['wccomHelper']['subscription_expired_notice']  = PluginsHelper::get_expired_subscription_notice( false );
			$settings['wccomHelper']['subscription_expiring_notice'] = PluginsHelper::get_expiring_subscription_notice( false );
			$settings['wccomHelper']['subscription_missing_notice']  = PluginsHelper::get_missing_subscription_notice();
			$settings['wccomHelper']['connection_url_notice']        = WC_Woo_Helper_Connection::get_connection_url_notice();
			$settings['wccomHelper']['has_host_plan_orders']         = WC_Woo_Helper_Connection::has_host_plan_orders();
		} else {
			$settings['wccomHelper']['disconnected_notice'] = PluginsHelper::get_wccom_disconnected_notice();
		}
	}

	return $settings;
}