| Server IP : 198.71.59.75 / Your IP : 216.73.216.240 Web Server : nginx/1.30.2 System : Linux elegant-dhawan.198-71-59-75.plesk.page 5.15.0-105-generic #115-Ubuntu SMP Mon Apr 15 09:52:04 UTC 2024 x86_64 User : realtyna_guys ( 10000) PHP Version : 8.2.31 Disable Function : opcache_get_status MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/vhosts/agenttango.com/httpdocs/wp-content/plugins/jetpack-boost/app/lib/ |
Upload File : |
<?php
namespace Automattic\Jetpack_Boost\Lib;
use Automattic\Jetpack_Boost\Contracts\Has_Setup;
class Setup {
protected static $instances = array();
/**
* This method takes a `Has_Setup` instance and registers the setup action.
* In addition, it will keep track of all the instances passed to it,
*
* This is useful if a plugin needs the instance
* to modify the behavior at a certain hook that
* Jetpack Boost is using.
*
* The use case would be something like this:
* ```
* $instance = my_get_instance_method( Setup::get_instances() );
* remove_action( 'wp_footer', array( $instance, 'foobar' ) );
* ```
*
* @param Has_Setup $instance
*
* @return void
*/
public static function add( Has_Setup $instance ) {
$instance->setup();
self::$instances[] = $instance;
}
public static function get_instances() {
return self::$instances;
}
/**
* @template T
* @param class-string<T> $class_name
* @return T|null
*/
public static function get_instance_of( $class_name ) {
foreach ( self::get_instances() as $instance ) {
if ( $instance instanceof $class_name ) {
// @phan-suppress-next-line PhanTypeMismatchReturn -- Phan isn't inferring the type correctly from the `instanceof $class_name` like it's supposed to.
return $instance;
}
}
return null;
}
}