fse = Container::instance()->getFilterService(); $this->em = Container::instance()->getEntityManager(); $this->setupDefaultFields(); } public function registerHooks() { if ( ! $this->hooksRegistered ) { add_filter( 'wpc_input_type_select', [ $this, 'addSpinnerToSelect' ], 10, 2 ); add_filter( 'wpc_input_type_radio', [ $this, 'addSpinnerToDateFormats' ], 10, 2 ); add_action( 'wp_ajax_wpc-delete-filter', [ $this, 'ajaxDeleteFilter' ] ); add_action( 'wp_ajax_wpc-load-exclude-terms', [ $this, 'sendExcludedTerms' ] ); add_action( 'wp_ajax_wpc_get_date_formats', [ $this, 'sendDateFormats' ] ); add_action( 'wp_ajax_wpc-validate-filters', [ $this, 'ajaxValidateFilters' ] ); add_action( 'after_delete_post', [ $this, 'deleteRelatedFilters' ], 10, 2 ); $this->hooksRegistered = true; } } private function setupDefaultFields() { // maybe add filter in future to allow change default fields do_action( 'wpc_before_setup_filter_fields' ); $entity = $this->em->getEntityByFilter( array('entity' => 'taxonomy', 'e_name' => 'category'), 'post' ); $entityTerms = $entity->getTermsForSelect(); asort( $entityTerms, SORT_NATURAL ); $defaultFields = array( 'ID' => array( 'type' => 'Hidden' ), 'parent' => array( 'type' => 'Hidden' ), 'menu_order' => array( 'type' => 'Hidden', 'class' => 'wpc-menu-order-field' ), 'entity' => array( 'type' => 'Select', 'label' => esc_html__( 'Filter by', 'filter-everything' ), 'class' => 'wpc-field-entity', 'options' => $this->em->getPossibleEntities(), 'default' => 'taxonomy_category', 'instructions' => esc_html__( 'A thing by which posts will be filtered', 'filter-everything' ), 'required' => true ), 'e_name' => array( 'type' => 'Text', 'label' => esc_html__( 'Meta Key', 'filter-everything' ), 'class' => 'wpc-field-ename', 'instructions' => esc_html__( 'Name of the Custom Field', 'filter-everything'), 'required' => true ), 'label' => array( 'type' => 'Text', 'label' => esc_html__( 'Filter Title', 'filter-everything' ), 'class' => 'wpc-field-label', 'placeholder' => esc_html__( 'New Filter', 'filter-everything'), 'instructions' => esc_html__( 'Will appear in the Filters widget', 'filter-everything' ) ), 'slug' => array( 'type' => 'Text', 'label' => esc_html__( 'Var Name for URL', 'filter-everything' ), 'class' => 'wpc-field-slug', 'instructions' => esc_html__( 'Name of a part of the URL responsible for this filter', 'filter-everything'), 'tooltip' => wp_kses( __( 'For example, in the URL path:
/?color=blue&size=large
"color" and "size" are the names of the URL vars.
In the PRO version of the plugin, the URL part after "?" becomes
/color-blue/size-large/', 'filter-everything'), array( 'br' => array() ) ), 'required' => true ), // Optional 'view' => array( 'type' => 'Select', 'label' => esc_html__( 'View in Widget', 'filter-everything' ), 'class' => 'wpc-field-view', 'options' => $this->getViewOptions(), 'default' => 'checkboxes', 'instructions' => '', ), 'show_range_list' => array( 'type' => 'inProButton', 'pro_label' => flrt_pro_promo_label(), 'label' => esc_html__('Show Range List', 'filter-everything'), 'class' => 'wpc-field-show-range-list', 'default' => '', 'tooltip' => '', ), 'dropdown_label' => array( 'type' => 'Text', 'label' => esc_html__( 'Dropdown Label', 'filter-everything' ), 'class' => 'wpc-field-dropdown-label', 'default' => '', 'placeholder' => esc_html__( 'e.g. - Select color -', 'filter-everything' ), 'instructions' => esc_html__( 'Label for the default dropdown option', 'filter-everything' ), ), 'date_type' => array( 'type' => 'Select', 'label' => esc_html__( 'Date Type', 'filter-everything' ), 'class' => 'wpc-date-type', 'options' => array( 'date' => esc_html__( 'Date', 'filter-everything' ), 'datetime' => esc_html__( 'Date Time', 'filter-everything' ), 'time' => esc_html__( 'Time', 'filter-everything' ), ), 'default' => 'date', 'instructions' => '', ), 'date_format' => array( 'type' => 'Radio', 'label' => esc_html__( 'Date Format', 'filter-everything' ), 'class' => 'wpc-date-format', 'options' => $this->getDateFormatOptions(), 'default' => __( 'F j, Y' ), 'instructions' => esc_html__( 'How the date will be displayed in the Filters widget', 'filter-everything' ), 'tooltip' => wp_kses( sprintf( __( 'More PHP date formats can be found on this page.', 'filter-everything' ), 'https://wordpress.org/documentation/article/customize-date-and-time-format/' ), array( 'a' => array( 'href' => true, ) ) ) ), 'show_term_names' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Show Term names', 'filter-everything' ), 'class' => 'wpc-field-show-term-names', 'default' => 'yes', 'instructions' => esc_html__( 'Term names for filters with swatches or brand images may be hidden', 'filter-everything' ), 'tooltip' => '', ), 'selected_and_above' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Mode «All stars+»', 'filter-everything' ), 'class' => 'wpc-field-show-selected-and-above', 'default' => 'no', 'instructions' => esc_html__( 'E.g. if 3 stars are selected, all products with rating 3+ will be shown', 'filter-everything' ), 'tooltip' => '', ), 'logic' => array( 'type' => 'Select', 'label' => esc_html__( 'Filter Logic', 'filter-everything' ), 'class' => 'wpc-field-logic', 'options' => array('or' => esc_html__('OR', 'filter-everything' ), 'and' => esc_html__('AND', 'filter-everything') ), 'default' => 'or', 'instructions' => esc_html__( 'Determines how to select posts when two or more terms of this filter are selected', 'filter-everything' ), 'tooltip' => wp_kses( __( '«OR» means to show posts if they are at least in one of the selected terms.
«AND» means that posts should belong to all selected terms at the same time.', 'filter-everything' ), array( 'br' => array() ) ), ), // AND 'orderby' => array( 'type' => 'Select', 'label' => esc_html__( 'Sort Terms by', 'filter-everything' ), 'class' => 'wpc-field-orderby', 'options' => $this->getOrderByOptions(), 'default' => 'default', 'instructions' => esc_html__('The order in which terms appear in the widget', 'filter-everything'), 'tooltip' => wp_kses( __( 'The "Default" option means that terms will be sorted in the order as they were received from the Database
The "Menu order" option is available for WooCommerce attributes only.', 'filter-everything' ), array( 'br' => array() ) ) ), 'in_path' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'In URL', 'filter-everything' ), 'class' => 'wpc-field-path', 'default' => 'yes', 'instructions' => '' ), 'exclude' => array( 'type' => 'Select', 'label' => esc_html__( 'Include/Exclude Terms', 'filter-everything' ), 'class' => 'wpc-field-exclude', 'options' => $entityTerms, //$entity->getTermsForSelect(), 'multiple' => 'multiple', 'instructions' => '', 'skip_view' => true ), 'include' => array( 'type' => 'Select', 'label' => '', 'class' => 'wpc-field-include', 'options' => [ 'no' => esc_html__( 'exclude', 'filter-everything' ), 'yes' => esc_html__('include', 'filter-everything' ) ], 'default' => 'no', 'instructions' => esc_html__( 'Include selected terms only', 'filter-everything' ), 'skip_view' => true ), 'collapse' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Folding', 'filter-everything' ), 'class' => 'wpc-field-collapse', 'default' => 'no', 'instructions' => esc_html__( 'Makes filter collapsible in the widget', 'filter-everything'), 'tooltip' => esc_html__( 'Useful in situations when the filter is rarely applied but takes up some space in the widget. Collapsed by default.', 'filter-everything' ) ), 'hierarchy' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Show Hierarchy', 'filter-everything' ), 'class' => 'wpc-field-hierarchy', 'default' => 'no', 'instructions' => esc_html__( 'Display the term hierarchy in the filter widget. Child terms will be collapsed by default', 'filter-everything' ) ), 'range_slider' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Enable Range Slider?', 'filter-everything' ), 'class' => 'wpc-field-range-slider', 'default' => 'yes', 'instructions' => esc_html__( 'If disabled, visitors must type numeric values in text inputs', 'filter-everything' ) ), 'step' => array( 'type' => 'Text', 'label' => esc_html__( 'Slider Step', 'filter-everything' ), 'class' => 'wpc-field-value-step', 'instructions' => esc_html__( 'Determines how the numeric value will be changed when you move slider controls', 'filter-everything' ), 'tooltip' => wp_kses( __('Step 1 means possible values are 1,2,3,4 ...
Step 0.1 means possible values are 5.1, 5.2, 5.3, 5.4 ...
Step 15 means possible values are 15, 30, 45, 60...', 'filter-everything'), array( 'br' => array() ) ), 'default' => 1 ), 'search' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Terms Search', 'filter-everything' ), 'class' => 'wpc-field-search', 'default' => 'no', 'instructions' => esc_html__( 'Adds a search field that allows you to quickly find filter terms', 'filter-everything' ) ), 'parent_filter' => array( 'type' => 'Select', 'label' => esc_html__( 'Parent Filter', 'filter-everything' ), 'class' => 'wpc-field-parent-filter', 'options' => [ '-1' => esc_html__( 'Please, add filters first', 'filter-everything' ) ], 'instructions' => esc_html__( 'If specified, current Filter terms become available only after the parent Filter selected', 'filter-everything' ) ), 'hide_until_parent' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Hide until the Parent selected', 'filter-everything' ), 'class' => 'wpc-field-hide-until-parent', 'default' => 'no', 'instructions' => esc_html__( 'Do not show this Filter until a parent is selected. Useful for step-by-step filtering', 'filter-everything' ) ), 'min_num_label' => array( 'type' => 'Text', 'label' => esc_html__( 'Labels for Chips', 'filter-everything' ), 'class' => 'wpc-field-min-num-label', 'default' => '', 'placeholder' => esc_html__( 'e.g. From {value}', 'filter-everything' ), 'instructions' => '', 'skip_view' => true, ), 'max_num_label' => array( 'type' => 'Text', 'label' => '', 'class' => 'wpc-field-max-num-label', 'default' => '', 'placeholder' => esc_html__( 'e.g. To {value}', 'filter-everything' ), 'instructions' => '', 'skip_view' => true, ), 'tooltip' => array( 'type' => 'Text', 'label' => esc_html__( 'Tooltip', 'filter-everything' ), 'class' => 'wpc-field-tooltip', 'instructions' => esc_html__( 'Will appear next to the Filter Title', 'filter-everything' ), 'default' => '' ), 'more_less' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'More/Less', 'filter-everything' ), 'class' => 'wpc-field-more-less', 'default' => 'no', 'instructions' => sprintf( esc_html__( 'Show a toggle link after %s terms', 'filter-everything' ), flrt_more_less_count() ) ), 'show_chips' => array( 'type' => 'Checkbox', 'label' => esc_html__( 'Show in Chips', 'filter-everything' ), 'class' => 'wpc-field-show-chips', 'default' => 'yes', 'instructions' => esc_html__( 'Show filter selected terms in the list of all chosen items', 'filter-everything' ) ), 'acf_fields' => array( 'type' => 'Text', 'label' => esc_html__( 'ACF Fields', 'filter-everything' ), 'class' => 'wpc-field-acf', 'default' => '', 'instructions' => esc_html__( 'Contains the IDs of ACF fields that are related to the Custom Field', 'filter-everything' ) ) ); $this->defaultFields = apply_filters( 'wpc_filter_default_fields', $defaultFields, $this ); } public static function getViewOptions() { $viewOptions = array( 'checkboxes' => esc_html__('Checkboxes', 'filter-everything'), 'radio' => esc_html__('Radio buttons', 'filter-everything'), 'labels' => esc_html__('Labels list', 'filter-everything'), 'dropdown' => esc_html__('Dropdown', 'filter-everything'), 'range' => esc_html__('Numeric range', 'filter-everything'), 'date' => esc_html__('Date range', 'filter-everything'), ); if(flrt_is_woocommerce()){ $viewOptions['rating'] = esc_html__('Rating', 'filter-everything'); } return $viewOptions; } public static function getDateFormatOptions( $type = 'date' ) { switch( $type ){ case 'date': $F_j_Y = date_i18n( __( 'F j, Y' ) ); $d_m_Y = date_i18n( 'd/m/Y' ); $m_d_Y = date_i18n( 'm/d/Y' ); $formatOptions = array( __( 'F j, Y' ) => '' . $F_j_Y . ''.__( 'F j, Y' ).'', 'd/m/Y' => '' . $d_m_Y . 'd/m/Y', 'm/d/Y' => '' . $m_d_Y . 'm/d/Y', ); break; case 'datetime': $F_j_Y = date_i18n( __('F j, Y g:i a') ); $d_m_Y = date_i18n( 'd/m/Y g:i a' ); $m_d_Y = date_i18n( 'm/d/Y g:i a' ); $formatOptions = array( __('F j, Y g:i a') => '' . $F_j_Y . ''.__('F j, Y g:i a').'', 'd/m/Y g:i a' => '' . $d_m_Y . 'd/m/Y g:i a', 'm/d/Y g:i a' => '' . $m_d_Y . 'm/d/Y g:i a', ); break; case 'time': $g_i_a = date_i18n( __('g:i a') ); $H_i_s = date_i18n( 'H:i:s' ); $formatOptions = array( __('g:i a') => '' . $g_i_a . ''.__('g:i a').'', 'H:i:s' => '' . $H_i_s . 'H:i:s', ); break; } $formatOptions['other'] = '' . esc_html__( 'Custom:', 'filter-everything' ) . ''; return $formatOptions; } public function getOrderByOptions() { $orderBy = array( 'default' => esc_html__( 'Default (no sorting)', 'filter-everything' ), 'nameasc' => esc_html__( 'Term name «abc»', 'filter-everything' ), 'postcountasc' => esc_html__( 'Posts count «123»', 'filter-everything' ), 'idasc' => esc_html__( 'Term ID «123»', 'filter-everything' ), 'menuasc' => esc_html__( 'Menu order «123»', 'filter-everything' ), 'namedesc' => esc_html__( 'Term name «cba»', 'filter-everything' ), 'postcountdesc' => esc_html__( 'Posts count «321»', 'filter-everything' ), 'iddesc' => esc_html__( 'Term ID «321»', 'filter-everything' ), 'menudesc' => esc_html__( 'Menu order «321»', 'filter-everything' ) ); return $orderBy; } public function getFieldsByType($type, $configuredFields = [] ) { $selected = []; $type = ucfirst($type); foreach ( $configuredFields as $key => $field) { if ( isset( $field['type'] ) && ( $field['type'] === $type ) ) { $selected[$key] = $field; } } return $selected; } private function getFilterNames( $set_id ) { $filternames = []; if( ! $set_id ){ return $filternames; } $filters = $this->em->selectOnlySetFilters( $set_id ); if( ! empty( $filters ) ) { if ( count( $filters ) > 1 ) { $filternames['-1'] = esc_html__( '— Select Filter —', 'filter-everything' ) ; } else { $filternames['-1'] = esc_html__( 'Please, add filters first', 'filter-everything' ); } foreach ( $filters as $filter ) { if ( in_array( $filter['entity'], [ 'post_meta_num', 'tax_numeric', 'post_date', 'post_meta_date' ] ) ) { continue; } if ( isset( $filter['ID'] ) ) { $filternames[ $filter['ID'] ] = $filter['label'] .' (' . $filter['e_name'] .')'; } } } return $filternames; } public function getEmptyFilterObject( $set_id ) { $defaults = new \stdClass(); $defaults->ID = self::FLRT_NEW_FILTER_ID; $defaults->post_parent = ''; $defaults->menu_order = 0; $defaults->post_title = ''; $defaults->post_content = ''; $defaults->post_name = ''; $filter = $this->em->prepareFilter( $defaults ); return $this->prepareFilterInputsToDisplay( $filter, $this->getFilterNames( $set_id ) ); } public function getFiltersInputs( $set_id ) { $preparedFilters = []; if( ! $set_id || empty( $set_id ) ){ return $preparedFilters; } $filters = $this->em->selectOnlySetFilters( $set_id ); foreach ( $filters as $field_key => $filter ){ $preparedFilters[] = $this->prepareFilterInputsToDisplay( $filter, $this->getFilterNames( $set_id ) ); } return $preparedFilters; } private function prepareFilterInputsToDisplay( $filter, $filternames ) { $postTypes = false; $terms = []; // Used for filter table class in filter set fields. // E.g. post_meta, taxonomy, author. $short_entity = $filter['entity'] ? $filter['entity'] : 'taxonomy'; if ( $short_entity === 'taxonomy' ) { // Add hierarchical class if ( is_taxonomy_hierarchical( $filter['e_name'] ) ) { $short_entity .= ' taxonomy-hierarchical'; } // Add product attribute class if ( strpos( $filter['e_name'], 'pa_' ) === 0 ) { $short_entity .= ' taxonomy-product-attribute'; } if ( strpos( $filter['e_name'], 'product_visibility') !== false && $filter['view'] === 'rating') { $short_entity .= ' selected-and-above-show '; } if ( flrt_get_experimental_option('use_color_swatches') === 'on' ) { $taxonomies = flrt_get_experimental_option( 'color_swatches_taxonomies', [] ); if ( in_array( $filter['e_name'], $taxonomies ) ) { $short_entity .= ' taxonomy-has-swatches'; } } } if ( in_array( $filter['e_name'], flrt_brand_filter_entities() ) ) { $short_entity .= ' wpc-filter-has-brands'; } $short_entity .= isset( $filter['view'] ) ? ' wpc-view-'.$filter['view'] : ''; $belongs = $this->filterBelongsToPostType( $filter['parent'], $filter['entity'], $filter['e_name'] ); $postType = ''; // For post_meta_num entity postType is critical value so we have to set it up if ( in_array( $filter['entity'], array( 'post_meta_num', 'post_meta_exists', 'post_meta_date' ) ) ) { $fss = Container::instance()->getFilterSetService(); $set = $fss->getSet( $filter['parent'] ); if( isset( $set['post_type']['value'] ) ){ $postType = $set['post_type']['value']; } } if ( in_array( $filter['entity'], array( 'post_meta_num', 'tax_numeric')) !== false && $filter['view'] === 'range' && (isset($filter['show_range_list']) && $filter['show_range_list'] === 'yes')) { $short_entity .= ' wpc-view-range-list'; } $entity = $this->em->getEntityByFilter( $filter, $postType ); if( $entity ){ $terms = $entity->getTermsForSelect(); asort( $terms, SORT_NATURAL ); } // This is required only for filter fields inputs $filter = $this->fse->combineEntityNameInFilter( $filter ); foreach( $this->getFieldsMapping() as $fieldKey => $fieldData ){ if ( isset( $filter[$fieldKey] ) ) { if ( $fieldKey === 'parent_filter' ) { // Exclude current filter if ( isset( $filternames[ $filter['ID'] ] ) ) { unset( $filternames[ $filter['ID'] ] ); } if ( ! empty( $filternames ) ) { $fieldData['options'] = $filternames; } } $default_value = isset( $fieldData['default'] ) ? $fieldData['default'] : ''; $multiple = ( $fieldKey === 'exclude' && ! in_array( $filter['entity'], [ 'post_meta_num', 'tax_numeric', 'post_date', 'post_meta_date' ] ) ); $fieldData['name'] = $this->generateInputName( $filter['ID'], $fieldKey, $multiple ); $fieldData['id'] = $this->generateInputID( $filter['ID'], $fieldKey ); $fieldData['value'] = ( $filter[$fieldKey] ) ? $filter[$fieldKey] : $default_value; if( $fieldKey === 'hide_until_parent' ){ if( (int) $filter['parent_filter'] > 0 ){ $fieldData['additional_class'] = 'wpc-opened'; } } if ( $fieldKey === 'slug' && $fieldData['value'] ) { $fieldData['readonly'] = 'readonly'; } if ( $fieldKey === 'e_name' && $fieldData['value'] ) { unset( $fieldData['options'] ); $fieldData['readonly'] = 'readonly'; $fieldData['type'] = 'Text'; if ( $filter['entity'] === 'tax_numeric' ) { $fieldData['label'] = esc_html__( 'Taxonomy', 'filter-everything' ); $fieldData['instructions'] = esc_html__( 'Taxonomy with numeric values you need to filter by', 'filter-everything' ); } } if( $fieldKey === 'entity' ) { $fieldData['short_entity'] = $short_entity; if ( $filter['ID'] === self::FLRT_NEW_FILTER_ID ) { $fieldData['entity_belongs'] = true; } else { $fieldData['entity_belongs'] = $belongs; } // Add instead-entity field if( $filter['ID'] !== self::FLRT_NEW_FILTER_ID ){ /** * @feature maybe move this to separate method * @bug slug wasn't saved for new filter */ // For existing filters we need to forbid changing entity value // And we need to show input instead select $fieldData['type'] = 'Text'; // To make it compatible with Text field unset( $fieldData['options'] ); // Forbid to edit field $fieldData['readonly'] = 'readonly'; $flatEntities = $this->em->getFlatEntities(); $insteadEntityVal = isset( $flatEntities[ $fieldData['value'] ] ) ? $flatEntities[ $fieldData['value'] ] : ''; if( $fieldData['value'] === 'post_meta_exists' && ! defined('FLRT_FILTERS_PRO') ){ $insteadEntityVal = esc_html__('Available in PRO', 'filter-everything'); } if( $fieldData['value'] === 'tax_numeric' && ! defined('FLRT_FILTERS_PRO') ){ $insteadEntityVal = esc_html__('Available in PRO', 'filter-everything'); } // Field, that will be visible instead of entity, that will be hidden. $prepared[ 'instead-entity' ] = $this->getInsteadEntityField( $filter['ID'], $insteadEntityVal ); } if ( $filter['ID'] === self::FLRT_NEW_FILTER_ID ) { if ( ! defined('FLRT_FILTERS_PRO') ) { $fieldData['disabled'] = array( 'post_meta_exists', 'tax_numeric' ); } } } if (!defined('FLRT_FILTERS_PRO')) { if ($fieldKey === 'show_range_list') { $fieldData['value'] = ''; } } if( $fieldKey === 'exclude' ){ // We always add terms even they are empty array to fill Select2 with related terms. $fieldData['options'] = $terms; if( in_array( $filter['entity'], [ 'post_meta_num', 'tax_numeric', 'post_date', 'post_meta_date' ] ) ) { $fieldData['options'] = []; } } // Set disabled fields for some situations if( in_array( $filter['entity'], array( 'author_author', 'post_meta_exists', 'taxonomy_product_visibility' ) ) /* $filter['entity'] === 'author_author'*/ && $fieldKey === 'logic' ){ $fieldData['disabled'] = array('and'); } if( in_array( $filter['entity'], [ 'post_meta_num', 'tax_numeric', 'post_date', 'post_meta_date' ] ) && $fieldKey === 'logic' ){ $fieldData['disabled'] = array('or'); } if ( $fieldKey === 'view' ) { if ( in_array( $filter['entity'], [ 'post_meta_num', 'tax_numeric' ] ) ) { $fieldData['disabled'] = array( 'checkboxes', 'dropdown', 'radio', 'labels', 'date', 'post_meta_date', 'colors', 'image', 'rating', ); } else if ( in_array( $filter['entity'], [ 'post_date', 'post_meta_date' ] ) ) { $fieldData['disabled'] = array( 'checkboxes', 'dropdown', 'radio', 'labels', 'range', 'colors', 'image', 'rating', ); } else if ( in_array( $filter['entity'], [ 'taxonomy_product_visibility' ] ) ) { $fieldData['disabled'] = array( 'date', 'post_meta_date', 'range', ); }else { $fieldData['disabled'] = array( 'range', 'date', 'post_meta_date', 'rating', ); } } if( $fieldKey === 'orderby' ) { if ( $filter['entity'] !== 'taxonomy_product_cat' && ( mb_strpos( $filter['entity'], 'taxonomy_pa' ) === false ) ){ $fieldData['disabled'] = ['menuasc', 'menudesc']; } } if ( ( $filter['ID'] === self::FLRT_NEW_FILTER_ID || $filter['entity'] === 'post_date' || $filter['entity'] === 'post_meta_date') && $fieldKey === 'date_format' ) { // This can be new filter or existing $date_type = $filter['date_type'] ? $filter['date_type'] : 'date'; $dateFormatOptions = $this->getDateFormatOptions( $date_type ); $disabled_custom = true; $value_to_custom = $fieldData['value']; if ( ! in_array( $value_to_custom, self::getPossibleDateFormats( $date_type ) ) ) { $disabled_custom = false; $fieldData['value'] = 'other'; } $customFormatField = '