✘✘ GRAYBYTE WORDPRESS FILE MANAGER ✘✘

​🇳​​🇦​​🇲​​🇪♯➤ premium290.web-hosting.com ​🇻​♯➤ 4.18.0-553.45.1.lve.el8.x86_64 #1 SMP 🇾​♯➤ 2025

𝗛𝗢𝗠𝗘 𝗜𝗗 ♯➤ 63.250.38.37 ♯➤ 𝗔𝗗𝗠𝗜𝗡 𝗜𝗗 216.73.216.105
𝗢𝗣𝗧𝗜𝗢𝗡𝗦 ♯ CRL ♯➤ 𝗢𝗞 ┃ WGT ♯➤ 𝗢𝗞 ┃ SDO ♯➤ 𝗢𝗙𝗙 ┃ PKEX ♯➤ 𝗢𝗙𝗙
𝗗𝗘𝗔𝗖𝗧𝗜𝗩𝗔𝗧𝗘𝗗 ♯➤ 𝗔𝗟𝗟 𝗪𝗢𝗥𝗞𝗜𝗡𝗚....

𝗛𝗢𝗠𝗘
𝗖𝗨𝗥𝗥𝗘𝗡𝗧 𝗙𝗜𝗟𝗘 : /home/tdhomesa/public_html/wp-content/plugins/woocommerce/src/Utilities//PluginUtil.php
<?php
/**
 * A class of utilities for dealing with plugins.
 */

namespace Automattic\WooCommerce\Utilities;

use Automattic\WooCommerce\Enums\FeaturePluginCompatibility;
use Automattic\WooCommerce\Internal\Features\FeaturesController;
use Automattic\WooCommerce\Internal\Utilities\PluginInstaller;
use Automattic\WooCommerce\Proxies\LegacyProxy;

/**
 * A class of utilities for dealing with plugins.
 */
class PluginUtil {

	/**
	 * The LegacyProxy instance to use.
	 *
	 * @var LegacyProxy
	 */
	private $proxy;

	/**
	 * The cached list of WooCommerce aware plugin ids.
	 *
	 * @var null|array
	 */
	private $woocommerce_aware_plugins = null;

	/**
	 * The cached list of enabled WooCommerce aware plugin ids.
	 *
	 * @var null|array
	 */
	private $woocommerce_aware_active_plugins = null;

	/**
	 * List of plugins excluded from feature compatibility warnings in UI.
	 *
	 * @var string[]
	 */
	private $plugins_excluded_from_compatibility_ui;

	/**
	 * Creates a new instance of the class.
	 */
	public function __construct() {
		add_action( 'activated_plugin', array( $this, 'handle_plugin_de_activation' ), 10, 0 );
		add_action( 'deactivated_plugin', array( $this, 'handle_plugin_de_activation' ), 10, 0 );

		$this->plugins_excluded_from_compatibility_ui = array( 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php' );
	}

	/**
	 * Initialize the class instance.
	 *
	 * @internal
	 *
	 * @param LegacyProxy $proxy The instance of LegacyProxy to use.
	 */
	final public function init( LegacyProxy $proxy ) {
		$this->proxy = $proxy;
		require_once ABSPATH . WPINC . '/plugin.php';
	}

	/**
	 * Wrapper for WP's private `wp_get_active_and_valid_plugins` and `wp_get_active_network_plugins` functions.
	 *
	 * This combines the results of the two functions to get a list of all plugins that are active within a site.
	 * It's more useful than just retrieving the option values because it also validates that the plugin files exist.
	 * This wrapper is also a hedge against backward-incompatible changes since both of the WP methods are marked as
	 * being "@access private", so if need be we can update our methods here to preserve functionality.
	 *
	 * Note that the doc block for `wp_get_active_and_valid_plugins` says it returns "Array of paths to plugin files
	 * relative to the plugins directory", but it actually returns absolute paths.
	 *
	 * @return string[] Array of plugin basenames (paths relative to the plugin directory).
	 */
	public function get_all_active_valid_plugins() {
		$local = wp_get_active_and_valid_plugins();

		if ( is_multisite() ) {
			require_once ABSPATH . WPINC . '/ms-load.php';
			$network = wp_get_active_network_plugins();
		} else {
			$network = array();
		}

		$all = array_merge( $local, $network );
		$all = array_unique( $all );
		$all = array_map( 'plugin_basename', $all );
		sort( $all );

		return $all;
	}

	/**
	 * Get a list with the names of the WordPress plugins that are WooCommerce aware
	 * (they have a "WC tested up to" header).
	 *
	 * @param bool $active_only True to return only active plugins, false to return all the active plugins.
	 * @return string[] A list of plugin ids (path/file.php).
	 */
	public function get_woocommerce_aware_plugins( bool $active_only = false ): array {
		if ( is_null( $this->woocommerce_aware_plugins ) ) {
			// In case `get_plugins` was called much earlier in the request (before our headers could be injected), we
			// invalidate the plugin cache list.
			wp_cache_delete( 'plugins', 'plugins' );
			$all_plugins = $this->proxy->call_function( 'get_plugins' );

			$this->woocommerce_aware_plugins =
				array_keys(
					array_filter(
						$all_plugins,
						array( $this, 'is_woocommerce_aware_plugin' )
					)
				);

			$this->woocommerce_aware_active_plugins =
				array_values(
					array_filter(
						$this->woocommerce_aware_plugins,
						function ( $plugin_name ) {
							return $this->proxy->call_function( 'is_plugin_active', $plugin_name );
						}
					)
				);
		}

		return $active_only ? $this->woocommerce_aware_active_plugins : $this->woocommerce_aware_plugins;
	}

	/**
	 * Get the printable name of a plugin.
	 *
	 * @param string $plugin_id Plugin id (path/file.php).
	 * @return string Printable plugin name, or the plugin id itself if printable name is not available.
	 */
	public function get_plugin_name( string $plugin_id ): string {
		$plugin_data = $this->proxy->call_function( 'get_plugin_data', WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin_id );
		return $plugin_data['Name'] ?? $plugin_id;
	}

	/**
	 * Check if a plugin is WooCommerce aware.
	 *
	 * @param string|array $plugin_file_or_data Plugin id (path/file.php) or plugin data (as returned by get_plugins).
	 * @return bool True if the plugin exists and is WooCommerce aware.
	 * @throws \Exception The input is neither a string nor an array.
	 */
	public function is_woocommerce_aware_plugin( $plugin_file_or_data ): bool {
		if ( is_string( $plugin_file_or_data ) ) {
			return in_array( $plugin_file_or_data, $this->get_woocommerce_aware_plugins(), true );
		} elseif ( is_array( $plugin_file_or_data ) ) {
			return '' !== ( $plugin_file_or_data['WC tested up to'] ?? '' );
		} else {
			throw new \Exception( 'is_woocommerce_aware_plugin requires a plugin name or an array of plugin data as input' );
		}
	}

	/**
	 * Match plugin identifier passed as a parameter with the output from `get_plugins()`.
	 *
	 * @param string $plugin_file Plugin identifier, either 'my-plugin/my-plugin.php', or output from __FILE__.
	 *
	 * @return string|false Key from the array returned by `get_plugins` if matched. False if no match.
	 */
	public function get_wp_plugin_id( $plugin_file ) {
		$wp_plugins = array_keys( $this->proxy->call_function( 'get_plugins' ) );

		// Try to match plugin_basename().
		$plugin_basename = $this->proxy->call_function( 'plugin_basename', $plugin_file );
		if ( in_array( $plugin_basename, $wp_plugins, true ) ) {
			return $plugin_basename;
		}

		// Try to match by the my-file/my-file.php (dir + file name), then by my-file.php (file name only).
		$plugin_file     = str_replace( array( '\\', '/' ), DIRECTORY_SEPARATOR, $plugin_file );
		$file_name_parts = explode( DIRECTORY_SEPARATOR, $plugin_file );
		$file_name       = array_pop( $file_name_parts );
		$directory_name  = array_pop( $file_name_parts );
		$full_matches    = array();
		$partial_matches = array();
		foreach ( $wp_plugins as $wp_plugin ) {
			if ( false !== strpos( $wp_plugin, $directory_name . DIRECTORY_SEPARATOR . $file_name ) ) {
				$full_matches[] = $wp_plugin;
			}

			if ( ! empty( $file_name ) && false !== strpos( $wp_plugin, $file_name ) ) {
				$partial_matches[] = $wp_plugin;
			}
		}

		if ( 1 === count( $full_matches ) ) {
			return $full_matches[0];
		}

		if ( 1 === count( $partial_matches ) ) {
			return $partial_matches[0];
		}

		return false;
	}

	/**
	 * Handle plugin activation and deactivation by clearing the WooCommerce aware plugin ids cache.
	 *
	 * @internal For exclusive usage of WooCommerce core, backwards compatibility not guaranteed.
	 */
	public function handle_plugin_de_activation(): void {
		$this->woocommerce_aware_plugins        = null;
		$this->woocommerce_aware_active_plugins = null;
	}

	/**
	 * Utility method to generate warning string for incompatible features based on active plugins.
	 *
	 * Additionally, this method will manually print a warning message on the HPOS feature if both
	 * the Legacy REST API and HPOS are active.
	 *
	 * @param string $feature_id Feature id.
	 * @param array  $plugin_feature_info Array of plugin feature info, as provided by FeaturesController->get_compatible_plugins_for_feature().
	 *
	 * @return string Warning string.
	 */
	public function generate_incompatible_plugin_feature_warning( string $feature_id, array $plugin_feature_info ): string {
		$incompatibles      = $this->get_items_considered_incompatible( $feature_id, $plugin_feature_info );
		$incompatibles      = array_filter( $incompatibles, 'is_plugin_active' );
		$incompatibles      = array_values( array_diff( $incompatibles, $this->get_plugins_excluded_from_compatibility_ui() ) );
		$incompatible_count = count( $incompatibles );

		$feature_warnings = array();
		if ( 'custom_order_tables' === $feature_id && 'yes' === get_option( 'woocommerce_api_enabled' ) ) {
			if ( is_plugin_active( 'woocommerce-legacy-rest-api/woocommerce-legacy-rest-api.php' ) ) {
				$legacy_api_and_hpos_incompatibility_warning_text =
					sprintf(
						// translators: %s is a URL.
						__( '⚠ <b><a target="_blank" href="%s">The Legacy REST API plugin</a> is installed and active on this site.</b> Please be aware that the WooCommerce Legacy REST API is <b>not</b> compatible with HPOS.', 'woocommerce' ),
						'https://wordpress.org/plugins/woocommerce-legacy-rest-api/'
					);
			} else {
				$legacy_api_and_hpos_incompatibility_warning_text =
				sprintf(
					// translators: %s is a URL.
					__( '⚠ <b><a target="_blank" href="%s">The Legacy REST API</a> is active on this site.</b> Please be aware that the WooCommerce Legacy REST API is <b>not</b> compatible with HPOS.', 'woocommerce' ),
					admin_url( 'admin.php?page=wc-settings&tab=advanced&section=legacy_api' )
				);
			}

			/**
			 * Filter to modify the warning text that appears in the HPOS section of the features settings page
			 * when both the Legacy REST API is active (via WooCommerce core or via the Legacy REST API plugin)
			 * and the orders table is in use as the primary data store for orders.
			 *
			 * @param string $legacy_api_and_hpos_incompatibility_warning_text Original warning text.
			 * @returns string|null Actual warning text to use, or null to suppress the warning.
			 *
			 * @since 8.9.0
			 */
			$legacy_api_and_hpos_incompatibility_warning_text = apply_filters( 'woocommerce_legacy_api_and_hpos_incompatibility_warning_text', $legacy_api_and_hpos_incompatibility_warning_text );

			if ( ! is_null( $legacy_api_and_hpos_incompatibility_warning_text ) ) {
				$feature_warnings[] = $legacy_api_and_hpos_incompatibility_warning_text . "\n";
			}
		}

		if ( $incompatible_count > 0 ) {
			if ( 1 === $incompatible_count ) {
				/* translators: %s = printable plugin name */
				$feature_warnings[] = sprintf( __( '⚠ 1 Incompatible plugin detected (%s).', 'woocommerce' ), $this->get_plugin_name( $incompatibles[0] ) );
			} elseif ( 2 === $incompatible_count ) {
				$feature_warnings[] = sprintf(
					/* translators: %1\$s, %2\$s = printable plugin names */
					__( '⚠ 2 Incompatible plugins detected (%1$s and %2$s).', 'woocommerce' ),
					$this->get_plugin_name( $incompatibles[0] ),
					$this->get_plugin_name( $incompatibles[1] )
				);
			} else {
				$feature_warnings[] = sprintf(
					/* translators: %1\$s, %2\$s = printable plugin names, %3\$d = plugins count */
					_n(
						'⚠ Incompatible plugins detected (%1$s, %2$s and %3$d other).',
						'⚠ Incompatible plugins detected (%1$s and %2$s plugins and %3$d others).',
						$incompatible_count - 2,
						'woocommerce'
					),
					$this->get_plugin_name( $incompatibles[0] ),
					$this->get_plugin_name( $incompatibles[1] ),
					$incompatible_count - 2
				);
			}

			$incompatible_plugins_url = add_query_arg(
				array(
					'plugin_status' => 'incompatible_with_feature',
					'feature_id'    => $feature_id,
				),
				admin_url( 'plugins.php' )
			);

			$feature_warnings[] = sprintf(
				/* translators: %1$s opening link tag %2$s closing link tag. */
				__( '%1$sView and manage%2$s', 'woocommerce' ),
				'<a href="' . esc_url( $incompatible_plugins_url ) . '">',
				'</a>'
			);
		}

		return str_replace( "\n", '<br>', implode( "\n", $feature_warnings ) );
	}

	/**
	 * Filter plugin/feature compatibility info, returning the names of the plugins/features that are considered incompatible.
	 * "Uncertain" information will be included or not depending on the value of the value of the 'default_plugin_compatibility'
	 * flag in the feature definition (default is 'compatible').
	 *
	 * @param string $feature_id Feature id.
	 * @param array  $compatibility_info Array containing "compatible', 'incompatible' and 'uncertain' keys.
	 * @return array Items in 'incompatible' and 'uncertain' if plugins are incompatible by default with the feature; only items in 'incompatible' otherwise.
	 */
	public function get_items_considered_incompatible( string $feature_id, array $compatibility_info ): array {
		$incompatible_by_default = FeaturePluginCompatibility::COMPATIBLE !== wc_get_container()->get( FeaturesController::class )->get_default_plugin_compatibility( $feature_id );

		return $incompatible_by_default ?
			array_merge( $compatibility_info['incompatible'], $compatibility_info['uncertain'] ) :
			$compatibility_info['incompatible'];
	}

	/**
	 * Get the names of the plugins that are excluded from the feature compatibility UI.
	 * These plugins won't be considered as incompatible with any existing feature for the purposes
	 * of displaying compatibility warning in UI, even if they declare incompatibilities explicitly.
	 *
	 * @return string[] Plugin names relative to the root plugins directory.
	 */
	public function get_plugins_excluded_from_compatibility_ui() {
		return $this->plugins_excluded_from_compatibility_ui;
	}
}


Current_dir [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ] Document_root [ 𝗪𝗥𝗜𝗧𝗘𝗔𝗕𝗟𝗘 ]


[ Back ]
𝗡𝗔𝗠𝗘
𝗦𝗜𝗭𝗘
𝗟𝗔𝗦𝗧 𝗧𝗢𝗨𝗖𝗛
𝗨𝗦𝗘𝗥
𝗦𝗧𝗔𝗧𝗨𝗦
𝗙𝗨𝗡𝗖𝗧𝗜𝗢𝗡𝗦
..
--
28 May 2026 10.38 AM
tdhomesa / tdhomesa
0755
ArrayUtil.php
12.987 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
CallbackUtil.php
4.398 KB
19 Jan 2026 2.46 PM
tdhomesa / tdhomesa
0644
DiscountsUtil.php
1.104 KB
30 May 2024 6.23 PM
tdhomesa / tdhomesa
0644
FeaturesUtil.php
5.189 KB
26 Jan 2026 10.40 AM
tdhomesa / tdhomesa
0644
I18nUtil.php
1.687 KB
22 Feb 2023 7.17 AM
tdhomesa / tdhomesa
0644
LoggingUtil.php
3.183 KB
27 Aug 2024 11.04 PM
tdhomesa / tdhomesa
0644
MetaDataUtil.php
1.87 KB
5 May 2026 2.26 PM
tdhomesa / tdhomesa
0644
NumberUtil.php
7.114 KB
29 Jul 2025 12.34 PM
tdhomesa / tdhomesa
0644
OrderUtil.php
9.194 KB
24 Nov 2025 11.10 PM
tdhomesa / tdhomesa
0644
PluginUtil.php
12.985 KB
6 Oct 2025 5.56 PM
tdhomesa / tdhomesa
0644
RestApiUtil.php
5.01 KB
24 Nov 2025 11.10 PM
tdhomesa / tdhomesa
0644
ShippingUtil.php
0.996 KB
12 May 2025 9.07 PM
tdhomesa / tdhomesa
0644
StringUtil.php
5.09 KB
4 Jun 2024 3.20 PM
tdhomesa / tdhomesa
0644
TimeUtil.php
1.158 KB
30 Jan 2024 11.24 PM
tdhomesa / tdhomesa
0644

✘✘ GRAYBYTE WORDPRESS FILE MANAGER @ 2026 CONTACT ME ✘✘
Static GIF Static GIF