WPR FM
uid=9814(b13i2mwmyrdbxio) php=8.4.28
info
cwd /data/sites/web/b13i2mwmyrdbxio/www |
naik
Buka
-
CommentTrait.php
637
x
-
Data.php
3007
x
-
Meta.php
4348
x
-
Rest.php
2266
x
-
ServiceProvider.php
1435
x
-
Subscriber.php
1180
x
Upload
Simpan
<?php declare(strict_types=1); namespace WP_Rocket\Engine\Support; use WP_Rocket\Admin\Options_Data; use WP_Rocket\Dependencies\Detection\MobileDetect; use WP_Rocket\Engine\License\API\User; class Meta { /** * Mobile Detect instance * * @var MobileDetect */ private $mobile_detect; /** * Options instance * * @var Options_Data */ private $options; /** * User instance * * @var User */ private $user; /** * Instantiate the class * * @param MobileDetect $mobile_detect Mobile Detect instance. * @param Options_Data $options Options instance. * @param User $user User instance. */ public function __construct( MobileDetect $mobile_detect, Options_Data $options, User $user ) { $this->mobile_detect = $mobile_detect; $this->options = $options; $this->user = $user; } /** * Add the WP Rocket meta generator tag to the HTML * * @param string $html The HTML content. * @return string */ public function add_meta_generator( $html ): string { if ( rocket_bypass() ) { return $html; } if ( rocket_get_constant( 'DONOTROCKETOPTIMIZE' ) ) { return $html; } /** * Filters whether to disable the WP Rocket meta generator tag. * * @since 3.17.2 * * @param bool $disable True to disable, false otherwise. */ if ( wpm_apply_filters_typed( 'boolean', 'rocket_disable_meta_generator', false ) ) { return $html; } if ( rocket_get_constant( 'WP_ROCKET_WHITE_LABEL_FOOTPRINT', false ) ) { return $this->remove_features_comments( $html ); } if ( is_user_logged_in() ) { return $this->remove_features_comments( $html ); } if ( false === preg_match_all( '/<!-- (?<feature>wpr_(?:[^-]*)) -->/i', $html, $comments, PREG_PATTERN_ORDER ) ) { return $html; } $meta = $this->get_meta_tag( $comments['feature'] ); if ( empty( $meta ) ) { return $html; } $result = preg_replace( '/<\/head>/i', $meta . '</head>', $html, 1 ); if ( null === $result ) { return $html; } return $this->remove_features_comments( $result ); } /** * Get the WP Rocket meta generator tag * * @param array $features Features to add to the meta tag. * * @return string The meta tag, or an empty string when there is no feature to report. */ private function get_meta_tag( array $features = [] ): string { $options = $this->options; // Feature mapping for meta tags. $features_to_check = [ 'wpr_preload_links' => 'preload_links', 'wpr_host_fonts_locally' => 'host_fonts_locally', ]; foreach ( $features_to_check as $meta_name => $option_name ) { if ( $options->get( $option_name, false ) ) { $features[] = $meta_name; } } // Mobile/Desktop caching. if ( $options->get( 'do_caching_mobile_files', false ) ) { $features[] = $this->mobile_detect->isMobile() ? 'wpr_mobile' : 'wpr_desktop'; } // CDN & DNS prefetch check. $dns_prefetch = rocket_get_dns_prefetch_domains(); if ( $dns_prefetch && ( ! $options->get( 'cdn', false ) || count( $dns_prefetch ) > 1 ) ) { $features[] = 'wpr_dns_prefetch'; } if ( ! $this->is_license_expired() ) { $features[] = 'wpr_insights'; } // Nothing to report (expired licence and no other feature): do not output the tag. if ( empty( $features ) ) { return ''; } // Check if WP Rocket version should be included. $version = wpm_apply_filters_typed( 'boolean', 'rocket_display_meta_generator_content_version', true ) ? ' ' . rocket_get_constant( 'WP_ROCKET_VERSION', '' ) : ''; return sprintf( '<meta name="generator" content="WP Rocket%s" data-wpr-features="%s" />', $version, implode( ' ', $features ) ); } /** * Check whether the licence is known to be expired. * * An expiration of 0 means the customer data is unavailable, so the licence is treated as not expired. * * @return bool */ private function is_license_expired(): bool { return 0 !== $this->user->get_license_expiration() && $this->user->is_license_expired(); } /** * Remove WP Rocket features comments from the HTML * * @param string $html The HTML content. * * @return string */ private function remove_features_comments( $html ): string { $result = preg_replace( '/<!-- wpr_[^-]* -->/i', '', $html ); if ( null === $result ) { return $html; } return $result; } }
Exec