Skip to content

Commit

Permalink
Merge pull request #1317 from publishpress/Feature/#135-Ability-to-hi…
Browse files Browse the repository at this point in the history
…de-admin-notices

Feature/#135 ability to hide admin notices
  • Loading branch information
olatechpro authored Feb 11, 2025
2 parents 8cad8e7 + 01d4e73 commit f24f3ec
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 53 deletions.
20 changes: 0 additions & 20 deletions common/css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -1798,26 +1798,6 @@ ul.ppc-redirects-tab li.active a {
color: #dc3232;
}

.ppc-settings-subtab {
margin: 8px 0 0;
padding: 0;
font-size: 13px;
color: #646970;
}

.ppc-settings-subtab a {
margin: 0;
white-space: nowrap;
line-height: 2;
padding: .2em;
}

.ppc-settings-subtab a.active {
color: #000;
font-weight: 600;
border: none;
}

.ppc-floating-status {
position: fixed;
bottom: 20px;
Expand Down
18 changes: 10 additions & 8 deletions common/js/admin.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -866,17 +866,19 @@ jQuery(document).ready( function($) {
});

// -------------------------------------------------------------
// Settings sub tab click
// Settings sub tab change
// -------------------------------------------------------------
$(document).on('click', '.ppc-settings-subtab a', function (e) {
$(document).on('change', '.ppc-settings-role-subtab', function (e) {
e.preventDefault();
var current_content = $(this).attr('data-content');

$('.ppc-settings-subtab a').removeClass('active');

var selectedOption = $(this).find(':selected');
var current_content = selectedOption.data('content');

$('.ppc-settings-tab-content').addClass('hidden-element');

$(this).addClass('active');
$(current_content).removeClass('hidden-element');

if (current_content) {
$(current_content).removeClass('hidden-element');
}
});


Expand Down
2 changes: 1 addition & 1 deletion common/js/admin.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions includes/admin-notices/admin-notices.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ public function render_panel() {
<circle cx="85" cy="85" r="85" fill="#a8a8a8"></circle>
<path d="M97.6667 78.6665H72.3333C70.5917 78.6665 69.1667 80.0915 69.1667 81.8332C69.1667 83.5748 70.5917 84.9998 72.3333 84.9998H97.6667C99.4083 84.9998 100.833 83.5748 100.833 81.8332C100.833 80.0915 99.4083 78.6665 97.6667 78.6665ZM107.167 56.4998H104V53.3332C104 51.5915 102.575 50.1665 100.833 50.1665C99.0917 50.1665 97.6667 51.5915 97.6667 53.3332V56.4998H72.3333V53.3332C72.3333 51.5915 70.9083 50.1665 69.1667 50.1665C67.425 50.1665 66 51.5915 66 53.3332V56.4998H62.8333C61.1536 56.4998 59.5427 57.1671 58.355 58.3548C57.1673 59.5426 56.5 61.1535 56.5 62.8332V107.167C56.5 108.846 57.1673 110.457 58.355 111.645C59.5427 112.833 61.1536 113.5 62.8333 113.5H107.167C110.65 113.5 113.5 110.65 113.5 107.167V62.8332C113.5 59.3498 110.65 56.4998 107.167 56.4998ZM104 107.167H66C64.2583 107.167 62.8333 105.742 62.8333 104V72.3332H107.167V104C107.167 105.742 105.742 107.167 104 107.167ZM88.1667 91.3332H72.3333C70.5917 91.3332 69.1667 92.7582 69.1667 94.4998C69.1667 96.2415 70.5917 97.6665 72.3333 97.6665H88.1667C89.9083 97.6665 91.3333 96.2415 91.3333 94.4998C91.3333 92.7582 89.9083 91.3332 88.1667 91.3332Z" fill="#8E8E8E"></path>
</svg>
<h4><?php esc_html_e('No Admin Notices.', 'capability-manager-enhanced'); ?></h4>
<p><?php esc_html_e('There are no admin notices on this page.', 'capability-manager-enhanced'); ?></p>
<h4><?php esc_html_e('Admin Notices', 'capability-manager-enhanced'); ?></h4>
<p><?php esc_html_e('There are currently no admin notices.', 'capability-manager-enhanced'); ?> <a target="_blank" href="<?php echo esc_url(admin_url('admin.php?page=pp-capabilities-settings&pp_tab=admin-notices')); ?>"><?php esc_html_e('Edit the settings.', 'capability-manager-enhanced'); ?></a></p>
</div>
</div>
</div>
Expand Down
54 changes: 32 additions & 22 deletions includes/settings-ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -280,35 +280,45 @@ class="pp-capabilities-settings-chosen"
$admin_notice_settings = (array) get_option('cme_admin_notice_options', []);
?>
<tbody>
<!-- table-tab -->
<tr>
<td colspan="2" style="padding-left: 0;padding-top: 0;">
<?php
$table_default_tab = '';
$table_tabs = [];
foreach (wp_roles()->roles as $role => $detail) :
if ($table_default_tab == '') {
$table_default_tab = $role;
}
$active_class = ($table_default_tab == $role) ? 'active' : '';

$table_tabs[] = '<a href="#" class="' . $active_class . '" data-content=".pp-admin-notices-settings-' . $role . '-content">' . esc_html($detail['name']) . '</a>';
endforeach; ?>
<div class="ppc-settings-subtab">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo join(' | ', $table_tabs);
?>
</div>

<p class="description">
<?php esc_html_e('The Admin Notices feature attempts to clean up the WordPress admin area. This will not remove any messages that appear when you perform an action. This feature can move extra messages and advertisements to the Admin Notices area.', 'capability-manager-enhanced'); ?>
</p
</p>
<p style="margin-top: 10px;">
<label>
<span><?php esc_html_e('Select Role', 'capability-manager-enhanced'); ?>:</span>
<select class="ppc-settings-role-subtab">
<?php
$table_default_tab_role = '';
$table_tabs = [];
foreach (wp_roles()->roles as $role => $detail) :
if ($table_default_tab_role == '') {
$table_default_tab_role = $role;
}
$active_option = ($table_default_tab_role == $role);
?>
<option
value="tab1"
data-content="<?php echo esc_attr('.pp-admin-notices-settings-' . $role . '-content'); ?>"
<?php selected($active_option, true); ?>
>
<?php echo esc_html($detail['name']); ?>
</option>
<?php
endforeach; ?>

<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo join(' | ', $table_tabs);
?>
</select>
</label>
</p>
</td>
</tr>
<!-- tab-content -->
<?php foreach (wp_roles()->roles as $role => $detail) :
$visibility_class = ($table_default_tab == $role) ? '' : 'hidden-element';
$visibility_class = ($table_default_tab_role == $role) ? '' : 'hidden-element';
?>
<tr class="ppc-settings-tab-content pp-admin-notices-settings-<?php echo esc_attr($role); ?>-content <?php echo esc_attr($visibility_class); ?>">
<?php
Expand Down

0 comments on commit f24f3ec

Please sign in to comment.