| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
| 3 |
class ESHB_NOTICE{ |
| 4 |
|
| 5 |
// Get Instance |
| 6 |
private static $_instance = null; |
| 7 |
public static function instance(){ |
| 8 |
if( is_null( self::$_instance ) ){ |
| 9 |
self::$_instance = new self(); |
| 10 |
} |
| 11 |
return self::$_instance; |
| 12 |
} |
| 13 |
|
| 14 |
function __construct(){ |
| 15 |
add_action('admin_notices', array($this, 'eshb_woocommerce_missing_notice')); |
| 16 |
} |
| 17 |
|
| 18 |
public function eshb_woocommerce_missing_notice(){ |
| 19 |
if ( ! class_exists( 'WooCommerce' ) ) { |
| 20 |
$notice_id = 'woocommerce_missing'; |
| 21 |
|
| 22 |
$content = 'Easy Hotel Plugin requires WooCommerce to function. Please install and activate WooCommerce to use this plugin\'s features. Visit Plugins > Add New and search for \'WooCommerce\' to install.'; |
| 23 |
$action_buttons = array( |
| 24 |
array( |
| 25 |
'title' => 'Install WooCommerce', |
| 26 |
'url' => admin_url().'plugin-install.php?s=woocommerce&tab=search&type=term', |
| 27 |
), |
| 28 |
); |
| 29 |
|
| 30 |
?> |
| 31 |
<div data-notice_id="<?php echo esc_attr( $notice_id )?>" id="eshb-notice-<?php echo esc_attr( $notice_id )?>" class="eshb-notice notice is-dismissible" expired_time="<?php echo esc_attr( $notice_id )?>" dismissible="global"> |
| 32 |
|
| 33 |
|
| 34 |
<div class="notice-right-container "> |
| 35 |
<div class="notice-contents"> |
| 36 |
|
| 37 |
<?php |
| 38 |
if(!empty($content)){ |
| 39 |
echo wp_kses_post( $content ); |
| 40 |
} |
| 41 |
?> |
| 42 |
</div> |
| 43 |
|
| 44 |
<?php |
| 45 |
if(!empty($action_buttons) && count($action_buttons) > 0){ |
| 46 |
|
| 47 |
echo '<div class="eshb-notice-action-buttons">'; |
| 48 |
foreach ($action_buttons as $key => $button) { |
| 49 |
$action_url = isset($button['url']) && !empty($button['url']) ? $button['url'] : ''; |
| 50 |
$action_title = isset($button['title']) && !empty($button['title']) ? $button['title'] : ''; |
| 51 |
if(!empty($action_url)){ |
| 52 |
echo '<a href="'. esc_url($action_url) .'" class="eshb-notice-button button-small">'. esc_html($action_title) .'</a>'; |
| 53 |
} |
| 54 |
|
| 55 |
} |
| 56 |
echo '</div>'; |
| 57 |
|
| 58 |
} |
| 59 |
?> |
| 60 |
|
| 61 |
</div> |
| 62 |
<div style="clear:both"></div> |
| 63 |
|
| 64 |
</div> |
| 65 |
<?php |
| 66 |
} |
| 67 |
|
| 68 |
} |
| 69 |
|
| 70 |
} |
| 71 |
|
| 72 |
// Instantiate the class to ensure the menu is registered |
| 73 |
if ( class_exists( 'ESHB_NOTICE' ) ) { |
| 74 |
$ESHB_NOTICE = new ESHB_NOTICE(); |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|