| @@ -107,8 +107,16 @@ | ||
| 107 | 107 | 'options' => $this->getViewOptions(), |
| 108 | 108 | 'default' => 'checkboxes', |
| 109 | 109 | 'instructions' => '', |
| 110 | 110 | ), |
| 111 | + 'show_range_list' => array( | |
| 112 | + 'type' => 'inProButton', | |
| 113 | + 'pro_label' => flrt_pro_promo_label(), | |
| 114 | + 'label' => esc_html__('Show Range List', 'filter-everything'), | |
| 115 | + 'class' => 'wpc-field-show-range-list', | |
| 116 | + 'default' => '', | |
| 117 | + 'tooltip' => '', | |
| 118 | + ), | |
| 111 | 119 | 'dropdown_label' => array( |
| 112 | 120 | 'type' => 'Text', |
| 113 | 121 | 'label' => esc_html__( 'Dropdown Label', 'filter-everything' ), |
| 114 | 122 | 'class' => 'wpc-field-dropdown-label', |
| @@ -251,9 +259,9 @@ | ||
| 251 | 259 | 'parent_filter' => array( |
| 252 | 260 | 'type' => 'Select', |
| 253 | 261 | 'label' => esc_html__( 'Parent Filter', 'filter-everything' ), |
| 254 | 262 | 'class' => 'wpc-field-parent-filter', |
| 255 | - 'options' => [ 'no' => esc_html__( 'Please, add filters first', 'filter-everything' ) ], | |
| 263 | + 'options' => [ '-1' => esc_html__( 'Please, add filters first', 'filter-everything' ) ], | |
| 256 | 264 | 'instructions' => esc_html__( 'If specified, current Filter terms become available only after the parent Filter selected', 'filter-everything' ) |
| 257 | 265 | ), |
| 258 | 266 | 'hide_until_parent' => array( |
| 259 | 267 | 'type' => 'Checkbox', |
| @@ -418,9 +426,9 @@ | ||
| 418 | 426 | if( ! empty( $filters ) ) { |
| 419 | 427 | if ( count( $filters ) > 1 ) { |
| 420 | 428 | $filternames['-1'] = esc_html__( '— Select Filter —', 'filter-everything' ) ; |
| 421 | 429 | } else { |
| 422 | - $filternames['no'] = esc_html__( 'Please, add filters first', 'filter-everything' ); | |
| 430 | + $filternames['-1'] = esc_html__( 'Please, add filters first', 'filter-everything' ); | |
| 423 | 431 | } |
| 424 | 432 | |
| 425 | 433 | foreach ( $filters as $filter ) { |
| 426 | 434 | |
| @@ -520,8 +528,13 @@ | ||
| 520 | 528 | $postType = $set['post_type']['value']; |
| 521 | 529 | } |
| 522 | 530 | } |
| 523 | 531 | |
| 532 | + if ( in_array( $filter['entity'], array( 'post_meta_num', 'tax_numeric')) !== false | |
| 533 | + && $filter['view'] === 'range' && (isset($filter['show_range_list']) && $filter['show_range_list'] === 'yes')) { | |
| 534 | + $short_entity .= ' wpc-view-range-list'; | |
| 535 | + } | |
| 536 | + | |
| 524 | 537 | $entity = $this->em->getEntityByFilter( $filter, $postType ); |
| 525 | 538 | |
| 526 | 539 | if( $entity ){ |
| 527 | 540 | $terms = $entity->getTermsForSelect(); |
| @@ -555,9 +568,9 @@ | ||
| 555 | 568 | |
| 556 | 569 | $fieldData['value'] = ( $filter[$fieldKey] ) ? $filter[$fieldKey] : $default_value; |
| 557 | 570 | |
| 558 | 571 | if( $fieldKey === 'hide_until_parent' ){ |
| 559 | - if( $filter['parent_filter'] > 0 ){ | |
| 572 | + if( (int) $filter['parent_filter'] > 0 ){ | |
| 560 | 573 | $fieldData['additional_class'] = 'wpc-opened'; |
| 561 | 574 | } |
| 562 | 575 | } |
| 563 | 576 | |
| @@ -624,8 +637,15 @@ | ||
| 624 | 637 | } |
| 625 | 638 | |
| 626 | 639 | } |
| 627 | 640 | |
| 641 | + if (!defined('FLRT_FILTERS_PRO')) { | |
| 642 | + if ($fieldKey === 'show_range_list') { | |
| 643 | + $fieldData['value'] = ''; | |
| 644 | + } | |
| 645 | + } | |
| 646 | + | |
| 647 | + | |
| 628 | 648 | if( $fieldKey === 'exclude' ){ |
| 629 | 649 | // We always add terms even they are empty array to fill Select2 with related terms. |
| 630 | 650 | $fieldData['options'] = $terms; |
| 631 | 651 | |
| @@ -727,10 +747,9 @@ | ||
| 727 | 747 | $sanitizedFilter[ $key ] = $value; |
| 728 | 748 | }else{ |
| 729 | 749 | |
| 730 | 750 | if( is_array( $value ) ){ |
| 731 | - array_map( 'esc_html', $value ); | |
| 732 | - $sanitizedFilter[ $key ] = $value; | |
| 751 | + $sanitizedFilter[ $key ] = map_deep( $value, 'esc_html' ); | |
| 733 | 752 | } else { |
| 734 | 753 | $sanitizedFilter[ $key ] = esc_html( $value ); |
| 735 | 754 | } |
| 736 | 755 | |
| @@ -1001,8 +1020,22 @@ | ||
| 1001 | 1020 | $this->pushError( 40, $filterID, 'e_name' ); // Invalid E_name. |
| 1002 | 1021 | $valid = false; |
| 1003 | 1022 | } |
| 1004 | 1023 | |
| 1024 | + | |
| 1025 | + if ( defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO && isset($filter['e_name'])) { | |
| 1026 | + if (!empty($filter['entity'])) { | |
| 1027 | + if (in_array($filter['entity'], array('post_meta_num', 'tax_numeric'))) { | |
| 1028 | + if (isset($filter['view']) && $filter['view'] === 'range' && !empty($filter['show_range_list']) && $filter['show_range_list'] === 'yes') { | |
| 1029 | + if (empty($filter['range_list_input'])) { | |
| 1030 | + $this->pushError(93, $filterID, 'range_list_input'); // Empty range_list. | |
| 1031 | + $valid = false; | |
| 1032 | + } | |
| 1033 | + } | |
| 1034 | + } | |
| 1035 | + } | |
| 1036 | + } | |
| 1037 | + | |
| 1005 | 1038 | /** |
| 1006 | 1039 | * View validations |
| 1007 | 1040 | */ |
| 1008 | 1041 | if( isset( $filter['view'] ) ){ |
| @@ -1167,8 +1200,19 @@ | ||
| 1167 | 1200 | public function ajaxValidateFilters() |
| 1168 | 1201 | { |
| 1169 | 1202 | $postData = Container::instance()->getThePost(); |
| 1170 | 1203 | $data = isset( $postData['validateData'] ) ? $postData['validateData'] : false; |
| 1204 | + // The current admin script sends a JSON string, but a stale (cached or | |
| 1205 | + // un-rebuilt .min) copy still sends the bracket-serialized array — | |
| 1206 | + // accept both instead of fataling on stripslashes(array) under PHP 8 | |
| 1207 | + if ( is_array( $data ) ) { | |
| 1208 | + $data = wp_unslash( $data ); | |
| 1209 | + } elseif ( $data ) { | |
| 1210 | + $data = json_decode( stripslashes( $data ), true ); | |
| 1211 | + } | |
| 1212 | + if ( isset( $data['wpc_set_fields']['wp_filter_query_vars'] ) ) { | |
| 1213 | + $data['wpc_set_fields']['wp_filter_query_vars'] = wp_slash( $data['wpc_set_fields']['wp_filter_query_vars'] ); | |
| 1214 | + } | |
| 1171 | 1215 | $response = []; |
| 1172 | 1216 | |
| 1173 | 1217 | if( ! $data ){ |
| 1174 | 1218 | $this->pushError(20); |
| @@ -1425,9 +1469,9 @@ | ||
| 1425 | 1469 | 'time' => __('g:i a'), |
| 1426 | 1470 | ]; |
| 1427 | 1471 | |
| 1428 | 1472 | $disabled_custom = true; |
| 1429 | - $value_to_custom = ( $savedValue['date_format'] && $dateType === $savedValue['date_type'] ) ? $savedValue['date_format'] : $default_formats[$dateType]; | |
| 1473 | + $value_to_custom = ( ! empty( $savedValue['date_format'] ) && $dateType === ( $savedValue['date_type'] ?? '' ) ) ? $savedValue['date_format'] : $default_formats[$dateType]; | |
| 1430 | 1474 | if ( $value_to_custom && ! in_array( $value_to_custom, self::getPossibleDateFormats( $dateType ) ) ) { |
| 1431 | 1475 | $disabled_custom = false; |
| 1432 | 1476 | $field['value'] = 'other'; |
| 1433 | 1477 | } |
| @@ -1622,11 +1666,11 @@ | ||
| 1622 | 1666 | |
| 1623 | 1667 | return false; |
| 1624 | 1668 | } |
| 1625 | 1669 | |
| 1626 | - public function getErrorMessage( $code = 20 ) | |
| 1670 | + public function getErrorMessage( $code = 20, $limit = null ) | |
| 1627 | 1671 | { |
| 1628 | - $messages = $this->getErrorsList(); | |
| 1672 | + $messages = self::getErrorsList($limit); | |
| 1629 | 1673 | |
| 1630 | 1674 | if( isset( $messages[$code] ) ){ |
| 1631 | 1675 | return $messages[$code]; |
| 1632 | 1676 | } |
| @@ -1735,10 +1779,12 @@ | ||
| 1735 | 1779 | } |
| 1736 | 1780 | return $name; |
| 1737 | 1781 | } |
| 1738 | 1782 | |
| 1739 | - public static function getErrorsList() | |
| 1783 | + public static function getErrorsList($limit = null) | |
| 1740 | 1784 | { |
| 1785 | + $effectiveLimit = is_int($limit) ? $limit : FilterSet::FREE_LIMIT_NEW; | |
| 1786 | + | |
| 1741 | 1787 | $errors = array( |
| 1742 | 1788 | // Set errors |
| 1743 | 1789 | 20 => esc_html__('An error occurred. Filter Set fields were not saved, please try again.', 'filter-everything'), |
| 1744 | 1790 | 201 => esc_html__('An error occurred. SEO Rule fields were not saved, please try again.', 'filter-everything'), |
| @@ -1799,10 +1845,12 @@ | ||
| 1799 | 1845 | ), |
| 1800 | 1846 | 91 => esc_html__('Error: you can not update settings because the Filter Everything Pro plugin is locked. Please, ask your site Superadmin to enter the plugin license key to unlock it.', 'filter-everything' ), |
| 1801 | 1847 | 92 => wp_kses( |
| 1802 | 1848 | sprintf( |
| 1803 | - __('The free version allows up to 3 filter sets per post type. Upgrade to <a href=\'%1$s\' target=\'_blank\'>PRO</a> for unlimited filter sets.', 'filter-everything' ), | |
| 1804 | - esc_url(FLRT_PLUGIN_URL .'/?get_pro=true') ), | |
| 1849 | + /* translators: 1: maximum number of free filter sets per post type, 2: PRO upgrade URL */ | |
| 1850 | + __('The free version allows up to %1$d filter sets per post type. Upgrade to <a href=\'%2$s\' target=\'_blank\'>PRO</a> for unlimited filter sets.', 'filter-everything' ), | |
| 1851 | + $effectiveLimit, | |
| 1852 | + esc_url(FLRT_PLUGIN_URL .'/pricing/?utm_source=free_plugin&utm_medium=internal&utm_campaign=free_plugin_upgrade&utm_content=msg_three_set') ), | |
| 1805 | 1853 | array( |
| 1806 | 1854 | 'a' => array( |
| 1807 | 1855 | 'href'=> true, |
| 1808 | 1856 | 'target' => true |
| @@ -1808,9 +1856,11 @@ | ||
| 1808 | 1856 | 'target' => true |
| 1809 | 1857 | ) |
| 1810 | 1858 | ) |
| 1811 | 1859 | ), |
| 1860 | + 93 => esc_html__('Error: The range list is empty. Please add values to the list.', 'filter-everything' ), | |
| 1861 | + | |
| 1812 | 1862 | ); |
| 1813 | 1863 | |
| 1814 | 1864 | return $errors; |
| 1815 | 1865 | } |
| 1816 | 1866 | } |