Skip to content

Commit

Permalink
Merge pull request #200 from pronamic/199-show-license-admin-notice-o…
Browse files Browse the repository at this point in the history
…nly-on-dashboard-and-pronamic-pay-pages

199 show license admin notice only on dashboard and pronamic pay pages
  • Loading branch information
remcotolsma authored Nov 18, 2024
2 parents 268b963 + 0508e3e commit 4d7cb8c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pronamic-pay-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,5 @@ function ( $modules ) {
'action_scheduler' => __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php',
]
);

\Pronamic\WordPress\Pay\LicenseManager::instance();
28 changes: 28 additions & 0 deletions src/LicenseManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,30 @@ 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;
}

/**
* Admin notices.
*
Expand All @@ -153,6 +177,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 4d7cb8c

Please sign in to comment.