Skip to content

Commit

Permalink
Added is_automattician check for Atomic sites (#34798)
Browse files Browse the repository at this point in the history
* Added is_automattician alternative for Atomic sites

* changelog

* Tests added

* Ver bump

* Lock maintenance

---------

Co-authored-by: Brandon Kraft <[email protected]>
  • Loading branch information
paulopmt1 and kraftbj authored Apr 24, 2024
1 parent 8723df5 commit 42b91bd
Show file tree
Hide file tree
Showing 35 changed files with 499 additions and 1,112 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Added is_automattician_feature_flags_only on Jetpack sites as an alternative to is_automattician present on simple sites.
13 changes: 13 additions & 0 deletions projects/packages/status/src/class-visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,17 @@ public function get_ip( $check_all_headers = false ) {

return ! empty( $_SERVER['REMOTE_ADDR'] ) ? filter_var( wp_unslash( $_SERVER['REMOTE_ADDR'] ) ) : '';
}

/**
* Simple gate check for a11n feature testing purposes using AT_PROXIED_REQUEST constant.
* IMPORTANT: Only use it for internal feature test purposes, not authorization.
*
* The goal of this function is to help us gate features by using a similar function name
* we find on simple sites: is_automattician().
*
* @return bool True if the current request is PROXIED, false otherwise.
*/
public function is_automattician_feature_flags_only() {
return ( defined( 'AT_PROXIED_REQUEST' ) && AT_PROXIED_REQUEST );
}
}
13 changes: 13 additions & 0 deletions projects/packages/status/tests/php/test-visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,17 @@ public function get_ip_data_provider() {
),
);
}

/**
* Tests is_automattician_feature_flags_only method.
*/
public function test_is_automattician_feature_flags_only() {
$is_a11n = $this->visitor_obj->is_automattician_feature_flags_only();
$this->assertFalse( $is_a11n );

define( 'AT_PROXIED_REQUEST', true );

$is_a11n = $this->visitor_obj->is_automattician_feature_flags_only();
$this->assertTrue( $is_a11n );
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


140 changes: 36 additions & 104 deletions projects/plugins/automattic-for-agencies-client/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


Loading

0 comments on commit 42b91bd

Please sign in to comment.