| 1 |
<?php |
| 2 |
/** |
| 3 |
* Inactive Tab Message — Admin Options. |
| 4 |
* |
| 5 |
* @package Merchant |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Messages Section. |
| 14 |
*/ |
| 15 |
Merchant_Admin_Options::create( array( |
| 16 |
'title' => esc_html__( 'Messages', 'merchant' ), |
| 17 |
'module' => 'inactive-tab-message', |
| 18 |
'fields' => array( |
| 19 |
|
| 20 |
array( |
| 21 |
'id' => 'info_dynamic_variables', |
| 22 |
'type' => 'info', |
| 23 |
'content' => '<strong>' . esc_html__( 'Dynamic Variables:', 'merchant' ) . '</strong><br>' |
| 24 |
. '<code>{cart_count}</code> — ' . esc_html__( 'Number of items in cart', 'merchant' ) . '<br>' |
| 25 |
. '<code>{cart_total}</code> — ' . esc_html__( 'Formatted cart total with currency', 'merchant' ) . '<br>' |
| 26 |
. '<code>{site_name}</code> — ' . esc_html__( 'Your site name', 'merchant' ), |
| 27 |
), |
| 28 |
|
| 29 |
array( |
| 30 |
'id' => 'message', |
| 31 |
'type' => 'text', |
| 32 |
'title' => esc_html__( 'Empty cart message', 'merchant' ), |
| 33 |
'desc' => esc_html__( 'Shown when the cart is empty and user switches to another tab.', 'merchant' ), |
| 34 |
'default' => esc_html__( '✋ Don\'t forget this', 'merchant' ), |
| 35 |
), |
| 36 |
|
| 37 |
array( |
| 38 |
'id' => 'abandoned_message', |
| 39 |
'type' => 'text', |
| 40 |
'title' => esc_html__( 'Cart items message', 'merchant' ), |
| 41 |
'desc' => esc_html__( 'Shown when the user has items in the cart and switches tab.', 'merchant' ), |
| 42 |
'default' => esc_html__( '✋ You left something in the cart', 'merchant' ), |
| 43 |
), |
| 44 |
|
| 45 |
array( |
| 46 |
'id' => 'high_value_message', |
| 47 |
'type' => 'text', |
| 48 |
'title' => esc_html__( 'High-value cart message', 'merchant' ), |
| 49 |
'desc' => esc_html__( 'Shown when the cart total exceeds the threshold below. Leave empty to disable.', 'merchant' ), |
| 50 |
'default' => '', |
| 51 |
), |
| 52 |
|
| 53 |
array( |
| 54 |
'id' => 'high_value_threshold', |
| 55 |
'type' => 'number', |
| 56 |
'title' => esc_html__( 'High-value threshold', 'merchant' ), |
| 57 |
'desc' => esc_html__( 'Cart total amount that triggers the high-value message.', 'merchant' ), |
| 58 |
'default' => 100, |
| 59 |
'conditions' => array( |
| 60 |
'relation' => 'AND', |
| 61 |
'terms' => array( |
| 62 |
array( |
| 63 |
'field' => 'high_value_message', |
| 64 |
'operator' => '!==', |
| 65 |
'value' => '', |
| 66 |
), |
| 67 |
), |
| 68 |
), |
| 69 |
), |
| 70 |
|
| 71 |
array( |
| 72 |
'id' => 'return_message', |
| 73 |
'type' => 'text', |
| 74 |
'title' => esc_html__( 'Return-to-tab message', 'merchant' ), |
| 75 |
'desc' => esc_html__( 'Brief message shown when the user returns to the tab. Leave empty to disable.', 'merchant' ), |
| 76 |
'default' => '', |
| 77 |
), |
| 78 |
|
| 79 |
array( |
| 80 |
'id' => 'return_duration', |
| 81 |
'type' => 'range', |
| 82 |
'title' => esc_html__( 'Return message duration (seconds)', 'merchant' ), |
| 83 |
'min' => 1, |
| 84 |
'max' => 10, |
| 85 |
'step' => 1, |
| 86 |
'unit' => 's', |
| 87 |
'default' => 2, |
| 88 |
'conditions' => array( |
| 89 |
'relation' => 'AND', |
| 90 |
'terms' => array( |
| 91 |
array( |
| 92 |
'field' => 'return_message', |
| 93 |
'operator' => '!==', |
| 94 |
'value' => '', |
| 95 |
), |
| 96 |
), |
| 97 |
), |
| 98 |
), |
| 99 |
|
| 100 |
), |
| 101 |
) ); |
| 102 |
|
| 103 |
/** |
| 104 |
* Favicon Section. |
| 105 |
*/ |
| 106 |
Merchant_Admin_Options::create( array( |
| 107 |
'title' => esc_html__( 'Favicon', 'merchant' ), |
| 108 |
'module' => 'inactive-tab-message', |
| 109 |
'fields' => array( |
| 110 |
|
| 111 |
array( |
| 112 |
'id' => 'enable_favicon', |
| 113 |
'type' => 'switcher', |
| 114 |
'title' => esc_html__( 'Change favicon on tab leave', 'merchant' ), |
| 115 |
'desc' => esc_html__( 'Replace the browser favicon when the tab is inactive. Restored on return.', 'merchant' ), |
| 116 |
'default' => 0, |
| 117 |
), |
| 118 |
|
| 119 |
array( |
| 120 |
'id' => 'favicon_type', |
| 121 |
'type' => 'radio', |
| 122 |
'title' => esc_html__( 'Favicon type', 'merchant' ), |
| 123 |
'options' => array( |
| 124 |
'emoji' => esc_html__( 'Emoji', 'merchant' ), |
| 125 |
'image' => esc_html__( 'Custom image', 'merchant' ), |
| 126 |
), |
| 127 |
'default' => 'emoji', |
| 128 |
'condition' => array( 'enable_favicon', '==', '1' ), |
| 129 |
), |
| 130 |
|
| 131 |
array( |
| 132 |
'id' => 'favicon_emoji', |
| 133 |
'type' => 'select', |
| 134 |
'title' => esc_html__( 'Favicon emoji', 'merchant' ), |
| 135 |
'options' => array( |
| 136 |
'wave' => '👋 ' . esc_html__( 'Wave', 'merchant' ), |
| 137 |
'bell' => '🔔 ' . esc_html__( 'Bell', 'merchant' ), |
| 138 |
'cart' => '🛒 ' . esc_html__( 'Cart', 'merchant' ), |
| 139 |
'clock' => '⏰ ' . esc_html__( 'Clock', 'merchant' ), |
| 140 |
'alert' => '❗ ' . esc_html__( 'Alert', 'merchant' ), |
| 141 |
'money' => '💰 ' . esc_html__( 'Money', 'merchant' ), |
| 142 |
'fire' => '🔥 ' . esc_html__( 'Fire', 'merchant' ), |
| 143 |
'star' => '⭐ ' . esc_html__( 'Star', 'merchant' ), |
| 144 |
), |
| 145 |
'default' => 'wave', |
| 146 |
'conditions' => array( |
| 147 |
'relation' => 'AND', |
| 148 |
'terms' => array( |
| 149 |
array( |
| 150 |
'field' => 'enable_favicon', |
| 151 |
'operator' => '===', |
| 152 |
'value' => true, |
| 153 |
), |
| 154 |
array( |
| 155 |
'field' => 'favicon_type', |
| 156 |
'operator' => '===', |
| 157 |
'value' => 'emoji', |
| 158 |
), |
| 159 |
), |
| 160 |
), |
| 161 |
), |
| 162 |
|
| 163 |
array( |
| 164 |
'id' => 'favicon_url', |
| 165 |
'type' => 'upload', |
| 166 |
'title' => esc_html__( 'Custom favicon image', 'merchant' ), |
| 167 |
'desc' => esc_html__( 'Upload a square image (recommended 32×32 or 64×64 pixels).', 'merchant' ), |
| 168 |
'default' => '', |
| 169 |
'conditions' => array( |
| 170 |
'relation' => 'AND', |
| 171 |
'terms' => array( |
| 172 |
array( |
| 173 |
'field' => 'enable_favicon', |
| 174 |
'operator' => '===', |
| 175 |
'value' => true, |
| 176 |
), |
| 177 |
array( |
| 178 |
'field' => 'favicon_type', |
| 179 |
'operator' => '===', |
| 180 |
'value' => 'image', |
| 181 |
), |
| 182 |
), |
| 183 |
), |
| 184 |
), |
| 185 |
|
| 186 |
), |
| 187 |
) ); |
| 188 |
|
| 189 |
/** |
| 190 |
* Message Rotation Section. |
| 191 |
*/ |
| 192 |
Merchant_Admin_Options::create( array( |
| 193 |
'title' => esc_html__( 'Message Rotation', 'merchant' ), |
| 194 |
'module' => 'inactive-tab-message', |
| 195 |
'fields' => array( |
| 196 |
|
| 197 |
array( |
| 198 |
'id' => 'enable_rotation', |
| 199 |
'type' => 'switcher', |
| 200 |
'title' => esc_html__( 'Enable rotating messages', 'merchant' ), |
| 201 |
'desc' => esc_html__( 'When enabled, the tab title cycles through the messages below instead of showing the single messages above.', 'merchant' ), |
| 202 |
'default' => 0, |
| 203 |
), |
| 204 |
|
| 205 |
array( |
| 206 |
'id' => 'rotation_messages', |
| 207 |
'type' => 'sortable_repeater', |
| 208 |
'title' => esc_html__( 'Rotation messages', 'merchant' ), |
| 209 |
'desc' => esc_html__( 'Add messages to cycle through. Dynamic variables ({cart_count}, {cart_total}, {site_name}) are supported.', 'merchant' ), |
| 210 |
'button_label' => esc_html__( 'Add Message', 'merchant' ), |
| 211 |
'default' => array(), |
| 212 |
'condition' => array( 'enable_rotation', '==', '1' ), |
| 213 |
), |
| 214 |
|
| 215 |
array( |
| 216 |
'id' => 'rotation_interval', |
| 217 |
'type' => 'range', |
| 218 |
'title' => esc_html__( 'Rotation interval (seconds)', 'merchant' ), |
| 219 |
'min' => 1, |
| 220 |
'max' => 10, |
| 221 |
'step' => 1, |
| 222 |
'unit' => 's', |
| 223 |
'default' => 3, |
| 224 |
'condition' => array( 'enable_rotation', '==', '1' ), |
| 225 |
), |
| 226 |
|
| 227 |
), |
| 228 |
) ); |
| 229 |
|
| 230 |
/** |
| 231 |
* Scrolling Text Section. |
| 232 |
*/ |
| 233 |
Merchant_Admin_Options::create( array( |
| 234 |
'title' => esc_html__( 'Scrolling Text', 'merchant' ), |
| 235 |
'module' => 'inactive-tab-message', |
| 236 |
'fields' => array( |
| 237 |
|
| 238 |
array( |
| 239 |
'id' => 'enable_scroll', |
| 240 |
'type' => 'switcher', |
| 241 |
'title' => esc_html__( 'Scroll long messages', 'merchant' ), |
| 242 |
'desc' => esc_html__( 'When enabled, the tab title will scroll (marquee) if the message is longer than the tab can display. Direction is automatically detected for RTL languages (Arabic, Farsi, etc.).', 'merchant' ), |
| 243 |
'default' => 0, |
| 244 |
), |
| 245 |
|
| 246 |
), |
| 247 |
) ); |
| 248 |
|