| 1 |
<?php |
| 2 |
|
| 3 |
namespace NotificationX\Admin; |
| 4 |
|
| 5 |
use NotificationX\GetInstance; |
| 6 |
|
| 7 |
class InfoTooltipManager { |
| 8 |
|
| 9 |
use GetInstance; |
| 10 |
|
| 11 |
private static $tooltips = [ |
| 12 |
'advanced_template' => [ |
| 13 |
'type' => 'image', |
| 14 |
'title' => 'Learn how <a href="https://notificationx.com/docs/notificationx-advanced-template/" target="_blank">Advanced Template</a> works', |
| 15 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/advanceTemplate.gif', |
| 16 |
'width' => '450', |
| 17 |
'height' => '235', |
| 18 |
], |
| 19 |
'animation' => [ |
| 20 |
'type' => 'image', |
| 21 |
'title' => 'Learn how <a href="https://notificationx.com/docs/notificationx-advanced-template/" target="_blank">Animation</a> works', |
| 22 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/notificationAnimation.gif', |
| 23 |
'width' => '450', |
| 24 |
'height' => '235', |
| 25 |
], |
| 26 |
'button' => [ |
| 27 |
'type' => 'image', |
| 28 |
'title' => 'Learn how <a href="https://notificationx.com/docs/configure-notification-button/" target="_blank">Button</a> works', |
| 29 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/notificationButton.gif', |
| 30 |
'width' => '450', |
| 31 |
'height' => '235', |
| 32 |
], |
| 33 |
'custom_css' => [ |
| 34 |
'type' => 'image', |
| 35 |
'title' => 'Learn how <a href="https://notificationx.com/docs/custom-css-in-notificationx/" target="_blank">Custom CSS</a> works', |
| 36 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/customCSS.gif', |
| 37 |
'width' => '450', |
| 38 |
'height' => '235', |
| 39 |
], |
| 40 |
'exclude_by' => [ |
| 41 |
'type' => 'image', |
| 42 |
'title' => 'Learn how <a href="https://notificationx.com/docs/how-exclude-by-works-in-notificationx/" target="_blank">Exclude By</a> works', |
| 43 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/excludeBy.gif', |
| 44 |
'width' => '450', |
| 45 |
'height' => '235', |
| 46 |
], |
| 47 |
'global_queue_management' => [ |
| 48 |
'type' => 'image', |
| 49 |
'title' => 'Learn how <a href="https://notificationx.com/docs/centralized-queue/" target="_blank">Global Queue Management</a> works', |
| 50 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/globalQueueManagement.gif', |
| 51 |
'width' => '450', |
| 52 |
'height' => '235', |
| 53 |
], |
| 54 |
'order_status' => [ |
| 55 |
'type' => 'image', |
| 56 |
'title' => 'Learn how <a href="https://notificationx.com/docs/how-order-status-works/" target="_blank">Order Status</a> works', |
| 57 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/orderStatus.gif', |
| 58 |
'width' => '450', |
| 59 |
'height' => '235', |
| 60 |
], |
| 61 |
'random_order' => [ |
| 62 |
'type' => 'image', |
| 63 |
'title' => 'Learn how <a href="https://notificationx.com/docs/random-order-notificationx/" target="_blank">Random Order</a> functions', |
| 64 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/randomOrder.gif', |
| 65 |
'width' => '450', |
| 66 |
'height' => '235', |
| 67 |
], |
| 68 |
'reporting_frequency' => [ |
| 69 |
'type' => 'image', |
| 70 |
'title' => 'Learn how <a href="https://notificationx.com/docs/how-reporting-frequency-works/" target="_blank">Reporting Frequency</a> works', |
| 71 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/reportingFrequency.gif', |
| 72 |
'width' => '450', |
| 73 |
'height' => '235', |
| 74 |
], |
| 75 |
'show_purchase_of' => [ |
| 76 |
'type' => 'image', |
| 77 |
'title' => 'Learn how <a href="https://notificationx.com/docs/how-show-purchase-of-works/" target="_blank">Show Purchase Of</a> works', |
| 78 |
'content' => 'https://notificationx.com/wp-content/uploads/2025/09/showPurchaseOf.gif', |
| 79 |
'width' => '450', |
| 80 |
'height' => '235', |
| 81 |
], |
| 82 |
'schedule_type' => [ |
| 83 |
'type' => 'content', |
| 84 |
'title' => 'Learn how <a href="https://notificationx.com/docs/notificationx-advanced-template/" target="_blank">Schedule Type</a> works', |
| 85 |
'content' => '', |
| 86 |
'width' => '450', |
| 87 |
'height' => '235', |
| 88 |
], |
| 89 |
'targeting' => [ |
| 90 |
'type' => 'content', |
| 91 |
'title' => 'Learn how <a href="https://notificationx.com/docs/how-audience-targeting-works/" target="_blank">Targeting</a> works', |
| 92 |
'content' => '', |
| 93 |
'width' => '450', |
| 94 |
'height' => '235', |
| 95 |
], |
| 96 |
'popup_notification_message_field' => [ |
| 97 |
'type' => 'content', |
| 98 |
'title' => 'Enable this field to let users send messages or feedback.','notificationx', |
| 99 |
'content' => '', |
| 100 |
'width' => '450', |
| 101 |
'height' => '235', |
| 102 |
], |
| 103 |
'popup_notification_email_field' => [ |
| 104 |
'type' => 'content', |
| 105 |
'title' => 'Enable this field to collect user\'s email addresses.','notificationx', |
| 106 |
'content' => '', |
| 107 |
'width' => '450', |
| 108 |
'height' => '235', |
| 109 |
], |
| 110 |
]; |
| 111 |
|
| 112 |
|
| 113 |
/** |
| 114 |
* Get full tooltip HTML for a given feature |
| 115 |
* |
| 116 |
* @param string $id Pro feature ID |
| 117 |
* @return string Full HTML or empty string if not found |
| 118 |
*/ |
| 119 |
public static function render($id) { |
| 120 |
if (!isset(self::$tooltips[$id])) { |
| 121 |
return ''; |
| 122 |
} |
| 123 |
$tooltip = self::$tooltips[$id]; |
| 124 |
$html = '<div class="nx-pro-feature-tooltip" style="padding:10px; border:1px solid #ccc; max-width:450px; background:#fff;">'; |
| 125 |
|
| 126 |
if ($tooltip['type'] === 'video') { |
| 127 |
$html .= sprintf( |
| 128 |
'<video width="%d" height="%d" autoplay loop muted playsinline> |
| 129 |
<source src="%s" type="video/mp4"> |
| 130 |
</video>', |
| 131 |
$tooltip['width'], |
| 132 |
$tooltip['height'], |
| 133 |
esc_url($tooltip['content']) |
| 134 |
); |
| 135 |
} elseif ($tooltip['type'] === 'image') { |
| 136 |
$html .= sprintf( |
| 137 |
'<img src="%s" alt="%s" style="max-width:100%%;">', |
| 138 |
esc_url($tooltip['content']), |
| 139 |
esc_attr($tooltip['title']) |
| 140 |
); |
| 141 |
} else { |
| 142 |
if( !empty($tooltip['content']) ) { |
| 143 |
$html .= sprintf('<p style="margin-bottom:5px;">%s</p>', wp_kses_post($tooltip['content'])); |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
if (!empty($tooltip['title'])) { |
| 148 |
$html .= '<h3 style="margin-bottom:5px;">' . wp_kses_post($tooltip['title']); |
| 149 |
$html .= '</h3>'; |
| 150 |
} |
| 151 |
|
| 152 |
$html .= '</div>'; |
| 153 |
return $html; |
| 154 |
} |
| 155 |
} |
| 156 |
|