SBR_Customize_Tab.php
1 month ago
SBR_Review_Alert_Tab.php
5 months ago
SBR_Settings_Tab.php
7 months ago
SBR_Settings_Tab.php
530 lines
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Class Settings Tab |
| 5 | * |
| 6 | * @since 1.0 |
| 7 | */ |
| 8 | |
| 9 | namespace SmashBalloon\Reviews\Common\Customizer\Tabs; |
| 10 | |
| 11 | use Smashballoon\Customizer\V2\SB_Sidebar_Tab; |
| 12 | use SmashBalloon\Reviews\Common\Util; |
| 13 | |
| 14 | if (!defined('ABSPATH')) { |
| 15 | exit; // Exit if accessed directly |
| 16 | } |
| 17 | |
| 18 | class SBR_Settings_Tab extends SB_Sidebar_Tab { |
| 19 | /** |
| 20 | * Get the Sidebar Tab info |
| 21 | * |
| 22 | * @since 1.0 |
| 23 | * |
| 24 | * @return array |
| 25 | */ |
| 26 | protected function tab_info() |
| 27 | { |
| 28 | return [ |
| 29 | 'id' => 'sb-settings-tab', |
| 30 | 'name' => __('Settings', 'reviews-feed') |
| 31 | ]; |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Get the Sidebar Tab Section |
| 36 | * |
| 37 | * @since 1.0 |
| 38 | * |
| 39 | * @return array |
| 40 | */ |
| 41 | protected function tab_sections() |
| 42 | { |
| 43 | return [ |
| 44 | 'sources_section' => [ |
| 45 | 'heading' => __('Sources', 'reviews-feed'), |
| 46 | 'icon' => 'sourcesadd', |
| 47 | 'controls' => self::get_sources_controls() |
| 48 | ], |
| 49 | 'sort_section' => [ |
| 50 | 'heading' => __('Sort', 'reviews-feed'), |
| 51 | 'icon' => 'sorting', |
| 52 | 'controls' => self::get_sort_controls() |
| 53 | ], |
| 54 | 'filters_section' => [ |
| 55 | 'heading' => __('Filters', 'reviews-feed'), |
| 56 | 'icon' => 'filter', |
| 57 | 'description' => Util::sbr_is_pro() ? '' : |
| 58 | sprintf( |
| 59 | /* translators: %s: Opening and closing anchor HTML tags */ |
| 60 | __('Upgrade to Pro to apply filters to your reviews feed. %sLearn More%s', 'reviews-feed'), |
| 61 | '<a>', |
| 62 | '</a>' |
| 63 | ), |
| 64 | 'upsellModal' => 'filtersModal', |
| 65 | 'controls' => self::get_filters_controls() |
| 66 | ], |
| 67 | 'moderation_section' => [ |
| 68 | 'heading' => __('Moderation', 'reviews-feed'), |
| 69 | 'icon' => 'eye', |
| 70 | 'controls' => Util::sbr_is_pro() ? self::get_moderation_controls() : self::get_moderation_free_controls(), |
| 71 | 'description' => Util::sbr_is_pro() ? '' : |
| 72 | sprintf( |
| 73 | /* translators: %s: Opening and closing anchor HTML tags */ |
| 74 | |
| 75 | __('Upgrade to Pro to moderate your feed. %sLearn More%s', 'reviews-feed'), |
| 76 | '<a>', |
| 77 | '</a>' |
| 78 | ), |
| 79 | 'upsellModal' => 'moderationModal', |
| 80 | 'separator' => true |
| 81 | ], |
| 82 | /* |
| 83 | 'advanced_section' => [ |
| 84 | 'heading' => __('Advanced', 'reviews-feed'), |
| 85 | 'icon' => 'cog', |
| 86 | 'controls' => self::get_advanced_controls() |
| 87 | ], |
| 88 | */ |
| 89 | 'language_section' => [ |
| 90 | 'heading' => __('Language', 'reviews-feed'), |
| 91 | 'description' => __('Change language of what posts are displayed in', 'reviews-feed'), |
| 92 | 'icon' => 'translate', |
| 93 | 'controls' => self::get_language_controls(), |
| 94 | 'separator' => true |
| 95 | ], |
| 96 | ]; |
| 97 | } |
| 98 | |
| 99 | /** |
| 100 | * Get the Sources Section Controls |
| 101 | * |
| 102 | * @since 1.0 |
| 103 | * |
| 104 | * @return array |
| 105 | */ |
| 106 | protected static function get_sources_controls() |
| 107 | { |
| 108 | return [ |
| 109 | [//Feed Sources |
| 110 | 'type' => 'feedsources', |
| 111 | 'ajaxAction' => 'feedFlyPreview', |
| 112 | 'id' => 'sources' |
| 113 | ] |
| 114 | ]; |
| 115 | } |
| 116 | /** |
| 117 | * Get the Sort Section Controls |
| 118 | * |
| 119 | * @since 1.0 |
| 120 | * |
| 121 | * @return array |
| 122 | */ |
| 123 | protected static function get_sort_controls() |
| 124 | { |
| 125 | return [ |
| 126 | [ |
| 127 | 'type' => 'separator', |
| 128 | 'top' => 10, |
| 129 | 'bottom' => 20, |
| 130 | ], |
| 131 | [ |
| 132 | 'type' => 'switcher', |
| 133 | 'id' => 'sortByDateEnabled', |
| 134 | 'labelStrong' => true, |
| 135 | 'layout' => 'third', |
| 136 | 'ajaxAction' => 'feedFlyPreview', |
| 137 | 'condition' => [ |
| 138 | 'sortRandomEnabled' => [false] |
| 139 | ], |
| 140 | 'label' => __('By Date', 'reviews-feed'), |
| 141 | 'stacked' => true, |
| 142 | 'options' => [ |
| 143 | 'enabled' => true, |
| 144 | 'disabled' => false |
| 145 | ] |
| 146 | ], |
| 147 | [ |
| 148 | 'type' => 'select', |
| 149 | 'id' => 'sortByDate', |
| 150 | 'child' => true, |
| 151 | 'ajaxAction' => 'feedFlyPreview', |
| 152 | 'condition' => [ |
| 153 | 'sortByDateEnabled' => [ true ], |
| 154 | 'sortRandomEnabled' => [ false ] |
| 155 | ], |
| 156 | 'stacked' => true, |
| 157 | 'options' => [ |
| 158 | 'latest' => __('Latest Reviews First', 'reviews-feed'), |
| 159 | 'oldest' => __('Oldest Reviews First', 'reviews-feed') |
| 160 | ] |
| 161 | ], |
| 162 | [ |
| 163 | 'type' => 'separator', |
| 164 | 'top' => 20, |
| 165 | 'condition' => [ |
| 166 | 'sortRandomEnabled' => [false] |
| 167 | ], |
| 168 | 'bottom' => 20, |
| 169 | ], |
| 170 | [ |
| 171 | 'type' => 'switcher', |
| 172 | 'id' => 'sortByRatingEnabled', |
| 173 | 'labelStrong' => true, |
| 174 | 'ajaxAction' => 'feedFlyPreview', |
| 175 | 'condition' => [ |
| 176 | 'sortRandomEnabled' => [false] |
| 177 | ], |
| 178 | 'layout' => 'third', |
| 179 | 'label' => __('By Rating', 'reviews-feed'), |
| 180 | 'stacked' => true, |
| 181 | 'options' => [ |
| 182 | 'enabled' => true, |
| 183 | 'disabled' => false |
| 184 | ] |
| 185 | ], |
| 186 | [ |
| 187 | 'type' => 'select', |
| 188 | 'id' => 'sortByRating', |
| 189 | 'ajaxAction' => 'feedFlyPreview', |
| 190 | 'child' => true, |
| 191 | 'condition' => [ |
| 192 | 'sortByRatingEnabled' => [ true ], |
| 193 | 'sortRandomEnabled' => [ false ] |
| 194 | ], |
| 195 | 'stacked' => true, |
| 196 | 'options' => [ |
| 197 | 'highest' => __('Highest Rated First', 'reviews-feed'), |
| 198 | 'lowest' => __('Lowest Rated First', 'reviews-feed') |
| 199 | ] |
| 200 | ], |
| 201 | [ |
| 202 | 'type' => 'separator', |
| 203 | 'top' => 20, |
| 204 | 'condition' => [ |
| 205 | 'sortRandomEnabled' => [false] |
| 206 | ], |
| 207 | 'bottom' => 20, |
| 208 | ], |
| 209 | |
| 210 | [ |
| 211 | 'type' => 'switcher', |
| 212 | 'id' => 'sortRandomEnabled', |
| 213 | 'labelStrong' => true, |
| 214 | 'ajaxAction' => 'feedFlyPreview', |
| 215 | 'layout' => 'third', |
| 216 | 'label' => __('Randomize', 'reviews-feed'), |
| 217 | 'labelDescription' => __('This will disable “By date” and “By rating” and randomly choose among the filtered reviews', 'reviews-feed'), |
| 218 | 'stacked' => true, |
| 219 | 'options' => [ |
| 220 | 'enabled' => true, |
| 221 | 'disabled' => false |
| 222 | ] |
| 223 | ], |
| 224 | ]; |
| 225 | } |
| 226 | /** |
| 227 | * Get the Filters Section Controls |
| 228 | * |
| 229 | * @since 1.0 |
| 230 | * |
| 231 | * @return array |
| 232 | */ |
| 233 | protected static function get_filters_controls() |
| 234 | { |
| 235 | return [ |
| 236 | [ |
| 237 | 'type' => 'checkboxsection', |
| 238 | 'id' => 'filter_reviews_sections', |
| 239 | 'settingId' => 'includedStarFilters', |
| 240 | 'ajaxAction' => 'feedFlyPreview', |
| 241 | 'includeTop' => false, |
| 242 | 'controls' => [ |
| 243 | [ |
| 244 | 'id' => 5, |
| 245 | 'icon' => '5stars', |
| 246 | 'upsellModal' => 'filtersModal', |
| 247 | 'disableProLabel' => true |
| 248 | ], |
| 249 | [ |
| 250 | 'id' => 4, |
| 251 | 'icon' => '4stars', |
| 252 | 'upsellModal' => 'filtersModal', |
| 253 | 'disableProLabel' => true |
| 254 | ], |
| 255 | [ |
| 256 | 'id' => 3, |
| 257 | 'icon' => '3stars', |
| 258 | 'upsellModal' => 'filtersModal', |
| 259 | 'disableProLabel' => true |
| 260 | ], |
| 261 | [ |
| 262 | 'id' => 2, |
| 263 | 'icon' => '2stars', |
| 264 | 'upsellModal' => 'filtersModal', |
| 265 | 'disableProLabel' => true |
| 266 | ], |
| 267 | [ |
| 268 | 'id' => 1, |
| 269 | 'icon' => '1stars', |
| 270 | 'upsellModal' => 'filtersModal', |
| 271 | 'disableProLabel' => true |
| 272 | ] |
| 273 | ] |
| 274 | ], |
| 275 | [//Filter By Words |
| 276 | 'type' => 'group', |
| 277 | 'id' => 'filter_bywords', |
| 278 | 'heading' => __('By Words', 'reviews-feed'), |
| 279 | 'controls' => [ |
| 280 | [ |
| 281 | 'type' => 'textarea', |
| 282 | 'id' => 'includeWords', |
| 283 | 'ajaxAction' => 'feedFlyPreview', |
| 284 | 'upsellModal' => 'filtersModal', |
| 285 | 'rows' => 5, |
| 286 | 'heading' => __('Only show reviews containing', 'reviews-feed'), |
| 287 | 'tooltip' => __('Only show reviews containing', 'reviews-feed'), |
| 288 | 'placeholder' => __('Add words here to only show posts containing these words', 'reviews-feed'), |
| 289 | ], |
| 290 | [ |
| 291 | 'type' => 'textarea', |
| 292 | 'id' => 'excludeWords', |
| 293 | 'ajaxAction' => 'feedFlyPreview', |
| 294 | 'upsellModal' => 'filtersModal', |
| 295 | 'rows' => 5, |
| 296 | 'heading' => __('Do not show reviews containing', 'reviews-feed'), |
| 297 | 'tooltip' => __('Only show reviews containing', 'reviews-feed'), |
| 298 | 'placeholder' => __('Add words here to hide any posts containing these words', 'reviews-feed'), |
| 299 | ], |
| 300 | ] |
| 301 | ], |
| 302 | /* |
| 303 | [//Filter By Content |
| 304 | 'type' => 'group', |
| 305 | 'id' => 'filter_bycontent', |
| 306 | 'heading' => __('By Content', 'reviews-feed'), |
| 307 | 'controls' => [ |
| 308 | [ |
| 309 | 'type' => 'checkbox', |
| 310 | 'id' => 'filterByImage', |
| 311 | 'label' => __('Images', 'reviews-feed'), |
| 312 | 'options' => [ |
| 313 | 'enabled' => true, |
| 314 | 'disabled' => false |
| 315 | ] |
| 316 | ], |
| 317 | [ |
| 318 | 'type' => 'checkbox', |
| 319 | 'id' => 'filterByVideos', |
| 320 | 'label' => __('Videos', 'reviews-feed'), |
| 321 | 'options' => [ |
| 322 | 'enabled' => true, |
| 323 | 'disabled' => false |
| 324 | ] |
| 325 | ], |
| 326 | ] |
| 327 | ], |
| 328 | */ |
| 329 | [//Filter By Length |
| 330 | 'type' => 'group', |
| 331 | 'id' => 'filter_bycharcount', |
| 332 | 'heading' => __('By Character Count', 'reviews-feed'), |
| 333 | 'controls' => [ |
| 334 | [ |
| 335 | 'type' => 'number', |
| 336 | 'id' => 'filterCharCountMin', |
| 337 | 'ajaxAction' => 'feedFlyPreview', |
| 338 | 'min' => 0, |
| 339 | 'layout' => 'third', |
| 340 | 'strongheading' => false, |
| 341 | 'stacked' => true, |
| 342 | 'heading' => __('Minimum', 'reviews-feed'), |
| 343 | 'trailingText' => __('characters', 'reviews-feed'), |
| 344 | ], |
| 345 | [ |
| 346 | 'type' => 'number', |
| 347 | 'id' => 'filterCharCountMax', |
| 348 | 'ajaxAction' => 'feedFlyPreview', |
| 349 | 'min' => 0, |
| 350 | 'layout' => 'third', |
| 351 | 'strongheading' => false, |
| 352 | 'stacked' => true, |
| 353 | 'heading' => __('Maxiumum', 'reviews-feed'), |
| 354 | 'trailingText' => __('characters', 'reviews-feed'), |
| 355 | 'placeholder' => __('Unset', 'reviews-feed'), |
| 356 | ], |
| 357 | ] |
| 358 | ], |
| 359 | ]; |
| 360 | } |
| 361 | /** |
| 362 | * Get the Moderation Section Controls |
| 363 | * |
| 364 | * @since 1.0 |
| 365 | * |
| 366 | * @return array |
| 367 | */ |
| 368 | protected static function get_moderation_controls() |
| 369 | { |
| 370 | return [ |
| 371 | [ |
| 372 | 'type' => 'separator', |
| 373 | 'top' => 10, |
| 374 | 'bottom' => 20, |
| 375 | ], |
| 376 | [ |
| 377 | 'type' => 'switcher', |
| 378 | 'id' => 'moderationEnabled', |
| 379 | 'labelStrong' => true, |
| 380 | 'layout' => 'third', |
| 381 | 'ajaxAction' => 'moderationModeStart', |
| 382 | 'label' => __('Enable', 'reviews-feed'), |
| 383 | 'stacked' => true, |
| 384 | 'options' => [ |
| 385 | 'enabled' => true, |
| 386 | 'disabled' => false |
| 387 | ] |
| 388 | ], |
| 389 | [ |
| 390 | 'type' => 'toggleset', |
| 391 | 'id' => 'moderationType', |
| 392 | 'strongLabel' => true, |
| 393 | 'condition' => [ |
| 394 | 'moderationEnabled' => [ true ] |
| 395 | ], |
| 396 | 'options' => [ |
| 397 | [ |
| 398 | 'value' => 'allow', |
| 399 | 'label' => __('Allow List', 'reviews-feed'), |
| 400 | 'description' => __('Hides post by default so you can select the ones you want to show', 'reviews-feed') |
| 401 | ], |
| 402 | [ |
| 403 | 'value' => 'block', |
| 404 | 'label' => __('Block List', 'reviews-feed'), |
| 405 | 'description' => __('Show all posts by default so you can select the ones you want to hide', 'reviews-feed') |
| 406 | ] |
| 407 | ] |
| 408 | ], |
| 409 | [ |
| 410 | 'type' => 'savemoderation', |
| 411 | 'condition' => [ |
| 412 | 'moderationEnabled' => [ true ] |
| 413 | ], |
| 414 | ], |
| 415 | [ |
| 416 | 'type' => 'notice', |
| 417 | 'condition' => [ |
| 418 | 'moderationEnabled' => [ true ] |
| 419 | ], |
| 420 | 'noticeIcon' => 'notice', |
| 421 | 'noticeHeading' => __('You can only view and filter through the last 100 reviews', 'reviews-feed'), |
| 422 | 'noticeText' => __('Due to platform API limitations, we cannot store and provide you with a complete repository of your reviews.', 'reviews-feed'), |
| 423 | ], |
| 424 | ]; |
| 425 | } |
| 426 | |
| 427 | protected static function get_moderation_free_controls() |
| 428 | { |
| 429 | return [ |
| 430 | [ |
| 431 | 'type' => 'toggleset', |
| 432 | 'id' => 'moderationType', |
| 433 | 'strongLabel' => true, |
| 434 | 'options' => [ |
| 435 | [ |
| 436 | 'value' => 'allow', |
| 437 | 'label' => __('Allow List', 'reviews-feed'), |
| 438 | 'upsellModal' => 'moderationModal', |
| 439 | 'description' => __('Hides post by default so you can select the ones you want to show', 'reviews-feed') |
| 440 | ], |
| 441 | [ |
| 442 | 'value' => 'block', |
| 443 | 'label' => __('Block List', 'reviews-feed'), |
| 444 | 'upsellModal' => 'moderationModal', |
| 445 | 'description' => __('Show all posts by default so you can select the ones you want to hide', 'reviews-feed') |
| 446 | ] |
| 447 | ] |
| 448 | ], |
| 449 | [ |
| 450 | 'type' => 'savemoderation', |
| 451 | 'upsellModal' => 'moderationModal', |
| 452 | ] |
| 453 | ]; |
| 454 | } |
| 455 | |
| 456 | /** |
| 457 | * Get the Advanced Section Controls |
| 458 | * |
| 459 | * @since 1.0 |
| 460 | * |
| 461 | * @return array |
| 462 | */ |
| 463 | protected static function get_advanced_controls() |
| 464 | { |
| 465 | return [ |
| 466 | [ |
| 467 | 'type' => 'heading', |
| 468 | 'heading' => __('Advanced', 'reviews-feed'), |
| 469 | ] |
| 470 | ]; |
| 471 | } |
| 472 | |
| 473 | /** |
| 474 | * Get the Language Section Controls |
| 475 | * |
| 476 | * @since 1.0 |
| 477 | * |
| 478 | * @return array |
| 479 | */ |
| 480 | protected static function get_language_controls() |
| 481 | { |
| 482 | return [ //Languages & Translation |
| 483 | [ |
| 484 | 'type' => 'list', |
| 485 | 'fullspace' => true, |
| 486 | 'controls' => [ |
| 487 | [ |
| 488 | 'type' => 'select', |
| 489 | 'id' => 'localization', |
| 490 | 'inputLeadingIcon' => 'translate', |
| 491 | 'ajaxAction' => 'feedFlyPreview', |
| 492 | 'options' => Util::get_translation_languages(true) |
| 493 | ], |
| 494 | [ |
| 495 | 'type' => 'button', |
| 496 | 'ajaxAction' => 'changeSettingValue', |
| 497 | 'data' => [ |
| 498 | 'name' => 'localization', |
| 499 | 'value' => 'default', |
| 500 | 'feedFlyPreview' => true |
| 501 | ], |
| 502 | 'buttonText' => __('Reset', 'reviews-feed'), |
| 503 | ], |
| 504 | |
| 505 | ] |
| 506 | ], |
| 507 | [ |
| 508 | 'type' => 'notice', |
| 509 | 'noticeIcon' => 'notice', |
| 510 | 'noticeHeading' => __('Limited Support', 'reviews-feed'), |
| 511 | 'noticeText' => __('Only Google supports different languages. Reviews from other providers will still show up in English or the language they were submitted in.', 'reviews-feed'), |
| 512 | ], |
| 513 | [ |
| 514 | 'type' => 'select', |
| 515 | 'id' => 'trustpilotLanguage', |
| 516 | 'inputLeadingIcon' => 'trustpilot', |
| 517 | 'ajaxAction' => 'feedFlyPreview', |
| 518 | 'heading' => __('TrustPilot Language', 'reviews-feed'), |
| 519 | 'description' => __('Change the language of the reviews from TrustPilot. This will only affect the reviews from TrustPilot.', 'reviews-feed'), |
| 520 | 'conditionSources' => ['trustpilot'], |
| 521 | 'options' => [ |
| 522 | 'all' => __('All Languages', 'reviews-feed'), |
| 523 | 'default' => __('Default', 'reviews-feed'), |
| 524 | ] |
| 525 | ], |
| 526 | ]; |
| 527 | } |
| 528 | |
| 529 | } |
| 530 |