| 1 |
<?php |
| 2 |
/** |
| 3 |
* Merchant - Product Labels |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
$text_shapes = array(); |
| 11 |
$image_shapes = array(); |
| 12 |
|
| 13 |
for ( $i = 1; $i <= 24; $i++ ) { |
| 14 |
if ( $i <= 8 ) { |
| 15 |
$text_shapes[ 'text-shape-' . $i ] = MERCHANT_URI . 'assets/images/icons/product-labels/text-shape-' . $i . '.svg'; |
| 16 |
} |
| 17 |
|
| 18 |
$image_shapes[ 'image-shape-' . $i ] = MERCHANT_URI . 'assets/images/icons/product-labels/image-shape-' . $i . '.svg'; |
| 19 |
} |
| 20 |
|
| 21 |
$display_rules = array( |
| 22 |
'featured_products' => esc_html__( 'Featured Products', 'merchant' ), |
| 23 |
'products_on_sale' => esc_html__( 'Products on Sale', 'merchant' ), |
| 24 |
'new_products' => esc_html__( 'New Products', 'merchant' ), |
| 25 |
'out_of_stock' => esc_html__( 'Out of Stock Products', 'merchant' ), |
| 26 |
'all_products' => esc_html__( 'All Products', 'merchant' ), |
| 27 |
'specific_products' => esc_html__( 'Specific Products', 'merchant' ), |
| 28 |
'by_category' => esc_html__( 'Specific Categories', 'merchant' ), |
| 29 |
'by_tags' => esc_html__( 'Specific Tags', 'merchant' ), |
| 30 |
'by_brands' => esc_html__( 'Specific Brands', 'merchant' ), |
| 31 |
); |
| 32 |
|
| 33 |
/** |
| 34 |
* `merchant_product_labels_display_rules` |
| 35 |
* |
| 36 |
* @since 1.10.1 |
| 37 |
*/ |
| 38 |
$display_rules = apply_filters( 'merchant_product_labels_display_rules', $display_rules, Merchant_Product_Labels::MODULE_ID ); |
| 39 |
|
| 40 |
/** |
| 41 |
* Settings |
| 42 |
*/ |
| 43 |
Merchant_Admin_Options::create( array( |
| 44 |
'title' => esc_html__( 'Settings', 'merchant' ), |
| 45 |
'module' => Merchant_Product_Labels::MODULE_ID, |
| 46 |
'fields' => array( |
| 47 |
array( |
| 48 |
'id' => 'labels', |
| 49 |
'type' => 'flexible_content', |
| 50 |
'sorting' => true, |
| 51 |
'accordion' => true, |
| 52 |
'duplicate' => true, |
| 53 |
'style' => Merchant_Product_Labels::MODULE_ID . '-style default', |
| 54 |
'button_label' => esc_html__( 'Add New Label', 'merchant' ), |
| 55 |
'layouts' => array( |
| 56 |
'single-label' => array( |
| 57 |
'title' => esc_html__( 'Product label', 'merchant' ), |
| 58 |
'title-field' => 'label-title', |
| 59 |
'status-field' => 'campaign_status', |
| 60 |
'fields' => array( |
| 61 |
array( |
| 62 |
'id' => 'campaign_status', |
| 63 |
'type' => 'select', |
| 64 |
'title' => esc_html__( 'Status', 'merchant' ), |
| 65 |
'options' => array( |
| 66 |
'active' => esc_html__( 'Active', 'merchant' ), |
| 67 |
'inactive' => esc_html__( 'Inactive', 'merchant' ), |
| 68 |
), |
| 69 |
'default' => 'active', |
| 70 |
), |
| 71 |
array( |
| 72 |
'id' => 'label-title', |
| 73 |
'title' => esc_html__( 'Label name', 'merchant' ), |
| 74 |
'desc' => esc_html__( 'Internal label name. This is not visible to customers.', 'merchant' ), |
| 75 |
'type' => 'text', |
| 76 |
'default' => esc_html__( 'Product label', 'merchant' ), |
| 77 |
), |
| 78 |
|
| 79 |
array( |
| 80 |
'id' => 'label_type', |
| 81 |
'type' => 'buttons_content', |
| 82 |
'title' => '', |
| 83 |
'desc' => '', |
| 84 |
'options' => array( |
| 85 |
'text' => array( |
| 86 |
'title' => esc_html__( 'Text', 'merchant' ), |
| 87 |
'desc' => esc_html__( 'Add text label', 'merchant' ), |
| 88 |
'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/text-icon.svg', |
| 89 |
), |
| 90 |
'image' => array( |
| 91 |
'title' => esc_html__( 'Image', 'merchant' ), |
| 92 |
'desc' => esc_html__( 'Add image label', 'merchant' ), |
| 93 |
'icon' => MERCHANT_URI . 'assets/images/icons/product-labels/image-icon.svg', |
| 94 |
), |
| 95 |
), |
| 96 |
'default' => 'text', |
| 97 |
), |
| 98 |
|
| 99 |
array( |
| 100 |
'id' => 'label', |
| 101 |
'title' => esc_html__( 'Label content', 'merchant' ), |
| 102 |
'type' => 'text', |
| 103 |
'default' => esc_html__( 'SALE', 'merchant' ), |
| 104 |
'desc' => __( 'You can use these codes in the content.', 'merchant' ), |
| 105 |
'hidden_desc' => sprintf( |
| 106 |
/* Translators: %1$s: Discount percentage, %2$s: Discount amount, %3$s: In Stock, %4$s: Total quantity */ |
| 107 |
__( |
| 108 |
'<strong>%1$s:</strong> to show discount percentage<br><strong>%2$s:</strong> to show discount amount<br><strong>%3$s:</strong> to show In Stock, Sold Out<br><strong>%4$s:</strong> to show total quantity in inventory', |
| 109 |
'merchant' |
| 110 |
), |
| 111 |
'{sale}', |
| 112 |
'{sale_amount}', |
| 113 |
'{inventory}', |
| 114 |
'{inventory_quantity}' |
| 115 |
), |
| 116 |
'condition' => array( 'label_type', '==', 'text' ), |
| 117 |
), |
| 118 |
|
| 119 |
array( |
| 120 |
'id' => 'label_text_shape', |
| 121 |
'type' => 'choices', |
| 122 |
'title' => esc_html__( 'Label shape', 'merchant' ), |
| 123 |
'options' => $text_shapes, |
| 124 |
'default' => 'text-shape-1', |
| 125 |
'condition' => array( 'label_type', '==', 'text' ), |
| 126 |
), |
| 127 |
|
| 128 |
array( |
| 129 |
'id' => 'label_image_shape', |
| 130 |
'type' => 'choices', |
| 131 |
'title' => esc_html__( 'Image label', 'merchant' ), |
| 132 |
'options' => $image_shapes, |
| 133 |
'default' => 'image-shape-1', |
| 134 |
'condition' => array( 'label_type', '==', 'image' ), |
| 135 |
), |
| 136 |
|
| 137 |
array( |
| 138 |
'id' => 'label_image_shape_custom', |
| 139 |
'type' => 'upload', |
| 140 |
'drag_drop' => true, |
| 141 |
'title' => esc_html__( 'Upload custom image label', 'merchant' ), |
| 142 |
'label' => esc_html__( 'Click to upload or drag and drop', 'merchant' ), |
| 143 |
'condition' => array( 'label_type', '==', 'image' ), |
| 144 |
), |
| 145 |
|
| 146 |
array( |
| 147 |
'id' => 'position_anchor', |
| 148 |
'type' => 'select', |
| 149 |
'title' => esc_html__( 'Anchor Point', 'merchant' ), |
| 150 |
'desc' => esc_html__( 'Which point of the label to use as the anchor for positioning.', 'merchant' ), |
| 151 |
'options' => array( |
| 152 |
'top-left' => esc_html__( 'Top Left', 'merchant' ), |
| 153 |
'top-right' => esc_html__( 'Top Right', 'merchant' ), |
| 154 |
), |
| 155 |
'default' => 'top-left', |
| 156 |
), |
| 157 |
|
| 158 |
array( |
| 159 |
'id' => 'position_x', |
| 160 |
'type' => 'range', |
| 161 |
'title' => esc_html__( 'Horizontal Position (X)', 'merchant' ), |
| 162 |
'desc' => esc_html__( 'Horizontal position from left edge.', 'merchant' ), |
| 163 |
'min' => -300, |
| 164 |
'max' => 300, |
| 165 |
'step' => 1, |
| 166 |
'default' => 0, |
| 167 |
'unit' => 'px', |
| 168 |
), |
| 169 |
|
| 170 |
array( |
| 171 |
'id' => 'position_y', |
| 172 |
'type' => 'range', |
| 173 |
'title' => esc_html__( 'Vertical Position (Y)', 'merchant' ), |
| 174 |
'desc' => esc_html__( 'Vertical position from top edge.', 'merchant' ), |
| 175 |
'min' => -300, |
| 176 |
'max' => 300, |
| 177 |
'step' => 1, |
| 178 |
'default' => 0, |
| 179 |
'unit' => 'px', |
| 180 |
), |
| 181 |
|
| 182 |
array( |
| 183 |
'id' => 'label_width', |
| 184 |
'type' => 'range', |
| 185 |
'title' => esc_html__( 'Label width', 'merchant' ), |
| 186 |
'min' => 1, |
| 187 |
'max' => 1000, |
| 188 |
'step' => 1, |
| 189 |
'default' => 100, |
| 190 |
'unit' => 'px', |
| 191 |
), |
| 192 |
array( |
| 193 |
'id' => 'label_height', |
| 194 |
'type' => 'range', |
| 195 |
'title' => esc_html__( 'Label height', 'merchant' ), |
| 196 |
'min' => 1, |
| 197 |
'max' => 250, |
| 198 |
'step' => 1, |
| 199 |
'default' => 32, |
| 200 |
'unit' => 'px', |
| 201 |
), |
| 202 |
|
| 203 |
array( |
| 204 |
'id' => 'background_color', |
| 205 |
'type' => 'color', |
| 206 |
'title' => esc_html__( 'Background color', 'merchant' ), |
| 207 |
'default' => '#212121', |
| 208 |
'condition' => array( 'label_type', '==', 'text' ), |
| 209 |
), |
| 210 |
|
| 211 |
array( |
| 212 |
'id' => 'shape_radius', |
| 213 |
'type' => 'range', |
| 214 |
'title' => esc_html__( 'Shape radius', 'merchant' ), |
| 215 |
'min' => 0, |
| 216 |
'max' => 250, |
| 217 |
'step' => 1, |
| 218 |
'unit' => 'px', |
| 219 |
'default' => 5, |
| 220 |
'condition' => array( 'label_type', '==', 'text' ), |
| 221 |
), |
| 222 |
|
| 223 |
array( |
| 224 |
'id' => 'font_size', |
| 225 |
'type' => 'range', |
| 226 |
'title' => esc_html__( 'Font size', 'merchant' ), |
| 227 |
'min' => 0, |
| 228 |
'max' => 250, |
| 229 |
'step' => 1, |
| 230 |
'unit' => 'px', |
| 231 |
'default' => 14, |
| 232 |
'condition' => array( 'label_type', '==', 'text' ), |
| 233 |
), |
| 234 |
|
| 235 |
array( |
| 236 |
'id' => 'font_style', |
| 237 |
'type' => 'select', |
| 238 |
'title' => esc_html__( 'Font style', 'merchant' ), |
| 239 |
'options' => array( |
| 240 |
'normal' => esc_html__( 'Normal', 'merchant' ), |
| 241 |
'italic' => esc_html__( 'Italic', 'merchant' ), |
| 242 |
'bold' => esc_html__( 'Bold', 'merchant' ), |
| 243 |
'bold_italic' => esc_html__( 'Bold Italic', 'merchant' ), |
| 244 |
), |
| 245 |
'default' => 'normal', |
| 246 |
'condition' => array( 'label_type', '==', 'text' ), |
| 247 |
), |
| 248 |
|
| 249 |
array( |
| 250 |
'id' => 'text_color', |
| 251 |
'type' => 'color', |
| 252 |
'title' => esc_html__( 'Font color', 'merchant' ), |
| 253 |
'default' => '#ffffff', |
| 254 |
'condition' => array( 'label_type', '==', 'text' ), |
| 255 |
), |
| 256 |
|
| 257 |
array( |
| 258 |
'id' => 'display_rules', |
| 259 |
'type' => 'select', |
| 260 |
'title' => esc_html__( 'Product trigger', 'merchant' ), |
| 261 |
'options' => $display_rules, |
| 262 |
'default' => 'products_on_sale', |
| 263 |
), |
| 264 |
|
| 265 |
array( |
| 266 |
'id' => 'new_products_days', |
| 267 |
'type' => 'number', |
| 268 |
'min' => 0, |
| 269 |
'step' => 1, |
| 270 |
'title' => esc_html__( 'How long counts as new', 'merchant' ), |
| 271 |
'desc' => esc_html__( 'Set the number of days the product will be marked as ‘New’ after it has been created', 'merchant' ), |
| 272 |
'default' => 3, |
| 273 |
'condition' => array( 'display_rules', '==', 'new_products' ), |
| 274 |
), |
| 275 |
|
| 276 |
array( |
| 277 |
'id' => 'product_cats', |
| 278 |
'type' => 'select_ajax', |
| 279 |
'title' => esc_html__( 'Categories', 'merchant' ), |
| 280 |
'source' => 'options', |
| 281 |
'multiple' => true, |
| 282 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 283 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 284 |
'desc' => esc_html__( 'Select the product categories that will show the label.', 'merchant' ), |
| 285 |
'condition' => array( 'display_rules', '==', 'by_category' ), |
| 286 |
), |
| 287 |
|
| 288 |
array( |
| 289 |
'id' => 'product_tags', |
| 290 |
'type' => 'select_ajax', |
| 291 |
'title' => esc_html__( 'Tags', 'merchant' ), |
| 292 |
'source' => 'options', |
| 293 |
'multiple' => true, |
| 294 |
'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 295 |
'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 296 |
'desc' => esc_html__( 'Select the product tags that will show the label.', 'merchant' ), |
| 297 |
'condition' => array( 'display_rules', '==', 'by_tags' ), |
| 298 |
), |
| 299 |
|
| 300 |
array( |
| 301 |
'id' => 'product_brands', |
| 302 |
'type' => 'select_ajax', |
| 303 |
'title' => esc_html__( 'Brands', 'merchant' ), |
| 304 |
'source' => 'options', |
| 305 |
'multiple' => true, |
| 306 |
'options' => Merchant_Admin_Options::get_brand_select2_choices(), |
| 307 |
'placeholder' => esc_html__( 'Select brands', 'merchant' ), |
| 308 |
'desc' => esc_html__( 'Select the product brands that will show the label.', 'merchant' ), |
| 309 |
'condition' => array( 'display_rules', '==', 'by_brands' ), |
| 310 |
), |
| 311 |
|
| 312 |
array( |
| 313 |
'id' => 'product_ids', |
| 314 |
'type' => 'products_selector', |
| 315 |
'multiple' => true, |
| 316 |
'desc' => esc_html__( 'Select the products that will show the label.', 'merchant' ), |
| 317 |
'allowed_types' => array( 'simple', 'variable' ), |
| 318 |
'condition' => array( 'display_rules', '==', 'specific_products' ), |
| 319 |
), |
| 320 |
|
| 321 |
array( |
| 322 |
'id' => 'exclude_products_toggle', |
| 323 |
'type' => 'switcher', |
| 324 |
'title' => esc_html__( 'Exclude Products', 'merchant' ), |
| 325 |
'desc' => esc_html__( 'Exclude specific products from this label.', 'merchant' ), |
| 326 |
'default' => 0, |
| 327 |
'conditions' => array( |
| 328 |
'relation' => 'AND', |
| 329 |
'terms' => array( |
| 330 |
array( |
| 331 |
'field' => 'display_rules', |
| 332 |
'operator' => 'in', |
| 333 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 334 |
), |
| 335 |
), |
| 336 |
), |
| 337 |
), |
| 338 |
|
| 339 |
array( |
| 340 |
'id' => 'excluded_products', |
| 341 |
'type' => 'products_selector', |
| 342 |
'title' => esc_html__( 'Excluded Products List', 'merchant' ), |
| 343 |
'desc' => esc_html__( 'Exclude products from this label.', 'merchant' ), |
| 344 |
'multiple' => true, |
| 345 |
'allowed_types' => array( 'simple', 'variable' ), |
| 346 |
'conditions' => array( |
| 347 |
'relation' => 'AND', |
| 348 |
'terms' => array( |
| 349 |
array( |
| 350 |
'field' => 'display_rules', |
| 351 |
'operator' => 'in', |
| 352 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 353 |
), |
| 354 |
array( |
| 355 |
'field' => 'exclude_products_toggle', |
| 356 |
'operator' => '===', |
| 357 |
'value' => true, |
| 358 |
), |
| 359 |
), |
| 360 |
), |
| 361 |
), |
| 362 |
|
| 363 |
array( |
| 364 |
'id' => 'exclude_categories_toggle', |
| 365 |
'type' => 'switcher', |
| 366 |
'title' => esc_html__( 'Exclude Categories', 'merchant' ), |
| 367 |
'desc' => esc_html__( 'Exclude specific categories from this label.', 'merchant' ), |
| 368 |
'default' => 0, |
| 369 |
'conditions' => array( |
| 370 |
'relation' => 'AND', |
| 371 |
'terms' => array( |
| 372 |
array( |
| 373 |
'field' => 'display_rules', |
| 374 |
'operator' => 'in', |
| 375 |
'value' => array( 'all_products', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 376 |
), |
| 377 |
), |
| 378 |
), |
| 379 |
), |
| 380 |
|
| 381 |
array( |
| 382 |
'id' => 'excluded_categories', |
| 383 |
'type' => 'select_ajax', |
| 384 |
'title' => esc_html__( 'Excluded Categories List', 'merchant' ), |
| 385 |
'source' => 'options', |
| 386 |
'multiple' => true, |
| 387 |
'options' => Merchant_Admin_Options::get_category_select2_choices(), |
| 388 |
'placeholder' => esc_html__( 'Select categories', 'merchant' ), |
| 389 |
'desc' => esc_html__( 'Exclude categories from this label.', 'merchant' ), |
| 390 |
'conditions' => array( |
| 391 |
'relation' => 'AND', |
| 392 |
'terms' => array( |
| 393 |
array( |
| 394 |
'field' => 'display_rules', |
| 395 |
'operator' => 'in', |
| 396 |
'value' => array( 'all_products', 'by_tags', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 397 |
), |
| 398 |
array( |
| 399 |
'field' => 'exclude_categories_toggle', |
| 400 |
'operator' => '===', |
| 401 |
'value' => true, |
| 402 |
), |
| 403 |
), |
| 404 |
), |
| 405 |
), |
| 406 |
|
| 407 |
array( |
| 408 |
'id' => 'exclude_tags_toggle', |
| 409 |
'type' => 'switcher', |
| 410 |
'title' => esc_html__( 'Exclude Tags', 'merchant' ), |
| 411 |
'desc' => esc_html__( 'Exclude specific tags from this label.', 'merchant' ), |
| 412 |
'default' => 0, |
| 413 |
'conditions' => array( |
| 414 |
'relation' => 'AND', |
| 415 |
'terms' => array( |
| 416 |
array( |
| 417 |
'field' => 'display_rules', |
| 418 |
'operator' => 'in', |
| 419 |
'value' => array( 'all_products', 'by_category', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 420 |
), |
| 421 |
), |
| 422 |
), |
| 423 |
), |
| 424 |
|
| 425 |
array( |
| 426 |
'id' => 'excluded_tags', |
| 427 |
'type' => 'select_ajax', |
| 428 |
'title' => esc_html__( 'Excluded Tags List', 'merchant' ), |
| 429 |
'source' => 'options', |
| 430 |
'multiple' => true, |
| 431 |
'options' => Merchant_Admin_Options::get_tag_select2_choices(), |
| 432 |
'placeholder' => esc_html__( 'Select tags', 'merchant' ), |
| 433 |
'desc' => esc_html__( 'Exclude tags from this label.', 'merchant' ), |
| 434 |
'conditions' => array( |
| 435 |
'relation' => 'AND', |
| 436 |
'terms' => array( |
| 437 |
array( |
| 438 |
'field' => 'display_rules', |
| 439 |
'operator' => 'in', |
| 440 |
'value' => array( 'all_products', 'by_category', 'by_brands', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 441 |
), |
| 442 |
array( |
| 443 |
'field' => 'exclude_tags_toggle', |
| 444 |
'operator' => '===', |
| 445 |
'value' => true, |
| 446 |
), |
| 447 |
), |
| 448 |
), |
| 449 |
), |
| 450 |
|
| 451 |
array( |
| 452 |
'id' => 'exclude_brands_toggle', |
| 453 |
'type' => 'switcher', |
| 454 |
'title' => esc_html__( 'Exclude Brands', 'merchant' ), |
| 455 |
'desc' => esc_html__( 'Exclude specific brands from this label.', 'merchant' ), |
| 456 |
'default' => 0, |
| 457 |
'conditions' => array( |
| 458 |
'relation' => 'AND', |
| 459 |
'terms' => array( |
| 460 |
array( |
| 461 |
'field' => 'display_rules', |
| 462 |
'operator' => 'in', |
| 463 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 464 |
), |
| 465 |
), |
| 466 |
), |
| 467 |
), |
| 468 |
|
| 469 |
array( |
| 470 |
'id' => 'excluded_brands', |
| 471 |
'type' => 'select_ajax', |
| 472 |
'title' => esc_html__( 'Excluded Brands List', 'merchant' ), |
| 473 |
'source' => 'options', |
| 474 |
'multiple' => true, |
| 475 |
'options' => Merchant_Admin_Options::get_brand_select2_choices(), |
| 476 |
'placeholder' => esc_html__( 'Select brands', 'merchant' ), |
| 477 |
'desc' => esc_html__( 'Exclude brands from this label.', 'merchant' ), |
| 478 |
'conditions' => array( |
| 479 |
'relation' => 'AND', |
| 480 |
'terms' => array( |
| 481 |
array( |
| 482 |
'field' => 'display_rules', |
| 483 |
'operator' => 'in', |
| 484 |
'value' => array( 'all_products', 'by_category', 'by_tags', 'featured_products', 'new_products', 'products_on_sale', 'out_of_stock', 'pre-order' ), |
| 485 |
), |
| 486 |
array( |
| 487 |
'field' => 'exclude_brands_toggle', |
| 488 |
'operator' => '===', |
| 489 |
'value' => true, |
| 490 |
), |
| 491 |
), |
| 492 |
), |
| 493 |
), |
| 494 |
|
| 495 |
array( |
| 496 |
'id' => 'show_pages', |
| 497 |
'type' => 'checkbox_multiple', |
| 498 |
'title' => esc_html__( 'Show on pages', 'merchant' ), |
| 499 |
'options' => array( |
| 500 |
'homepage' => esc_html__( 'Homepage', 'merchant' ), |
| 501 |
'single' => esc_html__( 'Product Single', 'merchant' ), |
| 502 |
'archive' => esc_html__( 'Product Archive', 'merchant' ), |
| 503 |
), |
| 504 |
'default' => array( 'homepage', 'single', 'archive' ), |
| 505 |
), |
| 506 |
|
| 507 |
array( |
| 508 |
'id' => 'show_devices', |
| 509 |
'type' => 'checkbox_multiple', |
| 510 |
'title' => esc_html__( 'Show on devices', 'merchant' ), |
| 511 |
'options' => array( |
| 512 |
'desktop' => esc_html__( 'Desktop', 'merchant' ), |
| 513 |
'mobile' => esc_html__( 'Mobile', 'merchant' ), |
| 514 |
), |
| 515 |
'default' => array( 'desktop', 'mobile' ), |
| 516 |
), |
| 517 |
), |
| 518 |
), |
| 519 |
), |
| 520 |
'default' => array( |
| 521 |
array( |
| 522 |
'layout' => 'single-label', |
| 523 |
'label' => esc_html__( 'SALE', 'merchant' ), |
| 524 |
'display_rules' => 'featured_products', |
| 525 |
), |
| 526 |
), |
| 527 |
), |
| 528 |
array( |
| 529 |
'id' => 'multiple_labels', |
| 530 |
'type' => 'switcher', |
| 531 |
'title' => __( 'Use multiple labels', 'merchant' ), |
| 532 |
'desc' => __( 'Enable this to display multiple labels assigned to the product when multiple labels are available.', 'merchant' ), |
| 533 |
'default' => 0, |
| 534 |
), |
| 535 |
), |
| 536 |
) ); |
| 537 |
|
| 538 |
// Shortcode |
| 539 |
$merchant_module_id = Merchant_Product_Labels::MODULE_ID; |
| 540 |
Merchant_Admin_Options::create( array( |
| 541 |
'module' => $merchant_module_id, |
| 542 |
'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 543 |
'fields' => array( |
| 544 |
array( |
| 545 |
'id' => 'use_shortcode', |
| 546 |
'type' => 'switcher', |
| 547 |
'title' => __( 'Use shortcode', 'merchant' ), |
| 548 |
'default' => 0, |
| 549 |
), |
| 550 |
array( |
| 551 |
'type' => 'info', |
| 552 |
'id' => 'shortcode_info', |
| 553 |
'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' ), |
| 554 |
), |
| 555 |
array( |
| 556 |
'id' => 'shortcode_text', |
| 557 |
'type' => 'text_readonly', |
| 558 |
'title' => esc_html__( 'Shortcode text', 'merchant' ), |
| 559 |
'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']', |
| 560 |
'condition' => array( 'use_shortcode', '==', '1' ), |
| 561 |
), |
| 562 |
), |
| 563 |
) ); |
| 564 |
|