Skip to content

Commit

Permalink
Show license admin notice only on dashboard and Pronamic Pay pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Nov 18, 2024
1 parent 5163c3d commit eff26a4
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/LicenseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,31 @@ public function input_license_key( $args ) {
printf( '<span class="dashicons dashicons-%s" style="vertical-align: text-bottom;"></span>', \esc_attr( $icon ) );
}

/**
* Should display license notice.
*
* @link https://github.com/pronamic/pronamic-pay/issues/104#issuecomment-2478346476
* @return bool
*/
private function should_display_license_notice() {
$screen = \get_current_screen();

if ( null === $screen ) {
return false;
}

if ( 'dashboard' === $screen->id ) {
return true;
}

if ( 'pronamic_ideal' === $screen->parent_base ) {
return true;
}

return false;

}

Check failure on line 171 in src/LicenseManager.php

View workflow job for this annotation

GitHub Actions / phpcs / phpcs

Function closing brace must go on the next line following the body; found 1 blank lines before brace

/**
* Admin notices.
*
Expand All @@ -153,6 +178,10 @@ public function input_license_key( $args ) {
* @return void
*/
public function admin_notices() {
if ( ! $this->should_display_license_notice() ) {
return;
}

// Show notices only to options managers (administrators).
if ( ! current_user_can( 'manage_options' ) ) {
return;
Expand Down

0 comments on commit eff26a4

Please sign in to comment.