Skip to content

Commit

Permalink
Add Toolbar proxy notice for Atomic sites (#38519)
Browse files Browse the repository at this point in the history
* Add profile-settings-notices file

* Update copy

* changelog

* Add translation

* Update copy
  • Loading branch information
DustyReagan authored Jul 24, 2024
1 parent 4b63023 commit 5fc4449
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: added

Add a12n notice about proxied toolbar
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,16 @@ public static function load_features() {
require_once __DIR__ . '/features/error-reporting/error-reporting.php';
require_once __DIR__ . '/features/first-posts-stream/first-posts-stream-helpers.php';
require_once __DIR__ . '/features/font-smoothing-antialiased/font-smoothing-antialiased.php';
require_once __DIR__ . '/features/google-analytics/google-analytics.php';
require_once __DIR__ . '/features/import-customizations/import-customizations.php';
require_once __DIR__ . '/features/marketplace-products-updater/class-marketplace-products-updater.php';
require_once __DIR__ . '/features/media/heif-support.php';
require_once __DIR__ . '/features/site-editor-dashboard-link/site-editor-dashboard-link.php';
require_once __DIR__ . '/features/wpcom-admin-dashboard/wpcom-admin-dashboard.php';
require_once __DIR__ . '/features/wpcom-block-editor/class-jetpack-wpcom-block-editor.php';
require_once __DIR__ . '/features/wpcom-block-editor/functions.editor-type.php';
require_once __DIR__ . '/features/wpcom-profile-settings/profile-settings-notices.php';
require_once __DIR__ . '/features/wpcom-themes/wpcom-theme-fixes.php';
require_once __DIR__ . '/features/google-analytics/google-analytics.php';

// Initializers, if needed.
\Marketplace_Products_Updater::init();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php
/**
* Custom notices for wp-admin/profile.php
*
* @package automattic/jetpack-mu-wpcom
*/

/**
* Adds a notice for Automatticians informing them that the Toolbar always shows on the front end on Atomic sites if
* they are connected to Autoproxxy.
*/
function maybe_show_wpcom_toolbar_proxy_notice() {
$is_proxied = isset( $_SERVER['A8C_PROXIED_REQUEST'] )
? sanitize_text_field( wp_unslash( $_SERVER['A8C_PROXIED_REQUEST'] ) )
: defined( 'A8C_PROXIED_REQUEST' ) && A8C_PROXIED_REQUEST;
$is_atomic = defined( 'IS_ATOMIC' ) && IS_ATOMIC;

if ( $is_proxied && $is_atomic ) {
?>
<style>
.toolbar-autoproxxy-notice {
color: #666;
font-style: italic;
margin-top: 5px;
}
</style>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
// Find the Toolbar checkbox label container using the unique ID.
var toolbarCheckboxLabel = document.querySelector('#admin_bar_front').parentNode;
if (toolbarCheckboxLabel) {
// Create a new div for the notice.
var newDiv = document.createElement('div');
newDiv.className = 'toolbar-autoproxxy-notice';
newDiv.textContent = '<?php echo esc_js( __( 'The Toolbar is always visible on Atomic sites while connected to the Automattic proxy.', 'jetpack-mu-wpcom' ) ); ?>'

// Insert the new div after the checkbox and label.
toolbarCheckboxLabel.appendChild(newDiv);

// Find and remove the <br> tag following the label to improve spacing.
var brElement = toolbarCheckboxLabel.nextSibling;
if (brElement && brElement.tagName === 'BR') {
brElement.parentNode.removeChild(brElement);
}
}
});
</script>
<?php
}
}

add_action( 'admin_footer-profile.php', 'maybe_show_wpcom_toolbar_proxy_notice' );

0 comments on commit 5fc4449

Please sign in to comment.