| 1 |
<?php |
| 2 |
/** |
| 3 |
* Merchant - Product Labels |
| 4 |
*/ |
| 5 |
|
| 6 |
if ( ! defined( 'ABSPATH' ) ) { |
| 7 |
exit; // Exit if accessed directly |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Settings |
| 12 |
*/ |
| 13 |
Merchant_Admin_Options::create( array( |
| 14 |
'title' => esc_html__( 'Settings', 'merchant' ), |
| 15 |
'module' => Merchant_Product_Labels::MODULE_ID, |
| 16 |
'fields' => array( |
| 17 |
array( |
| 18 |
'id' => 'labels', |
| 19 |
'type' => 'flexible_content', |
| 20 |
'sorting' => true, |
| 21 |
'style' => Merchant_Product_Labels::MODULE_ID . '-style default', |
| 22 |
'button_label' => esc_html__( 'Add', 'merchant' ), |
| 23 |
'layouts' => array( |
| 24 |
'single-label' => array( |
| 25 |
'title' => esc_html__( 'Products Label', 'merchant' ), |
| 26 |
'fields' => array( |
| 27 |
array( |
| 28 |
'id' => 'label', |
| 29 |
'title' => esc_html__( 'Label', 'merchant' ), |
| 30 |
'type' => 'text', |
| 31 |
'default' => esc_html__( 'Spring Special', 'merchant' ), |
| 32 |
), |
| 33 |
array( |
| 34 |
'id' => 'pages_to_display', |
| 35 |
'type' => 'radio', |
| 36 |
'title' => esc_html__( 'Pages to display', 'merchant' ), |
| 37 |
'options' => array( |
| 38 |
'both' => esc_html__( 'Both', 'merchant' ), |
| 39 |
'archive' => esc_html__( 'Archive', 'merchant' ), |
| 40 |
'single' => esc_html__( 'Single', 'merchant' ), |
| 41 |
), |
| 42 |
'default' => 'both', |
| 43 |
), |
| 44 |
array( |
| 45 |
'id' => 'display_rules', |
| 46 |
'type' => 'select', |
| 47 |
'title' => esc_html__( 'Display Rules', 'merchant' ), |
| 48 |
'options' => array( |
| 49 |
'featured_products' => esc_html__( 'Featured Products', 'merchant' ), |
| 50 |
'products_on_sale' => esc_html__( 'Products on Sale', 'merchant' ), |
| 51 |
'new_products' => esc_html__( 'New Products', 'merchant' ), |
| 52 |
'out_of_stock' => esc_html__( 'Out of Stock', 'merchant' ), |
| 53 |
'by_category' => esc_html__( 'By Product Category', 'merchant' ), |
| 54 |
), |
| 55 |
'default' => 'featured_products', |
| 56 |
), |
| 57 |
array( |
| 58 |
'id' => 'new_products_days', |
| 59 |
'type' => 'number', |
| 60 |
'min' => 0, |
| 61 |
'step' => 1, |
| 62 |
'title' => esc_html__( 'How long counts as new', 'merchant' ), |
| 63 |
'desc' => esc_html__( 'Set the number of days the product will be marked as ‘New’ after it has been created', 'merchant' ), |
| 64 |
'default' => 3, |
| 65 |
'condition' => array( 'display_rules', '==', 'new_products' ), |
| 66 |
), |
| 67 |
array( |
| 68 |
'id' => 'percentage_text', |
| 69 |
'type' => 'text', |
| 70 |
'title' => esc_html__( 'Sale Percentage', 'merchant' ), |
| 71 |
'default' => '-{value}%', |
| 72 |
'desc' => esc_html__( 'You may use the {value} tag. E.g. {value}% OFF!', 'merchant' ), |
| 73 |
'condition' => array( 'display_rules', '==', 'products_on_sale' ), |
| 74 |
), |
| 75 |
array( |
| 76 |
'id' => 'product_cats', |
| 77 |
'type' => 'select', |
| 78 |
'title' => esc_html__( 'Product Categories', 'merchant' ), |
| 79 |
'options' => merchant_get_product_categories(), |
| 80 |
'condition' => array( 'display_rules', '==', 'by_category' ), |
| 81 |
), |
| 82 |
array( |
| 83 |
'id' => 'background_color', |
| 84 |
'type' => 'color', |
| 85 |
'title' => esc_html__( 'Background color', 'merchant' ), |
| 86 |
'default' => '#212121', |
| 87 |
), |
| 88 |
array( |
| 89 |
'id' => 'text_color', |
| 90 |
'type' => 'color', |
| 91 |
'title' => esc_html__( 'Text color', 'merchant' ), |
| 92 |
'default' => '#ffffff', |
| 93 |
), |
| 94 |
), |
| 95 |
|
| 96 |
), |
| 97 |
), |
| 98 |
'default' => array( |
| 99 |
array( |
| 100 |
'layout' => 'single-label', |
| 101 |
'label' => Merchant_Admin_Options::get( Merchant_Product_Labels::MODULE_ID, 'label_text', esc_html__( 'Spring Special', 'merchant' ) ), |
| 102 |
'pages_to_display' => 'both', |
| 103 |
'display_rules' => 'products_on_sale', |
| 104 |
'percentage_text' => Merchant_Admin_Options::get( Merchant_Product_Labels::MODULE_ID, 'percentage_text', '-{value}%' ), |
| 105 |
'background_color' => Merchant_Admin_Options::get( Merchant_Product_Labels::MODULE_ID, 'background_color', '#212121' ), |
| 106 |
'text_color' => Merchant_Admin_Options::get( Merchant_Product_Labels::MODULE_ID, 'text_color', '#ffffff' ), |
| 107 |
), |
| 108 |
), |
| 109 |
), |
| 110 |
array( |
| 111 |
'id' => 'label_position', |
| 112 |
'type' => 'select', |
| 113 |
'title' => esc_html__( 'Position', 'merchant' ), |
| 114 |
'options' => array( |
| 115 |
'top-left' => esc_html__( 'Top left', 'merchant' ), |
| 116 |
'top-right' => esc_html__( 'Top right', 'merchant' ), |
| 117 |
), |
| 118 |
'default' => 'left', |
| 119 |
), |
| 120 |
|
| 121 |
array( |
| 122 |
'id' => 'label_shape', |
| 123 |
'type' => 'range', |
| 124 |
'title' => esc_html__( 'Shape radius', 'merchant' ), |
| 125 |
'min' => 0, |
| 126 |
'max' => 35, |
| 127 |
'step' => 1, |
| 128 |
'unit' => 'px', |
| 129 |
'default' => 0, |
| 130 |
), |
| 131 |
|
| 132 |
array( |
| 133 |
'id' => 'label_text_transform', |
| 134 |
'type' => 'select', |
| 135 |
'title' => esc_html__( 'Letter case', 'merchant' ), |
| 136 |
'options' => array( |
| 137 |
'uppercase' => esc_html__( 'Uppercase', 'merchant' ), |
| 138 |
'lowercase' => esc_html__( 'Lowercase', 'merchant' ), |
| 139 |
'capitalize' => esc_html__( 'Capitalize', 'merchant' ), |
| 140 |
'none' => esc_html__( 'None', 'merchant' ), |
| 141 |
), |
| 142 |
'default' => 'uppercase', |
| 143 |
), |
| 144 |
|
| 145 |
array( |
| 146 |
'id' => 'padding', |
| 147 |
'type' => 'range', |
| 148 |
'title' => esc_html__( 'Padding', 'merchant' ), |
| 149 |
'min' => 0, |
| 150 |
'max' => 250, |
| 151 |
'step' => 1, |
| 152 |
'unit' => 'px', |
| 153 |
'default' => 8, |
| 154 |
), |
| 155 |
|
| 156 |
array( |
| 157 |
'id' => 'font-size', |
| 158 |
'type' => 'range', |
| 159 |
'title' => esc_html__( 'Font size', 'merchant' ), |
| 160 |
'min' => 0, |
| 161 |
'max' => 250, |
| 162 |
'step' => 1, |
| 163 |
'unit' => 'px', |
| 164 |
'default' => 14, |
| 165 |
), |
| 166 |
), |
| 167 |
) ); |
| 168 |
|