| @@ -1,50 +1,180 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Payment Logos | |
| 4 | - * | |
| 3 | + * Payment Logos — Option group definitions. | |
| 4 | + * | |
| 5 | + * Pure data file. Returns the option groups array | |
| 6 | + * consumed by init_option_groups(). | |
| 7 | + * | |
| 5 | 8 | * @package Merchant |
| 6 | 9 | */ |
| 7 | 10 | |
| 8 | 11 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | - exit; // Exit if accessed directly | |
| 12 | + exit; // Exit if accessed directly. | |
| 10 | 13 | } |
| 11 | 14 | |
| 12 | 15 | /** |
| 13 | - * Payment Logos | |
| 16 | + * Icon Source. | |
| 14 | 17 | */ |
| 15 | -Merchant_Admin_Options::create( array( | |
| 18 | + | |
| 19 | +return array( | |
| 20 | + array( | |
| 16 | 21 | 'title' => esc_html__( 'Payment Logos', 'merchant' ), |
| 17 | 22 | 'module' => Merchant_Payment_Logos::MODULE_ID, |
| 18 | 23 | 'fields' => array( |
| 19 | 24 | |
| 20 | 25 | array( |
| 21 | - 'id' => 'logos', | |
| 22 | - 'type' => 'gallery', | |
| 23 | - 'label' => esc_html__( 'Select logos', 'merchant' ), | |
| 26 | + 'id' => 'icon_source', | |
| 27 | + 'type' => 'select', | |
| 28 | + 'title' => esc_html__( 'Icon source', 'merchant' ), | |
| 29 | + 'options' => array( | |
| 30 | + 'gallery' => esc_html__( 'Media Gallery (upload your own)', 'merchant' ), | |
| 31 | + 'library' => esc_html__( 'Built-in Icon Library', 'merchant' ), | |
| 32 | + ), | |
| 33 | + 'default' => 'gallery', | |
| 24 | 34 | ), |
| 25 | 35 | |
| 36 | + array( | |
| 37 | + 'id' => 'logos', | |
| 38 | + 'type' => 'gallery', | |
| 39 | + 'label' => esc_html__( 'Select logos', 'merchant' ), | |
| 40 | + 'condition' => array( 'icon_source', '==', 'gallery' ), | |
| 41 | + ), | |
| 42 | + | |
| 43 | + array( | |
| 44 | + 'id' => 'library_icons', | |
| 45 | + 'type' => 'choices', | |
| 46 | + 'title' => esc_html__( 'Select payment icons', 'merchant' ), | |
| 47 | + 'multiple' => true, | |
| 48 | + 'options' => Merchant_Payment_Icons_Library::get_choices_options(), | |
| 49 | + 'default' => array( 'visa', 'mastercard', 'paypal' ), | |
| 50 | + 'condition' => array( 'icon_source', '==', 'library' ), | |
| 51 | + ), | |
| 52 | + | |
| 26 | 53 | ), |
| 27 | -) ); | |
| 54 | +), | |
| 55 | + array( | |
| 56 | + 'title' => esc_html__( 'Display Locations', 'merchant' ), | |
| 57 | + 'module' => Merchant_Payment_Logos::MODULE_ID, | |
| 58 | + 'fields' => array( | |
| 28 | 59 | |
| 29 | -/** | |
| 30 | - * Settings | |
| 31 | - */ | |
| 32 | -Merchant_Admin_Options::create( array( | |
| 60 | + array( | |
| 61 | + 'id' => 'show_on_single_product', | |
| 62 | + 'type' => 'switcher', | |
| 63 | + 'title' => esc_html__( 'Single Product Page', 'merchant' ), | |
| 64 | + 'default' => 1, | |
| 65 | + ), | |
| 66 | + | |
| 67 | + array( | |
| 68 | + 'id' => 'show_on_cart_page', | |
| 69 | + 'type' => 'switcher', | |
| 70 | + 'title' => esc_html__( 'Cart Page', 'merchant' ), | |
| 71 | + 'default' => 0, | |
| 72 | + ), | |
| 73 | + | |
| 74 | + array( | |
| 75 | + 'id' => 'cart_position', | |
| 76 | + 'type' => 'select', | |
| 77 | + 'title' => esc_html__( 'Cart page position', 'merchant' ), | |
| 78 | + 'options' => array( | |
| 79 | + 'before_table' => esc_html__( 'Before cart table', 'merchant' ), | |
| 80 | + 'after_table' => esc_html__( 'After cart table', 'merchant' ), | |
| 81 | + 'before_proceed_to_checkout' => esc_html__( 'Before "Proceed to checkout" button', 'merchant' ), | |
| 82 | + 'after_cart_totals' => esc_html__( 'After cart totals', 'merchant' ), | |
| 83 | + ), | |
| 84 | + 'default' => 'after_table', | |
| 85 | + 'conditions' => array( | |
| 86 | + 'terms' => array( | |
| 87 | + array( | |
| 88 | + 'field' => 'show_on_cart_page', | |
| 89 | + 'operator' => '===', | |
| 90 | + 'value' => true, | |
| 91 | + ), | |
| 92 | + ), | |
| 93 | + ), | |
| 94 | + ), | |
| 95 | + | |
| 96 | + array( | |
| 97 | + 'id' => 'show_on_checkout_page', | |
| 98 | + 'type' => 'switcher', | |
| 99 | + 'title' => esc_html__( 'Checkout Page', 'merchant' ), | |
| 100 | + 'default' => 0, | |
| 101 | + ), | |
| 102 | + | |
| 103 | + array( | |
| 104 | + 'id' => 'checkout_position', | |
| 105 | + 'type' => 'select', | |
| 106 | + 'title' => esc_html__( 'Checkout page position', 'merchant' ), | |
| 107 | + 'options' => array( | |
| 108 | + 'before_checkout_form' => esc_html__( 'Before checkout form', 'merchant' ), | |
| 109 | + 'before_customer_details' => esc_html__( 'Before customer details', 'merchant' ), | |
| 110 | + 'after_customer_details' => esc_html__( 'After customer details', 'merchant' ), | |
| 111 | + 'before_place_order' => esc_html__( 'Before "Place order" button', 'merchant' ), | |
| 112 | + 'after_checkout_form' => esc_html__( 'After checkout form', 'merchant' ), | |
| 113 | + ), | |
| 114 | + 'default' => 'before_checkout_form', | |
| 115 | + 'conditions' => array( | |
| 116 | + 'terms' => array( | |
| 117 | + array( | |
| 118 | + 'field' => 'show_on_checkout_page', | |
| 119 | + 'operator' => '===', | |
| 120 | + 'value' => true, | |
| 121 | + ), | |
| 122 | + ), | |
| 123 | + ), | |
| 124 | + ), | |
| 125 | + | |
| 126 | + array( | |
| 127 | + 'id' => 'show_on_footer', | |
| 128 | + 'type' => 'switcher', | |
| 129 | + 'title' => esc_html__( 'Footer (site-wide)', 'merchant' ), | |
| 130 | + 'default' => 0, | |
| 131 | + ), | |
| 132 | + | |
| 133 | + array( | |
| 134 | + 'id' => 'show_on_archive_pages', | |
| 135 | + 'type' => 'switcher', | |
| 136 | + 'title' => esc_html__( 'Archive / Shop Pages', 'merchant' ), | |
| 137 | + 'default' => 0, | |
| 138 | + ), | |
| 139 | + | |
| 140 | + array( | |
| 141 | + 'id' => 'archive_position', | |
| 142 | + 'type' => 'select', | |
| 143 | + 'title' => esc_html__( 'Archive page position', 'merchant' ), | |
| 144 | + 'options' => array( | |
| 145 | + 'before_loop' => esc_html__( 'Before product loop', 'merchant' ), | |
| 146 | + 'after_loop' => esc_html__( 'After product loop', 'merchant' ), | |
| 147 | + ), | |
| 148 | + 'default' => 'after_loop', | |
| 149 | + 'conditions' => array( | |
| 150 | + 'terms' => array( | |
| 151 | + array( | |
| 152 | + 'field' => 'show_on_archive_pages', | |
| 153 | + 'operator' => '===', | |
| 154 | + 'value' => true, | |
| 155 | + ), | |
| 156 | + ), | |
| 157 | + ), | |
| 158 | + ), | |
| 159 | + | |
| 160 | + ), | |
| 161 | +), | |
| 162 | + array( | |
| 33 | 163 | 'title' => esc_html__( 'Settings', 'merchant' ), |
| 34 | 164 | 'module' => Merchant_Payment_Logos::MODULE_ID, |
| 35 | 165 | 'fields' => array( |
| 36 | 166 | |
| 37 | 167 | array( |
| 38 | - 'id' => 'align', | |
| 39 | - 'type' => 'select', | |
| 40 | - 'title' => esc_html__( 'Align logos', 'merchant' ), | |
| 41 | - 'options' => array( | |
| 168 | + 'id' => 'align', | |
| 169 | + 'type' => 'select', | |
| 170 | + 'title' => esc_html__( 'Align logos', 'merchant' ), | |
| 171 | + 'options' => array( | |
| 42 | 172 | 'flex-start' => esc_html__( 'Left', 'merchant' ), |
| 43 | 173 | 'center' => esc_html__( 'Center', 'merchant' ), |
| 44 | 174 | 'flex-end' => esc_html__( 'Right', 'merchant' ), |
| 45 | 175 | ), |
| 46 | - 'default' => 'flex-start', | |
| 176 | + 'default' => 'flex-start', | |
| 47 | 177 | ), |
| 48 | 178 | |
| 49 | 179 | array( |
| 50 | 180 | 'id' => 'title', |
| @@ -115,14 +245,174 @@ | ||
| 115 | 245 | 'unit' => 'px', |
| 116 | 246 | ), |
| 117 | 247 | |
| 118 | 248 | ), |
| 119 | -) ); | |
| 249 | +), | |
| 250 | + array( | |
| 251 | + 'title' => esc_html__( 'Container Styling', 'merchant' ), | |
| 252 | + 'module' => Merchant_Payment_Logos::MODULE_ID, | |
| 253 | + 'fields' => array( | |
| 120 | 254 | |
| 121 | -// Shortcode | |
| 122 | -$merchant_module_id = Merchant_Payment_Logos::MODULE_ID; | |
| 123 | -Merchant_Admin_Options::create( array( | |
| 124 | - 'module' => $merchant_module_id, | |
| 255 | + array( | |
| 256 | + 'id' => 'container_bg_color', | |
| 257 | + 'type' => 'color', | |
| 258 | + 'title' => esc_html__( 'Background color', 'merchant' ), | |
| 259 | + 'default' => 'transparent', | |
| 260 | + ), | |
| 261 | + | |
| 262 | + array( | |
| 263 | + 'id' => 'container_padding', | |
| 264 | + 'type' => 'range', | |
| 265 | + 'title' => esc_html__( 'Padding', 'merchant' ), | |
| 266 | + 'min' => 0, | |
| 267 | + 'max' => 100, | |
| 268 | + 'step' => 1, | |
| 269 | + 'default' => 0, | |
| 270 | + 'unit' => 'px', | |
| 271 | + ), | |
| 272 | + | |
| 273 | + array( | |
| 274 | + 'id' => 'container_border_radius', | |
| 275 | + 'type' => 'range', | |
| 276 | + 'title' => esc_html__( 'Border radius', 'merchant' ), | |
| 277 | + 'min' => 0, | |
| 278 | + 'max' => 100, | |
| 279 | + 'step' => 1, | |
| 280 | + 'default' => 0, | |
| 281 | + 'unit' => 'px', | |
| 282 | + ), | |
| 283 | + | |
| 284 | + array( | |
| 285 | + 'id' => 'container_border_color', | |
| 286 | + 'type' => 'color', | |
| 287 | + 'title' => esc_html__( 'Border color', 'merchant' ), | |
| 288 | + 'default' => 'transparent', | |
| 289 | + ), | |
| 290 | + | |
| 291 | + array( | |
| 292 | + 'id' => 'container_border_width', | |
| 293 | + 'type' => 'range', | |
| 294 | + 'title' => esc_html__( 'Border width', 'merchant' ), | |
| 295 | + 'min' => 0, | |
| 296 | + 'max' => 20, | |
| 297 | + 'step' => 1, | |
| 298 | + 'default' => 0, | |
| 299 | + 'unit' => 'px', | |
| 300 | + ), | |
| 301 | + | |
| 302 | + ), | |
| 303 | +), | |
| 304 | + array( | |
| 305 | + 'title' => esc_html__( 'Exclusion Rules', 'merchant' ), | |
| 306 | + 'module' => Merchant_Payment_Logos::MODULE_ID, | |
| 307 | + 'fields' => array( | |
| 308 | + | |
| 309 | + array( | |
| 310 | + 'id' => 'exclude_products_toggle', | |
| 311 | + 'type' => 'switcher', | |
| 312 | + 'title' => esc_html__( 'Exclude specific products', 'merchant' ), | |
| 313 | + 'default' => 0, | |
| 314 | + 'ai_meta' => array( | |
| 315 | + 'toggle_for' => 'excluded_products', | |
| 316 | + 'semantic_group' => 'product_exclusion', | |
| 317 | + 'usage_hint' => 'Enable this toggle before setting excluded_products. Hides payment logos on specific individual product pages.', | |
| 318 | + ), | |
| 319 | + ), | |
| 320 | + | |
| 321 | + array( | |
| 322 | + 'id' => 'excluded_products', | |
| 323 | + 'type' => 'products_selector', | |
| 324 | + 'title' => esc_html__( 'Excluded Products', 'merchant' ), | |
| 325 | + 'multiple' => true, | |
| 326 | + 'desc' => esc_html__( 'Payment logos will not appear on these products.', 'merchant' ), | |
| 327 | + 'allowed_types' => array( 'simple', 'variable', 'external', 'grouped' ), | |
| 328 | + 'conditions' => array( | |
| 329 | + 'terms' => array( | |
| 330 | + array( | |
| 331 | + 'field' => 'exclude_products_toggle', | |
| 332 | + 'operator' => '===', | |
| 333 | + 'value' => true, | |
| 334 | + ), | |
| 335 | + ), | |
| 336 | + ), | |
| 337 | + 'ai_meta' => array( | |
| 338 | + 'entity' => 'product', | |
| 339 | + 'reference_type' => 'static', | |
| 340 | + 'value_format' => 'product_id', | |
| 341 | + 'semantic_group' => 'product_exclusion', | |
| 342 | + 'abstraction_level' => 1, | |
| 343 | + 'toggled_by' => 'exclude_products_toggle', | |
| 344 | + 'usage_hint' => 'Use ONLY for excluding specific individual products. For category exclusions, prefer excluded_categories — it is dynamic and auto-excludes future products.', | |
| 345 | + ), | |
| 346 | + ), | |
| 347 | + | |
| 348 | + array( | |
| 349 | + 'id' => 'exclude_categories_toggle', | |
| 350 | + 'type' => 'switcher', | |
| 351 | + 'title' => esc_html__( 'Exclude specific categories', 'merchant' ), | |
| 352 | + 'default' => 0, | |
| 353 | + 'ai_meta' => array( | |
| 354 | + 'toggle_for' => 'excluded_categories', | |
| 355 | + 'semantic_group' => 'product_exclusion', | |
| 356 | + 'usage_hint' => 'Enable this toggle before setting excluded_categories. Hides payment logos on all products within the selected categories. Also gates include_subcategories.', | |
| 357 | + ), | |
| 358 | + ), | |
| 359 | + | |
| 360 | + array( | |
| 361 | + 'id' => 'excluded_categories', | |
| 362 | + 'type' => 'select_ajax', | |
| 363 | + 'title' => esc_html__( 'Excluded Categories', 'merchant' ), | |
| 364 | + 'source' => 'options', | |
| 365 | + 'multiple' => true, | |
| 366 | + 'options' => Merchant_Admin_Options::get_category_select2_choices(), | |
| 367 | + 'placeholder' => esc_html__( 'Select categories', 'merchant' ), | |
| 368 | + 'desc' => esc_html__( 'Payment logos will not appear on products in these categories.', 'merchant' ), | |
| 369 | + 'conditions' => array( | |
| 370 | + 'terms' => array( | |
| 371 | + array( | |
| 372 | + 'field' => 'exclude_categories_toggle', | |
| 373 | + 'operator' => '===', | |
| 374 | + 'value' => true, | |
| 375 | + ), | |
| 376 | + ), | |
| 377 | + ), | |
| 378 | + 'ai_meta' => array( | |
| 379 | + 'entity' => 'category', | |
| 380 | + 'reference_type' => 'dynamic', | |
| 381 | + 'taxonomy' => 'product_cat', | |
| 382 | + 'value_format' => 'slug', | |
| 383 | + 'semantic_group' => 'product_exclusion', | |
| 384 | + 'abstraction_level' => 3, | |
| 385 | + 'toggled_by' => 'exclude_categories_toggle', | |
| 386 | + 'usage_hint' => 'Use when excluding products by category. Dynamic: future products added to the category are automatically excluded. Prefer over excluded_products for category-level intent.', | |
| 387 | + ), | |
| 388 | + ), | |
| 389 | + | |
| 390 | + array( | |
| 391 | + 'id' => 'include_subcategories', | |
| 392 | + 'type' => 'switcher', | |
| 393 | + 'title' => esc_html__( 'Include subcategories', 'merchant' ), | |
| 394 | + 'desc' => esc_html__( 'When enabled, selecting a parent category also applies to all of its child categories.', 'merchant' ), | |
| 395 | + 'default' => 0, | |
| 396 | + 'conditions' => array( | |
| 397 | + 'terms' => array( | |
| 398 | + array( | |
| 399 | + 'field' => 'exclude_categories_toggle', | |
| 400 | + 'operator' => '===', | |
| 401 | + 'value' => true, | |
| 402 | + ), | |
| 403 | + ), | |
| 404 | + ), | |
| 405 | + 'ai_meta' => array( | |
| 406 | + 'semantic_group' => 'product_exclusion', | |
| 407 | + 'usage_hint' => 'Enable so selected parent categories also cover their child categories when excluding products. Off by default, which excludes only the exact categories chosen.', | |
| 408 | + ), | |
| 409 | + ), | |
| 410 | + | |
| 411 | + ), | |
| 412 | +), | |
| 413 | + array( | |
| 414 | + 'module' => Merchant_Payment_Logos::MODULE_ID, | |
| 125 | 415 | 'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 126 | 416 | 'fields' => array( |
| 127 | 417 | array( |
| 128 | 418 | 'id' => 'use_shortcode', |
| @@ -138,9 +428,10 @@ | ||
| 138 | 428 | array( |
| 139 | 429 | 'id' => 'shortcode_text', |
| 140 | 430 | 'type' => 'text_readonly', |
| 141 | 431 | 'title' => esc_html__( 'Shortcode text', 'merchant' ), |
| 142 | - 'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']', | |
| 432 | + 'default' => '[merchant_module_' . str_replace( '-', '_', Merchant_Payment_Logos::MODULE_ID ) . ']', | |
| 143 | 433 | 'condition' => array( 'use_shortcode', '==', '1' ), |
| 144 | 434 | ), |
| 145 | 435 | ), |
| 146 | -) ); | |
| 436 | +), | |
| 437 | +); | |