PHP 8.2.31
Preview: Marketplace.php Size: 3.48 KB
/home/nshryvcy/radiantskinclinics.org/wp-content/plugins/woocommerce/src/Internal/Admin/Marketplace.php

<?php
/**
 * WooCommerce Marketplace.
 */

namespace Automattic\WooCommerce\Internal\Admin;

use WC_Helper_Options;
use WC_Helper_Updater;

/**
 * Contains backend logic for the Marketplace feature.
 */
class Marketplace {
	const MARKETPLACE_TAB_SLUG = 'woo';

	/**
	 * Class initialization, to be executed when the class is resolved by the container.
	 *
	 * @internal
	 */
	final public function init() {
		add_action( 'init', array( $this, 'on_init' ) );
	}

	/**
	 * Hook into WordPress on init.
	 */
	public function on_init() {
		add_action( 'admin_menu', array( $this, 'register_pages' ), 70 );
		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );

		// Add a Woo Marketplace link to the plugin install action links.
		add_filter( 'install_plugins_tabs', array( $this, 'add_woo_plugin_install_action_link' ) );
		add_action( 'install_plugins_pre_woo', array( $this, 'maybe_open_woo_tab' ) );
	}

	/**
	 * Registers report pages.
	 */
	public function register_pages() {
		if ( ! function_exists( 'wc_admin_register_page' ) ) {
			return;
		}

		$marketplace_pages = $this->get_marketplace_pages();

		foreach ( $marketplace_pages as $marketplace_page ) {
			if ( ! is_null( $marketplace_page ) ) {
				wc_admin_register_page( $marketplace_page );
			}
		}
	}

	/**
	 * Get report pages.
	 */
	public function get_marketplace_pages() {
		$marketplace_pages = array(
			array(
				'id'         => 'woocommerce-marketplace',
				'parent'     => 'woocommerce',
				'title'      => __( 'Extensions', 'woocommerce' ) . $this->badge(),
				'page_title' => __( 'Extensions', 'woocommerce' ),
				'path'       => '/extensions',
			),
		);

		/**
		 * The marketplace items used in the menu.
		 *
		 * @since 8.0
		 */
		return apply_filters( 'woocommerce_marketplace_menu_items', $marketplace_pages );
	}

	private function badge(): string {
		$option = WC_Helper_Options::get( 'my_subscriptions_tab_loaded' );

		if ( ! $option ) {
			return WC_Helper_Updater::get_updates_count_html();
		}

		return '';
	}

	/**
	 * Enqueue update script.
	 *
	 * @param string $hook_suffix The current admin page.
	 */
	public function enqueue_scripts( $hook_suffix ) {
		// phpcs:disable WordPress.Security.NonceVerification.Recommended
		if ( 'woocommerce_page_wc-admin' !== $hook_suffix ) {
			return;
		}

		if ( ! isset( $_GET['path'] ) || '/extensions' !== $_GET['path'] ) {
			return;
		}

		// Enqueue WordPress updates script to enable plugin and theme installs and updates.
		wp_enqueue_script( 'updates' );
		// phpcs:enable WordPress.Security.NonceVerification.Recommended
	}

	/**
	 * Add a Woo Marketplace link to the plugin install action links.
	 *
	 * @param array $tabs Plugins list tabs.
	 * @return array
	 */
	public function add_woo_plugin_install_action_link( $tabs ) {
		$tabs[ self::MARKETPLACE_TAB_SLUG ] = 'WooCommerce Marketplace';
		return $tabs;
	}

	/**
	 * Open the Woo tab when the user clicks on the Woo link in the plugin installer.
	 */
	public function maybe_open_woo_tab() {
		// phpcs:disable WordPress.Security.NonceVerification.Recommended
		if ( ! isset( $_GET['tab'] ) || self::MARKETPLACE_TAB_SLUG !== $_GET['tab'] ) {
			return;
		}
		// phpcs:enable WordPress.Security.NonceVerification.Recommended

		$woo_url = add_query_arg(
			array(
				'page' => 'wc-admin',
				'path' => '/extensions',
				'tab'  => 'extensions',
				'ref'  => 'plugins',
			),
			admin_url( 'admin.php' )
		);

		wc_admin_record_tracks_event( 'marketplace_plugin_install_woo_clicked' );
		wp_safe_redirect( $woo_url );
		exit;
	}
}

Directory Contents

Dirs: 18 × Files: 25

Name Size Perms Modified Actions
Agentic DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
Emails DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
Logging DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
Marketing DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
Notes DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
Orders DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
Settings DIR
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
- drwxr-xr-x 2026-05-29 02:43:21
Edit Download
1.58 KB lrw-r--r-- 2022-08-24 02:07:06
Edit Download
11.78 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
7.99 KB lrw-r--r-- 2022-04-20 06:50:54
Edit Download
2.86 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
2.41 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
17.65 KB lrw-r--r-- 2025-11-24 23:10:10
Edit Download
8.54 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
6.77 KB lrw-r--r-- 2026-02-23 17:58:34
Edit Download
8.70 KB lrw-r--r-- 2026-05-11 17:17:08
Edit Download
19.18 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
6.29 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
3.48 KB lrw-r--r-- 2026-01-19 14:46:18
Edit Download
956 B lrw-r--r-- 2022-04-20 06:50:54
Edit Download
932 B lrw-r--r-- 2023-03-21 20:45:06
Edit Download
14.61 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
4.67 KB lrw-r--r-- 2024-09-23 20:44:04
Edit Download
3.63 KB lrw-r--r-- 2024-09-04 20:34:26
Edit Download
2.31 KB lrw-r--r-- 2023-02-22 07:17:34
Edit Download
768 B lrw-r--r-- 2022-04-20 06:50:54
Edit Download
5.85 KB lrw-r--r-- 2025-05-12 21:07:28
Edit Download
11.66 KB lrw-r--r-- 2024-11-14 01:17:00
Edit Download
17.74 KB lrw-r--r-- 2026-05-05 14:26:50
Edit Download
2.08 KB lrw-r--r-- 2025-04-22 15:40:34
Edit Download
5.26 KB lrw-r--r-- 2025-10-06 17:56:06
Edit Download
6.33 KB lrw-r--r-- 2025-06-23 19:46:28
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).