| 1 |
<?php |
| 2 |
|
| 3 |
namespace FilterEverything\Filter; |
| 4 |
|
| 5 |
if ( ! defined('ABSPATH') ) { |
| 6 |
exit; |
| 7 |
} |
| 8 |
|
| 9 |
use FilterEverything\Filter\Pro\Api\ApiRequests; |
| 10 |
use FilterEverything\Filter\Shortcodes; |
| 11 |
use FilterEverything\Filter\Pro\PluginPro; |
| 12 |
use FilterEverything\Filter\DefaultSettings; |
| 13 |
use FilterEverything\Filter\PluginHelpers; |
| 14 |
|
| 15 |
class Plugin |
| 16 |
{ |
| 17 |
use PluginHelpers; |
| 18 |
private $wpManager; |
| 19 |
|
| 20 |
public function __construct() |
| 21 |
{ |
| 22 |
$this->wpManager = Container::instance()->getWpManager(); |
| 23 |
$this->wpManager->init(); |
| 24 |
$this->register_hooks(); |
| 25 |
|
| 26 |
new Shortcodes(); |
| 27 |
|
| 28 |
if( defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO ){ |
| 29 |
new PluginPro(); |
| 30 |
} |
| 31 |
|
| 32 |
if( is_admin() ){ |
| 33 |
new Admin(); |
| 34 |
} |
| 35 |
} |
| 36 |
|
| 37 |
public function register_hooks(){ |
| 38 |
/** |
| 39 |
* string |
| 40 |
*/ |
| 41 |
$getData = Container::instance()->getTheGet(); |
| 42 |
|
| 43 |
if( ! is_admin() ){ |
| 44 |
global $wp_version; |
| 45 |
|
| 46 |
// Different ParseRequest methods for WP version 6.0 or prior |
| 47 |
if( version_compare( $wp_version, '5.9.3', '>' ) ){ |
| 48 |
add_filter( 'do_parse_request', array( $this->wpManager, 'customParseRequest' ), 10, 3 ); |
| 49 |
}else{ |
| 50 |
add_filter( 'do_parse_request', array( $this->wpManager, 'customParseRequestBefore60' ), 10, 3 ); |
| 51 |
} |
| 52 |
|
| 53 |
add_action( 'parse_request', array( $this->wpManager, 'parseRequest' ) ); |
| 54 |
add_action( 'pre_get_posts', array( $this->wpManager, 'addFilterQueryToWpQuery' ), 9999 ); |
| 55 |
|
| 56 |
add_filter( 'posts_where', [ $this->wpManager, 'fixPostsWhereForSearch' ], 10, 2 ); |
| 57 |
add_filter( 'post_limits_request', [ $this->wpManager, 'addSQlComment' ], 10, 2 ); |
| 58 |
add_action( 'pre_get_posts', array( $this->wpManager, 'fixSearchPostType' ), 9999 ); |
| 59 |
|
| 60 |
add_action( 'template_redirect', [ $this, 'prepareEntities' ] ); |
| 61 |
|
| 62 |
add_action( 'wpc_filtered_query_end', [ $this, 'addSearchArgsToWpQuery' ] ); |
| 63 |
add_action( 'wpc_all_set_wp_queried_posts', [ $this, 'addSearchArgsToWpQuery' ] ); |
| 64 |
|
| 65 |
add_filter( 'posts_where', [ $this, 'postDateWhere' ], 10000, 2 ); |
| 66 |
|
| 67 |
if ( flrt_is_woocommerce() ){ |
| 68 |
add_action( 'woocommerce_product_query', 'flrt_remove_product_query_post_clauses', 10, 2 ); |
| 69 |
add_filter( 'posts_search', [$this, 'addSkuSearchSql'], 10000, 2 ); |
| 70 |
} |
| 71 |
|
| 72 |
$sorting = new Sorting(); |
| 73 |
$sorting->registerHooks(); |
| 74 |
} |
| 75 |
|
| 76 |
add_action( 'body_class', array( $this, 'bodyClass' ) ); |
| 77 |
|
| 78 |
add_action( 'admin_print_styles', array( $this, 'includeAdminCss' ) ); |
| 79 |
add_action( 'admin_print_scripts', array( $this, 'includeAdminJs' ) ); |
| 80 |
|
| 81 |
// Do not include JS, if this page is admin or can't contain filters |
| 82 |
if( ! is_admin() && ! is_login() ){ |
| 83 |
add_action( 'wp_head', [ $this, 'inlineFrontCss' ] ); |
| 84 |
add_action( 'wp_print_styles', array( $this, 'includeFrontCss' ) ); |
| 85 |
add_action( 'wp_print_scripts', array( $this, 'includeFrontJs' ) ); |
| 86 |
add_action( 'wp_print_styles', array( $this, 'dynamicFrontCss' ) ); |
| 87 |
} |
| 88 |
|
| 89 |
add_action( 'wp_footer', [$this, 'footerHtml'] ); |
| 90 |
|
| 91 |
if( ! defined('FLRT_FILTERS_PRO') ) { |
| 92 |
add_action( 'wp_head', array($this, 'noIndexFilterPages'), 1 ); |
| 93 |
add_filter( 'wpc_filter_set_default_fields', [ $this, 'addAvailableInProFields' ], 10, 2 ); |
| 94 |
add_filter( 'wpc_pre_save_set_fields', [ $this, 'unsetAvailableInProFields' ] ); |
| 95 |
} |
| 96 |
|
| 97 |
add_filter( 'wpc_filter_set_default_fields', [ $this, 'addSetTailFields' ], 20, 2 ); |
| 98 |
|
| 99 |
// Disable single search result redirect |
| 100 |
add_filter( 'woocommerce_redirect_single_search_result', '__return_false' ); |
| 101 |
|
| 102 |
add_action( 'save_post', [$this, 'resetTransitions'] ); |
| 103 |
add_action( 'delete_post', [$this, 'resetTransitions'] ); |
| 104 |
add_action( 'woocommerce_ajax_save_product_variations', [$this, 'resetTransitions'] ); |
| 105 |
|
| 106 |
if( isset( $getData['reset_filters_cache'] ) && $getData['reset_filters_cache'] == true ){ |
| 107 |
$this->resetTransitions(); |
| 108 |
} |
| 109 |
|
| 110 |
add_action( 'wpc_before_filter_set_settings_fields', [$this, 'removeApplyButtonOrderField'] ); |
| 111 |
add_filter( 'wpc_filter_set_prepared_values', [$this, 'handleFilterSetFieldsVisibility'] ); |
| 112 |
|
| 113 |
add_action( 'wpc_cycle_filter_fields', [$this, 'showCombinedFields'], 10, 2 ); |
| 114 |
|
| 115 |
add_action( 'pre_get_posts', [$this, 'burpOutAllWpQueries'], 9999 ); |
| 116 |
|
| 117 |
add_action('wp_ajax_wpc-get-set-location-terms', [$this, 'sendSetLocationTerms']); |
| 118 |
|
| 119 |
add_filter('wpc_relevant_set_ids', [$this, 'findRelevantSets'], 10, 2); |
| 120 |
add_filter('wpc_is_filtered_query_free', [$this, 'isFilteredQuery'], 10, 2); |
| 121 |
|
| 122 |
|
| 123 |
add_filter('wpc_prepare_filter_set_parameters', [$this, 'prepareSetParameters'], 10, 2); |
| 124 |
|
| 125 |
add_filter('wpc_filter_before_make_default_set_values', [$this, 'legacyPrepareWpPageTypeValue'] ); |
| 126 |
|
| 127 |
add_filter('wpc_validation_wp_page_type_entities', [$this, 'validationWpPageTypeEntities'] ); |
| 128 |
|
| 129 |
add_filter('wpc_validation_location_entities', [$this, 'validationLocationEntities'], 10, 2); |
| 130 |
|
| 131 |
add_action( 'wpc_before_filter_set_settings_location_fields', [$this, 'showLocationFields'] ); |
| 132 |
|
| 133 |
add_filter('manage_edit-' . FLRT_FILTERS_SET_POST_TYPE . '_columns', array($this, 'filterSetPostTypeCol')); |
| 134 |
add_action('manage_' . FLRT_FILTERS_SET_POST_TYPE . '_posts_custom_column', array($this, 'filterSetPostTypeColContent'), 10, 2); |
| 135 |
|
| 136 |
$woo_shortcodes = array( |
| 137 |
'products', |
| 138 |
'featured_products', |
| 139 |
'sale_products', |
| 140 |
'best_selling_products', |
| 141 |
'recent_products', |
| 142 |
'product_attribute', |
| 143 |
'top_rated_products' |
| 144 |
); |
| 145 |
|
| 146 |
// Set first install timestamp |
| 147 |
$first_install = get_option( 'wpc_first_install' ); |
| 148 |
if ( ! $first_install ){ |
| 149 |
$first_install = []; |
| 150 |
$first_install['install_time'] = time(); |
| 151 |
$first_install['rate_disabled'] = false; |
| 152 |
$first_install['rate_delayed'] = false; |
| 153 |
update_option( 'wpc_first_install', $first_install ); |
| 154 |
} |
| 155 |
|
| 156 |
// Fix caching problem for products queried by shortcode |
| 157 |
foreach ( $woo_shortcodes as $woo_shortcode ){ |
| 158 |
add_filter( "shortcode_atts_{$woo_shortcode}", [$this, 'disableCacheProductsShortcode'] ); |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
public function resetTransitions() |
| 163 |
{ |
| 164 |
$em = Container::instance()->getEntityManager(); |
| 165 |
$all_filters = $em->getGlobalConfiguredSlugs(); |
| 166 |
|
| 167 |
if( is_array( $all_filters ) ){ |
| 168 |
foreach ( $all_filters as $entityEname => $slug ){ |
| 169 |
// For terms it should be entity name |
| 170 |
$parts = explode( '#', $entityEname, 2 ); |
| 171 |
$e_name = isset( $parts[1] ) ? $parts[1] : ''; |
| 172 |
$type = isset( $parts[0] ) ? $parts[0] : ''; |
| 173 |
|
| 174 |
$terms_transient_key = ''; |
| 175 |
|
| 176 |
if ( in_array( $type, [ 'post_meta_num', 'tax_numeric' ] ) ) { |
| 177 |
global $wpdb; |
| 178 |
$key = flrt_get_terms_transient_key( $type . '_'. $e_name, false ); |
| 179 |
|
| 180 |
$result = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%{$key}%'", ARRAY_A ); |
| 181 |
|
| 182 |
if ( isset( $result[0]['option_name'] ) ) { |
| 183 |
$terms_transient_key = str_replace( '_transient_', '', str_replace( '_transient_timeout_', '', $result[0]['option_name'] ) ); |
| 184 |
} |
| 185 |
} |
| 186 |
|
| 187 |
if ( in_array( $type, [ 'post_date' ] ) ) { |
| 188 |
global $wpdb; |
| 189 |
$key = 'wpc_terms_post_date_'; |
| 190 |
$result = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%{$key}%'", ARRAY_A ); |
| 191 |
if ( isset( $result[0]['option_name'] ) ) { |
| 192 |
$terms_transient_key = str_replace( '_transient_', '', str_replace( '_transient_timeout_', '', $result[0]['option_name'] ) ); |
| 193 |
} |
| 194 |
} |
| 195 |
|
| 196 |
if ( in_array( $type, [ 'post_meta_date' ] ) ) { |
| 197 |
global $wpdb; |
| 198 |
$key = 'wpc_terms_post_meta_date_'; |
| 199 |
$result = $wpdb->get_results( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%{$key}%'", ARRAY_A ); |
| 200 |
if ( isset( $result[0]['option_name'] ) ) { |
| 201 |
$terms_transient_key = str_replace( '_transient_', '', str_replace( '_transient_timeout_', '', $result[0]['option_name'] ) ); |
| 202 |
} |
| 203 |
} |
| 204 |
|
| 205 |
if ( $type === 'post_meta_exists' ) { |
| 206 |
delete_transient( flrt_get_post_ids_transient_key( $e_name .'_yes' ) ); |
| 207 |
delete_transient( flrt_get_post_ids_transient_key( $e_name .'_no' ) ); |
| 208 |
} |
| 209 |
|
| 210 |
if( ! $terms_transient_key ){ |
| 211 |
$terms_transient_key = flrt_get_terms_transient_key( $type . '_'. $e_name ); |
| 212 |
} |
| 213 |
|
| 214 |
$post_ids_transient_key = flrt_get_post_ids_transient_key( $slug ); |
| 215 |
$var_meta_transient_key = flrt_get_variations_transient_key( 'attribute_'. $e_name ); |
| 216 |
|
| 217 |
delete_transient( $terms_transient_key ); |
| 218 |
delete_transient( $post_ids_transient_key ); |
| 219 |
delete_transient( $var_meta_transient_key ); |
| 220 |
} |
| 221 |
} |
| 222 |
|
| 223 |
$variations_key = 'wpc_posts_variations'; |
| 224 |
$filter_key = 'wpc_filters_query'; |
| 225 |
|
| 226 |
delete_transient($variations_key); |
| 227 |
delete_transient($filter_key); |
| 228 |
|
| 229 |
unset( $terms_transient_key, $post_ids_transient_key, $var_meta_transient_key, $all_filters, $em ); |
| 230 |
} |
| 231 |
|
| 232 |
public function prepareEntities() |
| 233 |
{ |
| 234 |
$wpManager = Container::instance()->getWpManager(); |
| 235 |
$em = Container::instance()->getEntityManager(); |
| 236 |
$sets = $wpManager->getQueryVar('wpc_page_related_set_ids'); |
| 237 |
|
| 238 |
if( $sets ){ |
| 239 |
foreach( $sets as $set ){ |
| 240 |
$em->prepareEntitiesToDisplay( array( $set ) ); |
| 241 |
} |
| 242 |
} |
| 243 |
} |
| 244 |
|
| 245 |
|
| 246 |
public function addAvailableInProFields( $fields, $filterSet ) |
| 247 |
{ |
| 248 |
foreach ( $fields as $key => $attributes ){ |
| 249 |
// Always insert regular 'old' field |
| 250 |
$new_fields[$key] = $attributes; |
| 251 |
|
| 252 |
if( $key === 'show_count' ){ |
| 253 |
|
| 254 |
$new_fields['instead_custom_posts_container'] = array( |
| 255 |
'type' => 'inProButton', |
| 256 |
'label' => esc_html__('HTML id or class of the Posts Container', 'filter-everything'), |
| 257 |
'pro_label' => flrt_pro_promo_label(), |
| 258 |
'name' => $filterSet->generateFieldName('instead_custom_posts_container'), |
| 259 |
'id' => $filterSet->generateFieldId('instead_custom_posts_container'), |
| 260 |
'default' => '', |
| 261 |
'placeholder' => esc_html__('Available in PRO', 'filter-everything'), |
| 262 |
'settings' => true |
| 263 |
); |
| 264 |
|
| 265 |
} |
| 266 |
|
| 267 |
if( $key === 'hide_empty' ){ |
| 268 |
$new_fields['instead_hide_empty_filter_container'] = array( |
| 269 |
'type' => 'inProButton', |
| 270 |
'label' => esc_html__('Hide empty Filters', 'filter-everything'), |
| 271 |
'pro_label' => flrt_pro_promo_label(), |
| 272 |
'name' => $filterSet->generateFieldName('instead_custom_posts_container'), |
| 273 |
'id' => $filterSet->generateFieldId('instead_custom_posts_container'), |
| 274 |
'default' => '', |
| 275 |
'instructions' => esc_html__('Hide the Entire Filter if no one term contains posts', 'filter-everything'), |
| 276 |
'settings' => true |
| 277 |
); |
| 278 |
|
| 279 |
} |
| 280 |
|
| 281 |
} |
| 282 |
|
| 283 |
return $new_fields; |
| 284 |
} |
| 285 |
|
| 286 |
public function addSetTailFields( $fields, $filterSet ) |
| 287 |
{ |
| 288 |
$new_fields = []; |
| 289 |
$insert_after = defined('FLRT_FILTERS_PRO') ? 'custom_posts_container' : 'show_count'; |
| 290 |
|
| 291 |
foreach ( $fields as $key => $attributes ){ |
| 292 |
// Always insert regular 'old' field |
| 293 |
$new_fields[$key] = $attributes; |
| 294 |
|
| 295 |
if( $key === $insert_after ){ |
| 296 |
|
| 297 |
$new_fields['use_search_field'] = array( |
| 298 |
'type' => 'Checkbox', |
| 299 |
'label' => esc_html__('Search Field', 'filter-everything'), |
| 300 |
'name' => $filterSet->generateFieldName('use_search_field'), |
| 301 |
'id' => $filterSet->generateFieldId('use_search_field'), |
| 302 |
'class' => 'wpc-field-use-search-field', |
| 303 |
'default' => 'no', |
| 304 |
'instructions' => esc_html__('Allows you to search by text among filtered posts', 'filter-everything'), |
| 305 |
'settings' => true |
| 306 |
); |
| 307 |
|
| 308 |
$new_fields['search_field_menu_order'] = array( |
| 309 |
'type' => 'Hidden', |
| 310 |
'label' => '', |
| 311 |
'class' => 'wpc-menu-order-field', |
| 312 |
'id' => $filterSet->generateFieldId('search_field_menu_order'), |
| 313 |
'name' => $filterSet->generateFieldName('search_field_menu_order'), |
| 314 |
'default' => -1, |
| 315 |
'settings' => true |
| 316 |
); |
| 317 |
|
| 318 |
$new_fields['search_field_label'] = array( |
| 319 |
'type' => 'Text', |
| 320 |
'label' => esc_html__('Search Field Title', 'filter-everything'), |
| 321 |
'name' => $filterSet->generateFieldName('search_field_label'), |
| 322 |
'id' => $filterSet->generateFieldId('search_field_label'), |
| 323 |
'class' => 'wpc-search-field-label', |
| 324 |
'default' => esc_html__('Search', 'filter-everything'), |
| 325 |
'instructions' => esc_html__('Specify if needed or leave empty', 'filter-everything'), |
| 326 |
'settings' => true |
| 327 |
); |
| 328 |
|
| 329 |
$new_fields['search_field_placeholder'] = array( |
| 330 |
'type' => 'Text', |
| 331 |
'label' => esc_html__('Search Field Placeholder', 'filter-everything'), |
| 332 |
'name' => $filterSet->generateFieldName('search_field_placeholder'), |
| 333 |
'id' => $filterSet->generateFieldId('search_field_placeholder'), |
| 334 |
'class' => 'wpc-search-field-placeholder', |
| 335 |
'placeholder' => esc_html__( 'e.g. Search products, Search posts', 'filter-everything' ), |
| 336 |
'default' => '', |
| 337 |
'settings' => true |
| 338 |
); |
| 339 |
|
| 340 |
$new_fields['use_apply_button'] = array( |
| 341 |
'type' => 'Checkbox', |
| 342 |
'label' => esc_html__('«Apply Button» mode', 'filter-everything'), |
| 343 |
'name' => $filterSet->generateFieldName('use_apply_button'), |
| 344 |
'id' => $filterSet->generateFieldId('use_apply_button'), |
| 345 |
'class' => 'wpc-field-use-apply-button', |
| 346 |
'default' => 'no', |
| 347 |
'instructions' => esc_html__('Enables filtering by clicking the Apply button', 'filter-everything'), |
| 348 |
'settings' => true |
| 349 |
); |
| 350 |
|
| 351 |
$new_fields['apply_button_menu_order'] = array( |
| 352 |
'type' => 'Hidden', |
| 353 |
'label' => '', |
| 354 |
'class' => 'wpc-menu-order-field', |
| 355 |
'id' => $filterSet->generateFieldId('apply_button_menu_order'), |
| 356 |
'name' => $filterSet->generateFieldName('apply_button_menu_order'), |
| 357 |
'default' => -1, |
| 358 |
'settings' => true |
| 359 |
); |
| 360 |
|
| 361 |
$new_fields['apply_button_text'] = array( |
| 362 |
'type' => 'Text', |
| 363 |
'label' => esc_html__('Apply Button label', 'filter-everything'), |
| 364 |
'name' => $filterSet->generateFieldName('apply_button_text'), |
| 365 |
'id' => $filterSet->generateFieldId('apply_button_text'), |
| 366 |
'class' => 'wpc-field-apply-button-text', |
| 367 |
'default' => esc_html__('Apply', 'filter-everything'), |
| 368 |
'settings' => true |
| 369 |
); |
| 370 |
|
| 371 |
$new_fields['reset_button_text'] = array( |
| 372 |
'type' => 'Text', |
| 373 |
'label' => esc_html__('Reset Button label', 'filter-everything'), |
| 374 |
'name' => $filterSet->generateFieldName('reset_button_text'), |
| 375 |
'id' => $filterSet->generateFieldId('reset_button_text'), |
| 376 |
'class' => 'wpc-field-reset-button-text', |
| 377 |
'default' => esc_html__('Reset', 'filter-everything'), |
| 378 |
'settings' => true |
| 379 |
); |
| 380 |
|
| 381 |
$new_fields['horizontal_view'] = array( |
| 382 |
'type' => 'Checkbox', |
| 383 |
'label' => esc_html__('Horizontal filters', 'filter-everything'), |
| 384 |
'name' => $filterSet->generateFieldName('horizontal_view'), |
| 385 |
'id' => $filterSet->generateFieldId('horizontal_view'), |
| 386 |
'class' => 'wpc-field-horizontal-view-text', |
| 387 |
'default' => 'no', |
| 388 |
'instructions' => esc_html__('Display filters side by side instead of one per row', 'filter-everything'), |
| 389 |
'settings' => true |
| 390 |
); |
| 391 |
$columns_options = []; |
| 392 |
for ( $i = 2; $i <= 5; $i++ ){ |
| 393 |
$columns_options[(string)$i] = (string)$i; |
| 394 |
} |
| 395 |
$new_fields['horizontal_view_column'] = array( |
| 396 |
'type' => 'Select', |
| 397 |
'label' => esc_html__('Number of columns', 'filter-everything'), |
| 398 |
'class' => 'wpc-field-horizontal-view-column', |
| 399 |
'id' => $filterSet->generateFieldId('horizontal_view_column'), |
| 400 |
'name' => $filterSet->generateFieldName('horizontal_view_column'), |
| 401 |
'options' => $columns_options, |
| 402 |
'default' => '3', |
| 403 |
'instructions' => esc_html__('How many columns to use in horizontal mode', 'filter-everything'), |
| 404 |
'settings' => true |
| 405 |
); |
| 406 |
|
| 407 |
$screen = function_exists('get_current_screen') ? get_current_screen() : null; |
| 408 |
$new_fields['horizontal_view_priority'] = array( |
| 409 |
'type' => 'Select', |
| 410 |
'label' => esc_html__('Horizontal priority', 'filter-everything'), |
| 411 |
'class' => 'wpc-field-horizontal-view-priority', |
| 412 |
'id' => $filterSet->generateFieldId('horizontal_view_priority'), |
| 413 |
'name' => $filterSet->generateFieldName('horizontal_view_priority'), |
| 414 |
'options' => ['widget' => 'widget', 'filter_set' => 'filter_set'], |
| 415 |
'default' => ($screen && $screen->base === 'post' && $screen->action === 'add') ? 'filter_set' : 'widget', |
| 416 |
'instructions' => esc_html__('How many columns to use in horizontal mode', 'filter-everything'), |
| 417 |
'settings' => true, |
| 418 |
); |
| 419 |
} |
| 420 |
} |
| 421 |
|
| 422 |
return $new_fields; |
| 423 |
} |
| 424 |
|
| 425 |
public function unsetAvailableInProFields( $setFields ) |
| 426 |
{ |
| 427 |
unset( $setFields['instead_post_name'], $setFields['instead_custom_posts_container'] ); |
| 428 |
|
| 429 |
return $setFields; |
| 430 |
} |
| 431 |
|
| 432 |
public function noIndexFilterPages() |
| 433 |
{ |
| 434 |
if( flrt_is_filter_request() ){ |
| 435 |
$robots['index'] = 'noindex'; |
| 436 |
$robots['follow'] = 'nofollow'; |
| 437 |
$content = implode(', ', $robots ); |
| 438 |
echo sprintf('<meta name="robots" content="%s">', $content)."\r\n"; |
| 439 |
} |
| 440 |
} |
| 441 |
|
| 442 |
public function inlineFrontCss() |
| 443 |
{ |
| 444 |
$inline = '<style type="text/css" id="filter-everything-inline-css">.wpc-orderby-select{width:100%}.wpc-filters-open-button-container{display:none}.wpc-debug-message{padding:16px;font-size:14px;border:1px dashed #ccc;margin-bottom:20px}.wpc-debug-title{visibility:hidden}.wpc-button-inner,.wpc-chip-content{display:flex;align-items:center}.wpc-icon-html-wrapper{position:relative;margin-right:10px;top:2px}.wpc-icon-html-wrapper span{display:block;height:1px;width:18px;border-radius:3px;background:#2c2d33;margin-bottom:4px;position:relative}span.wpc-icon-line-1:after,span.wpc-icon-line-2:after,span.wpc-icon-line-3:after{content:"";display:block;width:3px;height:3px;border:1px solid #2c2d33;background-color:#fff;position:absolute;top:-2px;box-sizing:content-box}span.wpc-icon-line-3:after{border-radius:50%;left:2px}span.wpc-icon-line-1:after{border-radius:50%;left:5px}span.wpc-icon-line-2:after{border-radius:50%;left:12px}body .wpc-filters-open-button-container a.wpc-filters-open-widget,body .wpc-filters-open-button-container a.wpc-open-close-filters-button{display:inline-block;text-align:left;border:1px solid #2c2d33;border-radius:2px;line-height:1.5;padding:7px 12px;background-color:transparent;color:#2c2d33;box-sizing:border-box;text-decoration:none!important;font-weight:400;transition:none;position:relative}@media screen and (max-width:768px){.wpc_show_bottom_widget .wpc-filters-open-button-container,.wpc_show_open_close_button .wpc-filters-open-button-container{display:block}.wpc_show_bottom_widget .wpc-filters-open-button-container{margin-top:1em;margin-bottom:1em}}</style>'."\r\n"; |
| 445 |
echo $inline; |
| 446 |
} |
| 447 |
|
| 448 |
public function dynamicFrontCss() |
| 449 |
{ |
| 450 |
// Do not include plugin CSS if there are no Filter Sets on the page |
| 451 |
$sets = $this->wpManager->getQueryVar( 'wpc_page_related_set_ids', [] ); |
| 452 |
if( empty( $sets ) ) { |
| 453 |
return false; |
| 454 |
} |
| 455 |
|
| 456 |
$maxHeight = flrt_get_option( 'container_height' ); |
| 457 |
$color = flrt_get_option( 'primary_color', flrt_default_theme_color() ); |
| 458 |
$move_to_top = flrt_get_option( 'try_move_to_top_sidebar' ); |
| 459 |
$wpc_mobile_width = flrt_get_mobile_width(); |
| 460 |
|
| 461 |
// Experimental Options |
| 462 |
$custom_css = flrt_get_experimental_option('custom_css'); |
| 463 |
$use_loader = flrt_get_experimental_option('use_loader'); |
| 464 |
$dark_overlay = flrt_get_experimental_option('dark_overlay'); |
| 465 |
$styled_inputs = flrt_get_experimental_option('styled_inputs'); |
| 466 |
$use_select2 = flrt_get_experimental_option('select2_dropdowns'); |
| 467 |
$rounded_swatch = flrt_get_experimental_option('rounded_swatches'); |
| 468 |
$contrastColor = false; |
| 469 |
|
| 470 |
$swatches_measurements = [ 'width' => 32, 'height' => 32 ]; |
| 471 |
if( $rounded_swatch ) { |
| 472 |
$swatches_measurements = [ 'width' => 32, 'height' => 32 ]; |
| 473 |
} |
| 474 |
|
| 475 |
$swatches = apply_filters( 'wpc_swatches_width_height', $swatches_measurements ); |
| 476 |
$brands = apply_filters( 'wpc_brands_width_height', [ 'width' => 70, 'height' => 40 ] ); |
| 477 |
|
| 478 |
$css = ''; |
| 479 |
$css .= '@media screen and (min-width:'.($wpc_mobile_width+1).'px){.wpc_show_bottom_widget .wpc-filters-widget-content{height:auto!important}body.wpc_show_open_close_button .wpc-filters-widget-content.wpc-closed,body.wpc_show_open_close_button .wpc-filters-widget-content.wpc-opened,body.wpc_show_open_close_button .wpc-filters-widget-content:not(.wpc-opened){display:block!important}}@media screen and (min-width:'.$wpc_mobile_width.'px){.wpc-custom-selected-terms{clear:both;width:100%}.wpc-custom-selected-terms ul.wpc-filter-chips-list{display:flex;overflow-x:auto;padding-left:0}.wpc-filters-main-wrap .wpc-custom-selected-terms ul.wpc-filter-chips-list{display:block;overflow:visible}html.is-active .wpc-filters-overlay{top:0;opacity:.3;background:#fff}.wpc-filters-main-wrap input.wpc-label-input+label:hover{border:1px solid rgba(0,0,0,.25);border-radius:5px}.wpc-filters-main-wrap input.wpc-label-input+label:hover span.wpc-filter-label-wrapper{color:#333;background-color:rgba(0,0,0,.25)}.wpc-filters-main-wrap .wpc-filters-labels li.wpc-term-item input+label:hover a{color:#333}.theme-storefront #primary .storefront-sorting .wpc-custom-selected-terms{font-size:inherit}.theme-storefront #primary .wpc-custom-selected-terms{font-size:.875em}}@media screen and (max-width:'.$wpc_mobile_width.'px){.wpc-filters-labels li.wpc-term-item label:hover .wpc-term-swatch-wrapper:after,.wpc-filters-labels li.wpc-term-item label:hover .wpc-term-swatch-wrapper:before{display:none;}.wpc_show_bottom_widget .wpc-filters-widget-top-container,.wpc_show_open_close_button .wpc-filters-widget-top-container{text-align:center}.wpc_show_bottom_widget .wpc-filters-widget-top-container{position:sticky;top:0;z-index:99999;border-bottom:1px solid #f7f7f7}.wpc-custom-selected-terms:not(.wpc-show-on-mobile),.wpc-edit-filter-set,.wpc_show_bottom_widget .widget_wpc_selected_filters_widget,.wpc_show_bottom_widget .wpc-filters-widget-content .wpc-filter-set-widget-title,.wpc_show_bottom_widget .wpc-filters-main-wrap .widget-title,.wpc_show_bottom_widget .wpc-filters-widget-wrapper .wpc-filter-layout-submit-button,.wpc_show_bottom_widget .wpc-posts-found,body.wpc_show_bottom_widget .wpc-open-close-filters-button,body.wpc_show_open_close_button .wpc-filters-widget-content:not(.wpc-opened){display:none}.wpc_show_bottom_widget .wpc-filters-widget-top-container:not(.wpc-show-on-desktop),.wpc_show_bottom_widget .wpc-spinner.is-active,.wpc_show_bottom_widget .wpc-widget-close-container,html.is-active body:not(.wpc_show_bottom_widget) .wpc-spinner{display:block}body .wpc-filters-main-wrap li.wpc-term-item{padding:2px 0}.wpc-chip-empty{width:0;display:list-item;visibility:hidden;margin-right:0!important}.wpc-overlay-visible #secondary{z-index:auto}html.is-active:not(.wpc-overlay-visible) .wpc-filters-overlay{top:0;opacity:.2;background:#fff}.wpc-custom-selected-terms.wpc-show-on-mobile ul.wpc-filter-chips-list{display:flex;overflow-x:auto;padding-left:0}html.is-active body:not(.wpc_show_bottom_widget) .wpc-filters-overlay{top:0;opacity:.3;background:#fff}body.wpc_show_bottom_widget .wpc-filters-widget-content.wpc-closed,body.wpc_show_bottom_widget .wpc-filters-widget-content.wpc-opened,body.wpc_show_bottom_widget .wpc-filters-widget-content:not(.wpc-opened){display:block!important}.wpc-open-close-filters-button{display:block;margin-bottom:20px}.wpc-overlay-visible body,html.wpc-overlay-visible{overflow:hidden!important}.wpc_show_bottom_widget .widget_wpc_filters_widget,.wpc_show_bottom_widget .wpc-filters-main-wrap{padding:0!important;margin:0!important}.wpc_show_bottom_widget .wpc-filters-range-column{width:48%;max-width:none}.wpc_show_bottom_widget .wpc-filters-toolbar{display:flex;margin:1em 0}.wpc_show_bottom_widget .wpc-inner-widget-chips-wrapper{display:block;padding-left:20px;padding-right:20px}.wpc_show_bottom_widget .wpc-filters-main-wrap .widget-title.wpc-filter-title{display:flex}.wpc_show_bottom_widget .wpc-inner-widget-chips-wrapper .wpc-filter-chips-list,.wpc_show_open_close_button .wpc-inner-widget-chips-wrapper .wpc-filter-chips-list{display:flex;-webkit-box-pack:start;place-content:center flex-start;overflow-x:auto;padding-top:5px;padding-bottom:5px;margin-left:0;padding-left:0}.wpc-overlay-visible .wpc_show_bottom_widget .wpc-filters-overlay{top:0;opacity:.4}.wpc_show_bottom_widget .wpc-filters-main-wrap .wpc-spinner.is-active+.wpc-filters-widget-content .wpc-filters-scroll-container .wpc-filters-widget-wrapper{opacity:.6;pointer-events:none}.wpc_show_bottom_widget .wpc-filters-open-button-container{margin-top:1em;margin-bottom:1em}.wpc_show_bottom_widget .wpc-filters-widget-content{position:fixed;bottom:0;right:0;left:0;top:5%;z-index:999999;padding:0;background-color:#fff;margin:0;box-sizing:border-box;border-radius:7px 7px 0 0;transition:transform .25s;transform:translate3d(0,120%,0);-webkit-overflow-scrolling:touch;height:auto}.wpc_show_bottom_widget .wpc-filters-widget-containers-wrapper{padding:0;margin:0;overflow-y:scroll;box-sizing:border-box;position:fixed;top:56px;left:0;right:0;bottom:0}.wpc_show_bottom_widget .wpc-filters-widget-content.wpc-filters-widget-opened{transform:translate3d(0,0,0)}.theme-twentyfourteen .wpc_show_bottom_widget .wpc-filters-widget-content,.theme-twentyfourteen.wpc_show_bottom_widget .wpc-filters-scroll-container{background-color:#000}.wpc_show_bottom_widget .wpc-filters-section:not(.wpc-filter-post_meta_num):not(.wpc-filter-tax_numeric) .wpc-filter-content ul.wpc-filters-ul-list,.wpc_show_open_close_button .wpc-filters-section:not(.wpc-filter-post_meta_num):not(.wpc-filter-tax_numeric) .wpc-filter-content ul.wpc-filters-ul-list{max-height:none}.wpc_show_bottom_widget .wpc-filters-scroll-container{background:#fff;min-height:100%}.wpc_show_bottom_widget .wpc-filters-widget-wrapper{padding:20px 20px 15px}.wpc-filter-everything-dropdown .select2-search--dropdown .select2-search__field,.wpc-sorting-form select,.wpc_show_bottom_widget .wpc-filters-main-wrap input[type=number],.wpc_show_bottom_widget .wpc-filters-main-wrap input[type=text],.wpc_show_bottom_widget .wpc-filters-main-wrap select,.wpc_show_bottom_widget .wpc-filters-main-wrap textarea,.wpc_show_bottom_widget .wpc-search-field,.wpc_show_open_close_button .wpc-search-field,.wpc_show_open_close_button .wpc-filter-search-field{font-size:16px}.wpc-filter-layout-dropdown .select2-container .select2-selection--single,.wpc-sorting-form .select2-container .select2-selection--single{height:auto;padding:6px}.wpc_show_bottom_widget .wpc-filters-section:not(.wpc-filter-post_meta_num):not(.wpc-filter-tax_numeric) .wpc-filter-content ul.wpc-filters-ul-list{overflow-y:visible}.theme-twentyeleven #primary,.theme-twentyeleven #secondary{margin-left:0;margin-right:0;clear:both;float:none}#main>.fusion-row{max-width:100%}.wpc_show_bottom_widget .wpc-filters-open-button-container,.wpc_show_bottom_widget .wpc-filters-widget-controls-container,.wpc_show_bottom_widget .wpc-filters-widget-top-container,.wpc_show_open_close_button .wpc-filters-open-button-container{display:block}}'."\r\n"; |
| 480 |
$css .= '.wpc-preload-img{display:none;}'; |
| 481 |
// Number of items visible by default in More/Less filters |
| 482 |
$css .= '.wpc-filter-more-less:not(.wpc-search-active) .wpc-filters-ul-list > li:nth-child(-n+'.flrt_more_less_count().'){display: list-item;}'."\r\n"; |
| 483 |
|
| 484 |
$css .= 'li.wpc-term-item label span.wpc-term-swatch,.wpc-term-swatch-wrapper{width:'.$swatches['width'].'px;min-width:'.$swatches['width'].'px;'; |
| 485 |
|
| 486 |
if ( $rounded_swatch ) { |
| 487 |
$css .= 'border-radius:'.$swatches['height'].'px;'; |
| 488 |
} |
| 489 |
|
| 490 |
$css .= 'height:'.$swatches['height'].'px;}'."\r\n"; |
| 491 |
$css .= '.wpc-term-swatch-wrapper:after{width:'.($swatches['width']/2.5).'px;height:'.($swatches['width']/5).'px;left:'.($swatches['width']/3.5).'px;top:'.($swatches['height']/3.5).'px;}'; |
| 492 |
$css .= '.wpc-term-image-wrapper{width:'.$brands['width'].'px;min-width:'.$brands['width'].'px;height:'.$brands['height'].'px;}'; |
| 493 |
|
| 494 |
if( $maxHeight ){ |
| 495 |
$css .= '.wpc-filters-section:not(.wpc-filter-more-less):not(.wpc-filter-post_meta_num):not(.wpc-filter-tax_numeric):not(.wpc-filter-layout-dropdown):not(.wpc-filter-terms-count-0) .wpc-filter-content:not(.wpc-filter-has-hierarchy) ul.wpc-filters-ul-list{ |
| 496 |
max-height: '.$maxHeight.'px; |
| 497 |
overflow-y: auto; |
| 498 |
}'."\r\n"; |
| 499 |
} |
| 500 |
|
| 501 |
if( $color ){ |
| 502 |
$contrastColor = flrt_get_contrast_color($color); |
| 503 |
$css .= '.wpc-filters-range-inputs .ui-slider-horizontal .ui-slider-range{ |
| 504 |
background-color: '.$color.'; |
| 505 |
} |
| 506 |
'."\r\n"; |
| 507 |
|
| 508 |
$css .= '.wpc-spinner:after { |
| 509 |
border-top-color: '.$color.'; |
| 510 |
}'."\r\n"; |
| 511 |
|
| 512 |
$css .= '.theme-Avada .wpc-filter-product_visibility .star-rating:before, |
| 513 |
.wpc-filter-product_visibility .star-rating span:before{ |
| 514 |
color: '.$color.'; |
| 515 |
}'."\r\n"; |
| 516 |
|
| 517 |
$css .= 'body .wpc-filters-main-wrap input.wpc-label-input:checked+label span.wpc-filter-label-wrapper{ |
| 518 |
background-color: '.$color.'; |
| 519 |
}'."\r\n"; |
| 520 |
|
| 521 |
$css .= 'body .wpc-filters-main-wrap input.wpc-label-input:checked+label{ |
| 522 |
border-color: '.$color.'; |
| 523 |
}'."\r\n"; |
| 524 |
|
| 525 |
// Disabled label |
| 526 |
$css .= 'body .wpc-filters-main-wrap .wpc-term-disabled input.wpc-label-input:checked+label span.wpc-filter-label-wrapper{ |
| 527 |
background-color: #d8d8d8; |
| 528 |
}'."\r\n"; |
| 529 |
|
| 530 |
$css .= 'body .wpc-filters-main-wrap .wpc-term-disabled input.wpc-label-input:checked+label{ |
| 531 |
border-color: #d8d8d8; |
| 532 |
}'."\r\n"; |
| 533 |
|
| 534 |
$css .= 'body .wpc-filters-main-wrap .wpc-term-disabled input.wpc-label-input+label:hover{ |
| 535 |
border-color: #d8d8d8; |
| 536 |
}'."\r\n"; |
| 537 |
|
| 538 |
$css .= 'body .wpc-filters-main-wrap .wpc-term-disabled input.wpc-label-input:checked+label span.wpc-filter-label-wrapper, |
| 539 |
body .wpc-filters-main-wrap .wpc-filters-labels li.wpc-term-item.wpc-term-disabled input:checked+label a{ |
| 540 |
color: #333333; |
| 541 |
}'."\r\n"; |
| 542 |
// End of disabled label |
| 543 |
|
| 544 |
$css .= 'body .wpc-filters-main-wrap input.wpc-label-input:checked+label span.wpc-filter-label-wrapper, |
| 545 |
body .wpc-filters-main-wrap .wpc-filters-labels li.wpc-term-item input:checked+label a{ |
| 546 |
color: '.$contrastColor.'; |
| 547 |
}'."\r\n"; |
| 548 |
|
| 549 |
$css .= 'body .wpc-filter-chips-list li.wpc-filter-chip:not(.wpc-chip-reset-all) a{ |
| 550 |
border-color: '.$color.'; |
| 551 |
}'."\r\n"; |
| 552 |
|
| 553 |
$css .= 'body .wpc-filters-main-wrap .wpc-filters-widget-controls-container a.wpc-filters-apply-button, |
| 554 |
body .wpc-filters-main-wrap a.wpc-filters-submit-button{ |
| 555 |
border-color: '.$color.'; |
| 556 |
background-color: '.$color.'; |
| 557 |
color: '.$contrastColor.'; |
| 558 |
}'."\r\n"; |
| 559 |
|
| 560 |
$css .= 'body .wpc-filter-chips-list li.wpc-filter-chip a:hover{ |
| 561 |
opacity: 0.9; |
| 562 |
}'."\r\n"; |
| 563 |
|
| 564 |
$css .= 'body .wpc-filter-chips-list li.wpc-filter-chip a:active{ |
| 565 |
opacity: 0.75; |
| 566 |
}'."\r\n"; |
| 567 |
|
| 568 |
$css .= '.star-rating span, |
| 569 |
.star-rating span:before{ |
| 570 |
color: '.$color.'; |
| 571 |
}'."\r\n"; |
| 572 |
|
| 573 |
$css .= 'body a.wpc-filters-open-widget:active, a.wpc-filters-open-widget:active, |
| 574 |
.wpc-filters-open-widget:active{ |
| 575 |
border-color: '.$color.'; |
| 576 |
background-color: '.$color.'; |
| 577 |
color: '.$contrastColor.'; |
| 578 |
}'."\r\n"; |
| 579 |
|
| 580 |
$css .= 'a.wpc-filters-open-widget:active span.wpc-icon-line-1:after, |
| 581 |
a.wpc-filters-open-widget:active span.wpc-icon-line-2:after, |
| 582 |
a.wpc-filters-open-widget:active span.wpc-icon-line-3:after{ |
| 583 |
background-color: '.$color.'; |
| 584 |
border-color: '.$contrastColor.'; |
| 585 |
}'."\r\n"; |
| 586 |
|
| 587 |
$css .= 'a.wpc-filters-open-widget:active .wpc-icon-html-wrapper span{ |
| 588 |
background-color: '.$contrastColor.'; |
| 589 |
}'."\r\n"; |
| 590 |
|
| 591 |
//$css .= '@media screen and (min-width: '.$wpc_mobile_width.'px) {'."\r\n"; |
| 592 |
$css .= 'body .wpc-filters-main-wrap input.wpc-label-input+label:hover span.wpc-filter-label-wrapper{ |
| 593 |
color: '.$contrastColor.'; |
| 594 |
background-color: '.$color.'; |
| 595 |
}'."\r\n"; |
| 596 |
|
| 597 |
$css .= 'body .wpc-filters-main-wrap .wpc-filters-labels li.wpc-term-item input+label:hover a{ |
| 598 |
color: '.$contrastColor.'; |
| 599 |
}'."\r\n"; |
| 600 |
$css .= 'body .wpc-filters-main-wrap input.wpc-label-input+label:hover{ |
| 601 |
border-color: '.$color.'; |
| 602 |
}'."\r\n"; |
| 603 |
|
| 604 |
|
| 605 |
$css .= '#ui-datepicker-div.wpc-filter-datepicker .ui-state-active, |
| 606 |
#ui-datepicker-div.ui-widget-content.wpc-filter-datepicker .ui-state-active, |
| 607 |
#ui-datepicker-div.wpc-filter-datepicker .ui-widget-header .ui-state-active{ |
| 608 |
border-color: '.$color.'; |
| 609 |
background: '.$color.'; |
| 610 |
opacity: 0.95; |
| 611 |
}'."\r\n"; |
| 612 |
|
| 613 |
$css .= '#ui-datepicker-div.wpc-filter-datepicker .ui-state-hover, |
| 614 |
#ui-datepicker-div.ui-widget-content.wpc-filter-datepicker .ui-state-hover, |
| 615 |
#ui-datepicker-div.wpc-filter-datepicker .ui-widget-header .ui-state-hover, |
| 616 |
#ui-datepicker-div.wpc-filter-datepicker .ui-state-focus, |
| 617 |
#ui-datepicker-div.ui-widget-content.wpc-filter-datepicker .ui-state-focus, |
| 618 |
#ui-datepicker-div.wpc-filter-datepicker .ui-widget-header .ui-state-focus{ |
| 619 |
border-color: '.$color.'; |
| 620 |
background: '.$color.'; |
| 621 |
opacity: 0.6; |
| 622 |
}'; |
| 623 |
|
| 624 |
$css .= '#ui-datepicker-div.wpc-filter-datepicker .ui-datepicker-close.ui-state-default{ |
| 625 |
background: '.$color.'; |
| 626 |
color: '.$contrastColor.'; |
| 627 |
}'."\r\n"; |
| 628 |
|
| 629 |
//$css .= '}'."\r\n"; |
| 630 |
$css .= '.flrt-star-label svg{ |
| 631 |
stroke: '.$color.'; |
| 632 |
}'."\r\n"; |
| 633 |
|
| 634 |
$css .= '.flrt-star-label-hover svg, .wpc-chip-stars svg{ |
| 635 |
fill: '.$color.'; |
| 636 |
}'."\r\n"; |
| 637 |
|
| 638 |
$css .= '.wpc-filter-label-stars-wrapper{ |
| 639 |
padding: 4px 5px !important; |
| 640 |
}'."\r\n"; |
| 641 |
|
| 642 |
$css .= '.wpc-filter-label-stars-wrapper .flrt-star-label svg{ |
| 643 |
height: 17px; |
| 644 |
width: 17px; |
| 645 |
}'."\r\n"; |
| 646 |
|
| 647 |
$css .= 'body .wpc-filters-main-wrap input.wpc-label-input:checked+label span.wpc-filter-label-stars-wrapper .flrt-star-label svg, |
| 648 |
span.wpc-filter-label-stars-wrapper:hover .flrt-star-label svg{ |
| 649 |
fill: ' . flrt_get_contrast_color($color) . '; |
| 650 |
}'."\r\n"; |
| 651 |
} |
| 652 |
if( $styled_inputs ){ |
| 653 |
$styled_color = $color ? $color : '#0570e2'; |
| 654 |
$contrastColor = $contrastColor ? $contrastColor : flrt_get_contrast_color($styled_color); |
| 655 |
$hoverColor = flrt_add_color_opacity($color); |
| 656 |
$no_hex_color = substr( $color, 1, 6 ); |
| 657 |
$css .= '.wpc-filters-main-wrap input[type=checkbox], |
| 658 |
.wpc-filters-main-wrap input[type=radio]{ |
| 659 |
-webkit-appearance: none; |
| 660 |
-moz-appearance: none; |
| 661 |
position: relative; |
| 662 |
width: 20px; |
| 663 |
height: 20px; |
| 664 |
border: 1px solid #c9d1e0; |
| 665 |
background: #ffffff; |
| 666 |
border-radius: 5px; |
| 667 |
min-width: 20px; |
| 668 |
} |
| 669 |
i.wpc-toggle-children-list:after, |
| 670 |
i.wpc-toggle-children-list:before{ |
| 671 |
background-color: #b8bcc8; |
| 672 |
} |
| 673 |
i.wpc-toggle-children-list:hover:after, |
| 674 |
i.wpc-toggle-children-list:hover:before{ |
| 675 |
background-color: '.$color.'; |
| 676 |
} |
| 677 |
.wpc-filters-widget-content input[type=email], |
| 678 |
.wpc-filters-widget-content input[type=number], |
| 679 |
.wpc-filters-widget-content input[type=password], |
| 680 |
.wpc-filters-widget-content input[type=search], |
| 681 |
.wpc-filters-widget-content input[type=tel], |
| 682 |
.wpc-filters-widget-content input[type=text], |
| 683 |
.wpc-filters-widget-content input[type=url]{ |
| 684 |
height: 44px; |
| 685 |
} |
| 686 |
.wpc-filters-widget-content .wpc-filters-section input[type="number"], |
| 687 |
.wpc-filters-widget-content .wpc-filters-section input[type="text"]{ |
| 688 |
border: 1px solid #ccd0dc; |
| 689 |
border-radius: 6px; |
| 690 |
background: transparent; |
| 691 |
box-shadow: none; |
| 692 |
padding: 8px 16px; |
| 693 |
} |
| 694 |
.wpc-filters-main-wrap input[type=checkbox]:after { |
| 695 |
content: ""; |
| 696 |
opacity: 0; |
| 697 |
display: block; |
| 698 |
left: 3px; |
| 699 |
top: 3px; |
| 700 |
position: absolute; |
| 701 |
width: 12px; |
| 702 |
height: 12px; |
| 703 |
border: navajowhite; |
| 704 |
box-sizing: content-box; |
| 705 |
background-color: '.$styled_color.'; |
| 706 |
border-radius: 2px; |
| 707 |
} |
| 708 |
.wpc-filters-main-wrap input[type=radio]:after { |
| 709 |
content: ""; |
| 710 |
opacity: 0; |
| 711 |
display: block; |
| 712 |
left: 3px; |
| 713 |
top: 3px; |
| 714 |
position: absolute; |
| 715 |
width: 12px; |
| 716 |
height: 12px; |
| 717 |
border-radius: 50%; |
| 718 |
background: '.$styled_color.'; |
| 719 |
box-sizing: content-box; |
| 720 |
} |
| 721 |
.wpc-filters-main-wrap input[type=radio]:checked, |
| 722 |
.wpc-filters-main-wrap input[type=checkbox]:checked { |
| 723 |
border-color: '.$styled_color.'; |
| 724 |
} |
| 725 |
.wpc-filters-main-wrap .wpc-radio-item.wpc-term-disabled input[type=radio], |
| 726 |
.wpc-filters-main-wrap .wpc-checkbox-item.wpc-term-disabled > div > input[type=checkbox], |
| 727 |
.wpc-filters-main-wrap .wpc-checkbox-item.wpc-term-disabled > div > input[type=checkbox]:after, |
| 728 |
.wpc-filters-main-wrap .wpc-term-count-0:not(.wpc-has-not-empty-children) input[type=checkbox]:after, |
| 729 |
.wpc-filters-main-wrap .wpc-term-count-0:not(.wpc-has-not-empty-children) input[type=checkbox], |
| 730 |
.wpc-filters-main-wrap .wpc-term-count-0:not(.wpc-has-not-empty-children) input[type=radio], |
| 731 |
.wpc-term-swatch-no-image{ |
| 732 |
border-color: #d8d8d8; |
| 733 |
} |
| 734 |
.wpc-filters-main-wrap .wpc-term-count-0:not(.wpc-has-not-empty-children) input[type=checkbox]:after, |
| 735 |
.wpc-filters-main-wrap .wpc-checkbox-item.wpc-term-disabled > div > input[type=checkbox]:after { |
| 736 |
background-color: #d8d8d8; |
| 737 |
} |
| 738 |
.wpc-filters-main-wrap .wpc-radio-item.wpc-term-disabled input[type=radio]:after, |
| 739 |
.wpc-filters-main-wrap .wpc-term-count-0:not(.wpc-has-not-empty-children) input[type=radio]:after{ |
| 740 |
background-color: #d8d8d8; |
| 741 |
} |
| 742 |
.wpc-filters-main-wrap input[type=radio]:checked:after, |
| 743 |
.wpc-filters-main-wrap input[type=checkbox]:checked:after { |
| 744 |
opacity: 1; |
| 745 |
} |
| 746 |
.wpc-filters-main-wrap input[type=radio] { |
| 747 |
border-radius: 50%; |
| 748 |
} |
| 749 |
.wpc-filters-widget-content .wpc-filters-section .wpc-filter-search-wrapper .wpc-filter-search-field { |
| 750 |
padding: 8px 16px 8px 48px; |
| 751 |
} |
| 752 |
.wpc-filters-widget-content .wpc-filters-date-range-wrapper input[type="text"]{ |
| 753 |
padding-right: 48px; |
| 754 |
background-image: url("data:image/svg+xml,%3Csvg width=\'24\' height=\'24\' viewBox=\'0 0 16 16\' fill=\'none\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Crect x=\'2\' y=\'4\' width=\'12\' height=\'10\' rx=\'1.33333\' stroke=\'%23b8bcc8\' stroke-width=\'1.33333\'/%3E%3Cpath d=\'M2.66699 7.3335H13.3337\' stroke=\'%23b8bcc8\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3Cpath d=\'M6 10.6667H10\' stroke=\'%23b8bcc8\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3Cpath d=\'M5.33301 2L5.33301 4.66667\' stroke=\'%23b8bcc8\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3Cpath d=\'M10.667 2L10.667 4.66667\' stroke=\'%23b8bcc8\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3C/svg%3E%0A"); |
| 755 |
background-repeat: no-repeat; |
| 756 |
background-position: right 16px bottom 50%; |
| 757 |
background-size: 16px; |
| 758 |
} |
| 759 |
.wpc-filters-widget-content .wpc-filters-date-range-wrapper input[type="text"]:focus, |
| 760 |
.wpc-filters-widget-content .wpc-filters-date-range-wrapper input[type="text"]:hover{ |
| 761 |
background-image: url("data:image/svg+xml,%3Csvg width=\'24\' height=\'24\' viewBox=\'0 0 16 16\' fill=\'none\' xmlns=\'http://www.w3.org/2000/svg\'%3E%3Crect x=\'2\' y=\'4\' width=\'12\' height=\'10\' rx=\'1.33333\' stroke=\'%23'.$no_hex_color.'\' stroke-width=\'1.33333\'/%3E%3Cpath d=\'M2.66699 7.3335H13.3337\' stroke=\'%23'.$no_hex_color.'\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3Cpath d=\'M6 10.6667H10\' stroke=\'%23b8bcc8\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3Cpath d=\'M5.33301 2L5.33301 4.66667\' stroke=\'%23'.$no_hex_color.'\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3Cpath d=\'M10.667 2L10.667 4.66667\' stroke=\'%23'.$no_hex_color.'\' stroke-width=\'1.33333\' stroke-linecap=\'round\'/%3E%3C/svg%3E%0A"); |
| 762 |
} |
| 763 |
.wpc-filter-layout-dropdown .select2-container--default .select2-selection--single .select2-selection__arrow b, |
| 764 |
.wpc-sorting-form .select2-container--default .select2-selection--single .select2-selection__arrow b{ |
| 765 |
border-left: 1px solid #b8bcc8; |
| 766 |
border-top: 1px solid #b8bcc8; |
| 767 |
} |
| 768 |
.wpc-filter-layout-dropdown .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b, |
| 769 |
.wpc-sorting-form .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{ |
| 770 |
border-left: 1px solid #b8bcc8; |
| 771 |
border-top: 1px solid #b8bcc8; |
| 772 |
} |
| 773 |
.wpc-filter-collapsible .wpc-filter-title .wpc-open-icon, |
| 774 |
.wpc-filter-collapsible-reverse.wpc-filter-collapsible.wpc-closed .wpc-filter-title .wpc-open-icon, |
| 775 |
.wpc-filter-collapsible.wpc-closed .wpc-filter-title .wpc-open-icon, |
| 776 |
.wpc-filter-has-selected.wpc-closed .wpc-filter-title .wpc-open-icon{ |
| 777 |
border-left: 1px solid #b8bcc8; |
| 778 |
border-top: 1px solid #b8bcc8; |
| 779 |
} |
| 780 |
.wpc-sorting-form .select2-container--default .select2-selection--single:hover, |
| 781 |
.wpc-filters-widget-content input[type=email]:hover, |
| 782 |
.wpc-filters-widget-content input[type=number]:hover, |
| 783 |
.wpc-filters-widget-content input[type=password]:hover, |
| 784 |
.wpc-filters-widget-content input[type=search]:hover, |
| 785 |
.wpc-filters-widget-content input[type=tel]:hover, |
| 786 |
.wpc-filters-widget-content input[type=text]:hover, |
| 787 |
.wpc-filters-widget-content input[type=url]:hover{ |
| 788 |
border-color: '. $hoverColor.'; |
| 789 |
} |
| 790 |
.wpc-filter-layout-dropdown .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b, |
| 791 |
.wpc-sorting-form .select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b, |
| 792 |
.widget_wpc_sorting_widget .select2-container--default .select2-selection--single:hover .select2-selection__arrow b, |
| 793 |
.wpc-filter-layout-dropdown .select2-container--default .select2-selection--single:hover .select2-selection__arrow b, |
| 794 |
.wpc-filter-layout-dropdown .select2-container--default .select2-selection--single:hover, |
| 795 |
.select2-container--default.select2-container--open .wpc-filter-everything-dropdown.select2-dropdown, |
| 796 |
.wpc-sorting-form .select2-container--open .select2-selection--single:hover, |
| 797 |
.widget_wpc_sorting_widget .select2-container--open .select2-selection--single, |
| 798 |
.wpc-filter-layout-dropdown .select2-container--open .select2-selection--single, |
| 799 |
.wpc-filters-widget-content input[type=email]:focus, |
| 800 |
.wpc-filters-widget-content input[type=number]:focus, |
| 801 |
.wpc-filters-widget-content input[type=password]:focus, |
| 802 |
.wpc-filters-widget-content input[type=search]:focus, |
| 803 |
.wpc-filters-widget-content input[type=tel]:focus, |
| 804 |
.wpc-filters-widget-content input[type=text]:focus, |
| 805 |
.wpc-filters-widget-content input[type=url]:focus, |
| 806 |
.wpc-filters-widget-content input[type=email]:active, |
| 807 |
.wpc-filters-widget-content input[type=number]:active, |
| 808 |
.wpc-filters-widget-content input[type=password]:active, |
| 809 |
.wpc-filters-widget-content input[type=search]:active, |
| 810 |
.wpc-filters-widget-content input[type=tel]:active, |
| 811 |
.wpc-filters-widget-content input[type=text]:active, |
| 812 |
.wpc-filters-widget-content input[type=url]:active, |
| 813 |
.wpc-filter-collapsible .wpc-filter-title button:hover .wpc-open-icon, |
| 814 |
.wpc-filter-collapsible-reverse.wpc-filter-collapsible.wpc-closed .wpc-filter-title button:hover .wpc-open-icon, |
| 815 |
.wpc-filter-collapsible.wpc-closed .wpc-filter-title button:hover .wpc-open-icon, |
| 816 |
.wpc-filter-has-selected.wpc-closed .wpc-filter-title button:hover .wpc-open-icon{ |
| 817 |
border-color: '.$color.'; |
| 818 |
} |
| 819 |
|
| 820 |
.wpc-filters-main-wrap a.wpc-toggle-a:hover { |
| 821 |
color: '.$color.'; |
| 822 |
} |
| 823 |
.wpc-sorting-form .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple, |
| 824 |
.wpc-filter-layout-dropdown .select2-container--default.select2-container--open.select2-container--above .select2-selection--single, |
| 825 |
.wpc-sorting-form .select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple, |
| 826 |
.wpc-filter-layout-dropdown .select2-container--default.select2-container--open.select2-container--above .select2-selection--single{ |
| 827 |
border-top: 1px solid transparent; |
| 828 |
} |
| 829 |
.wpc-search-field-wrapper .wpc-search-clear-icon-wrapper, |
| 830 |
.wpc-filter-search-wrapper button.wpc-search-clear{ |
| 831 |
color: #b5bed2; |
| 832 |
} |
| 833 |
.wpc-filters-main-wrap .wpc-filters-labels li.wpc-term-item label { |
| 834 |
border-color: #ccd0dc; |
| 835 |
} |
| 836 |
.wpc-filters-main-wrap .wpc-filters-labels li.wpc-term-item label span.wpc-filter-label-wrapper{ |
| 837 |
padding: 8px 7px; |
| 838 |
} |
| 839 |
.wpc-filters-labels li.wpc-term-has-image label:hover .wpc-term-image-wrapper, |
| 840 |
.wpc-filters-labels li.wpc-term-has-image input[type=checkbox]:checked + label .wpc-term-image-wrapper{ |
| 841 |
border-color: '.$color.'; |
| 842 |
} |
| 843 |
@media screen and (min-width: '.$wpc_mobile_width.'px) { |
| 844 |
.wpc-filters-main-wrap input[type=radio]:hover, |
| 845 |
.wpc-filters-main-wrap input[type=checkbox]:hover{ |
| 846 |
border-color: '.$styled_color.'; |
| 847 |
} |
| 848 |
.wpc-filter-label-wrapper .wpc-term-swatch-no-image:hover, |
| 849 |
.wpc-filters-main-wrap .wpc-term-count-0:not(.wpc-has-not-empty-children) input[type=radio]:hover, |
| 850 |
.wpc-filters-main-wrap .wpc-term-count-0:not(.wpc-has-not-empty-children) input[type=checkbox]:hover{ |
| 851 |
border-color: #c3c3c3; |
| 852 |
} |
| 853 |
}'; |
| 854 |
} |
| 855 |
|
| 856 |
if( $use_select2 ){ |
| 857 |
$styled_color = $color ? $color : '#0570e2'; |
| 858 |
$contrastColor = $contrastColor ? $contrastColor : flrt_get_contrast_color($styled_color); |
| 859 |
|
| 860 |
$css .= '.wpc-sorting-form select, |
| 861 |
.wpc-filter-content select{ |
| 862 |
padding: 2px 8px 2px 10px; |
| 863 |
border-color: #c9d1e0; |
| 864 |
border-radius: 3px; |
| 865 |
color: inherit; |
| 866 |
-webkit-appearance: none; |
| 867 |
} |
| 868 |
.select2-container--default .wpc-filter-everything-dropdown .select2-results__option--highlighted::after, |
| 869 |
.select2-container--default .wpc-filter-everything-dropdown .select2-results__option[aria-selected="true"]::after, |
| 870 |
.select2-container--default .wpc-filter-everything-dropdown .select2-results__option[data-selected="true"]::after { |
| 871 |
border: 2px solid '.$color.'; |
| 872 |
content: ""; |
| 873 |
position: absolute !important; |
| 874 |
right: 13px !important; |
| 875 |
width: 18px; |
| 876 |
height: 10px; |
| 877 |
top: 30% !important; |
| 878 |
font-size: 16px !important; |
| 879 |
color: #000 !important; |
| 880 |
transform: rotate(137deg) !important; |
| 881 |
border-bottom: none; |
| 882 |
border-left: none; |
| 883 |
box-sizing: border-box; |
| 884 |
} |
| 885 |
.select2-container--default .wpc-filter-everything-dropdown .select2-results__option--highlighted::after { |
| 886 |
border-top: 2px solid #C7D1E2; |
| 887 |
border-right: 2px solid #C7D1E2; |
| 888 |
} |
| 889 |
.select2-container--default .wpc-filter-everything-dropdown .select2-results__option--highlighted[aria-selected], |
| 890 |
.select2-container--default .wpc-filter-everything-dropdown .select2-results__option--highlighted[data-selected]{ |
| 891 |
background-color: rgba(0,0,0,0.05); |
| 892 |
color: inherit; |
| 893 |
} |
| 894 |
'; |
| 895 |
$css .= '@media screen and (max-width: '.$wpc_mobile_width.'px) {'."\r\n"; |
| 896 |
$css .= '.wpc-sorting-form select, |
| 897 |
.wpc-filter-content select{ |
| 898 |
padding: 6px 12px 6px 14px; |
| 899 |
}'; |
| 900 |
|
| 901 |
$css .= '}'."\r\n"; |
| 902 |
} |
| 903 |
|
| 904 |
if( $move_to_top ){ |
| 905 |
$css .= '@media screen and (max-width: '.$wpc_mobile_width.'px) {'."\r\n"; |
| 906 |
|
| 907 |
$css .= 'body #main, |
| 908 |
body #content .col-full, |
| 909 |
.woocommerce-page .content-has-sidebar, |
| 910 |
.woocommerce-page .has-one-sidebar, |
| 911 |
.woocommerce-page #main-sidebar-container, |
| 912 |
.woocommerce-page .theme-page-wrapper, |
| 913 |
.woocommerce-page #content-area, |
| 914 |
.theme-jevelin.woocommerce-page .woocomerce-styling, |
| 915 |
.woocommerce-page .content_wrapper, |
| 916 |
.woocommerce-page #col-mask, |
| 917 |
body #main-content .content-area { |
| 918 |
-js-display: flex; |
| 919 |
display: -webkit-box; |
| 920 |
display: -webkit-flex; |
| 921 |
display: -moz-box; |
| 922 |
display: -ms-flexbox; |
| 923 |
display: flex; |
| 924 |
-webkit-box-orient: vertical; |
| 925 |
-moz-box-orient: vertical; |
| 926 |
-webkit-flex-direction: column; |
| 927 |
-ms-flex-direction: column; |
| 928 |
flex-direction: column; |
| 929 |
} |
| 930 |
body #primary, |
| 931 |
.woocommerce-page .has-one-sidebar > section, |
| 932 |
.woocommerce-page .theme-content, |
| 933 |
.woocommerce-page #left-area, |
| 934 |
.woocommerce-page #content, |
| 935 |
.woocommerce-page .sections_group, |
| 936 |
.woocommerce-page .content-box, |
| 937 |
body #main-sidebar-container #main { |
| 938 |
-webkit-box-ordinal-group: 2; |
| 939 |
-moz-box-ordinal-group: 2; |
| 940 |
-ms-flex-order: 2; |
| 941 |
-webkit-order: 2; |
| 942 |
order: 2; |
| 943 |
} |
| 944 |
body #secondary, |
| 945 |
.woocommerce-page .has-one-sidebar > aside, |
| 946 |
body aside#mk-sidebar, |
| 947 |
.woocommerce-page #sidebar, |
| 948 |
.woocommerce-page .sidebar, |
| 949 |
body #main-sidebar-container #sidebar { |
| 950 |
-webkit-box-ordinal-group: 1; |
| 951 |
-moz-box-ordinal-group: 1; |
| 952 |
-ms-flex-order: 1; |
| 953 |
-webkit-order: 1; |
| 954 |
order: 1; |
| 955 |
} |
| 956 |
|
| 957 |
/*second method first method solve issue theme specific*/ |
| 958 |
.woocommerce-page:not(.single,.page) .btWithSidebar.btSidebarLeft .btContentHolder, |
| 959 |
body .theme-generatepress.woocommerce #content { |
| 960 |
display: table; |
| 961 |
} |
| 962 |
body .btContent, |
| 963 |
body .theme-generatepress.woocommerce #primary { |
| 964 |
display: table-footer-group; |
| 965 |
} |
| 966 |
body .btSidebar, |
| 967 |
body .theme-generatepress.woocommerce #left-sidebar { |
| 968 |
display: table-header-group; |
| 969 |
}'."\r\n"; |
| 970 |
$css .= '#ui-datepicker-div.wpc-filter-datepicker .ui-datepicker-close.ui-state-default{ |
| 971 |
background: '.$color.'; |
| 972 |
color: '.$contrastColor.'; |
| 973 |
}'."\r\n"; |
| 974 |
$css .= '.wpc-filters-date-range-column{ |
| 975 |
justify-content: left; |
| 976 |
}'."\r\n"; |
| 977 |
$css .= '}'."\r\n"; |
| 978 |
} |
| 979 |
|
| 980 |
if( $use_loader ){ |
| 981 |
$css .= '@media screen and (min-width: '.$wpc_mobile_width.'px) {'."\r\n"; |
| 982 |
$css .= 'html.is-active .wpc-spinner{ |
| 983 |
display: block; |
| 984 |
}'; |
| 985 |
$css .= '}'."\r\n"; |
| 986 |
} |
| 987 |
|
| 988 |
if( $dark_overlay ){ |
| 989 |
$css .= '@media screen and (min-width: '.$wpc_mobile_width.'px) {'."\r\n"; |
| 990 |
$css .= 'html.is-active .wpc-filters-overlay{ |
| 991 |
opacity: .15; |
| 992 |
background: #000000; |
| 993 |
}'; |
| 994 |
$css .= '}'."\r\n"; |
| 995 |
} |
| 996 |
|
| 997 |
if( $custom_css ){ |
| 998 |
$css .= $custom_css."\r\n"; |
| 999 |
} |
| 1000 |
|
| 1001 |
$wp_upload_dir = wp_upload_dir(); |
| 1002 |
$upload_dir_baseurl = $wp_upload_dir['baseurl']; |
| 1003 |
$upload_dir_basepath = $wp_upload_dir['basedir']; |
| 1004 |
|
| 1005 |
$cache_dir = $upload_dir_basepath . '/cache/filter-everything/'; |
| 1006 |
|
| 1007 |
if ( ! file_exists( $cache_dir ) ) { |
| 1008 |
mkdir($cache_dir, 0777, true); |
| 1009 |
chmod($cache_dir, 0777); |
| 1010 |
} |
| 1011 |
|
| 1012 |
$filename = md5( $css ) . '.css'; |
| 1013 |
|
| 1014 |
$fileurl = $upload_dir_baseurl .'/cache/filter-everything/' . $filename; |
| 1015 |
$filepath = $cache_dir . $filename; |
| 1016 |
|
| 1017 |
if ( $css !== '' ) { |
| 1018 |
if ( ! file_exists( $filepath ) ) { |
| 1019 |
file_put_contents( $filepath, $css ); |
| 1020 |
} |
| 1021 |
|
| 1022 |
if( file_exists( $filepath ) ){ |
| 1023 |
wp_enqueue_style('wpc-filter-everything-custom', $fileurl ); |
| 1024 |
} |
| 1025 |
} |
| 1026 |
|
| 1027 |
} |
| 1028 |
|
| 1029 |
public function bodyClass( $classes ) |
| 1030 |
{ |
| 1031 |
if( flrt_get_option('mobile_filter_settings') === 'show_open_close_button' ){ |
| 1032 |
$classes[] = 'wpc_show_open_close_button'; |
| 1033 |
} |
| 1034 |
|
| 1035 |
if( flrt_is_filter_request() ){ |
| 1036 |
$classes[] = 'wpc_is_filter_request'; |
| 1037 |
} |
| 1038 |
|
| 1039 |
return $classes; |
| 1040 |
} |
| 1041 |
|
| 1042 |
public static function activate() |
| 1043 |
{ |
| 1044 |
$defaultSettings = new DefaultSettings(); |
| 1045 |
if ( ! get_option('wpc_filter_settings') ) { |
| 1046 |
add_option('wpc_filter_settings', $defaultSettings->wpc_filter_settings() ); |
| 1047 |
} |
| 1048 |
|
| 1049 |
if( ! get_option( 'wpc_filter_experimental' ) ){ |
| 1050 |
add_option('wpc_filter_experimental', $defaultSettings->wpc_filter_experimental() ); |
| 1051 |
} |
| 1052 |
} |
| 1053 |
|
| 1054 |
/** |
| 1055 |
* Clears all plugin data: options and posts |
| 1056 |
*/ |
| 1057 |
public static function uninstall( $force = false ) |
| 1058 |
{ |
| 1059 |
$allow_to_delete = true; |
| 1060 |
|
| 1061 |
if( is_multisite() ){ |
| 1062 |
$active_plugins = get_site_option('active_sitewide_plugins'); |
| 1063 |
if( is_array( $active_plugins ) ){ |
| 1064 |
$active_plugins = array_keys( $active_plugins ); |
| 1065 |
} |
| 1066 |
}else{ |
| 1067 |
$active_plugins = apply_filters('active_plugins', get_option('active_plugins')); |
| 1068 |
} |
| 1069 |
|
| 1070 |
$fe_active = []; |
| 1071 |
$to_compare = [ |
| 1072 |
'filter-everything-pro/filter-everything.php', |
| 1073 |
'filter-everything/filter-everything.php' |
| 1074 |
]; |
| 1075 |
|
| 1076 |
if( ! empty( $active_plugins ) ){ |
| 1077 |
foreach ( $active_plugins as $plugin_path ){ |
| 1078 |
if( in_array( $plugin_path, $to_compare ) ){ |
| 1079 |
$fe_active[] = $plugin_path; |
| 1080 |
} |
| 1081 |
} |
| 1082 |
} |
| 1083 |
|
| 1084 |
if( count( $fe_active ) > 0 ){ |
| 1085 |
$allow_to_delete = false; |
| 1086 |
} |
| 1087 |
|
| 1088 |
if ( $force == true ) { |
| 1089 |
$allow_to_delete = true; |
| 1090 |
} |
| 1091 |
|
| 1092 |
if( $allow_to_delete ){ |
| 1093 |
|
| 1094 |
$options = [ |
| 1095 |
'wpc_filter_settings', |
| 1096 |
'wpc_indexing_deep_settings', |
| 1097 |
'wpc_filter_permalinks', |
| 1098 |
'wpc_seo_rules_settings', |
| 1099 |
'wpc_xml_write_date', |
| 1100 |
'wpc_filter_experimental', |
| 1101 |
'widget_wpc_filters_widget', |
| 1102 |
'widget_wpc_sorting_widget', |
| 1103 |
'widget_wpc_chips_widget', |
| 1104 |
]; |
| 1105 |
|
| 1106 |
foreach ( $options as $option_name ){ |
| 1107 |
delete_option( $option_name ); |
| 1108 |
} |
| 1109 |
|
| 1110 |
// Deactivate and erase license if exists |
| 1111 |
if ( defined( 'FLRT_FILTERS_PRO' ) && FLRT_FILTERS_PRO ) { |
| 1112 |
|
| 1113 |
wpc_clear_folder(FLRT_XML_PATH); |
| 1114 |
|
| 1115 |
$to_send = false; |
| 1116 |
$saved_value = get_option( FLRT_LICENSE_KEY ); |
| 1117 |
|
| 1118 |
if( isset( $saved_value['license_key'] ) ) { |
| 1119 |
$saved_value_arr = maybe_unserialize( base64_decode( $saved_value['license_key'] ) ); |
| 1120 |
$to_send = $saved_value_arr; |
| 1121 |
} |
| 1122 |
|
| 1123 |
if ( is_array( $to_send ) ){ |
| 1124 |
$to_send['home_url'] = home_url(); |
| 1125 |
|
| 1126 |
// Make data suitable to send as GET variables |
| 1127 |
$to_send = array_map( 'urlencode', $to_send ); |
| 1128 |
|
| 1129 |
if ( isset( $saved_value_arr['id'] ) && $saved_value_arr['id'] ) { |
| 1130 |
$apiRequest = new ApiRequests(); |
| 1131 |
$result = $apiRequest->sendRequest('DELETE', 'license', $to_send ); |
| 1132 |
|
| 1133 |
// If license was deactivated, we have to refresh updates info |
| 1134 |
delete_transient(FLRT_VERSION_TRANSIENT ); |
| 1135 |
delete_option( FLRT_LICENSE_KEY ); |
| 1136 |
} |
| 1137 |
} |
| 1138 |
|
| 1139 |
} |
| 1140 |
|
| 1141 |
$postTypes = array( |
| 1142 |
FLRT_FILTERS_SET_POST_TYPE, |
| 1143 |
FLRT_FILTERS_POST_TYPE |
| 1144 |
); |
| 1145 |
|
| 1146 |
if( defined( 'FLRT_SEO_RULES_POST_TYPE' ) ){ |
| 1147 |
$postTypes[] = FLRT_SEO_RULES_POST_TYPE; |
| 1148 |
} |
| 1149 |
|
| 1150 |
$filterPosts = new \WP_Query( |
| 1151 |
array( |
| 1152 |
'posts_per_page' => -1, |
| 1153 |
'post_status' => array('any'), |
| 1154 |
'post_type' => $postTypes, |
| 1155 |
'fields' => 'ids', |
| 1156 |
'suppress_filters' => true |
| 1157 |
) |
| 1158 |
); |
| 1159 |
|
| 1160 |
$filterPostsIds = $filterPosts->get_posts(); |
| 1161 |
|
| 1162 |
if( ! empty( $filterPostsIds ) ){ |
| 1163 |
foreach ($filterPostsIds as $post_id) { |
| 1164 |
wp_delete_post( $post_id, true ); |
| 1165 |
} |
| 1166 |
} |
| 1167 |
|
| 1168 |
$filterTrashPosts = new \WP_Query( |
| 1169 |
array( |
| 1170 |
'posts_per_page' => -1, |
| 1171 |
'post_status' => array('trash'), |
| 1172 |
'post_type' => $postTypes, |
| 1173 |
'fields' => 'ids', |
| 1174 |
'suppress_filters' => true |
| 1175 |
) |
| 1176 |
); |
| 1177 |
|
| 1178 |
$filterTrashPostsIds = $filterTrashPosts->get_posts(); |
| 1179 |
|
| 1180 |
if( ! empty( $filterTrashPostsIds ) ){ |
| 1181 |
foreach ($filterTrashPostsIds as $post_id) { |
| 1182 |
wp_delete_post( $post_id, true ); |
| 1183 |
} |
| 1184 |
} |
| 1185 |
} |
| 1186 |
} |
| 1187 |
|
| 1188 |
public static function switchTheme() { |
| 1189 |
flrt_remove_option('posts_container'); |
| 1190 |
flrt_remove_option('primary_color'); |
| 1191 |
} |
| 1192 |
|
| 1193 |
public function includeAdminCss() |
| 1194 |
{ |
| 1195 |
$screen = get_current_screen(); |
| 1196 |
if ( ! is_null( $screen ) && property_exists( $screen, 'base' ) ) { |
| 1197 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 1198 |
$ver = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? rand(0, 1000) : FLRT_PLUGIN_VER; |
| 1199 |
$is_about_pro_tab = isset($_GET['tab']) && $_GET['tab'] === 'aboutpro'; |
| 1200 |
|
| 1201 |
if ( in_array( $screen->base, [ 'edit', 'post', 'edit-tags', 'term' ] ) || ( strpos( $screen->base, 'filters-settings' ) !== false ) ) { |
| 1202 |
wp_enqueue_style( 'wpc-filter-everything-admin', FLRT_PLUGIN_DIR_URL . 'assets/css/filter-everything-admin'.$suffix.'.css', ['wp-color-picker'], $ver ); |
| 1203 |
if($is_about_pro_tab){ |
| 1204 |
wp_enqueue_style( 'wpc-filter-everything-pro-benefits', FLRT_PLUGIN_DIR_URL . 'assets/css/pro-benefits-page'.$suffix.'.css', ['wpc-filter-everything-admin'], $ver ); |
| 1205 |
} |
| 1206 |
} |
| 1207 |
|
| 1208 |
if ( $screen->base === 'widgets' ) { |
| 1209 |
wp_enqueue_style('wpc-widgets', FLRT_PLUGIN_DIR_URL . 'assets/css/wpc-widgets' . $suffix . '.css', [], $ver ); |
| 1210 |
} |
| 1211 |
|
| 1212 |
} |
| 1213 |
} |
| 1214 |
|
| 1215 |
public function includeAdminJs() |
| 1216 |
{ |
| 1217 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 1218 |
$ver = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? rand(0, 1000) : FLRT_PLUGIN_VER; |
| 1219 |
$select2ver = '4.1.0'; |
| 1220 |
|
| 1221 |
wp_register_script( 'jquery-tiptip', FLRT_PLUGIN_DIR_URL . 'assets/js/jquery-tiptip/jquery.tipTip' . $suffix . '.js', array( 'jquery' ), $ver, true ); |
| 1222 |
wp_enqueue_script('jquery-tiptip'); |
| 1223 |
wp_enqueue_script('wpc-filters-admin', FLRT_PLUGIN_DIR_URL . 'assets/js/wpc-filters-common-admin' . $suffix . '.js', array( 'jquery', 'jquery-ui-sortable', 'wp-color-picker', 'select2'), $ver, true ); |
| 1224 |
|
| 1225 |
$l10n = array( |
| 1226 |
'prefixesOrderAvailableInPro' => esc_html__( 'Editing the order of URL prefixes is available in the PRO version', 'filter-everything' ), |
| 1227 |
'chipsPlaceholder' => esc_html__( 'Select or enter hooks', 'filter-everything' ), |
| 1228 |
'colorSwatchesPlaceholder' => esc_html__( 'Click to select taxonomies', 'filter-everything' ), |
| 1229 |
); |
| 1230 |
wp_localize_script( 'wpc-filters-admin', 'wpcFiltersAdminCommon', $l10n ); |
| 1231 |
|
| 1232 |
wp_enqueue_script( 'select2', FLRT_PLUGIN_DIR_URL . "assets/js/select2/select2".$suffix.".js", array('jquery'), $select2ver ); |
| 1233 |
wp_enqueue_style('select2', FLRT_PLUGIN_DIR_URL . "assets/css/select2/select2".$suffix.".css", '', $select2ver ); |
| 1234 |
|
| 1235 |
$screen = get_current_screen(); |
| 1236 |
|
| 1237 |
if( ! is_null( $screen ) && property_exists( $screen, 'base' ) && $screen->base === 'widgets' ){ |
| 1238 |
wp_enqueue_script('wpc-widgets', FLRT_PLUGIN_DIR_URL . 'assets/js/wpc-widgets' . $suffix . '.js', array('jquery'), $ver ); |
| 1239 |
$l10n = array( |
| 1240 |
'wpcItemNum' => esc_html__( 'Item #', 'filter-everything') |
| 1241 |
); |
| 1242 |
wp_localize_script( 'wpc-widgets', 'wpcWidgets', $l10n ); |
| 1243 |
} |
| 1244 |
} |
| 1245 |
|
| 1246 |
public function includeFrontCss() |
| 1247 |
{ |
| 1248 |
$suffix = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? '' : '.min'; |
| 1249 |
$ver = (defined('SCRIPT_DEBUG') && SCRIPT_DEBUG) ? rand(0, 1000) : FLRT_PLUGIN_VER; |
| 1250 |
/** |
| 1251 |
* string |
| 1252 |
*/ |
| 1253 |
$getData = Container::instance()->getTheGet(); |
| 1254 |
if( isset( $getData[FLRT_BEAVER_BUILDER_VAR] ) ){ |
| 1255 |
wp_enqueue_style('wpc-widgets', FLRT_PLUGIN_DIR_URL . 'assets/css/wpc-widgets' . $suffix . '.css', [], $ver ); |
| 1256 |
} |
| 1257 |
|
| 1258 |
// Do not include plugin CSS if there are no Filter Sets on the page |
| 1259 |
$sets = $this->wpManager->getQueryVar('wpc_page_related_set_ids', []); |
| 1260 |
if( empty( $sets ) ) { |
| 1261 |
return false; |
| 1262 |
} |
| 1263 |
|
| 1264 |
wp_enqueue_style('wpc-filter-everything', FLRT_PLUGIN_DIR_URL . 'assets/css/filter-everything' . $suffix . '.css', [], $ver); |
| 1265 |
} |
| 1266 |
|
| 1267 |
public function footerHtml() |
| 1268 |
{ |
| 1269 |
echo '<div class="wpc-filters-overlay"></div>'."\r\n"; |
| 1270 |
} |
| 1271 |
|
| 1272 |
public function includeFrontJs() |
| 1273 |
{ |
| 1274 |
$suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; |
| 1275 |
$ver = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? rand(0, 1000) : FLRT_PLUGIN_VER; |
| 1276 |
/** |
| 1277 |
* string |
| 1278 |
*/ |
| 1279 |
$getData = Container::instance()->getTheGet(); |
| 1280 |
$em = Container::instance()->getEntityManager(); |
| 1281 |
|
| 1282 |
$wpcFrontJsVariables = []; |
| 1283 |
|
| 1284 |
if( isset( $getData[FLRT_BEAVER_BUILDER_VAR] ) ){ |
| 1285 |
wp_enqueue_script('wpc-widgets', FLRT_PLUGIN_DIR_URL . 'assets/js/wpc-widgets' . $suffix . '.js', array('jquery'), $ver ); |
| 1286 |
$l10n = array( |
| 1287 |
'wpcItemNum' => esc_html__( 'Item #', 'filter-everything' ) |
| 1288 |
); |
| 1289 |
wp_localize_script( 'wpc-widgets', 'wpcWidgets', $l10n ); |
| 1290 |
} |
| 1291 |
|
| 1292 |
// Do not include plugin JS if there are no Filter Sets on the page |
| 1293 |
$sets = $this->wpManager->getQueryVar( 'wpc_page_related_set_ids', [] ); |
| 1294 |
$related_filters = $em->getSetsRelatedFilters( $sets ); |
| 1295 |
$date_filters = []; |
| 1296 |
$include_timepicker = false; |
| 1297 |
|
| 1298 |
if ( ! empty( $related_filters ) ) { |
| 1299 |
foreach ( $related_filters as $filter ) { |
| 1300 |
if ( in_array( $filter['entity'], [ 'post_date', 'post_meta_date' ] ) ) { |
| 1301 |
|
| 1302 |
$date_time = flrt_split_date_time( $filter['date_format'] ); |
| 1303 |
|
| 1304 |
global $wp_locale; |
| 1305 |
$date_filters[ $filter['ID'] ] = [ |
| 1306 |
'date_type' => $filter['date_type'], |
| 1307 |
'date_format' => flrt_convert_date_to_js( $date_time['date'] ), |
| 1308 |
'time_format' => flrt_convert_time_to_js( $date_time['time'] ), |
| 1309 |
]; |
| 1310 |
|
| 1311 |
if ( in_array( $filter['date_type'], [ 'time', 'datetime' ] ) ) { |
| 1312 |
$include_timepicker = true; |
| 1313 |
} |
| 1314 |
|
| 1315 |
} |
| 1316 |
} |
| 1317 |
} |
| 1318 |
|
| 1319 |
/** |
| 1320 |
* Do not continue and do not include any assets |
| 1321 |
* if this page does not contain Filter Sets |
| 1322 |
*/ |
| 1323 |
if ( empty( $sets ) ) { |
| 1324 |
return false; |
| 1325 |
} |
| 1326 |
|
| 1327 |
$showBottomWidget = 'no'; |
| 1328 |
$ajaxEnabled = false; |
| 1329 |
$autoScroll = false; |
| 1330 |
$waitCursor = false; |
| 1331 |
$wpcUseSelect2 = false; |
| 1332 |
$wpcPopupCompatMode = false; |
| 1333 |
$autoScrollOffset = apply_filters( 'wpc_auto_scroll_offset', 150 ); |
| 1334 |
$wpc_mobile_width = flrt_get_mobile_width(); |
| 1335 |
$per_page = []; |
| 1336 |
$applyButtonSets = []; |
| 1337 |
$queryOnThePageSets = []; |
| 1338 |
$filterSetService = Container::instance()->getFilterSetService(); |
| 1339 |
|
| 1340 |
if ( flrt_get_option('mobile_filter_settings') === 'show_bottom_widget' ) { |
| 1341 |
$showBottomWidget = 'yes'; |
| 1342 |
} |
| 1343 |
|
| 1344 |
if ( flrt_get_option('enable_ajax') === 'on' ) { |
| 1345 |
$ajaxEnabled = true; |
| 1346 |
} |
| 1347 |
|
| 1348 |
if ( flrt_get_experimental_option('auto_scroll') === 'on' ) { |
| 1349 |
$autoScroll = true; |
| 1350 |
} |
| 1351 |
|
| 1352 |
if ( flrt_get_experimental_option( 'use_wait_cursor' ) === 'on' ) { |
| 1353 |
$waitCursor = true; |
| 1354 |
} |
| 1355 |
|
| 1356 |
if ( flrt_get_option('bottom_widget_compatibility') ) { |
| 1357 |
$wpcPopupCompatMode = true; |
| 1358 |
} |
| 1359 |
|
| 1360 |
//@todo This appears on login page and produce not an array error |
| 1361 |
foreach( $sets as $set ){ |
| 1362 |
if( $set['filtered_post_type'] === 'product' && function_exists('wc_get_default_products_per_row') ){ |
| 1363 |
$numberposts = apply_filters( 'loop_shop_per_page', wc_get_default_products_per_row() * wc_get_default_product_rows_per_page() ); |
| 1364 |
}else{ |
| 1365 |
$numberposts = get_option( 'posts_per_page' ); |
| 1366 |
} |
| 1367 |
|
| 1368 |
$per_page[ $set['ID'] ] = intval($numberposts); |
| 1369 |
$theSet = $filterSetService->getSet( $set['ID'] ); |
| 1370 |
|
| 1371 |
if( isset( $set['query_on_the_page'] ) && $set['query_on_the_page'] ){ |
| 1372 |
if( (int) $set['ID'] > 0 ) { |
| 1373 |
$queryOnThePageSets[] = (int) $set['ID']; |
| 1374 |
} |
| 1375 |
} |
| 1376 |
|
| 1377 |
if( isset( $theSet['use_apply_button']['value'] ) && $theSet['use_apply_button']['value'] === 'yes' ){ |
| 1378 |
if( (int) $set['ID'] > 0 ){ |
| 1379 |
$applyButtonSets[] = (int) $set['ID']; |
| 1380 |
} |
| 1381 |
} |
| 1382 |
} |
| 1383 |
|
| 1384 |
$per_page = apply_filters( 'wpc_filter_sets_posts_per_page', $per_page ); |
| 1385 |
|
| 1386 |
$wpcPostContainers = apply_filters( 'wpc_posts_containers', flrt_get_option( 'posts_container', flrt_default_posts_container() ) ); |
| 1387 |
|
| 1388 |
wp_register_script( 'wc-jquery-ui-touchpunch', FLRT_PLUGIN_DIR_URL . 'assets/js/jquery-ui-touch-punch/jquery-ui-touch-punch'.$suffix.'.js', [], $ver, true ); |
| 1389 |
|
| 1390 |
$wpcFrontJsVariables = array( |
| 1391 |
'ajaxUrl' => admin_url('admin-ajax.php'), |
| 1392 |
'wpcAjaxEnabled' => $ajaxEnabled, |
| 1393 |
'wpcStatusCookieName' => FLRT_FOLDING_COOKIE_NAME, |
| 1394 |
'wpcMoreLessCookieName' => FLRT_MORELESS_COOKIE_NAME, |
| 1395 |
'wpcHierarchyListCookieName' => FLRT_HIERARCHY_LIST_COOKIE_NAME, |
| 1396 |
'wpcWidgetStatusCookieName' => FLRT_OPEN_CLOSE_BUTTON_COOKIE_NAME, |
| 1397 |
'wpcMobileWidth' => $wpc_mobile_width, |
| 1398 |
'showBottomWidget' => $showBottomWidget, |
| 1399 |
'_nonce' => wp_create_nonce('wpcNonceFront'), |
| 1400 |
'wpcPostContainers' => $wpcPostContainers, |
| 1401 |
'wpcAutoScroll' => $autoScroll, |
| 1402 |
'wpcAutoScrollOffset' => $autoScrollOffset, |
| 1403 |
'wpcWaitCursor' => $waitCursor, |
| 1404 |
'wpcPostsPerPage' => $per_page, |
| 1405 |
'wpcUseSelect2' => $wpcUseSelect2, |
| 1406 |
'wpcDateFilters' => false, |
| 1407 |
'wpcPopupCompatMode' => $wpcPopupCompatMode, |
| 1408 |
'wpcApplyButtonSets' => $applyButtonSets, |
| 1409 |
'wpcQueryOnThePageSets' => $queryOnThePageSets, |
| 1410 |
'wpcNoPostsContainerMsg' => esc_html__('It appears that this page does not contain a container with the specified «HTML id or class of the Posts Container». Try to specify the correct one in the Filter Set settings or the common plugin Settings.', 'filter-everything'), |
| 1411 |
); |
| 1412 |
|
| 1413 |
/** |
| 1414 |
* We includes Flatpickr.js only on pages, where date filter is used. |
| 1415 |
*/ |
| 1416 |
if ( ! empty( $date_filters ) ) { |
| 1417 |
|
| 1418 |
wp_enqueue_script( 'jquery-ui-datepicker' ); |
| 1419 |
wp_enqueue_style( 'wpc-datepicker', FLRT_PLUGIN_DIR_URL . 'assets/css/datepicker/jquery-ui'.$suffix.'.css', array(), '1.11.4' ); |
| 1420 |
|
| 1421 |
if ( $include_timepicker ) { |
| 1422 |
wp_enqueue_script( 'wpc-timepicker', FLRT_PLUGIN_DIR_URL . "assets/js/timepicker/jquery-ui-timepicker-addon".$suffix.".js", array( 'jquery-ui-datepicker' ), '1.6.3' ); |
| 1423 |
wp_enqueue_style( 'wpc-timepicker', FLRT_PLUGIN_DIR_URL . "assets/css/timepicker/jquery-ui-timepicker-addon".$suffix.".css", array(), '1.6.3' ); |
| 1424 |
} |
| 1425 |
|
| 1426 |
$wpcFrontJsVariables['wpcDateFilters'] = $date_filters; |
| 1427 |
$wpcFrontJsVariables['wpcDateFiltersLocale'] = determine_locale(); |
| 1428 |
$wpcFrontJsVariables['wpcDateFiltersL10n'] = array( |
| 1429 |
'closeText' => _x( 'Filter', 'Date Picker closeText', 'filter-everything' ), |
| 1430 |
'currentText' => _x( 'Today', 'Date Picker currentText', 'filter-everything' ), |
| 1431 |
'nextText' => _x( 'Next', 'Date Picker nextText', 'filter-everything' ), |
| 1432 |
'prevText' => _x( 'Prev', 'Date Picker prevText', 'filter-everything' ), |
| 1433 |
'weekHeader' => _x( 'Wk', 'Date Picker weekHeader', 'filter-everything' ), |
| 1434 |
'timeOnlyTitle' => _x( 'Choose Time', 'Date Time Picker timeOnlyTitle', 'filter-everything' ), |
| 1435 |
'timeText' => _x( 'Time', 'Date Time Picker timeText', 'filter-everything' ), |
| 1436 |
'hourText' => _x( 'Hour', 'Date Time Picker hourText', 'filter-everything' ), |
| 1437 |
'minuteText' => _x( 'Minute', 'Date Time Picker minuteText', 'filter-everything' ), |
| 1438 |
'secondText' => _x( 'Second', 'Date Time Picker secondText', 'filter-everything' ), |
| 1439 |
'timezoneText' => _x( 'Time Zone', 'Date Time Picker timezoneText', 'filter-everything' ), |
| 1440 |
'selectText' => _x( 'Select', 'Date Time Picker selectText', 'filter-everything' ), |
| 1441 |
'amNames' => array( |
| 1442 |
_x( 'AM', 'Date Time Picker amText', 'filter-everything' ), |
| 1443 |
_x( 'A', 'Date Time Picker amTextShort', 'filter-everything' ), |
| 1444 |
), |
| 1445 |
'pmNames' => array( |
| 1446 |
_x( 'PM', 'Date Time Picker pmText', 'filter-everything' ), |
| 1447 |
_x( 'P', 'Date Time Picker pmTextShort', 'filter-everything' ), |
| 1448 |
), |
| 1449 |
|
| 1450 |
'monthNames' => array_values( $wp_locale->month ), |
| 1451 |
'monthNamesShort' => array_values( $wp_locale->month_abbrev ), |
| 1452 |
'dayNames' => array_values( $wp_locale->weekday ), |
| 1453 |
'dayNamesMin' => array_values( $wp_locale->weekday_initial ), |
| 1454 |
'dayNamesShort' => array_values( $wp_locale->weekday_abbrev ), |
| 1455 |
'firstDay' => get_option( 'start_of_week' ), |
| 1456 |
); |
| 1457 |
} |
| 1458 |
|
| 1459 |
/** |
| 1460 |
* Include Main Front filters javascript |
| 1461 |
*/ |
| 1462 |
wp_enqueue_script('wpc-filter-everything', FLRT_PLUGIN_DIR_URL . 'assets/js/filter-everything'.$suffix.'.js', array('jquery', 'jquery-ui-slider', 'wc-jquery-ui-touchpunch'), $ver, true ); |
| 1463 |
|
| 1464 |
if( flrt_get_experimental_option('select2_dropdowns') === 'on' ){ |
| 1465 |
$select2ver = '4.1.0'; |
| 1466 |
$wpcUseSelect2 = 'yes'; |
| 1467 |
wp_enqueue_script( 'select2', FLRT_PLUGIN_DIR_URL . "assets/js/select2/select2".$suffix.".js", array('jquery'), $select2ver ); |
| 1468 |
wp_enqueue_style('select2', FLRT_PLUGIN_DIR_URL . "assets/css/select2/select2".$suffix.".css", '', $select2ver ); |
| 1469 |
} |
| 1470 |
|
| 1471 |
$wpcFrontJsVariables['wpcUseSelect2'] = $wpcUseSelect2; |
| 1472 |
|
| 1473 |
wp_localize_script( 'wpc-filter-everything', 'wpcFilterFront', $wpcFrontJsVariables ); |
| 1474 |
|
| 1475 |
unset( $filterSetService, $wpcFrontJsVariables ); |
| 1476 |
} |
| 1477 |
|
| 1478 |
public function removeApplyButtonOrderField( &$set_settings_fields ) |
| 1479 |
{ |
| 1480 |
unset( $set_settings_fields['apply_button_menu_order'], $set_settings_fields['search_field_menu_order'] ); |
| 1481 |
} |
| 1482 |
|
| 1483 |
public function handleFilterSetFieldsVisibility( $filterSetFields ) |
| 1484 |
{ |
| 1485 |
if( isset( $filterSetFields['use_apply_button']['value'] ) && $filterSetFields['use_apply_button']['value'] === 'yes' ) { |
| 1486 |
$filterSetFields['apply_button_text']['additional_class'] = 'wpc-opened'; |
| 1487 |
$filterSetFields['reset_button_text']['additional_class'] = 'wpc-opened'; |
| 1488 |
} |
| 1489 |
|
| 1490 |
if ( isset( $filterSetFields['use_search_field']['value'] ) && $filterSetFields['use_search_field']['value'] === 'yes' ) { |
| 1491 |
$filterSetFields['search_field_placeholder']['additional_class'] = 'wpc-opened'; |
| 1492 |
$filterSetFields['search_field_label']['additional_class'] = 'wpc-opened'; |
| 1493 |
} |
| 1494 |
|
| 1495 |
if (isset( $filterSetFields['horizontal_view']['value'] ) && $filterSetFields['horizontal_view']['value'] === 'yes'){ |
| 1496 |
$filterSetFields['horizontal_view_column']['additional_class'] = 'wpc-opened'; |
| 1497 |
} |
| 1498 |
|
| 1499 |
return $filterSetFields; |
| 1500 |
} |
| 1501 |
|
| 1502 |
public function disableCacheProductsShortcode( $out ) |
| 1503 |
{ |
| 1504 |
$wpManager = Container::instance()->getWpManager(); |
| 1505 |
$is_filter_request = $wpManager->getQueryVar('wpc_is_filter_request'); |
| 1506 |
$thePost = Container::instance()->getThePost(); |
| 1507 |
$action = isset( $thePost['action'] ) ? $thePost['action'] : false; |
| 1508 |
|
| 1509 |
// wpc_get_wp_queries - action to get WP_Queries on a page |
| 1510 |
if( isset( $out['cache'] ) && ( $is_filter_request || $action === 'wpc_get_wp_queries' ) ){ |
| 1511 |
$out['cache'] = false; |
| 1512 |
} |
| 1513 |
|
| 1514 |
return $out; |
| 1515 |
} |
| 1516 |
|
| 1517 |
public function showCombinedFields( &$filter, $field_key ) |
| 1518 |
{ |
| 1519 |
$includeExclude = flrt_extract_vars( $filter, array('exclude', 'include') ); |
| 1520 |
if( $includeExclude ): |
| 1521 |
|
| 1522 |
?><tr class="<?php echo esc_attr( flrt_filter_row_class( $includeExclude['exclude'] ) ); ?>"<?php flrt_maybe_hide_row( $includeExclude['exclude'] ); ?>><?php |
| 1523 |
|
| 1524 |
flrt_include_admin_view('filter-field-label', array( |
| 1525 |
'field_key' => 'exclude', |
| 1526 |
'attributes' => $includeExclude['exclude'] |
| 1527 |
) |
| 1528 |
); |
| 1529 |
?> |
| 1530 |
<td class="wpc-filter-field-td wpc-filter-field-include-exclude-td"> |
| 1531 |
<div class="wpc-filter-field-include-exclude-wrap"> |
| 1532 |
<div class="wpc-field-wrap wpc-field-exclude-wrap <?php if( isset( $includeExclude['exclude']['id'] ) ){ echo esc_attr( $includeExclude['exclude']['id'] ); } ?>-wrap"> |
| 1533 |
<?php echo flrt_render_input( $includeExclude['exclude'] ); // Already escaped in function ?> |
| 1534 |
<?php do_action('wpc_after_filter_input', $includeExclude['exclude'] ); ?> |
| 1535 |
</div> |
| 1536 |
<div class="wpc-field-wrap wpc-field-include-wrap <?php if( isset( $includeExclude['include']['id'] ) ){ echo esc_attr( $includeExclude['include']['id'] ); } ?>-wrap"> |
| 1537 |
<?php echo flrt_render_input( $includeExclude['include'] ); // Already escaped in function ?> |
| 1538 |
<?php do_action('wpc_after_filter_input', $includeExclude['include'] ); ?> |
| 1539 |
</div> |
| 1540 |
</div> |
| 1541 |
</td> |
| 1542 |
</tr><?php |
| 1543 |
|
| 1544 |
endif; |
| 1545 |
|
| 1546 |
if ( $field_key === 'min_num_label' ) { |
| 1547 |
$min_max_num_labels = flrt_extract_vars( $filter, array( 'min_num_label', 'max_num_label' ) ); |
| 1548 |
|
| 1549 |
if( $min_max_num_labels ) : |
| 1550 |
$min_field_id = $max_field_id = ''; |
| 1551 |
|
| 1552 |
if (isset($min_max_num_labels['min_num_label']['id'])) { |
| 1553 |
$min_field_id = esc_attr($min_max_num_labels['min_num_label']['id']); |
| 1554 |
} |
| 1555 |
if( isset( $min_max_num_labels['max_num_label']['id'] ) ){ |
| 1556 |
$max_field_id = esc_attr( $min_max_num_labels['max_num_label']['id'] ); |
| 1557 |
} |
| 1558 |
|
| 1559 |
if( isset($min_max_num_labels['min_num_label']['value']) ){ |
| 1560 |
$min_max_num_labels['min_num_label']['data-caret'] = mb_strlen( $min_max_num_labels['min_num_label']['value'] ) + 1; |
| 1561 |
} |
| 1562 |
|
| 1563 |
if( isset($min_max_num_labels['max_num_label']['value']) ){ |
| 1564 |
$min_max_num_labels['max_num_label']['data-caret'] = mb_strlen( $min_max_num_labels['max_num_label']['value'] ) + 1; |
| 1565 |
} |
| 1566 |
|
| 1567 |
?><tr class="<?php echo esc_attr( flrt_filter_row_class( $min_max_num_labels['min_num_label'] ) ); ?>"<?php flrt_maybe_hide_row( $min_max_num_labels['min_num_label'] ); ?>><?php |
| 1568 |
|
| 1569 |
flrt_include_admin_view('filter-field-label', array( |
| 1570 |
'field_key' => 'min_num_label', |
| 1571 |
'attributes' => $min_max_num_labels['min_num_label'] |
| 1572 |
) |
| 1573 |
); |
| 1574 |
?> |
| 1575 |
<td class="wpc-filter-field-td wpc-filter-field-min-max-labels-td"> |
| 1576 |
<div class="wpc-filter-field-min-max-labels-wrap"> |
| 1577 |
<div class="wpc-field-wrap wpc-field-min_num_label-wrap <?php echo $min_field_id; ?>-wrap"> |
| 1578 |
<?php echo flrt_render_input( $min_max_num_labels['min_num_label'] ); // Already escaped in function ?> |
| 1579 |
<?php do_action('wpc_after_filter_input', $min_max_num_labels['min_num_label'] ); ?> |
| 1580 |
</div> |
| 1581 |
<div class="wpc-field-wrap wpc-field-max_num_label-wrap <?php echo $max_field_id; ?>-wrap"> |
| 1582 |
<?php echo flrt_render_input( $min_max_num_labels['max_num_label'] ); // Already escaped in function ?> |
| 1583 |
<?php do_action('wpc_after_filter_input', $min_max_num_labels['max_num_label'] ); ?> |
| 1584 |
</div> |
| 1585 |
<p class="description"><?php echo wp_kses( |
| 1586 |
sprintf( __('For example, "Price from <span class="wpc-variable-inserter" data-field="%s" title="Click to insert the variable">{value}</span> $" will be displayed as "Price from 150 $"', 'filter-everything'), $min_field_id ), |
| 1587 |
array( 'span' => array( |
| 1588 |
'class' => true, |
| 1589 |
'data-field' => true, |
| 1590 |
'title' => true, |
| 1591 |
) ) |
| 1592 |
) ?></p> |
| 1593 |
</div> |
| 1594 |
</td> |
| 1595 |
</tr><?php |
| 1596 |
|
| 1597 |
endif; |
| 1598 |
} |
| 1599 |
} |
| 1600 |
|
| 1601 |
public function addSearchArgsToWpQuery( $wp_query ) |
| 1602 |
{ |
| 1603 |
if ( isset( $_GET['srch'] ) && $_GET['srch'] ) { |
| 1604 |
$keyword = filter_input( INPUT_GET, 'srch', FILTER_DEFAULT ); |
| 1605 |
$wp_query->set( 's', $keyword ); |
| 1606 |
} |
| 1607 |
|
| 1608 |
return $wp_query; |
| 1609 |
} |
| 1610 |
|
| 1611 |
public function addSkuSearchSql( $search, $wp_query ) |
| 1612 |
{ |
| 1613 |
if( $wp_query->get('flrt_query_hash') || $wp_query->get('flrt_query_clone') ){ |
| 1614 |
|
| 1615 |
if ( $wp_query->get('wc_query') === 'product_query' || $wp_query->get('post_type') === 'product' /* || $wp_query->get('post_type') === 'product_variation' */ ) { |
| 1616 |
global $wpdb; |
| 1617 |
|
| 1618 |
$product_id = wc_get_product_id_by_sku( $wp_query->get('s') ); |
| 1619 |
if ( ! $product_id ) { |
| 1620 |
return $search; |
| 1621 |
} |
| 1622 |
|
| 1623 |
$product = wc_get_product( $product_id ); |
| 1624 |
if ( $product->is_type( 'variation' ) ) { |
| 1625 |
$product_id = $product->get_parent_id(); |
| 1626 |
} |
| 1627 |
|
| 1628 |
$search = str_replace( 'AND (((', "AND (({$wpdb->posts}.ID IN (" . $product_id . ")) OR ((", $search ); |
| 1629 |
return $search; |
| 1630 |
} |
| 1631 |
|
| 1632 |
} |
| 1633 |
return $search; |
| 1634 |
} |
| 1635 |
|
| 1636 |
public function postDateWhere( $where, $wp_query ) |
| 1637 |
{ global $wpdb; |
| 1638 |
$sql = []; |
| 1639 |
$operator = ''; |
| 1640 |
$wpc_date_query = $wp_query->get( 'wpc_date_query' ); |
| 1641 |
|
| 1642 |
if( ! empty( $wpc_date_query ) && is_array( $wpc_date_query ) ) { |
| 1643 |
foreach ( $wpc_date_query as $edge => $value ) { |
| 1644 |
if( $edge === 'from' ) { |
| 1645 |
$operator = '>='; |
| 1646 |
} elseif ( $edge === 'to' ) { |
| 1647 |
$operator = '<='; |
| 1648 |
} |
| 1649 |
|
| 1650 |
$sql[] = $wpdb->prepare( "AND {$wpdb->posts}.post_date {$operator} %s ", $value ); |
| 1651 |
|
| 1652 |
} |
| 1653 |
|
| 1654 |
$where = implode( ' ', $sql ) . $where; |
| 1655 |
} |
| 1656 |
|
| 1657 |
return $where; |
| 1658 |
} |
| 1659 |
} |
| 1660 |
|