diff options
Diffstat (limited to 'plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php')
-rw-r--r-- | plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php b/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php index 1e0094f2..e4941537 100644 --- a/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php +++ b/plugins/jetpack/modules/geo-location/class.jetpack-geo-location.php @@ -33,6 +33,15 @@ class Jetpack_Geo_Location { private static $instance; + /** + * Whether dashicons are enqueued. + * + * @since 6.6.0 + * + * @var bool + */ + private static $style_enqueued = false; + public static function init() { if ( is_null( self::$instance ) ) { self::$instance = new Jetpack_Geo_Location(); @@ -52,7 +61,6 @@ class Jetpack_Geo_Location { add_action( 'init', array( $this, 'wordpress_init' ) ); add_action( 'wp_head', array( $this, 'wp_head' ) ); add_filter( 'the_content', array( $this, 'the_content_microformat' ) ); - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); $this->register_rss_hooks(); } @@ -152,6 +160,12 @@ class Jetpack_Geo_Location { return; } + if ( ! self::$style_enqueued ) { + // only enqueue scripts and styles when needed. + self::enqueue_scripts(); + self::$style_enqueued = true; + } + echo "\n<!-- Jetpack Geo-location Tags -->\n"; if ( $meta_values['label'] ) { @@ -235,7 +249,7 @@ class Jetpack_Geo_Location { * Add the georss namespace during RSS generation. */ public function rss_namespace() { - echo 'xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" '; + echo PHP_EOL . 'xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"' . PHP_EOL; } /** @@ -262,7 +276,7 @@ class Jetpack_Geo_Location { /** * Enqueue CSS for rendering post flair with geo-location. */ - public function enqueue_scripts() { + private static function enqueue_scripts() { wp_enqueue_style( 'dashicons' ); } |