Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filterable frontend indicator method #509

Merged
merged 2 commits into from
May 6, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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 );

if ( ! empty( $comment ) ) {
echo sprintf( "<!-- %s -->\n", esc_html( $comment ) ); // xss ok
}

return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fjarrett I think we can omit this one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadyvb Yeah, it's not needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@shadyvb Done in 650df12

}

/**
* Return active instance of WP_Stream, create one if it doesn't exist
*
Expand Down