| 1 |
<?php |
| 2 |
/** |
| 3 |
* EasyFonts Notices |
| 4 |
* |
| 5 |
* Handles admin notices for the EasyFonts plugin. |
| 6 |
* |
| 7 |
* @package EasyFonts |
| 8 |
* @since 1.2.0 |
| 9 |
*/ |
| 10 |
|
| 11 |
if ( ! defined( 'WPINC' ) ) { |
| 12 |
die; |
| 13 |
} |
| 14 |
|
| 15 |
class EasyFonts_Notices { |
| 16 |
|
| 17 |
public function __construct() { |
| 18 |
add_action( 'admin_notices', [ $this, 'check_incompatible_plugins' ] ); |
| 19 |
} |
| 20 |
|
| 21 |
/** |
| 22 |
* Check for incompatible plugins and display notices if active. |
| 23 |
*/ |
| 24 |
public function check_incompatible_plugins() { |
| 25 |
/* Only show on the EasyFonts settings page to avoid cluttering other admin areas. |
| 26 |
if ( 'settings_page_easyfonts' !== get_current_screen()->id ) { |
| 27 |
return; |
| 28 |
}*/ |
| 29 |
|
| 30 |
// Check for 'Local Google Fonts'. |
| 31 |
if ( is_plugin_active( 'local-google-fonts/local-google-fonts.php' ) ) { |
| 32 |
$this->display_notice( __( 'The "Local Google Fonts" plugin is active and may cause conflicts with EasyFonts. Please deactivate it to avoid issues.', 'easyfonts' ) ); |
| 33 |
} |
| 34 |
|
| 35 |
// Check for 'OMGF | Host Google Fonts Locally'. |
| 36 |
if ( is_plugin_active( 'host-webfonts-local/host-webfonts-local.php' ) ) { |
| 37 |
$this->display_notice( __( 'The "OMGF | Host Google Fonts Locally" plugin is active and may cause conflicts with EasyFonts. Please deactivate it to avoid issues.', 'easyfonts' ) ); |
| 38 |
} |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* Display an error notice. |
| 43 |
* |
| 44 |
* @param string $message The notice message. |
| 45 |
*/ |
| 46 |
private function display_notice( $message ) { |
| 47 |
?> |
| 48 |
<div class="notice notice-error is-dismissible"> |
| 49 |
<p><?php echo esc_html( $message ); ?></p> |
| 50 |
</div> |
| 51 |
<?php |
| 52 |
} |
| 53 |
} |
| 54 |
|
| 55 |
new EasyFonts_Notices(); |