PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 All 504 releases
← All changes | modules/stats.php +211 -472 12.7.316.3-a.1 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 /**
3 3 * Module Name: Jetpack Stats
4 - * Module Description: Collect valuable traffic stats and insights.
4 + * Module Description: Clear, concise traffic insights right in your WordPress dashboard.
5 5 * Sort Order: 1
6 6 * Recommendation Order: 2
7 7 * First Introduced: 1.1
8 8 * Requires Connection: Yes
@@ -15,21 +15,24 @@
15 15 */
16 16
17 17 use Automattic\Jetpack\Admin_UI\Admin_Menu;
18 18 use Automattic\Jetpack\Connection\Client;
19 -use Automattic\Jetpack\Connection\Manager as Connection_Manager;
20 -use Automattic\Jetpack\Connection\XMLRPC_Async_Call;
21 19 use Automattic\Jetpack\Redirect;
22 20 use Automattic\Jetpack\Stats\Main as Stats;
23 21 use Automattic\Jetpack\Stats\Options as Stats_Options;
24 22 use Automattic\Jetpack\Stats\Tracking_Pixel as Stats_Tracking_Pixel;
23 +use Automattic\Jetpack\Stats\WPCOM_Stats;
25 24 use Automattic\Jetpack\Stats\XMLRPC_Provider as Stats_XMLRPC;
25 +use Automattic\Jetpack\Stats_Admin\Admin_Post_List_Column;
26 26 use Automattic\Jetpack\Stats_Admin\Dashboard as Stats_Dashboard;
27 27 use Automattic\Jetpack\Stats_Admin\Main as Stats_Main;
28 -use Automattic\Jetpack\Stats_Admin\Notices as Stats_Notices;
29 28 use Automattic\Jetpack\Status\Host;
30 29 use Automattic\Jetpack\Tracking;
31 30
31 +if ( ! defined( 'ABSPATH' ) ) {
32 + exit( 0 );
33 +}
34 +
32 35 if ( defined( 'STATS_DASHBOARD_SERVER' ) ) {
33 36 return;
34 37 }
35 38
@@ -52,20 +55,21 @@
52 55 */
53 56 function stats_load() {
54 57 Jetpack::enable_module_configurable( __FILE__ );
55 58
56 - add_action( 'wp_head', 'stats_admin_bar_head', 100 );
59 + // Only run the callback for those who can see the stats.
60 + if ( is_user_logged_in() && current_user_can( 'view_stats' ) ) {
61 + add_action( 'admin_head', 'stats_admin_bar_head', 100 );
62 + add_action( 'wp_head', 'stats_admin_bar_head', 100 );
63 + }
57 64
65 + Admin_Post_List_Column::register();
66 +
58 67 add_action( 'jetpack_admin_menu', 'stats_admin_menu' );
68 + add_action( 'wp_before_admin_bar_render', 'stats_add_link_to_admin_bar_site_menu' );
59 69
60 70 add_filter( 'pre_option_db_version', 'stats_ignore_db_version' );
61 71
62 - // Add an icon to see stats in WordPress.com for a particular post.
63 - add_action( 'admin_print_styles-edit.php', 'jetpack_stats_load_admin_css' );
64 - add_filter( 'manage_posts_columns', 'jetpack_stats_post_table' );
65 - add_filter( 'manage_pages_columns', 'jetpack_stats_post_table' );
66 - add_action( 'manage_posts_custom_column', 'jetpack_stats_post_table_cell', 10, 2 );
67 - add_action( 'manage_pages_custom_column', 'jetpack_stats_post_table_cell', 10, 2 );
68 72 // Filter for adding the Jetpack plugin version to tracking stats.
69 73 add_filter( 'stats_array', 'filter_stats_array_add_jp_version' );
70 74
71 75 require_once __DIR__ . '/stats/class-jetpack-stats-upgrade-nudges.php';
@@ -135,9 +139,9 @@
135 139 * Stats Build View Data.
136 140 *
137 141 * @deprecated 11.5
138 142 * @access public
139 - * @return array.
143 + * @return array
140 144 */
141 145 function stats_build_view_data() {
142 146 _deprecated_function( __METHOD__, 'jetpack-11.5', 'Automattic\Jetpack\Stats\Tracking_Pixel::build_view_data' );
143 147 return Stats_Tracking_Pixel::build_view_data();
@@ -148,9 +152,9 @@
148 152 *
149 153 * @deprecated 11.5
150 154 *
151 155 * @access public
152 - * @return array.
156 + * @return array
153 157 */
154 158 function stats_get_options() {
155 159 _deprecated_function( __METHOD__, 'jetpack-11.5', 'Automattic\Jetpack\Stats\Options::get_options' );
156 160 return Stats_Options::get_options();
@@ -162,9 +166,9 @@
162 166 * @deprecated 11.5
163 167 *
164 168 * @access public
165 169 * @param mixed $option Option.
166 - * @return mixed|null.
170 + * @return mixed|null
167 171 */
168 172 function stats_get_option( $option ) {
169 173 _deprecated_function( __METHOD__, 'jetpack-11.5', 'Automattic\Jetpack\Stats\Options::get_option' );
170 174 return Stats_Options::get_option( $option );
@@ -177,9 +181,9 @@
177 181 *
178 182 * @access public
179 183 * @param mixed $option Option.
180 184 * @param mixed $value Value.
181 - * @return bool.
185 + * @return bool
182 186 */
183 187 function stats_set_option( $option, $value ) {
184 188 _deprecated_function( __METHOD__, 'jetpack-11.5', 'Automattic\Jetpack\Stats\Options::set_option' );
185 189 return Stats_Options::set_option( $option, $value );
@@ -228,9 +232,9 @@
228 232 $redirect_url = str_replace( array( '/wp-admin/index.php?', '/wp-admin/?' ), '/wp-admin/admin.php?', isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : null );
229 233 $relative_pos = strpos( $redirect_url, '/wp-admin/' );
230 234 if ( false !== $relative_pos ) {
231 235 wp_safe_redirect( admin_url( substr( $redirect_url, $relative_pos + 10 ) ) );
232 - exit;
236 + exit( 0 );
233 237 }
234 238 }
235 239
236 240 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
@@ -240,20 +244,28 @@
240 244 Stats_Main::update_new_stats_status( true );
241 245 }
242 246
243 247 // phpcs:ignore WordPress.Security.NonceVerification.Recommended
244 - if ( ( new Host() )->is_woa_site() || ! Stats_Options::get_option( 'enable_odyssey_stats' ) || isset( $_GET['noheader'] ) ) {
248 + if ( ! Stats_Options::get_option( 'enable_odyssey_stats' ) || isset( $_GET['noheader'] ) ) {
245 249 // Show old Jetpack Stats interface for:
246 - // - Atomic sites.
247 250 // - When the "enable_odyssey_stats" option is disabled.
248 251 // - When being shown in the adminbar outside of wp-admin.
249 - $hook = Admin_Menu::add_menu( __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'stats', 'jetpack_admin_ui_stats_report_page_wrapper' );
252 + $hook = Admin_Menu::add_menu(
253 + __( 'Stats', 'jetpack' ),
254 + __( 'Stats', 'jetpack' ),
255 + 'view_stats',
256 + 'stats',
257 + 'jetpack_admin_ui_stats_report_page_wrapper',
258 + null,
259 + array(
260 + 'product' => 'stats',
261 + 'key' => 'jetpack-stats',
262 + )
263 + );
250 264 add_action( "load-$hook", 'stats_reports_load' );
251 265 } else {
252 266 // Enable the new Odyssey Stats experience.
253 - $stats_dashboard = new Stats_Dashboard();
254 - $hook = Admin_Menu::add_menu( __( 'Stats', 'jetpack' ), __( 'Stats', 'jetpack' ), 'view_stats', 'stats', array( $stats_dashboard, 'render' ) );
255 - add_action( "load-$hook", array( $stats_dashboard, 'admin_init' ) );
267 + Stats_Dashboard::init();
256 268 }
257 269 }
258 270
259 271 /**
@@ -293,9 +305,8 @@
293 305 // Detect if JS is on. If so, remove cookie so next page load is via JS.
294 306 add_action( 'admin_print_footer_scripts', 'stats_js_remove_stnojs_cookie' );
295 307 } elseif ( ! isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
296 308 // Normal page load. Load page content via JS.
297 - add_action( 'admin_print_footer_scripts', 'stats_js_load_page_via_ajax' );
298 309 add_action( 'admin_print_footer_scripts', 'stats_script_dismiss_nudge_handler' );
299 310 }
300 311 }
301 312
@@ -314,10 +325,10 @@
314 325 element.classList.toggle( "is-hidden" );
315 326 // Send an AJAX request.
316 327 // Note we can provide a 'postponed_for' parameter to set the delay.
317 328 // Without a parameter it defaults to 30 days which is what we want here.
318 - let nonce = <?php echo wp_json_encode( wp_create_nonce( 'wp_rest' ) ); ?>;
319 - let url = <?php echo wp_json_encode( rest_url( '/jetpack/v4/stats-app/stats/notices' ) ); ?>;
329 + let nonce = <?php echo wp_json_encode( wp_create_nonce( 'wp_rest' ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>;
330 + let url = <?php echo wp_json_encode( rest_url( '/jetpack/v4/stats-app/stats/notices' ), JSON_UNESCAPED_SLASHES | JSON_HEX_TAG | JSON_HEX_AMP ); ?>;
320 331 let data = {
321 332 id: 'opt_in_new_stats',
322 333 status: 'postponed',
323 334 };
@@ -345,16 +356,8 @@
345 356 max-width: 1040px;
346 357 margin: 0 auto;
347 358 overflow: hidden;
348 359 }
349 -
350 -#stats-loading-wrap p {
351 - text-align: center;
352 - font-size: 2em;
353 - margin-bottom: 3em;
354 - height: 64px;
355 - line-height: 64px;
356 -}
357 360 </style>
358 361 <?php
359 362 }
360 363
@@ -368,9 +371,9 @@
368 371 $parsed = wp_parse_url( admin_url() );
369 372 ?>
370 373 <script type="text/javascript">
371 374 /* <![CDATA[ */
372 -document.cookie = 'stnojs=0; expires=Wed, 9 Mar 2011 16:55:50 UTC; path=<?php echo esc_js( $parsed['path'] ); ?>';
375 +document.cookie = <?php echo wp_json_encode( 'stnojs=0; expires=Wed, 9 Mar 2011 16:55:50 UTC; path=' . $parsed['path'], JSON_UNESCAPED_SLASHES | JSON_HEX_TAG ); ?>;
373 376 /* ]]> */
374 377 </script>
375 378 <?php
376 379 }
@@ -375,33 +378,8 @@
375 378 <?php
376 379 }
377 380
378 381 /**
379 - * Normal page load. Load page content via JS.
380 - *
381 - * @access public
382 - * @return void
383 - */
384 -function stats_js_load_page_via_ajax() {
385 - ?>
386 -<script type="text/javascript">
387 -/* <![CDATA[ */
388 -if ( -1 == document.location.href.indexOf( 'noheader' ) ) {
389 - jQuery( function( $ ) {
390 - const loadStatsUrl = new URL( document.location.href );
391 - loadStatsUrl.searchParams.append( 'noheader', 1 );
392 - $.get( loadStatsUrl.toString(), function( responseText ) {
393 - $( '#stats-loading-wrap' ).replaceWith( responseText );
394 - $( '#jp-stats-wrap' )[0].dispatchEvent( new Event( 'stats-loaded' ) );
395 - } );
396 - } );
397 -}
398 -/* ]]> */
399 -</script>
400 - <?php
401 -}
402 -
403 -/**
404 382 * Jetpack Admin Page Wrapper.
405 383 */
406 384 function jetpack_admin_ui_stats_report_page_wrapper() {
407 385 if ( ! isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) && empty( $_COOKIE['stnojs'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
@@ -418,19 +396,110 @@
418 396 * @param bool $main_chart_only (default: false) Main Chart Only.
419 397 */
420 398 function stats_reports_page( $main_chart_only = false ) {
421 399 if ( isset( $_GET['dashboard'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
422 - return stats_dashboard_widget_content();
400 + stats_dashboard_widget_content();
401 + exit( 0 ); // @phan-suppress-current-line PhanPluginUnreachableCode -- Safer to include it even though stats_dashboard_widget_content() never returns.
423 402 }
424 403
425 - $blog_id = Stats_Options::get_option( 'blog_id' );
404 + $blog_id = Stats_Options::get_option( 'blog_id' );
405 + $learn_url = Redirect::get_url( 'jetpack-stats-learn-more' );
406 + $redirect_url = admin_url( 'admin.php?page=stats&enable_new_stats=1' );
407 + $stats_bg_url = plugins_url( 'images/odyssey-upgrade/background.png', JETPACK__PLUGIN_FILE );
408 + $stats_bg_gradient_url = plugins_url( 'images/odyssey-upgrade/gradient.png', JETPACK__PLUGIN_FILE );
426 409
427 - if ( ! $main_chart_only && ! isset( $_GET['noheader'] ) && empty( $_GET['nojs'] ) && empty( $_COOKIE['stnojs'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
428 - $nojs_url = add_query_arg( 'nojs', '1' );
429 - $http = is_ssl() ? 'https' : 'http';
430 - // Loading message. No JS fallback message.
410 + if ( ! $main_chart_only && ! isset( $_GET['noheader'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
431 411 ?>
432 412
413 + <style>
414 + .stats-odyssey-notice {
415 + display: flex;
416 + font-size: var( --font-body );
417 +
418 + border: 1px solid var( --jp-gray-5 );
419 + border-left-color: var( --jp-black );
420 + border-left-width: 6px;
421 + border-radius: 4px;
422 +
423 + margin-top: 24px;
424 + background: white;
425 + position: relative;
426 + }
427 + .stats-odyssey-notice--content__highlighted {
428 + border-left-color: var( --jp-red );
429 + }
430 + .stats-odyssey-notice--content {
431 + padding: 24px 0 24px 30px;
432 + font-size: 2em;
433 + width: 100%;
434 + }
435 + .stats-odyssey-notice--content-header {
436 + font-size: 24px;
437 + line-height: 32px;
438 + margin: 0;
439 + margin-bottom: 8px;
440 + }
441 + .stats-odyssey-notice--content-text {
442 + font-size: 16px;
443 + margin: 0;
444 + }
445 + .stats-odyssey-notice--image-container {
446 + background-image: url("<?php echo esc_url( $stats_bg_url ); ?>"), url("<?php echo esc_url( $stats_bg_gradient_url ); ?>");
447 + background-size: cover;
448 + padding-right: 28px;
449 + width: 100%;
450 + }
451 + .stats-odyssey-notice--close-button {
452 + position: absolute;
453 + top: 1rem;
454 + right: 1rem;
455 + background-color: transparent;
456 + border: none;
457 + cursor: pointer;
458 + }
459 + .stats-odyssey-notice--action-bar {
460 + display: flex;
461 + align-items: center;
462 + margin-top: 24px;
463 + }
464 + .stats-odyssey-notice--primary-button {
465 + margin-right: 18px;
466 + padding-left: 20px;
467 + padding-right: 20px;
468 + font-size: 16px;
469 + border-color: black;
470 + background-color: black;
471 + }
472 + .stats-odyssey-notice--primary-button:hover {
473 + border-color: #3c434a;
474 + background-color: #3c434a;
475 + }
476 + .is-primary-link {
477 + color: white;
478 + text-decoration: none;
479 + }
480 + .is-primary-link:active {
481 + color: white;
482 + }
483 + .is-primary-link:focus {
484 + color: white;
485 + box-shadow: none;
486 + outline: none;
487 + }
488 + .is-primary-link:hover {
489 + color: white;
490 + }
491 + .is-secondary-link {
492 + color: black;
493 + font-size: var( --font-body );
494 + }
495 + .is-secondary-link:hover {
496 + color: black;
497 + }
498 + .is-hidden {
499 + display: none;
500 + }
501 + </style>
433 502 <div id="jp-stats-wrap">
434 503 <div class="wrap">
435 504 <h1><?php esc_html_e( 'Jetpack Stats', 'jetpack' ); ?>
436 505 <?php
@@ -438,9 +507,9 @@
438 507 $i18n_headers = jetpack_get_module_i18n( 'stats' );
439 508 ?>
440 509 <a
441 510 style="font-size:13px;"
442 - href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack#/settings?term=' . rawurlencode( $i18n_headers['name'] ) ) ); ?>"
511 + href="<?php echo esc_url( admin_url( 'admin.php?page=jetpack#/settings?term=' . rawurlencode( $i18n_headers['name'] ?? '' ) ) ); ?>"
443 512 >
444 513 <?php esc_html_e( 'Configure', 'jetpack' ); ?>
445 514 </a>
446 515 <?php
@@ -445,27 +514,27 @@
445 514 </a>
446 515 <?php
447 516 endif;
448 517
449 - /**
450 - * Sets external resource URL.
451 - *
452 - * @module stats
453 - *
454 - * @since 1.4.0
455 - * @todo Clean up various uses of this filter. It's seemingly filtering different types of images in different places.
456 - *
457 - * @param string $args URL of external resource.
458 - */
459 - $static_url = apply_filters( 'jetpack_static_url', "{$http}://en.wordpress.com/i/loading/loading-64.gif" );
460 518 ?>
461 519 </h2>
462 520 </div>
463 - <div id="stats-loading-wrap" class="wrap">
464 - <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>
465 - <p class="hide-if-js"><?php esc_html_e( 'Jetpack Stats work better with JavaScript enabled.', 'jetpack' ); ?><br />
466 - <a href="<?php echo esc_url( $nojs_url ); ?>"><?php esc_html_e( 'View Jetpack Stats without JavaScript', 'jetpack' ); ?></a>.</p>
521 + <div class="wrap">
522 + <div class="stats-odyssey-notice stats-odyssey-notice--content__highlighted">
523 + <div class="stats-odyssey-notice--content">
524 + <h2 class="stats-odyssey-notice--content-header"><?php esc_html_e( 'Deprecated Jetpack Stats Experience', 'jetpack' ); ?></h2>
525 + <p class="stats-odyssey-notice--content-text"><?php esc_html_e( 'The old Jetpack Stats has been deprecated. Please click the button to enable the new experience.', 'jetpack' ); ?></p>
526 + <div class="stats-odyssey-notice--action-bar">
527 + <button class="dops-button stats-odyssey-notice--primary-button">
528 + <a class="is-primary-link" href="<?php echo esc_url( $redirect_url ); ?>"><?php esc_html_e( 'Switch to new Stats', 'jetpack' ); ?></a>
529 + </button>
530 + <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>
531 + </div>
532 + </div>
533 + <div class="stats-odyssey-notice--image-container"></div>
534 + </div>
467 535 </div>
536 + <p></p>
468 537 </div>
469 538 <?php
470 539 return;
471 540 }
@@ -522,21 +591,20 @@
522 591 }
523 592 } elseif ( null === $vals ) {
524 593 $q[ $var ] = '';
525 594 } elseif ( 'data' === $vals ) {
526 - if ( 'index.php' === substr( $val, 0, 9 ) ) {
595 + if ( str_starts_with( $val, 'index.php' ) ) {
527 596 $q[ $var ] = $val;
528 597 }
529 598 }
530 599 }
531 600
601 + $url = 'https://' . STATS_DASHBOARD_SERVER . '/wp-admin/index.php';
532 602 if ( isset( $_GET['chart'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
533 603 if ( preg_match( '/^[a-z0-9-]+$/', $_GET['chart'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
534 604 $chart = sanitize_title( $_GET['chart'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended, WordPress.Security.ValidatedSanitizedInput
535 605 $url = 'https://' . STATS_DASHBOARD_SERVER . "/wp-includes/charts/{$chart}.php";
536 606 }
537 - } else {
538 - $url = 'https://' . STATS_DASHBOARD_SERVER . '/wp-admin/index.php';
539 607 }
540 608
541 609 $url = add_query_arg( $q, $url );
542 610 $method = 'GET';
@@ -544,34 +612,19 @@
544 612 $user_id = 0; // Means use the blog token.
545 613
546 614 $get = Client::remote_request( compact( 'url', 'method', 'timeout', 'user_id' ) );
547 615 $get_code = wp_remote_retrieve_response_code( $get );
548 - if ( is_wp_error( $get ) || ( 2 !== (int) ( $get_code / 100 ) && 304 !== $get_code ) || empty( $get['body'] ) ) {
616 + if ( is_wp_error( $get ) || $get_code === '' || ( 2 !== (int) ( $get_code / 100 ) && 304 !== $get_code ) || empty( $get['body'] ) ) {
549 617 stats_print_wp_remote_error( $get, $url );
550 - } else {
551 - if ( ! empty( $get['headers']['content-type'] ) ) {
552 - $type = $get['headers']['content-type'];
553 - if ( substr( $type, 0, 5 ) === 'image' ) {
554 - $img = $get['body'];
555 - header( 'Content-Type: ' . $type );
556 - header( 'Content-Length: ' . strlen( $img ) );
557 - echo $img; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
558 - die();
559 - }
618 + } elseif ( ! empty( $get['headers']['content-type'] ) ) {
619 + $type = $get['headers']['content-type'];
620 + if ( str_starts_with( $type, 'image' ) ) {
621 + $img = $get['body'];
622 + header( 'Content-Type: ' . $type );
623 + header( 'Content-Length: ' . strlen( $img ) );
624 + echo $img; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
625 + die( 0 );
560 626 }
561 - $body = stats_convert_post_titles( $get['body'] );
562 - $body = stats_convert_chart_urls( $body );
563 - $body = stats_convert_image_urls( $body );
564 - $body = stats_convert_admin_urls( $body );
565 -
566 - // The response can contain either the content to display OR
567 - // the scripts for the chart UI. The following calls inspect the
568 - // response, insert the Odyssey nudge as needed, and make sure
569 - // everything is output correctly.
570 - stats_print_header_section( $body );
571 - stats_print_odyssey_nudge( $body );
572 - stats_print_content_section( $body );
573 - stats_print_chart_scripts( $body );
574 627 }
575 628
576 629 if ( isset( $_GET['page'] ) && 'stats' === $_GET['page'] && ! isset( $_GET['chart'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
577 630 $tracking = new Tracking();
@@ -578,246 +631,13 @@
578 631 $tracking->record_user_event( 'wpa_page_view', array( 'path' => 'old_stats' ) );
579 632 }
580 633
581 634 if ( isset( $_GET['noheader'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
582 - die;
635 + die( 0 );
583 636 }
584 637 }
585 638
586 639 /**
587 - * Legacy Stats: Print Header Section
588 - *
589 - * @access public
590 - * @param mixed $html HTML.
591 - * @return void
592 - */
593 -function stats_print_header_section( $html ) {
594 - $header = stats_parse_header_section( $html );
595 - if ( $header !== '' ) {
596 - echo $header; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
597 - }
598 -}
599 -
600 -/**
601 - * Legacy Stats: Print Content Section
602 - *
603 - * @access public
604 - * @param mixed $html HTML.
605 - * @return void
606 - */
607 -function stats_print_content_section( $html ) {
608 - $content = stats_parse_content_section( $html );
609 - if ( $content !== '' ) {
610 - echo $content; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
611 - }
612 -}
613 -
614 -/**
615 - * Legacy Stats: Print Chart Scripts
616 - *
617 - * @access public
618 - * @param mixed $html HTML.
619 - * @return void
620 - */
621 -function stats_print_chart_scripts( $html ) {
622 - if ( is_chart_scripts( $html ) ) {
623 - echo $html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
624 - }
625 -}
626 -
627 -/**
628 - * Legacy Stats: Test for presence of chart scripts
629 - *
630 - * @access public
631 - * @param mixed $html Input HTML that may or may not include the chart scripts.
632 - * @return bool
633 - */
634 -function is_chart_scripts( $html ) {
635 - $pos = strpos( $html, STATS_CONTENT_MARKER );
636 - return $pos === false;
637 -}
638 -
639 -/**
640 - * Legacy Stats: Parse Header Section
641 - *
642 - * Returns the section of the content up to and including the date header.
643 - *
644 - * @access public
645 - * @param mixed $html HTML.
646 - * @return string
647 - */
648 -function stats_parse_header_section( $html ) {
649 - $head = strstr( $html, STATS_CONTENT_MARKER, true );
650 - // Enforce a string result instead of string|false.
651 - if ( $head === false ) {
652 - return '';
653 - }
654 - return $head;
655 -}
656 -
657 -/**
658 - * Legacy Stats: Print Content Section
659 - *
660 - * Returns the section of the content excluding the date header.
661 - *
662 - * @access public
663 - * @param mixed $html HTML.
664 - * @return string
665 - */
666 -function stats_parse_content_section( $html ) {
667 - $body = strstr( $html, STATS_BODY_MARKER );
668 - // Enforce a string result instead of string|false.
669 - if ( $body === false ) {
670 - return '';
671 - }
672 - return $body;
673 -}
674 -
675 -/**
676 - * Legacy Stats: Determine if we need to show the Odyssey upgrade nudge.
677 - *
678 - * @access public
679 - * @return boolean
680 - */
681 -function stats_should_show_odyssey_nudge() {
682 - $stats_notices = ( new Stats_Notices() )->get_notices_to_show();
683 - return isset( $stats_notices[ Stats_Notices::OPT_IN_NEW_STATS_NOTICE_ID ] )
684 - && $stats_notices[ Stats_Notices::OPT_IN_NEW_STATS_NOTICE_ID ];
685 -}
686 -
687 -/**
688 - * Legacy Stats: Print the Odyssey upgrade nudge.
689 - *
690 - * @access public
691 - * @param mixed $html HTML.
692 - * @return void
693 - */
694 -function stats_print_odyssey_nudge( $html ) {
695 - if ( ! stats_should_show_odyssey_nudge() ) {
696 - return;
697 - }
698 - $pos = strpos( $html, STATS_CONTENT_MARKER );
699 - if ( $pos === false ) {
700 - return;
701 - }
702 - $learn_url = Redirect::get_url( 'jetpack-stats-learn-more' );
703 - $redirect_url = admin_url( 'admin.php?page=stats&enable_new_stats=1' );
704 - ?>
705 - <style>
706 - .stats-odyssey-notice {
707 - display: flex;
708 - font-size: var( --font-body );
709 -
710 - border: 1px solid var( --jp-gray-5 );
711 - border-left-color: var( --jp-black );
712 - border-left-width: 6px;
713 - border-radius: 4px;
714 -
715 - margin-top: 24px;
716 - background: white;
717 - position: relative;
718 - }
719 - .stats-odyssey-notice--content {
720 - padding: 24px 0 24px 30px;
721 - font-size: 2em;
722 - width: 100%;
723 - }
724 - .stats-odyssey-notice--content-header {
725 - font-size: 24px;
726 - line-height: 32px;
727 - margin: 0;
728 - margin-bottom: 8px;
729 - }
730 - .stats-odyssey-notice--content-text {
731 - font-size: 16px;
732 - margin: 0;
733 - }
734 - .stats-odyssey-notice--image-container {
735 - background-image: url("/wp-content/plugins/jetpack/images/odyssey-upgrade/background.png"), url("/wp-content/plugins/jetpack/images/odyssey-upgrade/gradient.png");
736 - background-size: cover;
737 - padding-right: 28px;
738 - width: 100%;
739 - }
740 - .stats-odyssey-notice--close-button {
741 - position: absolute;
742 - top: 1rem;
743 - right: 1rem;
744 - background-color: transparent;
745 - border: none;
746 - cursor: pointer;
747 - }
748 - .stats-odyssey-notice--action-bar {
749 - display: flex;
750 - align-items: center;
751 - margin-top: 24px;
752 - }
753 - .stats-odyssey-notice--primary-button {
754 - margin-right: 18px;
755 - padding-left: 20px;
756 - padding-right: 20px;
757 - font-size: 16px;
758 - border-color: black;
759 - background-color: black;
760 - }
761 - .stats-odyssey-notice--primary-button:hover {
762 - border-color: #3c434a;
763 - background-color: #3c434a;
764 - }
765 - .is-primary-link {
766 - color: white;
767 - text-decoration: none;
768 - }
769 - .is-primary-link:active {
770 - color: white;
771 - }
772 - .is-primary-link:focus {
773 - color: white;
774 - box-shadow: none;
775 - outline: none;
776 - }
777 - .is-primary-link:hover {
778 - color: white;
779 - }
780 - .is-secondary-link {
781 - color: black;
782 - font-size: var( --font-body );
783 - }
784 - .is-secondary-link:hover {
785 - color: black;
786 - }
787 - .is-hidden {
788 - display: none;
789 - }
790 - </style>
791 - <div id="stats-odyssey-nudge-main" class="stats-odyssey-notice">
792 - <div class="stats-odyssey-notice--content">
793 - <h2 class="stats-odyssey-notice--content-header"><?php esc_html_e( 'Explore the new Jetpack Stats', 'jetpack' ); ?></h2>
794 - <p class="stats-odyssey-notice--content-text"><?php esc_html_e( "We've added new stats and insights in a more modern and mobile friendly experience to help you grow your site.", 'jetpack' ); ?></p>
795 - <div class="stats-odyssey-notice--action-bar">
796 - <button class="dops-button stats-odyssey-notice--primary-button">
797 - <a class="is-primary-link" href="<?php echo esc_url( $redirect_url ); ?>"><?php esc_html_e( 'Switch to new Stats', 'jetpack' ); ?></a>
798 - </button>
799 - <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>
800 - </div>
801 - </div>
802 - <div class="stats-odyssey-notice--image-container"></div>
803 - <button class="stats-odyssey-notice--close-button" onclick="stats_odyssey_dismiss_nudge()"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
804 - </div>
805 - <?php
806 -}
807 -
808 -/**
809 - * Stats Convert Admin Urls.
810 - *
811 - * @access public
812 - * @param mixed $html HTML.
813 - * @return string
814 - */
815 -function stats_convert_admin_urls( $html ) {
816 - return str_replace( 'index.php?page=stats', 'admin.php?page=stats', $html );
817 -}
818 -
819 -/**
820 640 * Stats Convert Image URLs.
821 641 *
822 642 * @access public
823 643 * @param mixed $html HTML.
@@ -922,8 +742,13 @@
922 742 * @access public
923 743 * @return void
924 744 */
925 745 function stats_admin_bar_head() {
746 + // Let's not show the stats admin bar to users who are not logged in.
747 + if ( ! is_user_logged_in() ) {
748 + return;
749 + }
750 +
926 751 if ( ! Stats_Options::get_option( 'admin_bar' ) ) {
927 752 return;
928 753 }
929 754
@@ -1004,9 +829,9 @@
1004 829
1005 830 $menu = array(
1006 831 'id' => 'stats',
1007 832 'href' => add_query_arg( 'page', 'stats', admin_url( 'admin.php' ) ), // no menu_page_url() blog-side.
1008 - 'title' => "<div><img src='$img_src' srcset='$img_src 1x, $img_src_2x 2x' width='112' height='24' alt='$alt' title='$title'></div>",
833 + 'title' => "<div><img fetchpriority='low' loading='lazy' decoding='async' src='$img_src' srcset='$img_src 1x, $img_src_2x 2x' width='112' height='24' alt='$alt' title='$title'></div>",
1009 834 );
1010 835
1011 836 $wp_admin_bar->add_menu( $menu );
1012 837 }
@@ -1011,21 +836,33 @@
1011 836 $wp_admin_bar->add_menu( $menu );
1012 837 }
1013 838
1014 839 /**
840 + * Adds a Stats link to the site-name admin bar submenu, alongside Dashboard.
1015 841 *
1016 - * Deprecated. The stats module should not update blog details. This is handled by Sync.
1017 - *
1018 - * Stats Update Blog.
1019 - *
1020 842 * @access public
1021 843 * @return void
1022 - *
1023 - * @deprecated since 10.3.
1024 844 */
1025 -function stats_update_blog() {
1026 - _deprecated_function( __METHOD__, 'jetpack-10.3' );
1027 - XMLRPC_Async_Call::add_call( 'jetpack.updateBlog', 0, stats_get_blog() );
845 +function stats_add_link_to_admin_bar_site_menu() {
846 + global $wp_admin_bar;
847 +
848 + if (
849 + ! is_object( $wp_admin_bar ) ||
850 + ! $wp_admin_bar->get_node( 'dashboard' ) ||
851 + ! current_user_can( 'view_stats' ) ||
852 + ( new Host() )->is_wpcom_platform()
853 + ) {
854 + return;
855 + }
856 +
857 + $wp_admin_bar->add_node(
858 + array(
859 + 'parent' => 'site-name',
860 + 'id' => 'jetpack-stats',
861 + 'title' => __( 'Stats', 'jetpack' ),
862 + 'href' => admin_url( 'admin.php?page=stats' ),
863 + )
864 + );
1028 865 }
1029 866
1030 867 /**
1031 868 * Stats Get Blog.
@@ -1215,9 +1052,9 @@
1215 1052 *
1216 1053 * TODO: This should be moved into class-jetpack-stats-dashboard-widget.php.
1217 1054 *
1218 1055 * @access public
1219 - * @return void
1056 + * @return never
1220 1057 */
1221 1058 function stats_dashboard_widget_content() {
1222 1059 $width = isset( $_GET['width'] ) ? intval( $_GET['width'] ) / 2 : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
1223 1060 $height = isset( $_GET['height'] ) ? intval( $_GET['height'] ) - 36 : null; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
@@ -1256,9 +1093,9 @@
1256 1093 $user_id = 0; // Means use the blog token.
1257 1094
1258 1095 $get = Client::remote_request( compact( 'url', 'method', 'timeout', 'user_id' ) );
1259 1096 $get_code = wp_remote_retrieve_response_code( $get );
1260 - if ( is_wp_error( $get ) || ( 2 !== (int) ( $get_code / 100 ) && 304 !== $get_code ) || empty( $get['body'] ) ) {
1097 + if ( is_wp_error( $get ) || $get_code === '' || ( 2 !== (int) ( $get_code / 100 ) && 304 !== $get_code ) || empty( $get['body'] ) ) {
1261 1098 stats_print_wp_remote_error( $get, $url );
1262 1099 } else {
1263 1100 $body = stats_convert_post_titles( $get['body'] );
1264 1101 $body = stats_convert_chart_urls( $body );
@@ -1361,9 +1198,9 @@
1361 1198 </div>
1362 1199 </div>
1363 1200 </div>
1364 1201 <?php
1365 - exit;
1202 + exit( 0 );
1366 1203 }
1367 1204
1368 1205 /**
1369 1206 * Stats Print WP Remote Error.
@@ -1375,9 +1212,9 @@
1375 1212 */
1376 1213 function stats_print_wp_remote_error( $get, $url ) {
1377 1214 $state_name = 'stats_remote_error_' . substr( md5( $url ), 0, 8 );
1378 1215 $previous_error = Jetpack::state( $state_name );
1379 - $error = md5( wp_json_encode( compact( 'get', 'url' ) ) );
1216 + $error = md5( wp_json_encode( compact( 'get', 'url' ), JSON_UNESCAPED_SLASHES ) );
1380 1217 Jetpack::state( $state_name, $error );
1381 1218 if ( $error !== $previous_error ) {
1382 1219 ?>
1383 1220 <div class="wrap">
@@ -1437,8 +1274,9 @@
1437 1274 * @type string $days The length of the desired time frame. Default is 30. Maximum 90 days.
1438 1275 * @type int $limit The maximum number of records to return. Default is 10. Maximum 100.
1439 1276 * @type int $post_id The ID of the post to retrieve stats data for
1440 1277 * @type string $summarize If present, summarizes all matching records. Default Null.
1278 + * @type int $blog_id The WordPress.com blog ID to retrieve stats data for. Default is the current blog.
1441 1279 *
1442 1280 * }
1443 1281 *
1444 1282 * @return array {
@@ -1460,13 +1298,13 @@
1460 1298 'days' => false,
1461 1299 'limit' => 3,
1462 1300 'post_id' => false,
1463 1301 'summarize' => '',
1302 + 'blog_id' => Jetpack_Options::get_option( 'id' ),
1464 1303 );
1465 1304
1466 - $args = wp_parse_args( $args, $defaults );
1467 - $args['table'] = $table;
1468 - $args['blog_id'] = Jetpack_Options::get_option( 'id' );
1305 + $args = wp_parse_args( $args, $defaults );
1306 + $args['table'] = $table;
1469 1307
1470 1308 $stats_csv_url = add_query_arg( $args, 'https://stats.wordpress.com/csv.php' );
1471 1309
1472 1310 $key = md5( $stats_csv_url );
@@ -1536,9 +1374,9 @@
1536 1374 $user_id = 0; // Blog token.
1537 1375
1538 1376 $get = Client::remote_request( compact( 'url', 'method', 'timeout', 'user_id' ) );
1539 1377 $get_code = wp_remote_retrieve_response_code( $get );
1540 - if ( is_wp_error( $get ) || ( 2 !== (int) ( $get_code / 100 ) && 304 !== $get_code ) || empty( $get['body'] ) ) {
1378 + if ( is_wp_error( $get ) || $get_code === '' || ( 2 !== (int) ( $get_code / 100 ) && 304 !== $get_code ) || empty( $get['body'] ) ) {
1541 1379 return array(); // @todo: return an error?
1542 1380 } else {
1543 1381 return stats_str_getcsv( $get['body'] );
1544 1382 }
@@ -1549,13 +1387,19 @@
1549 1387 *
1550 1388 * @since 9.7.0 Remove custom handling since str_getcsv is available on all servers running this now.
1551 1389 *
1552 1390 * @param mixed $csv CSV.
1553 - * @return array.
1391 + * @return array
1554 1392 */
1555 1393 function stats_str_getcsv( $csv ) {
1556 - $lines = str_getcsv( $csv, "\n" );
1557 - return array_map( 'str_getcsv', $lines );
1394 + // @todo Correctly handle embedded newlines. Note, despite claims online, `str_getcsv( $csv, "\n" )` does not actually work.
1395 + $lines = explode( "\n", rtrim( $csv, "\n" ) );
1396 + return array_map(
1397 + function ( $line ) {
1398 + return str_getcsv( $line, ',', '"', '' );
1399 + },
1400 + $lines
1401 + );
1558 1402 }
1559 1403
1560 1404 /**
1561 1405 * Abstract out building the rest api stats path.
@@ -1575,9 +1419,9 @@
1575 1419 * @access public
1576 1420 * @deprecated 11.5 Use WPCOM_Stats available methodsinstead.
1577 1421 * @param array $args (default: array()) The args that are passed to the endpoint.
1578 1422 * @param string $resource (default: '') Optional sub-endpoint following /stats/.
1579 - * @return array|WP_Error.
1423 + * @return array|WP_Error
1580 1424 */
1581 1425 function stats_get_from_restapi( $args = array(), $resource = '' ) {
1582 1426 _deprecated_function( __METHOD__, 'jetpack-11.5', 'Please checkout the methods available in Automattic\Jetpack\Stats\WPCOM_Stats' );
1583 1427 $endpoint = jetpack_stats_api_path( $resource );
@@ -1582,9 +1426,9 @@
1582 1426 _deprecated_function( __METHOD__, 'jetpack-11.5', 'Please checkout the methods available in Automattic\Jetpack\Stats\WPCOM_Stats' );
1583 1427 $endpoint = jetpack_stats_api_path( $resource );
1584 1428 $api_version = '1.1';
1585 1429 $args = wp_parse_args( $args, array() );
1586 - $cache_key = md5( implode( '|', array( $endpoint, $api_version, wp_json_encode( $args ) ) ) );
1430 + $cache_key = md5( implode( '|', array( $endpoint, $api_version, wp_json_encode( $args, JSON_UNESCAPED_SLASHES ) ) ) );
1587 1431
1588 1432 $transient_name = "jetpack_restapi_stats_cache_{$cache_key}";
1589 1433
1590 1434 $stats_cache = get_transient( $transient_name );
@@ -1621,107 +1465,8 @@
1621 1465 return $return;
1622 1466 }
1623 1467
1624 1468 /**
1625 - * Load CSS needed for Stats column width in WP-Admin area.
1626 - *
1627 - * @since 4.7.0
1628 - */
1629 -function jetpack_stats_load_admin_css() {
1630 - ?>
1631 - <style type="text/css">
1632 - .fixed .column-stats {
1633 - width: 5em;
1634 - }
1635 - </style>
1636 - <?php
1637 -}
1638 -
1639 -/**
1640 - * Set header for column that allows to view an entry's stats.
1641 - *
1642 - * @param array $columns An array of column names.
1643 - *
1644 - * @since 4.7.0
1645 - *
1646 - * @return mixed
1647 - */
1648 -function jetpack_stats_post_table( $columns ) {
1649 - /*
1650 - * Stats can be accessed in wp-admin or in Calypso,
1651 - * depending on what version of the stats screen is enabled on your site.
1652 - *
1653 - * In both cases, the user must be allowed to access stats.
1654 - *
1655 - * If the Odyssey Stats experience isn't enabled, the user will need to go to Calypso,
1656 - * so they need to be connected to WordPress.com to be able to access that page.
1657 - */
1658 - if (
1659 - ! current_user_can( 'view_stats' )
1660 - || (
1661 - ! Stats_Options::get_option( 'enable_odyssey_stats' )
1662 - && ! ( new Connection_Manager( 'jetpack' ) )->is_user_connected()
1663 - )
1664 - ) {
1665 - return $columns;
1666 - }
1667 -
1668 - // Array-Fu to add before comments.
1669 - $pos = array_search( 'comments', array_keys( $columns ), true );
1670 -
1671 - // Fallback to the last position if the post type does not support comments.
1672 - if ( ! is_int( $pos ) ) {
1673 - $pos = count( $columns );
1674 - }
1675 -
1676 - // Final fallback, if the array was malformed by another plugin for example.
1677 - if ( ! is_int( $pos ) ) {
1678 - return $columns;
1679 - }
1680 -
1681 - $chunks = array_chunk( $columns, $pos, true );
1682 - $chunks[0]['stats'] = esc_html__( 'Stats', 'jetpack' );
1683 -
1684 - return call_user_func_array( 'array_merge', $chunks );
1685 -}
1686 -
1687 -/**
1688 - * Set content for cell with link to an entry's stats in Odyssey Stats.
1689 - *
1690 - * @param string $column The name of the column to display.
1691 - * @param int $post_id The current post ID.
1692 - *
1693 - * @since 4.7.0
1694 - *
1695 - * @return mixed
1696 - */
1697 -function jetpack_stats_post_table_cell( $column, $post_id ) {
1698 - if ( 'stats' === $column ) {
1699 - if ( 'publish' !== get_post_status( $post_id ) ) {
1700 - printf(
1701 - '<span aria-hidden="true">—</span><span class="screen-reader-text">%s</span>',
1702 - esc_html__( 'No stats', 'jetpack' )
1703 - );
1704 - } else {
1705 - $stats_post_url = ! ( new Host() )->is_woa_site() && Stats_Options::get_option( 'enable_odyssey_stats' )
1706 - ? admin_url( sprintf( 'admin.php?page=stats#!/stats/post/%d/%d', $post_id, Jetpack_Options::get_option( 'id', 0 ) ) )
1707 - : Redirect::get_url(
1708 - 'calypso-stats-post',
1709 - array(
1710 - 'path' => $post_id,
1711 - )
1712 - );
1713 -
1714 - printf(
1715 - '<a href="%s" title="%s" class="dashicons dashicons-chart-bar" target="_blank"></a>',
1716 - esc_url( $stats_post_url ),
1717 - esc_html__( 'View stats for this post', 'jetpack' )
1718 - );
1719 - }
1720 - }
1721 -}
1722 -
1723 -/**
1724 1469 * Add the Jetpack plugin version to the stats tracking data.
1725 1470 *
1726 1471 * @param array $kvs The stats array in key values.
1727 1472 * @return array
@@ -1738,14 +1483,8 @@
1738 1483 * @param array $stats_array The stats array.
1739 1484 * @return WP_Error|Object|null
1740 1485 */
1741 1486 function convert_stats_array_to_object( $stats_array ) {
1487 + _deprecated_function( __FUNCTION__, 'jetpack-13.2', 'Automattic\Jetpack\Stats\WPCOM_Stats->convert_stats_array_to_object' );
1742 1488
1743 - if ( is_wp_error( $stats_array ) ) {
1744 - return $stats_array;
1745 - }
1746 - $encoded_array = wp_json_encode( $stats_array );
1747 - if ( ! $encoded_array ) {
1748 - return new WP_Error( 'stats_encoding_error', 'Failed to encode stats array' );
1749 - }
1750 - return json_decode( $encoded_array );
1489 + return ( new WPCOM_Stats() )->convert_stats_array_to_object( $stats_array );
1751 1490 }