Skip to content

Commit

Permalink
Stats: Deprecating old Stats experience (#37591)
Browse files Browse the repository at this point in the history
* Stats: Update old Stats with a deprecation notice

* changelog

* Stats: Updating path source

* Update projects/plugins/jetpack/modules/stats.php

* Update projects/plugins/jetpack/modules/stats.php

* Update projects/plugins/jetpack/modules/stats.php

---------

Co-authored-by: Jasper Kang <jasper.kang@automattic.com>
  • Loading branch information
grzegorz-cp and kangzj authored May 29, 2024
1 parent df4b0b6 commit 0a6ac84
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: enhancement

Stats: Deprecating old Stats experience
110 changes: 109 additions & 1 deletion projects/plugins/jetpack/modules/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -423,14 +423,107 @@ function stats_reports_page( $main_chart_only = false ) {
exit; // @phan-suppress-current-line PhanPluginUnreachableCode -- Safer to include it even though stats_dashboard_widget_content() never returns.
}

$blog_id = Stats_Options::get_option( 'blog_id' );
$blog_id = Stats_Options::get_option( 'blog_id' );
$learn_url = Redirect::get_url( 'jetpack-stats-learn-more' );
$redirect_url = admin_url( 'admin.php?page=stats&enable_new_stats=1' );
$stats_bg_url = plugins_url( 'images/odyssey-upgrade/background.png', JETPACK__PLUGIN_FILE );
$stats_bg_gradient_url = plugins_url( 'images/odyssey-upgrade/gradient.png', JETPACK__PLUGIN_FILE );

if ( ! $main_chart_only && ! isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) && empty( $_COOKIE['stnojs'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
$nojs_url = add_query_arg( 'nojs', '1' );
$http = is_ssl() ? 'https' : 'http';
// Loading message. No JS fallback message.
?>

<style>
.stats-odyssey-notice {
display: flex;
font-size: var( --font-body );

border: 1px solid var( --jp-gray-5 );
border-left-color: var( --jp-black );
border-left-width: 6px;
border-radius: 4px;

margin-top: 24px;
background: white;
position: relative;
}
.stats-odyssey-notice--content__highlighted {
border-left-color: var( --jp-red );
}
.stats-odyssey-notice--content {
padding: 24px 0 24px 30px;
font-size: 2em;
width: 100%;
}
.stats-odyssey-notice--content-header {
font-size: 24px;
line-height: 32px;
margin: 0;
margin-bottom: 8px;
}
.stats-odyssey-notice--content-text {
font-size: 16px;
margin: 0;
}
.stats-odyssey-notice--image-container {
background-image: url("<?php echo esc_url( $stats_bg_url ); ?>"), url("<?php echo esc_url( $stats_bg_gradient_url ); ?>");
background-size: cover;
padding-right: 28px;
width: 100%;
}
.stats-odyssey-notice--close-button {
position: absolute;
top: 1rem;
right: 1rem;
background-color: transparent;
border: none;
cursor: pointer;
}
.stats-odyssey-notice--action-bar {
display: flex;
align-items: center;
margin-top: 24px;
}
.stats-odyssey-notice--primary-button {
margin-right: 18px;
padding-left: 20px;
padding-right: 20px;
font-size: 16px;
border-color: black;
background-color: black;
}
.stats-odyssey-notice--primary-button:hover {
border-color: #3c434a;
background-color: #3c434a;
}
.is-primary-link {
color: white;
text-decoration: none;
}
.is-primary-link:active {
color: white;
}
.is-primary-link:focus {
color: white;
box-shadow: none;
outline: none;
}
.is-primary-link:hover {
color: white;
}
.is-secondary-link {
color: black;
font-size: var( --font-body );
}
.is-secondary-link:hover {
color: black;
}
.is-hidden {
display: none;
}
</style>
<div id="jp-stats-wrap">
<div class="wrap">
<h1><?php esc_html_e( 'Jetpack Stats', 'jetpack' ); ?>
Expand Down Expand Up @@ -461,6 +554,21 @@ function stats_reports_page( $main_chart_only = false ) {
?>
</h2>
</div>
<div class="wrap">
<div class="stats-odyssey-notice stats-odyssey-notice--content__highlighted">
<div class="stats-odyssey-notice--content">
<h2 class="stats-odyssey-notice--content-header"><?php esc_html_e( 'Deprecated Jetpack Stats Experience', 'jetpack' ); ?></h2>
<p class="stats-odyssey-notice--content-text"><?php esc_html_e( 'The old Jetpack Stats has been deprecated and will be removed soon. Please click the button to enable the new experience.', 'jetpack' ); ?></p>
<div class="stats-odyssey-notice--action-bar">
<button class="dops-button stats-odyssey-notice--primary-button">
<a class="is-primary-link" href="<?php echo esc_url( $redirect_url ); ?>"><?php esc_html_e( 'Switch to new Stats', 'jetpack' ); ?></a>
</button>
<a class="is-secondary-link" href="<?php echo esc_url( $learn_url ); ?>" rel="noopener noreferrer" target="_blank"><?php esc_html_e( 'Learn about Stats', 'jetpack' ); ?> <svg xmlns="http://www.w3.org/2000/svg" style="vertical-align: middle;" viewBox="0 0 24 24" width="16" height="16" aria-hidden="true" focusable="false"><path d="M18.2 17c0 .7-.6 1.2-1.2 1.2H7c-.7 0-1.2-.6-1.2-1.2V7c0-.7.6-1.2 1.2-1.2h3.2V4.2H7C5.5 4.2 4.2 5.5 4.2 7v10c0 1.5 1.2 2.8 2.8 2.8h10c1.5 0 2.8-1.2 2.8-2.8v-3.6h-1.5V17zM14.9 3v1.5h3.7l-6.4 6.4 1.1 1.1 6.4-6.4v3.7h1.5V3h-6.3z"></path></svg></a>
</div>
</div>
<div class="stats-odyssey-notice--image-container"></div>
</div>
</div>
<div id="stats-loading-wrap" class="wrap">
<p class="hide-if-no-js"><img width="32" height="32" alt="<?php esc_attr_e( 'Loading&hellip;', 'jetpack' ); ?>" src="<?php echo esc_url( $static_url ); ?>" /></p>
<p class="hide-if-js"><?php esc_html_e( 'Jetpack Stats work better with JavaScript enabled.', 'jetpack' ); ?><br />
Expand Down

0 comments on commit 0a6ac84

Please sign in to comment.