| 1 |
<?php |
| 2 |
|
| 3 |
namespace FilterEverything\Filter; |
| 4 |
|
| 5 |
if ( ! defined('ABSPATH') ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
class ExperimentalTab extends BaseSettings |
| 10 |
{ |
| 11 |
protected $page = 'wpc-filter-experimental-settings'; |
| 12 |
|
| 13 |
protected $group = 'wpc_filter_experimental'; |
| 14 |
|
| 15 |
protected $optionName = 'wpc_filter_experimental'; |
| 16 |
|
| 17 |
public function init() |
| 18 |
{ |
| 19 |
add_action('admin_init', array($this, 'initSettings')); |
| 20 |
} |
| 21 |
|
| 22 |
public function initSettings() |
| 23 |
{ |
| 24 |
register_setting($this->group, $this->optionName); |
| 25 |
$taxonomies = EntityManager::getTaxonomies(); |
| 26 |
$taxonomiesForSelect = []; |
| 27 |
|
| 28 |
foreach( $taxonomies as $taxonomy ) { |
| 29 |
$taxonomiesForSelect[ $taxonomy->name ] = ucwords( flrt_ucfirst( mb_strtolower( $taxonomy->label ) ) ); |
| 30 |
|
| 31 |
if ( $taxonomy->name === 'elementor_library_category' ) { |
| 32 |
$taxonomiesForSelect[ $taxonomy->name ] .= ' ' . esc_html__( '(Elementor Library)', 'filter-everything' ); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
$settings = array( |
| 37 |
'ajax_settings' => array( |
| 38 |
'label' => esc_html__('AJAX', 'filter-everything'), |
| 39 |
'fields' => array( |
| 40 |
'use_loader' => array( |
| 41 |
'type' => 'checkbox', |
| 42 |
'title' => esc_html__('AJAX loading icon (on desktop only)', 'filter-everything'), |
| 43 |
'id' => 'use_loader', |
| 44 |
'label' => esc_html__('Show icon', 'filter-everything'), |
| 45 |
), |
| 46 |
'use_wait_cursor' => array( |
| 47 |
'type' => 'checkbox', |
| 48 |
'title' => esc_html__('Wait Cursor (on desktop only)', 'filter-everything'), |
| 49 |
'id' => 'use_wait_cursor', |
| 50 |
'label' => esc_html__('Use Wait Cursor for AJAX', 'filter-everything'), |
| 51 |
), |
| 52 |
'dark_overlay' => array( |
| 53 |
'type' => 'checkbox', |
| 54 |
'title' => esc_html__('Dark Overlay (on desktop only)', 'filter-everything'), |
| 55 |
'id' => 'dark_overlay', |
| 56 |
'label' => esc_html__('Use a dark transparent overlay instead of white', 'filter-everything'), |
| 57 |
), |
| 58 |
'auto_scroll' => array( |
| 59 |
'type' => 'checkbox', |
| 60 |
'title' => esc_html__('Smart Auto Scroll (on desktop only)', 'filter-everything'), |
| 61 |
'id' => 'auto_scroll', |
| 62 |
'label' => esc_html__('Automatically Scroll to the top of the posts grid', 'filter-everything'), |
| 63 |
) |
| 64 |
) |
| 65 |
), |
| 66 |
'layout_settings' => array( |
| 67 |
'label' => esc_html__('Appearance', 'filter-everything'), |
| 68 |
'fields' => array( |
| 69 |
'styled_inputs' => array( |
| 70 |
'type' => 'checkbox', |
| 71 |
'title' => esc_html__('Styled checkboxes and radio buttons', 'filter-everything'), |
| 72 |
'id' => 'styled_inputs', |
| 73 |
'label' => esc_html__('Enable styling', 'filter-everything'), |
| 74 |
), |
| 75 |
'select2_dropdowns' => array( |
| 76 |
'type' => 'checkbox', |
| 77 |
'title' => esc_html__('Improved dropdowns', 'filter-everything'), |
| 78 |
'id' => 'select2_dropdowns', |
| 79 |
'label' => esc_html__('Use improved dropdowns instead of regular ones (jQuery plugin Select2)', 'filter-everything'), |
| 80 |
), |
| 81 |
) |
| 82 |
) |
| 83 |
); |
| 84 |
|
| 85 |
if( flrt_is_woocommerce() ){ |
| 86 |
$settings['woocommerce_settings'] = array( |
| 87 |
'label' => esc_html__('WooCommerce', 'filter-everything'), |
| 88 |
'fields' => array( |
| 89 |
'disable_woo_orderby' => array( |
| 90 |
'type' => 'checkbox', |
| 91 |
'title' => esc_html__('Woocommerce Order By dropdown', 'filter-everything'), |
| 92 |
'id' => 'disable_woo_orderby', |
| 93 |
'label' => esc_html__('Hide Woocommerce default sorting dropdown', 'filter-everything'), |
| 94 |
), |
| 95 |
'hide_out_of_stock' => array( |
| 96 |
'type' => (defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO) ? 'checkbox' : 'inProButton', |
| 97 |
'pro_label' => (defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO) ? '' : flrt_pro_promo_label(), |
| 98 |
'title' => esc_html__('Out of stock visibility', 'filter-everything'), |
| 99 |
'id' => 'hide_out_of_stock', |
| 100 |
'label' => esc_html__('Hide out of stock items from filtering results', 'filter-everything'), |
| 101 |
'description' => esc_html__( 'It also hides variable products if their variations are out of stock. Please do not use it together with the Filter by the Stock status!', 'filter-everything' ), |
| 102 |
) |
| 103 |
) |
| 104 |
); |
| 105 |
} |
| 106 |
|
| 107 |
$settings['experimental_other'] = array( |
| 108 |
'label' => esc_html__('Other', 'filter-everything'), |
| 109 |
'fields' => array( |
| 110 |
'use_color_swatches' => array( |
| 111 |
'type' => 'checkbox', |
| 112 |
'title' => esc_html__('Color swatches for Filters', 'filter-everything'), |
| 113 |
'id' => 'use_color_swatches', |
| 114 |
'label' => esc_html__('Enable Color swatches', 'filter-everything'), |
| 115 |
), |
| 116 |
'color_swatches_taxonomies' => array( |
| 117 |
'type' => 'select', |
| 118 |
'class' => 'wpc-color-swatches-taxonomies', |
| 119 |
'title' => esc_html__('Taxonomies for Color swatches', 'filter-everything'), |
| 120 |
'id' => 'color_swatches_taxonomies', |
| 121 |
'options' => $taxonomiesForSelect, |
| 122 |
'multiple' => true, |
| 123 |
'description' => esc_html__( 'Please specify taxonomies whose filters should display color swatches', 'filter-everything' ) |
| 124 |
), |
| 125 |
'rounded_swatches' => array( |
| 126 |
'type' => 'checkbox', |
| 127 |
'class' => 'wpc-color-swatches-taxonomies', |
| 128 |
'title' => esc_html__('Rounded swatches', 'filter-everything'), |
| 129 |
'id' => 'rounded_swatches', |
| 130 |
'label' => esc_html__('Make swatches rounded', 'filter-everything'), |
| 131 |
), |
| 132 |
) |
| 133 |
); |
| 134 |
|
| 135 |
$settings['customization'] = array( |
| 136 |
'label' => esc_html__('Customization', 'filter-everything'), |
| 137 |
'fields' => array( |
| 138 |
'custom_css' => array( |
| 139 |
'type' => 'textarea', |
| 140 |
'title' => esc_html__('Custom CSS', 'filter-everything'), |
| 141 |
'id' => 'custom_css', |
| 142 |
'label' => '' |
| 143 |
) |
| 144 |
) |
| 145 |
); |
| 146 |
|
| 147 |
$settings = apply_filters('wpc_experimental_filters_settings', $settings); |
| 148 |
|
| 149 |
$this->registerSettings($settings, $this->page, $this->optionName); |
| 150 |
} |
| 151 |
|
| 152 |
public function getLabel() |
| 153 |
{ |
| 154 |
return esc_html__('Experimental', 'filter-everything'); |
| 155 |
} |
| 156 |
|
| 157 |
public function getName() |
| 158 |
{ |
| 159 |
return 'experimental'; |
| 160 |
} |
| 161 |
|
| 162 |
public function valid() |
| 163 |
{ |
| 164 |
return true; |
| 165 |
} |
| 166 |
} |