SBR_Customize_Tab.php
3 weeks ago
SBR_Review_Alert_Tab.php
3 weeks ago
SBR_Settings_Tab.php
3 weeks ago
SBR_Review_Alert_Tab.php
417 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Review Alert Customizer Tab |
| 5 | * |
| 6 | * Defines the customizer sidebar controls for review alert editing. |
| 7 | * This tab only displays when editing a review alert, not when editing feeds. |
| 8 | * |
| 9 | * @since 2.5.0 |
| 10 | * @package SmashBalloon\Reviews |
| 11 | */ |
| 12 | |
| 13 | namespace SmashBalloon\Reviews\Common\Customizer\Tabs; |
| 14 | |
| 15 | use Smashballoon\Customizer\V2\SB_Sidebar_Tab; |
| 16 | use SmashBalloon\Reviews\Common\Util; |
| 17 | |
| 18 | if (!defined('ABSPATH')) { |
| 19 | exit; |
| 20 | } |
| 21 | |
| 22 | class SBR_Review_Alert_Tab extends SB_Sidebar_Tab |
| 23 | { |
| 24 | /** |
| 25 | * Determine if this tab should be displayed |
| 26 | * |
| 27 | * Only show in the review alert editor context, not in the feed editor. |
| 28 | * |
| 29 | * @since 2.5.0 |
| 30 | * |
| 31 | * @return bool |
| 32 | */ |
| 33 | public function should_display() |
| 34 | { |
| 35 | // Only display when editing a popup (popup_id parameter present) |
| 36 | // Never display on feed editor pages (feed_id parameter present) |
| 37 | if (isset($_GET['feed_id'])) { |
| 38 | return false; |
| 39 | } |
| 40 | |
| 41 | return isset($_GET['popup_id']); |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Get the Sidebar Tab info |
| 46 | * |
| 47 | * @since 2.5.0 |
| 48 | * |
| 49 | * @return array |
| 50 | */ |
| 51 | protected function tab_info() |
| 52 | { |
| 53 | return [ |
| 54 | 'id' => 'sb-review-alert-tab', |
| 55 | 'name' => __('Review Alert', 'reviews-feed') |
| 56 | ]; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Get the Sidebar Tab Sections |
| 61 | * |
| 62 | * Structured to match Figma design: |
| 63 | * - Theme (click to see theme options) |
| 64 | * - Accent Color (click to see color picker) |
| 65 | * - Positioning (click to see position options) |
| 66 | * - Review Alert (click to see popup settings with nested sections) |
| 67 | * - Review Feed (click to see expanded popup settings) |
| 68 | * |
| 69 | * @since 2.5.0 |
| 70 | * |
| 71 | * @return array |
| 72 | */ |
| 73 | protected function tab_sections() |
| 74 | { |
| 75 | return [ |
| 76 | 'theme_section' => [ |
| 77 | 'heading' => __('Theme', 'reviews-feed'), |
| 78 | 'icon' => 'theme', |
| 79 | 'controls' => self::get_theme_controls(), |
| 80 | ], |
| 81 | 'accent_color_section' => [ |
| 82 | 'heading' => __('Accent Color', 'reviews-feed'), |
| 83 | 'icon' => 'color', |
| 84 | 'controls' => self::get_accent_color_controls(), |
| 85 | ], |
| 86 | 'positioning_section' => [ |
| 87 | 'heading' => __('Positioning', 'reviews-feed'), |
| 88 | 'icon' => 'position', |
| 89 | 'controls' => self::get_positioning_controls(), |
| 90 | ], |
| 91 | 'review_alert_section' => [ |
| 92 | 'heading' => __('Review Alert', 'reviews-feed'), |
| 93 | 'icon' => 'notification', |
| 94 | 'controls' => self::get_review_alert_controls(), |
| 95 | ], |
| 96 | 'review_feed_section' => [ |
| 97 | 'heading' => __('Review Feed', 'reviews-feed'), |
| 98 | 'icon' => 'reviews', |
| 99 | 'controls' => self::get_review_feed_controls(), |
| 100 | ], |
| 101 | ]; |
| 102 | } |
| 103 | |
| 104 | /** |
| 105 | * Get Theme Controls |
| 106 | * |
| 107 | * Toggle set options matching Figma design: |
| 108 | * Light, Dark, Minimal, Minimal Dark |
| 109 | * |
| 110 | * @since 2.5.0 |
| 111 | * |
| 112 | * @return array |
| 113 | */ |
| 114 | public static function get_theme_controls() |
| 115 | { |
| 116 | return [ |
| 117 | [ |
| 118 | 'type' => 'toggleset', |
| 119 | 'id' => 'theme', |
| 120 | 'options' => [ |
| 121 | [ |
| 122 | 'value' => 'light', |
| 123 | 'label' => __('Light', 'reviews-feed') |
| 124 | ], |
| 125 | [ |
| 126 | 'value' => 'dark', |
| 127 | 'label' => __('Dark', 'reviews-feed'), |
| 128 | 'upsellModal' => 'reviewAlertDarkTheme' |
| 129 | ], |
| 130 | [ |
| 131 | 'value' => 'minimal', |
| 132 | 'label' => __('Minimal', 'reviews-feed'), |
| 133 | 'upsellModal' => 'reviewAlertMinimalTheme' |
| 134 | ], |
| 135 | [ |
| 136 | 'value' => 'minimal-dark', |
| 137 | 'label' => __('Minimal Dark', 'reviews-feed'), |
| 138 | 'upsellModal' => 'reviewAlertMinimalDarkTheme' |
| 139 | ] |
| 140 | ] |
| 141 | ], |
| 142 | ]; |
| 143 | } |
| 144 | |
| 145 | /** |
| 146 | * Get Accent Color Controls |
| 147 | * |
| 148 | * Color picker matching Figma design |
| 149 | * |
| 150 | * @since 2.5.0 |
| 151 | * |
| 152 | * @return array |
| 153 | */ |
| 154 | public static function get_accent_color_controls() |
| 155 | { |
| 156 | return [ |
| 157 | [ |
| 158 | 'type' => 'colorpicker', |
| 159 | 'id' => 'accent_color', |
| 160 | 'heading' => __('Choose Color', 'reviews-feed'), |
| 161 | 'layout' => 'full', |
| 162 | 'default' => '#1E88E5', |
| 163 | 'upsellModal' => 'reviewAlertCustomColor' |
| 164 | ], |
| 165 | ]; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Get Positioning Controls |
| 170 | * |
| 171 | * Left/Right toggle options matching Figma design |
| 172 | * |
| 173 | * @since 2.5.0 |
| 174 | * |
| 175 | * @return array |
| 176 | */ |
| 177 | public static function get_positioning_controls() |
| 178 | { |
| 179 | return [ |
| 180 | [ |
| 181 | 'type' => 'toggleset', |
| 182 | 'id' => 'position', |
| 183 | 'options' => [ |
| 184 | [ |
| 185 | 'value' => 'bottom-left', |
| 186 | 'icon' => 'leftalign', |
| 187 | 'label' => __('Left', 'reviews-feed') |
| 188 | ], |
| 189 | [ |
| 190 | 'value' => 'bottom-right', |
| 191 | 'icon' => 'rightalign', |
| 192 | 'label' => __('Right', 'reviews-feed') |
| 193 | ] |
| 194 | ] |
| 195 | ], |
| 196 | ]; |
| 197 | } |
| 198 | |
| 199 | /** |
| 200 | * Get Review Alert Controls |
| 201 | * |
| 202 | * Controls for Review Alert settings (closed state) |
| 203 | * matching Figma design |
| 204 | * |
| 205 | * @since 2.5.0 |
| 206 | * |
| 207 | * @return array |
| 208 | */ |
| 209 | public static function get_review_alert_controls() |
| 210 | { |
| 211 | return [ |
| 212 | // Popup Type |
| 213 | [ |
| 214 | 'type' => 'toggleset', |
| 215 | 'id' => 'popup_type', |
| 216 | 'heading' => __('Popup Type', 'reviews-feed'), |
| 217 | 'options' => [ |
| 218 | [ |
| 219 | 'value' => 'aggregate', |
| 220 | 'label' => __('Aggregate Review', 'reviews-feed'), |
| 221 | ], |
| 222 | [ |
| 223 | 'value' => 'recent', |
| 224 | 'label' => __('Recent Reviews', 'reviews-feed'), |
| 225 | ] |
| 226 | ] |
| 227 | ], |
| 228 | // Timing |
| 229 | [ |
| 230 | 'type' => 'slider', |
| 231 | 'id' => 'show_after', |
| 232 | 'heading' => __('Timing', 'reviews-feed'), |
| 233 | 'label' => __('Show after', 'reviews-feed'), |
| 234 | 'unit' => 's', |
| 235 | 'inputNumber' => true, |
| 236 | ], |
| 237 | // Separator |
| 238 | [ |
| 239 | 'type' => 'separator', |
| 240 | 'top' => 15, |
| 241 | 'bottom' => 15, |
| 242 | ], |
| 243 | // Show/Hide Elements Group |
| 244 | [ |
| 245 | 'type' => 'group', |
| 246 | 'id' => 'show_hide_elements', |
| 247 | 'heading' => __('Show/Hide Elements', 'reviews-feed'), |
| 248 | 'controls' => [ |
| 249 | [ |
| 250 | 'type' => 'switcher', |
| 251 | 'id' => 'show_rating_number', |
| 252 | 'layout' => 'half', |
| 253 | 'label' => __('Rating Number', 'reviews-feed'), |
| 254 | 'options' => [ |
| 255 | 'enabled' => true, |
| 256 | 'disabled' => false |
| 257 | ] |
| 258 | ], |
| 259 | [ |
| 260 | 'type' => 'switcher', |
| 261 | 'id' => 'show_rating_stars', |
| 262 | 'layout' => 'half', |
| 263 | 'label' => __('Rating Stars', 'reviews-feed'), |
| 264 | 'options' => [ |
| 265 | 'enabled' => true, |
| 266 | 'disabled' => false |
| 267 | ] |
| 268 | ], |
| 269 | [ |
| 270 | 'type' => 'switcher', |
| 271 | 'id' => 'show_review_count', |
| 272 | 'layout' => 'half', |
| 273 | 'label' => __('Review Count', 'reviews-feed'), |
| 274 | 'options' => [ |
| 275 | 'enabled' => true, |
| 276 | 'disabled' => false |
| 277 | ] |
| 278 | ], |
| 279 | [ |
| 280 | 'type' => 'switcher', |
| 281 | 'id' => 'show_powered_by', |
| 282 | 'layout' => 'half', |
| 283 | 'label' => __('Powered By', 'reviews-feed'), |
| 284 | 'upsellModal' => 'reviewAlertBranding', |
| 285 | 'options' => [ |
| 286 | 'enabled' => true, |
| 287 | 'disabled' => false |
| 288 | ] |
| 289 | ], |
| 290 | ] |
| 291 | ], |
| 292 | ]; |
| 293 | } |
| 294 | |
| 295 | /** |
| 296 | * Get Review Feed Controls |
| 297 | * |
| 298 | * Controls for Review Feed (expanded popup) settings |
| 299 | * matching Figma design |
| 300 | * |
| 301 | * @since 2.5.0 |
| 302 | * |
| 303 | * @return array |
| 304 | */ |
| 305 | public static function get_review_feed_controls() |
| 306 | { |
| 307 | return [ |
| 308 | // Header Group |
| 309 | [ |
| 310 | 'type' => 'group', |
| 311 | 'id' => 'header_group', |
| 312 | 'heading' => __('Header', 'reviews-feed'), |
| 313 | 'controls' => [ |
| 314 | [ |
| 315 | 'type' => 'switcher', |
| 316 | 'id' => 'show_heading', |
| 317 | 'layout' => 'half', |
| 318 | 'label' => __('Heading', 'reviews-feed'), |
| 319 | 'options' => [ |
| 320 | 'enabled' => true, |
| 321 | 'disabled' => false |
| 322 | ] |
| 323 | ], |
| 324 | [ |
| 325 | 'type' => 'switcher', |
| 326 | 'id' => 'show_button', |
| 327 | 'layout' => 'half', |
| 328 | 'label' => __('Button', 'reviews-feed'), |
| 329 | 'options' => [ |
| 330 | 'enabled' => true, |
| 331 | 'disabled' => false |
| 332 | ] |
| 333 | ], |
| 334 | ] |
| 335 | ], |
| 336 | // Review Cards Group |
| 337 | [ |
| 338 | 'type' => 'group', |
| 339 | 'id' => 'review_cards_group', |
| 340 | 'heading' => __('Review Cards', 'reviews-feed'), |
| 341 | 'controls' => [ |
| 342 | [ |
| 343 | 'type' => 'switcher', |
| 344 | 'id' => 'show_stars', |
| 345 | 'layout' => 'half', |
| 346 | 'label' => __('Stars', 'reviews-feed'), |
| 347 | 'options' => [ |
| 348 | 'enabled' => true, |
| 349 | 'disabled' => false |
| 350 | ] |
| 351 | ], |
| 352 | [ |
| 353 | 'type' => 'switcher', |
| 354 | 'id' => 'show_title', |
| 355 | 'layout' => 'half', |
| 356 | 'label' => __('Title', 'reviews-feed'), |
| 357 | 'options' => [ |
| 358 | 'enabled' => true, |
| 359 | 'disabled' => false |
| 360 | ] |
| 361 | ], |
| 362 | [ |
| 363 | 'type' => 'switcher', |
| 364 | 'id' => 'show_text', |
| 365 | 'layout' => 'half', |
| 366 | 'label' => __('Content', 'reviews-feed'), |
| 367 | 'options' => [ |
| 368 | 'enabled' => true, |
| 369 | 'disabled' => false |
| 370 | ] |
| 371 | ], |
| 372 | [ |
| 373 | 'type' => 'switcher', |
| 374 | 'id' => 'show_author', |
| 375 | 'layout' => 'half', |
| 376 | 'label' => __('Author', 'reviews-feed'), |
| 377 | 'options' => [ |
| 378 | 'enabled' => true, |
| 379 | 'disabled' => false |
| 380 | ] |
| 381 | ], |
| 382 | [ |
| 383 | 'type' => 'switcher', |
| 384 | 'id' => 'show_date', |
| 385 | 'layout' => 'half', |
| 386 | 'label' => __('Date', 'reviews-feed'), |
| 387 | 'options' => [ |
| 388 | 'enabled' => true, |
| 389 | 'disabled' => false |
| 390 | ] |
| 391 | ], |
| 392 | ] |
| 393 | ], |
| 394 | // Branding Group |
| 395 | [ |
| 396 | 'type' => 'group', |
| 397 | 'id' => 'branding_group', |
| 398 | 'heading' => __('Branding', 'reviews-feed'), |
| 399 | 'controls' => [ |
| 400 | [ |
| 401 | 'type' => 'switcher', |
| 402 | 'id' => 'show_powered_by', |
| 403 | 'layout' => 'half', |
| 404 | 'label' => __('Powered By Badge', 'reviews-feed'), |
| 405 | 'upsellModal' => 'reviewAlertBranding', |
| 406 | 'options' => [ |
| 407 | 'enabled' => true, |
| 408 | 'disabled' => false |
| 409 | ] |
| 410 | ], |
| 411 | ] |
| 412 | ], |
| 413 | ]; |
| 414 | } |
| 415 | |
| 416 | } |
| 417 |