-
Notifications
You must be signed in to change notification settings - Fork 801
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CloudFlare Analytics: move feature to mu-wpcom (#37061)
* CloudFlare Analytics: move feature to mu-wpcom The feature is only used on WordPress.com sites, it is not needed in the Jetpack plugin. Since the feature was loaded on all connected Jetpack sites, it also had the inconvenient of making an option call on every frontend call. * Update Phan config * Stop loading the Jetpack module * Update projects/packages/jetpack-mu-wpcom/src/features/cloudflare-analytics/cloudflare-analytics.php Co-authored-by: Foteini Giannaropoulou <[email protected]> * Fix PHPCS error --------- Co-authored-by: Foteini Giannaropoulou <[email protected]>
- Loading branch information
Showing
7 changed files
with
59 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
projects/packages/jetpack-mu-wpcom/changelog/update-cloudflare-analytics-move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: added | ||
|
||
CloudFlare Analytics: add tracking code management (originally in the Jetpack plugin). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...ects/packages/jetpack-mu-wpcom/src/features/cloudflare-analytics/cloudflare-analytics.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Cloudflare Analytics | ||
* Let WPCOM users automatically insert a Cloudflare analytics JS snippet into their site footer. | ||
* | ||
* @since $$next-version$$ -- Ported from Jetpack. | ||
* | ||
* @package automattic/jetpack-mu-wpcom | ||
*/ | ||
|
||
namespace Automattic\Jetpack\Jetpack_Mu_Wpcom\Cloudflare_Analytics; | ||
|
||
/** | ||
* Add Cloudflare Analytics tracking code to the head. | ||
* | ||
* @since $$next-version$$ -- Ported from Jetpack. | ||
*/ | ||
function insert_tracking_id() { | ||
$option = get_option( 'jetpack_cloudflare_analytics' ); | ||
|
||
if ( | ||
! empty( $option['code'] ) | ||
&& ! is_admin() | ||
&& ( | ||
! class_exists( 'Jetpack_AMP_Support' ) | ||
|| ( class_exists( 'Jetpack_AMP_Support' ) && ! \Jetpack_AMP_Support::is_amp_request() ) | ||
) | ||
) { | ||
// phpcs:disable WordPress.WP.EnqueuedResources.NonEnqueuedScript | ||
printf( | ||
"<!-- Jetpack Cloudflare Web Analytics --> | ||
<script defer | ||
src='https://static.cloudflareinsights.com/beacon.min.js' | ||
data-cf-beacon='{\"token\": \"%s\"}'> | ||
</script> | ||
<!-- End Jetpack Cloudflare Web Analytics -->\r\n", | ||
esc_html( $option['code'] ) | ||
); | ||
// phpcs:enable WordPress.WP.EnqueuedResources.NonEnqueuedScript | ||
} | ||
} | ||
add_action( 'wp_footer', __NAMESPACE__ . '\insert_tracking_id', 999 ); |
4 changes: 4 additions & 0 deletions
4
projects/plugins/jetpack/changelog/update-cloudflare-analytics-move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: patch | ||
Type: other | ||
|
||
CloudFlare Analytics: deprecate feature and move to mu-wpcom. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters