From 843b41b03869ff50916f061f9741e49548e1b536 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Tue, 6 May 2014 15:33:17 -0500 Subject: [PATCH 1/2] Add filterable frontend indicator method --- stream.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/stream.php b/stream.php index c2cd53cd8..ac08fa5bd 100755 --- a/stream.php +++ b/stream.php @@ -103,6 +103,9 @@ private function __construct() { require_once WP_STREAM_INC_DIR . 'feeds.php'; add_action( 'init', array( 'WP_Stream_Feeds', 'load' ) ); + // Add frontend indicator + add_action( 'wp_head', array( $this, 'frontend_indicator' ) ); + // Include Stream extension updater require_once WP_STREAM_INC_DIR . 'updater.php'; WP_Stream_Updater::instance(); @@ -261,6 +264,33 @@ public static function notice( $message, $is_error = true ) { } } + /** + * Displays an HTML comment in the frontend head to indicate that Stream is activated, + * and which version of Stream is currently in use. + * + * @since 1.4.5 + * + * @action wp_head + * @return string|void An HTML comment, or nothing if the value is filtered out. + */ + public function frontend_indicator() { + $comment = sprintf( 'Stream WordPress user activity plugin v%s', esc_html( self::VERSION ) ); // Localization not needed + + /** + * Filter allows the HTML output of the frontend indicator comment + * to be altered or removed, if desired. + * + * @return string $comment The content of the HTML comment + */ + $comment = apply_filters( 'wp_stream_frontend_indicator', $comment ); // xss ok + + if ( ! empty( $comment ) ) { + echo sprintf( "\n", esc_html( $comment ) ); + } + + return; + } + /** * Return active instance of WP_Stream, create one if it doesn't exist * From 834d59104bc738b125ff07a6e22fe6d39cd8a770 Mon Sep 17 00:00:00 2001 From: Frankie Jarrett Date: Tue, 6 May 2014 16:05:59 -0500 Subject: [PATCH 2/2] Move xss ok comment to the correct line --- stream.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stream.php b/stream.php index ac08fa5bd..5cd32380b 100755 --- a/stream.php +++ b/stream.php @@ -282,10 +282,10 @@ public function frontend_indicator() { * * @return string $comment The content of the HTML comment */ - $comment = apply_filters( 'wp_stream_frontend_indicator', $comment ); // xss ok + $comment = apply_filters( 'wp_stream_frontend_indicator', $comment ); if ( ! empty( $comment ) ) { - echo sprintf( "\n", esc_html( $comment ) ); + echo sprintf( "\n", esc_html( $comment ) ); // xss ok } return;