| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Promo_Boot |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Ui_Topmenu $topmenu, |
| 7 |
HC3_Hooks $hooks, |
| 8 |
HC3_Auth $auth, |
| 9 |
HC3_IPermission $permission |
| 10 |
) |
| 11 |
{ |
| 12 |
if( defined('SH4_PRO_VERSION') && (! defined('SH4_FORCE_PROMO')) ){ |
| 13 |
return; |
| 14 |
} |
| 15 |
|
| 16 |
// promo |
| 17 |
$label = 'ShiftController Pro'; |
| 18 |
$href = 'https://www.shiftcontroller.com/order/'; |
| 19 |
|
| 20 |
// $hooks |
| 21 |
// ->add( 'sh4/app/html/view/admin::menu::after', function( $return ) use ($label, $href) { |
| 22 |
// $label = '<div class="hc-border hc-border-olive hc-rounded hc-p2">' . $label . '</div>'; |
| 23 |
// $return['promo'] = array( $href, $label ); |
| 24 |
// return $return; |
| 25 |
// }) |
| 26 |
// ; |
| 27 |
|
| 28 |
$currentUser = $auth->getCurrentUser(); |
| 29 |
$isAdmin = $permission->isAdmin($currentUser); |
| 30 |
|
| 31 |
if( $isAdmin ){ |
| 32 |
$topmenu |
| 33 |
->addAfter( 'profile', 'promo', array( $href, $label) ) |
| 34 |
; |
| 35 |
} |
| 36 |
|
| 37 |
$hooks |
| 38 |
->add( 'hc3/layout::render::before', function( $args ) use($label, $href, $isAdmin) { |
| 39 |
if( ! ($isAdmin && is_admin()) ){ |
| 40 |
return $args; |
| 41 |
} |
| 42 |
|
| 43 |
$content = $args[0]; |
| 44 |
|
| 45 |
$promo = array(); |
| 46 |
if( is_admin() ){ |
| 47 |
// $promo[] = '<div class="update-nag hc-block hc-fs4 hc-my3">'; |
| 48 |
$promo[] = '<div class="notice notice-success inline hc-block hc-fs4 hc-my3 hc-p3">'; |
| 49 |
} |
| 50 |
else { |
| 51 |
$promo[] = '<div class="hc-border hc-border-olive hc-rounded hc-p3 hc-block hc-fs4">'; |
| 52 |
} |
| 53 |
$promo[] = '<span class="dashicons dashicons-star-filled hc-olive"></span> <a target="_blank" href="' . $href . '"><strong>' . $label . '</strong></a> with nice features like recurring shifts, bulk actions, shifts pickup and more!'; |
| 54 |
$promo[] = '</div>'; |
| 55 |
$promo = join('', $promo); |
| 56 |
|
| 57 |
$content = $promo . $content; |
| 58 |
$args[0] = $content; |
| 59 |
return $args; |
| 60 |
}) |
| 61 |
; |
| 62 |
} |
| 63 |
} |