Skip to content

Commit

Permalink
Update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
DustyReagan committed Aug 5, 2024
1 parent 4f0ea5e commit 443f5e6
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,42 @@
*/

/**
* Initialize customizations for the options-general admin page.
* Hide the Administration Email section in General Settings on Simple Classic sites.
*/
function init_admin_email_address_customizations() {
function wpcom_maybe_hide_admin_email_address() {
$is_classic_site = get_option( 'wpcom_admin_interface' ) === 'wp-admin';
$is_simple_site = defined( 'IS_WPCOM' ) && IS_WPCOM;

if ( $is_simple_site && $is_classic_site ) {
add_action( 'admin_enqueue_scripts', 'wpcom_hide_admin_email_address_section' );
add_action( 'admin_enqueue_scripts', 'wpcom_hide_admin_email_address' );
}
}

/**
* Hide the Administration Email Address section in General Settings on Simple Classic sites.
* Hide the Administration Email section in General Settings.
*/
function wpcom_hide_admin_email_address_section() {
function wpcom_hide_admin_email_address() {
/**
* Use the CSS :has selector to hide the admin email tr elegantly. However, some older browsers do not support :has.
* Fallback to hiding the elements in the tr. This leaves some white space because it doesn't remove the row.
*/
?>
<style type="text/css">
/* The :has selector hides the admin email tr completely, but some older browsers do not support it. */
tr:has(#new_admin_email) {
display: none;
}

/* We fall back on hiding the elements in the tr. This leaves some white space because it doesn't remove the row. */
#new_admin_email,
#new-admin-email-description,
label[for=new_admin_email] {
display: none;
}
</style>
<?php
/**
* JavaScript is used to remove the whitespace of the row if we had to "fallback."
*/
?>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var emailField = document.getElementById('new_admin_email');
Expand All @@ -48,4 +55,4 @@ function wpcom_hide_admin_email_address_section() {
</script>
<?php
}
add_action( 'load-options-general.php', 'init_admin_email_address_customizations' );
add_action( 'load-options-general.php', 'wpcom_maybe_hide_admin_email_address' );

0 comments on commit 443f5e6

Please sign in to comment.