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