/home/altere25/labratnyc.com/wp-content/plugins/query-monitor/classes
NameSizeModeActions
Activation.php30380644editdlrm
ArrayAccess.php11050644editdlrm
Backtrace.php228870644editdlrm
Backtrace_Frame.php8700644editdlrm
CLI.php15680644editdlrm
Collector.php87070644editdlrm
Collectors.php34450644editdlrm
Collector_Assets.php145000644editdlrm
Component.php38660644editdlrm
Component_Altis_Vendor.php3560644editdlrm
Component_Core.php2630644editdlrm
Component_Dropin.php3460644editdlrm
Component_MU_Plugin.php3330644editdlrm
Component_MU_Vendor.php3420644editdlrm
Component_Other.php1700644editdlrm
Component_PHP.php2210644editdlrm
Component_Plugin.php3240644editdlrm
Component_Stylesheet.php3410644editdlrm
Component_Template.php2780644editdlrm
Component_Unknown.php8660644editdlrm
Component_VIP_Plugin.php3460644editdlrm
Data.php4280644editdlrm
DataCollector.php3960644editdlrm
DB.php15460644editdlrm
debug_bar.php17130644editdlrm
debug_bar_panel.php14460644editdlrm
Deprecated_Argument_Run.php10350644editdlrm
Deprecated_Class_Run.php9660644editdlrm
Deprecated_Constructor_Run.php11440644editdlrm
Deprecated_File_Included.php10950644editdlrm
Deprecated_Function_Run.php9830644editdlrm
Deprecated_Hook_Run.php10980644editdlrm
Dispatcher.php50970644editdlrm
Dispatchers.php12410644editdlrm
Doing_It_Wrong_Run.php8920644editdlrm
Frame_Registry.php14560644editdlrm
Hook.php13790644editdlrm
Output.php9230644editdlrm
PHP.php13970644editdlrm
Plugin.php24000644editdlrm
QM.php44510644editdlrm
QueryMonitor.php87050644editdlrm
Timer.php33260644editdlrm
Util.php199010644editdlrm
Wrong.php8220644editdlrm
Edit: /home/altere25/labratnyc.com/wp-content/plugins/query-monitor/classes/Collector_Assets.php (14500B)
, * } * @phpstan-type QMScriptModule array{ * id: string, * src: string, * version: string|false|null, * dependencies: list, * dependents: list, * } * @extends QM_DataCollector */ abstract class QM_Collector_Assets extends QM_DataCollector { /** * @var ?array */ protected $header = null; /** * @var array */ protected $footer = array(); /** * @var list */ protected $broken = array(); /** * @var list */ protected $missing = array(); /** * @var string */ protected $default_version = ''; public function get_storage(): QM_Data { return new QM_Data_Assets(); } /** * @return void */ public function set_up() { parent::set_up(); add_action( 'admin_print_footer_scripts', array( $this, 'action_print_footer_scripts' ), 9999 ); add_action( 'wp_print_footer_scripts', array( $this, 'action_print_footer_scripts' ), 9999 ); add_action( 'admin_head', array( $this, 'action_head' ), 9999 ); add_action( 'wp_head', array( $this, 'action_head' ), 9999 ); add_action( 'login_head', array( $this, 'action_head' ), 9999 ); add_action( 'embed_head', array( $this, 'action_head' ), 9999 ); } /** * @return void */ public function tear_down() { remove_action( 'admin_print_footer_scripts', array( $this, 'action_print_footer_scripts' ), 9999 ); remove_action( 'wp_print_footer_scripts', array( $this, 'action_print_footer_scripts' ), 9999 ); remove_action( 'admin_head', array( $this, 'action_head' ), 9999 ); remove_action( 'wp_head', array( $this, 'action_head' ), 9999 ); remove_action( 'login_head', array( $this, 'action_head' ), 9999 ); remove_action( 'embed_head', array( $this, 'action_head' ), 9999 ); parent::tear_down(); } /** * @return string */ abstract public function get_dependency_type(); /** * @return void */ public function action_head() { $type = $this->get_dependency_type(); /** @var WP_Dependencies $dependencies */ $dependencies = $GLOBALS[ "wp_{$type}" ]; $this->header = $dependencies->done; } /** * @return void */ public function action_print_footer_scripts() { if ( null === $this->header ) { return; } $type = $this->get_dependency_type(); /** @var WP_Dependencies $dependencies */ $dependencies = $GLOBALS[ "wp_{$type}" ]; $this->footer = array_diff( $dependencies->done, $this->header ); } /** * @return void */ public function process() { $type = $this->get_dependency_type(); $modules = null; if ( $type === 'scripts' ) { $modules = self::get_script_modules(); } if ( null === $this->header && empty( $this->footer ) && empty( $modules ) ) { return; } $this->default_version = get_bloginfo( 'version' ); $url = new QM_Data_URL(); $url->origin = self::get_origin(); $url->scheme = is_ssl() ? 'https' : 'http'; $url->hostname = (string) parse_url( $url->origin, PHP_URL_HOST ); $port = (string) parse_url( $url->origin, PHP_URL_PORT ); $url->host = $port ? "{$url->hostname}:{$port}" : $url->hostname; $url->insecure = ( 'https' !== $url->scheme ) && ( 'localhost' !== $url->hostname ); $url->local = true; $url->absolute = $url->origin; $this->data->url = $url; $positions = array( 'missing', 'broken', 'header', 'footer', ); $type = $this->get_dependency_type(); /** @var WP_Dependencies $raw */ $raw = $GLOBALS[ "wp_{$type}" ]; $broken = array_values( array_diff( $raw->queue, $raw->done ) ); $missing = array_values( array_diff( $raw->queue, array_keys( $raw->registered ) ) ); // A broken asset is one which has been deregistered without also being dequeued if ( ! empty( $broken ) ) { foreach ( $broken as $key => $handle ) { /** @var _WP_Dependency|false $item */ $item = $raw->query( $handle ); if ( $item ) { $broken = array_merge( $broken, self::get_broken_dependencies( $item, $raw ) ); } else { unset( $broken[ $key ] ); $missing[] = $handle; } } if ( ! empty( $broken ) ) { $this->broken = array_values( array_unique( $broken ) ); } } // A missing asset is one which has been enqueued with dependencies that don't exist if ( ! empty( $missing ) ) { $this->missing = array_values( array_unique( $missing ) ); foreach ( $this->missing as $handle ) { $raw->add( $handle, false ); $key = array_search( $handle, $raw->done, true ); if ( false !== $key ) { unset( $raw->done[ $key ] ); } } } $asset_data = array(); $missing_dependencies = array(); if ( is_array( $modules ) ) { foreach ( $modules as $id => $module ) { $url = $this->hyper_determine_the_proto_characteristics_of_a_pseudo_url_from_space( $module['src'] ); $position = 'modules'; $asset_data[] = array( 'handle' => $id, 'position' => $position, 'url' => $url, 'source' => $module['src'], 'ver' => $module['version'] ?: '', 'warning' => false, 'dependents' => $module['dependents'], 'dependencies' => $module['dependencies'], ); $this->log_type( $position ); } } foreach ( $positions as $position ) { if ( empty( $this->{$position} ) ) { continue; } /** @var string $handle */ foreach ( $this->{$position} as $handle ) { /** @var _WP_Dependency|false $dependency */ $dependency = $raw->query( $handle ); if ( ! $dependency ) { continue; } $dependents = $this->get_dependents( $dependency, $raw ); list( $url, $source ) = $this->get_dependency_data( $dependency ); // Widen this type because plugins can set ver to boolean true. /** @var string|bool|null $dependency_ver */ $dependency_ver = $dependency->ver; if ( empty( $dependency_ver ) || $dependency_ver === true ) { $ver = ''; } else { $ver = $dependency_ver; } $warning = ! in_array( $handle, $raw->done, true ); if ( $source instanceof WP_Error ) { /** This filter is documented in collectors/http.php */ $silent = apply_filters( 'qm/collect/silent_http_errors', array( 'http_request_not_executed', 'airplane_mode_enabled', ) ); if ( ! in_array( $source->get_error_code(), $silent, true ) ) { $warning = true; } } $dependencies = array_values( $dependency->deps ); foreach ( $dependencies as $dep ) { if ( ! $raw->query( $dep ) ) { // A missing dependency is a dependency on an asset that doesn't exist $missing_dependencies[ $dep ] = true; } } $asset_data[] = array( 'handle' => $handle, 'position' => $position, 'url' => $url, 'source' => $source, 'ver' => $ver, 'warning' => $warning, 'dependents' => $dependents, 'dependencies' => $dependencies, ); $this->log_type( $position ); } } $this->data->assets = $asset_data; $this->data->missing_dependencies = $missing_dependencies; } /** * Returns the script modules registered in WP_Script_Modules. * * @return array|null * @phpstan-return array|null */ protected static function get_script_modules(): ?array { // WP 6.5 if ( ! function_exists( 'wp_script_modules' ) ) { return null; } $modules = wp_script_modules(); $reflector = new ReflectionClass( $modules ); $get_marked_for_enqueue = $reflector->getMethod( 'get_marked_for_enqueue' ); $get_dependencies = $reflector->getMethod( 'get_dependencies' ); $get_src = $reflector->getMethod( 'get_src' ); if ( \PHP_VERSION_ID < 80100 ) { $get_marked_for_enqueue->setAccessible( true ); $get_dependencies->setAccessible( true ); $get_src->setAccessible( true ); } /** * Script modules marked for enqueue, keyed by script module ID. * * @var array> $enqueued * @phpstan-var array $enqueued */ $enqueued = $get_marked_for_enqueue->invoke( $modules ); $deps = self::get_module_dependencies( $modules, $get_dependencies, array_keys( $enqueued ) ); $all_modules = array_merge( $enqueued, $deps ); /** * @var array>> $sources * @phpstan-var array $sources */ $sources = array(); foreach ( $all_modules as $id => $module ) { /** @var string $src */ $src = $get_src->invoke( $modules, $id ); $dependencies = array_values( wp_list_pluck( $all_modules[ $id ]['dependencies'], 'id' ) ); $dependents = array(); foreach ( $all_modules as $dep_id => $dep ) { foreach ( $dep['dependencies'] as $dependency ) { if ( $dependency['id'] === $id ) { $dependents[] = $dep_id; } } } $sources[ $id ] = array( 'id' => $id, 'src' => $src, 'version' => $module['version'] ?? '', 'dependencies' => $dependencies, 'dependents' => $dependents, ); } if ( \PHP_VERSION_ID < 80100 ) { $get_marked_for_enqueue->setAccessible( false ); $get_dependencies->setAccessible( false ); $get_src->setAccessible( false ); } return $sources; } /** * Retrieves all the dependencies for the given script module identifiers. * * @param list $ids * * @return array> $deps * @phpstan-return array $deps */ private static function get_module_dependencies( WP_Script_Modules $modules, ReflectionMethod $get_dependencies, array $ids ): array { return $get_dependencies->invoke( $modules, $ids ); } /** * @param _WP_Dependency $item * @param WP_Dependencies $dependencies * @return array */ protected static function get_broken_dependencies( _WP_Dependency $item, WP_Dependencies $dependencies ) { $broken = array(); foreach ( $item->deps as $handle ) { $dep = $dependencies->query( $handle ); if ( $dep instanceof _WP_Dependency ) { $broken = array_merge( $broken, self::get_broken_dependencies( $dep, $dependencies ) ); } else { $broken[] = $item->handle; } } return $broken; } /** * @param _WP_Dependency $dependency * @param WP_Dependencies $dependencies * @return array */ public function get_dependents( _WP_Dependency $dependency, WP_Dependencies $dependencies ) { $dependents = array(); $handles = array_unique( array_merge( $dependencies->queue, $dependencies->done ) ); foreach ( $handles as $handle ) { $item = $dependencies->query( $handle ); if ( $item instanceof _WP_Dependency ) { if ( in_array( $dependency->handle, $item->deps, true ) ) { $dependents[] = $handle; } } } sort( $dependents ); return $dependents; } /** * @param _WP_Dependency $dependency * @return array{ * 0: QM_Data_URL, * 1: string|WP_Error, * } */ public function get_dependency_data( _WP_Dependency $dependency ) { $loader = rtrim( $this->get_dependency_type(), 's' ); $src = $dependency->src; $url = new QM_Data_URL(); if ( null === $dependency->ver ) { $ver = ''; } else { $ver = $dependency->ver ?: $this->default_version; } if ( ! empty( $src ) && ! empty( $ver ) ) { $src = add_query_arg( 'ver', $ver, $src ); } /** This filter is documented in wp-includes/class.wp-scripts.php */ $source = apply_filters( "{$loader}_loader_src", $src, $dependency->handle ); if ( is_string( $source ) ) { // @TODO this still needs to normalise to absolute URL. $url = $this->hyper_determine_the_proto_characteristics_of_a_pseudo_url_from_space( $source ); } if ( $url->insecure ) { $source = new WP_Error( 'qm_insecure_content', __( 'Insecure content', 'query-monitor' ), array( 'src' => $source, ) ); } if ( $source instanceof WP_Error ) { $error_data = $source->get_error_data(); if ( $error_data && isset( $error_data['src'] ) ) { $url = $this->hyper_determine_the_proto_characteristics_of_a_pseudo_url_from_space( $error_data['src'] ); } } elseif ( empty( $source ) ) { $source = ''; } return array( $url, $source ); } /** * Accepts an absolute URL, relative URL, or root-relative URL and returns its normalised information. * * This is primarily so relative URLs are correctly handled in the same way as local absolute URLs. */ protected function hyper_determine_the_proto_characteristics_of_a_pseudo_url_from_space( string $url ): QM_Data_URL { return self::determine_url_characteristics( $url, $this->data->url ); } /** * Determines the normalised information for the given URL relative to the current page's URL. * * @param string $url An absolute URL, relative URL, or root-relative URL. * @param QM_Data_URL $site The URL information for the current page. */ public static function determine_url_characteristics( string $url, QM_Data_URL $site ): QM_Data_URL { $parsed_url = new QM_Data_URL(); $parsed_url->hostname = (string) parse_url( $url, PHP_URL_HOST ); $parsed_url->scheme = (string) parse_url( $url, PHP_URL_SCHEME ); $port = (string) parse_url( $url, PHP_URL_PORT ); if ( empty( $parsed_url->hostname ) ) { // Relative URL - prepend the origin $parsed_url->origin = $site->origin; $parsed_url->hostname = $site->hostname; $parsed_url->scheme = $site->scheme; $parsed_url->absolute = $site->origin . $url; $port = (string) parse_url( $site->origin, PHP_URL_PORT ); } else { // Absolute URL if ( empty( $parsed_url->scheme ) ) { // Protocol-relative URL - inherit the scheme from the current page $parsed_url->scheme = $site->scheme; } $parsed_url->origin = $parsed_url->scheme . '://' . $parsed_url->hostname . ( $port ? ':' . $port : '' ); $parsed_url->absolute = $url; } // Mixed content is only a concern when the current page itself is served over HTTPS. $parsed_url->insecure = ( 'https' === $site->scheme ) && ( 'https' !== $parsed_url->scheme ) && ( 'localhost' !== $parsed_url->hostname ); $parsed_url->host = $port ? "{$parsed_url->hostname}:{$port}" : $parsed_url->hostname; $parsed_url->local = ( $site->origin === $parsed_url->origin ); return $parsed_url; } }