| 1 |
<?php |
| 2 |
/** |
| 3 |
* Payment Logos Options. |
| 4 |
* |
| 5 |
* @package Merchant |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Icon Source. |
| 14 |
*/ |
| 15 |
Merchant_Admin_Options::create( array( |
| 16 |
'title' => esc_html__( 'Payment Logos', 'merchant' ), |
| 17 |
'module' => Merchant_Payment_Logos::MODULE_ID, |
| 18 |
'fields' => array( |
| 19 |
|
| 20 |
array( |
| 21 |
'id' => 'icon_source', |
| 22 |
'type' => 'select', |
| 23 |
'title' => esc_html__( 'Icon source', 'merchant' ), |
| 24 |
'options' => array( |
| 25 |
'gallery' => esc_html__( 'Media Gallery (upload your own)', 'merchant' ), |
| 26 |
'library' => esc_html__( 'Built-in Icon Library', 'merchant' ), |
| 27 |
), |
| 28 |
'default' => 'gallery', |
| 29 |
), |
| 30 |
|
| 31 |
array( |
| 32 |
'id' => 'logos', |
| 33 |
'type' => 'gallery', |
| 34 |
'label' => esc_html__( 'Select logos', 'merchant' ), |
| 35 |
'condition' => array( 'icon_source', '==', 'gallery' ), |
| 36 |
), |
| 37 |
|
| 38 |
array( |
| 39 |
'id' => 'library_icons', |
| 40 |
'type' => 'choices', |
| 41 |
'title' => esc_html__( 'Select payment icons', 'merchant' ), |
| 42 |
'multiple' => true, |
| 43 |
'options' => Merchant_Payment_Icons_Library::get_choices_options(), |
| 44 |
'default' => array( 'visa', 'mastercard', 'paypal' ), |
| 45 |
'condition' => array( 'icon_source', '==', 'library' ), |
| 46 |
), |
| 47 |
|
| 48 |
), |
| 49 |
) ); |
| 50 |
|
| 51 |
/** |
| 52 |
* Display Locations. |
| 53 |
*/ |
| 54 |
Merchant_Admin_Options::create( array( |
| 55 |
'title' => esc_html__( 'Display Locations', 'merchant' ), |
| 56 |
'module' => Merchant_Payment_Logos::MODULE_ID, |
| 57 |
'fields' => array( |
| 58 |
|
| 59 |
array( |
| 60 |
'id' => 'show_on_single_product', |
| 61 |
'type' => 'switcher', |
| 62 |
'title' => esc_html__( 'Single Product Page', 'merchant' ), |
| 63 |
'default' => 1, |
| 64 |
), |
| 65 |
|
| 66 |
array( |
| 67 |
'id' => 'show_on_cart_page', |
| 68 |
'type' => 'switcher', |
| 69 |
'title' => esc_html__( 'Cart Page', 'merchant' ), |
| 70 |
'default' => 0, |
| 71 |
), |
| 72 |
|
| 73 |
array( |
| 74 |
'id' => 'cart_position', |
| 75 |
'type' => 'select', |
| 76 |
'title' => esc_html__( 'Cart page position', 'merchant' ), |
| 77 |
'options' => array( |
| 78 |
'before_table' => esc_html__( 'Before cart table', 'merchant' ), |
| 79 |
'after_table' => esc_html__( 'After cart table', 'merchant' ), |
| 80 |
'before_proceed_to_checkout' => esc_html__( 'Before "Proceed to checkout" button', 'merchant' ), |
| 81 |
'after_cart_totals' => esc_html__( 'After cart totals', 'merchant' ), |
| 82 |
), |
| 83 |
'default' => 'after_table', |
| 84 |
'conditions' => array( |
| 85 |
'terms' => array( |
| 86 |
array( |
| 87 |
'field' => 'show_on_cart_page', |
| 88 |
'operator' => '===', |
| 89 |
'value' => true, |
| 90 |
), |
| 91 |
), |
| 92 |
), |
| 93 |
), |
| 94 |
|
| 95 |
array( |
| 96 |
'id' => 'show_on_checkout_page', |
| 97 |
'type' => 'switcher', |
| 98 |
'title' => esc_html__( 'Checkout Page', 'merchant' ), |
| 99 |
'default' => 0, |
| 100 |
), |
| 101 |
|
| 102 |
array( |
| 103 |
'id' => 'checkout_position', |
| 104 |
'type' => 'select', |
| 105 |
'title' => esc_html__( 'Checkout page position', 'merchant' ), |
| 106 |
'options' => array( |
| 107 |
'before_checkout_form' => esc_html__( 'Before checkout form', 'merchant' ), |
| 108 |
'before_customer_details' => esc_html__( 'Before customer details', 'merchant' ), |
| 109 |
'after_customer_details' => esc_html__( 'After customer details', 'merchant' ), |
| 110 |
'before_place_order' => esc_html__( 'Before "Place order" button', 'merchant' ), |
| 111 |
'after_checkout_form' => esc_html__( 'After checkout form', 'merchant' ), |
| 112 |
), |
| 113 |
'default' => 'before_checkout_form', |
| 114 |
'conditions' => array( |
| 115 |
'terms' => array( |
| 116 |
array( |
| 117 |
'field' => 'show_on_checkout_page', |
| 118 |
'operator' => '===', |
| 119 |
'value' => true, |
| 120 |
), |
| 121 |
), |
| 122 |
), |
| 123 |
), |
| 124 |
|
| 125 |
array( |
| 126 |
'id' => 'show_on_footer', |
| 127 |
'type' => 'switcher', |
| 128 |
'title' => esc_html__( 'Footer (site-wide)', 'merchant' ), |
| 129 |
'default' => 0, |
| 130 |
), |
| 131 |
|
| 132 |
array( |
| 133 |
'id' => 'show_on_archive_pages', |
| 134 |
'type' => 'switcher', |
| 135 |
'title' => esc_html__( 'Archive / Shop Pages', 'merchant' ), |
| 136 |
'default' => 0, |
| 137 |
), |
| 138 |
|
| 139 |
array( |
| 140 |
'id' => 'archive_position', |
| 141 |
'type' => 'select', |
| 142 |
'title' => esc_html__( 'Archive page position', 'merchant' ), |
| 143 |
'options' => array( |
| 144 |
'before_loop' => esc_html__( 'Before product loop', 'merchant' ), |
| 145 |
'after_loop' => esc_html__( 'After product loop', 'merchant' ), |
| 146 |
), |
| 147 |
'default' => 'after_loop', |
| 148 |
'conditions' => array( |
| 149 |
'terms' => array( |
| 150 |
array( |
| 151 |
'field' => 'show_on_archive_pages', |
| 152 |
'operator' => '===', |
| 153 |
'value' => true, |
| 154 |
), |
| 155 |
), |
| 156 |
), |
| 157 |
), |
| 158 |
|
| 159 |
), |
| 160 |
) ); |
| 161 |
|
| 162 |
/** |
| 163 |
* Settings. |
| 164 |
*/ |
| 165 |
Merchant_Admin_Options::create( array( |
| 166 |
'title' => esc_html__( 'Settings', 'merchant' ), |
| 167 |
'module' => Merchant_Payment_Logos::MODULE_ID, |
| 168 |
'fields' => array( |
| 169 |
|
| 170 |
array( |
| 171 |
'id' => 'align', |
| 172 |
'type' => 'select', |
| 173 |
'title' => esc_html__( 'Align logos', 'merchant' ), |
| 174 |
'options' => array( |
| 175 |
'flex-start' => esc_html__( 'Left', 'merchant' ), |
| 176 |
'center' => esc_html__( 'Center', 'merchant' ), |
| 177 |
'flex-end' => esc_html__( 'Right', 'merchant' ), |
| 178 |
), |
| 179 |
'default' => 'flex-start', |
| 180 |
), |
| 181 |
|
| 182 |
array( |
| 183 |
'id' => 'title', |
| 184 |
'type' => 'text', |
| 185 |
'title' => esc_html__( 'Text above the logos', 'merchant' ), |
| 186 |
'default' => esc_html__( '🔒 Safe & Secure Checkout', 'merchant' ), |
| 187 |
), |
| 188 |
|
| 189 |
array( |
| 190 |
'id' => 'font-size', |
| 191 |
'type' => 'range', |
| 192 |
'title' => esc_html__( 'Font size', 'merchant' ), |
| 193 |
'min' => 1, |
| 194 |
'max' => 250, |
| 195 |
'step' => 1, |
| 196 |
'default' => 18, |
| 197 |
'unit' => 'px', |
| 198 |
), |
| 199 |
|
| 200 |
array( |
| 201 |
'id' => 'text-color', |
| 202 |
'type' => 'color', |
| 203 |
'title' => esc_html__( 'Text color', 'merchant' ), |
| 204 |
'default' => '#212121', |
| 205 |
), |
| 206 |
|
| 207 |
array( |
| 208 |
'id' => 'margin-top', |
| 209 |
'type' => 'range', |
| 210 |
'title' => esc_html__( 'Margin top', 'merchant' ), |
| 211 |
'min' => 1, |
| 212 |
'max' => 250, |
| 213 |
'step' => 1, |
| 214 |
'default' => 20, |
| 215 |
'unit' => 'px', |
| 216 |
), |
| 217 |
|
| 218 |
array( |
| 219 |
'id' => 'margin-bottom', |
| 220 |
'type' => 'range', |
| 221 |
'title' => esc_html__( 'Margin bottom', 'merchant' ), |
| 222 |
'min' => 1, |
| 223 |
'max' => 250, |
| 224 |
'step' => 1, |
| 225 |
'default' => 20, |
| 226 |
'unit' => 'px', |
| 227 |
), |
| 228 |
|
| 229 |
array( |
| 230 |
'id' => 'image-max-width', |
| 231 |
'type' => 'range', |
| 232 |
'title' => esc_html__( 'Image max width', 'merchant' ), |
| 233 |
'min' => 1, |
| 234 |
'max' => 250, |
| 235 |
'step' => 1, |
| 236 |
'default' => 80, |
| 237 |
'unit' => 'px', |
| 238 |
), |
| 239 |
|
| 240 |
array( |
| 241 |
'id' => 'image-max-height', |
| 242 |
'type' => 'range', |
| 243 |
'title' => esc_html__( 'Image max height', 'merchant' ), |
| 244 |
'min' => 1, |
| 245 |
'max' => 250, |
| 246 |
'step' => 1, |
| 247 |
'default' => 100, |
| 248 |
'unit' => 'px', |
| 249 |
), |
| 250 |
|
| 251 |
), |
| 252 |
) ); |
| 253 |
|
| 254 |
/** |
| 255 |
* Container Styling. |
| 256 |
*/ |
| 257 |
Merchant_Admin_Options::create( array( |
| 258 |
'title' => esc_html__( 'Container Styling', 'merchant' ), |
| 259 |
'module' => Merchant_Payment_Logos::MODULE_ID, |
| 260 |
'fields' => array( |
| 261 |
|
| 262 |
array( |
| 263 |
'id' => 'container_bg_color', |
| 264 |
'type' => 'color', |
| 265 |
'title' => esc_html__( 'Background color', 'merchant' ), |
| 266 |
'default' => 'transparent', |
| 267 |
), |
| 268 |
|
| 269 |
array( |
| 270 |
'id' => 'container_padding', |
| 271 |
'type' => 'range', |
| 272 |
'title' => esc_html__( 'Padding', 'merchant' ), |
| 273 |
'min' => 0, |
| 274 |
'max' => 100, |
| 275 |
'step' => 1, |
| 276 |
'default' => 0, |
| 277 |
'unit' => 'px', |
| 278 |
), |
| 279 |
|
| 280 |
array( |
| 281 |
'id' => 'container_border_radius', |
| 282 |
'type' => 'range', |
| 283 |
'title' => esc_html__( 'Border radius', 'merchant' ), |
| 284 |
'min' => 0, |
| 285 |
'max' => 100, |
| 286 |
'step' => 1, |
| 287 |
'default' => 0, |
| 288 |
'unit' => 'px', |
| 289 |
), |
| 290 |
|
| 291 |
array( |
| 292 |
'id' => 'container_border_color', |
| 293 |
'type' => 'color', |
| 294 |
'title' => esc_html__( 'Border color', 'merchant' ), |
| 295 |
'default' => 'transparent', |
| 296 |
), |
| 297 |
|
| 298 |
array( |
| 299 |
'id' => 'container_border_width', |
| 300 |
'type' => 'range', |
| 301 |
'title' => esc_html__( 'Border width', 'merchant' ), |
| 302 |
'min' => 0, |
| 303 |
'max' => 20, |
| 304 |
'step' => 1, |
| 305 |
'default' => 0, |
| 306 |
'unit' => 'px', |
| 307 |
), |
| 308 |
|
| 309 |
), |
| 310 |
) ); |
| 311 |
|
| 312 |
/** |
| 313 |
* Product / Category Exclusion. |
| 314 |
*/ |
| 315 |
Merchant_Admin_Options::create( array( |
| 316 |
'title' => esc_html__( 'Exclusion Rules', 'merchant' ), |
| 317 |
'module' => Merchant_Payment_Logos::MODULE_ID, |
| 318 |
'fields' => array( |
| 319 |
|
| 320 |
array( |
| 321 |
'id' => 'exclude_products_toggle', |
| 322 |
'type' => 'switcher', |
| 323 |
'title' => esc_html__( 'Exclude specific products', 'merchant' ), |
| 324 |
'default' => 0, |
| 325 |
), |
| 326 |
|
| 327 |
array( |
| 328 |
'id' => 'excluded_products', |
| 329 |
'type' => 'products_selector', |
| 330 |
'title' => esc_html__( 'Excluded Products', 'merchant' ), |
| 331 |
'multiple' => true, |
| 332 |
'desc' => esc_html__( 'Payment logos will not appear on these products.', 'merchant' ), |
| 333 |
'allowed_types' => array( 'simple', 'variable', 'external', 'grouped' ), |
| 334 |
'conditions' => array( |
| 335 |
'terms' => array( |
| 336 |
array( |
| 337 |
'field' => 'exclude_products_toggle', |
| 338 |
'operator' => '===', |
| 339 |
'value' => true, |
| 340 |
), |
| 341 |
), |
| 342 |
), |
| 343 |
), |
| 344 |
|
| 345 |
array( |
| 346 |
'id' => 'exclude_categories_toggle', |
| 347 |
'type' => 'switcher', |
| 348 |
'title' => esc_html__( 'Exclude specific categories', 'merchant' ), |
| 349 |
'default' => 0, |
| 350 |
), |
| 351 |
|
| 352 |
array( |
| 353 |
'id' => 'excluded_categories', |
| 354 |
'type' => 'select_ajax', |
| 355 |
'title' => esc_html__( 'Excluded Categories', 'merchant' ), |
| 356 |
'source' => 'options', |
| 357 |
'multiple' => true, |
| 358 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 359 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 360 |
'desc' => esc_html__( 'Payment logos will not appear on products in these categories.', 'merchant' ), |
| 361 |
'conditions' => array( |
| 362 |
'terms' => array( |
| 363 |
array( |
| 364 |
'field' => 'exclude_categories_toggle', |
| 365 |
'operator' => '===', |
| 366 |
'value' => true, |
| 367 |
), |
| 368 |
), |
| 369 |
), |
| 370 |
), |
| 371 |
|
| 372 |
), |
| 373 |
) ); |
| 374 |
|
| 375 |
// Shortcode. |
| 376 |
$merchant_module_id = Merchant_Payment_Logos::MODULE_ID; |
| 377 |
Merchant_Admin_Options::create( array( |
| 378 |
'module' => $merchant_module_id, |
| 379 |
'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 380 |
'fields' => array( |
| 381 |
array( |
| 382 |
'id' => 'use_shortcode', |
| 383 |
'type' => 'switcher', |
| 384 |
'title' => __( 'Use shortcode', 'merchant' ), |
| 385 |
'default' => 0, |
| 386 |
), |
| 387 |
array( |
| 388 |
'type' => 'info', |
| 389 |
'id' => 'shortcode_info', |
| 390 |
'content' => esc_html__( 'If you are using a page builder or a theme that supports shortcodes, then you can output the module using the shortcode above. This might be useful if, for example, you find that you want to control the position of the module output more precisely than with the module settings. Note that the shortcodes can only be used on single product pages.', 'merchant' ), |
| 391 |
), |
| 392 |
array( |
| 393 |
'id' => 'shortcode_text', |
| 394 |
'type' => 'text_readonly', |
| 395 |
'title' => esc_html__( 'Shortcode text', 'merchant' ), |
| 396 |
'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']', |
| 397 |
'condition' => array( 'use_shortcode', '==', '1' ), |
| 398 |
), |
| 399 |
), |
| 400 |
) ); |