| 1 |
<?php |
| 2 |
/** |
| 3 |
* Merchant - Real Time Search |
| 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' => 'real-time-search', |
| 16 |
'fields' => array( |
| 17 |
|
| 18 |
array( |
| 19 |
'id' => 'results_amounth_per_search', |
| 20 |
'type' => 'range', |
| 21 |
'title' => esc_html__( 'Results amount per search', 'merchant' ), |
| 22 |
'desc' => esc_html__( 'Control the maximum amount of products to show in the search results.', 'merchant' ), |
| 23 |
'min' => 1, |
| 24 |
'max' => 100, |
| 25 |
'step' => 1, |
| 26 |
'default' => 5, |
| 27 |
), |
| 28 |
|
| 29 |
array( |
| 30 |
'id' => 'results_description', |
| 31 |
'type' => 'select', |
| 32 |
'title' => esc_html__( 'Results description', 'merchant' ), |
| 33 |
'options' => array( |
| 34 |
'product-post-content' => esc_html__( 'Product Description', 'merchant' ), |
| 35 |
'product-short-description' => esc_html__( 'Product short description', 'merchant' ), |
| 36 |
), |
| 37 |
'default' => 'product-short-description', |
| 38 |
), |
| 39 |
|
| 40 |
array( |
| 41 |
'id' => 'results_description_length', |
| 42 |
'type' => 'range', |
| 43 |
'title' => esc_html__( 'Results description length', 'merchant' ), |
| 44 |
'desc' => esc_html__( 'The number of words to show in the description of the results.', 'merchant' ), |
| 45 |
'min' => 1, |
| 46 |
'max' => 100, |
| 47 |
'step' => 1, |
| 48 |
'default' => 10, |
| 49 |
), |
| 50 |
|
| 51 |
array( |
| 52 |
'id' => 'results_order_by', |
| 53 |
'type' => 'select', |
| 54 |
'title' => esc_html__( 'Results order by', 'merchant' ), |
| 55 |
'options' => array( |
| 56 |
'none' => esc_html__( 'None', 'merchant' ), |
| 57 |
'title' => esc_html__( 'Product name', 'merchant' ), |
| 58 |
'date' => esc_html__( 'Published date', 'merchant' ), |
| 59 |
'modified' => esc_html__( 'Modified date', 'merchant' ), |
| 60 |
'rand' => esc_html__( 'Random', 'merchant' ), |
| 61 |
'price' => esc_html__( 'Product price', 'merchant' ), |
| 62 |
), |
| 63 |
'default' => 'title', |
| 64 |
), |
| 65 |
|
| 66 |
array( |
| 67 |
'id' => 'results_order', |
| 68 |
'type' => 'select', |
| 69 |
'title' => esc_html__( 'Results order', 'merchant' ), |
| 70 |
'options' => array( |
| 71 |
'asc' => esc_html__( 'Ascendant', 'merchant' ), |
| 72 |
'desc' => esc_html__( 'Descendant', 'merchant' ), |
| 73 |
), |
| 74 |
'default' => 'asc', |
| 75 |
), |
| 76 |
|
| 77 |
array( |
| 78 |
'id' => 'results_box_width', |
| 79 |
'type' => 'range', |
| 80 |
'title' => esc_html__( 'Results box width', 'merchant' ), |
| 81 |
'min' => 1, |
| 82 |
'max' => 1000, |
| 83 |
'step' => 1, |
| 84 |
'default' => 500, |
| 85 |
'unit' => 'px', |
| 86 |
), |
| 87 |
|
| 88 |
array( |
| 89 |
'id' => 'display_categories', |
| 90 |
'type' => 'checkbox', |
| 91 |
'label' => esc_html__( 'Display categories', 'merchant' ), |
| 92 |
'desc' => esc_html__( 'Display product categories in the results if the searched term matches with category name.', 'merchant' ), |
| 93 |
'default' => false, |
| 94 |
), |
| 95 |
|
| 96 |
array( |
| 97 |
'id' => 'enable_search_by_sku', |
| 98 |
'type' => 'checkbox', |
| 99 |
'label' => esc_html__( 'Enable search by SKU', 'merchant' ), |
| 100 |
'desc' => esc_html__( 'Return search results based on either product name or SKU.', 'merchant' ), |
| 101 |
'default' => false, |
| 102 |
), |
| 103 |
|
| 104 |
), |
| 105 |
) ); |
| 106 |
|
| 107 |
|
| 108 |
// Shortcode |
| 109 |
$merchant_module_id = Merchant_Real_Time_Search::MODULE_ID; |
| 110 |
Merchant_Admin_Options::create( array( |
| 111 |
'module' => $merchant_module_id, |
| 112 |
'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 113 |
'fields' => array( |
| 114 |
array( |
| 115 |
'id' => 'use_shortcode', |
| 116 |
'type' => 'switcher', |
| 117 |
'title' => esc_html__( 'Use shortcode', 'merchant' ), |
| 118 |
'default' => 0, |
| 119 |
), |
| 120 |
array( |
| 121 |
'type' => 'info', |
| 122 |
'id' => 'shortcode_info', |
| 123 |
'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.', 'merchant' ), |
| 124 |
), |
| 125 |
array( |
| 126 |
'id' => 'shortcode_text', |
| 127 |
'type' => 'text_readonly', |
| 128 |
'title' => esc_html__( 'Shortcode text', 'merchant' ), |
| 129 |
'default' => '[merchant_module_' . str_replace( '-', '_', $merchant_module_id ) . ']', |
| 130 |
'condition' => array( 'use_shortcode', '==', '1' ), |
| 131 |
), |
| 132 |
), |
| 133 |
) ); |
| 134 |
|