PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.7
Filter Everything — WordPress & WooCommerce Filters v1.9.7
1.9.7 1.9.6 1.9.5 1.9.4 1.9.3 1.9.2.2 1.9.2.1 trunk 1.2.1 1.2.3 1.2.4 1.2.5 1.3.0 1.3.1 1.3.2 1.4.1 1.4.4 1.4.5 1.4.8 1.4.9 1.5.0 1.5.1 1.6.0 1.6.1 1.6.2 All 52 releases
← All changes | filter-everything.php +134 -117 1.6.11.9.7 View file →
@@ -1,10 +1,12 @@
1 1 <?php
2 2 /*
3 -Plugin Name: Filter Everything&nbsp;— WooCoomerce Product & WordPress Filter
3 +Plugin Name: Filter Everything&nbsp;— WordPress & WooCommerce Filters
4 4 Plugin URI: https://filtereverything.pro
5 -Description: Filters everything in WordPress & WooCommerce: Products, any Post types, by Any Criteria. Compatible with WPML, ACF and others popular. Supports AJAX.
6 -Version: 1.6.1
5 +Description: Instantly filter any WordPress content & WooCommerce products by attributes, taxonomies, custom fields + AJAX, Elementor, automatic filter creation.
6 +Version: 1.9.7
7 +Requires at least: 6.0
8 +Requires PHP: 7.4
7 9 Author: Andrii Stepasiuk
8 10 Author URI: https://filtereverything.pro/about/
9 11 Text Domain: filter-everything
10 12 Domain Path: /lang
@@ -10,10 +12,10 @@
10 12 Domain Path: /lang
11 13 */
12 14
13 15 // If this file is called directly, abort.
14 -if ( ! defined('WPINC') ) {
15 - wp_die();
16 +if ( ! defined('ABSPATH') ) {
17 + exit;
16 18 }
17 19
18 20 if( ! class_exists( 'FlrtFilter' ) ):
19 21
@@ -20,18 +22,15 @@
20 22 class FlrtFilter{
21 23
22 24 public function init()
23 25 {
24 - global $flrt_sets, $wpc_not_fired;
25 -
26 - $wpc_not_fired = true;
27 - $flrt_sets = [];
28 -
29 - $this->define( 'FLRT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
30 - $this->define( 'FLRT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
26 + $this->define( 'FLRT_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) );
27 + $this->define( 'FLRT_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
31 28 $this->define( 'FLRT_PLUGIN_BASENAME', plugin_basename(__FILE__) );
32 - $this->define( 'FLRT_PLUGIN_VER', '1.6.1' );
33 - $this->define( 'FLRT_PLUGIN_LINK', 'https://filtereverything.pro' );
29 + $this->define( 'FLRT_PLUGIN_SLUG', 'filter-everything-pro' );
30 + $this->define( 'FLRT_PLUGIN_VER', '1.9.7' );
31 + $this->define( 'FLRT_PLUGIN_URL', 'https://filtereverything.pro' );
32 + $this->define( 'FLRT_PLUGIN_TESTED_TO', '7.1' );
34 33 $this->define( 'FLRT_PLUGIN_DEBUG', false );
35 34 $this->define( 'FLRT_TEMPLATES_DIR_NAME', 'filters' );
36 35
37 36 $this->define( 'FLRT_FILTERS_SET_POST_TYPE', 'filter-set' );
@@ -37,74 +36,82 @@
37 36 $this->define( 'FLRT_FILTERS_SET_POST_TYPE', 'filter-set' );
38 37 $this->define( 'FLRT_FILTERS_POST_TYPE', 'filter-field' );
39 38 $this->define( 'FLRT_PREFIX_SEPARATOR', '-' );
40 39 $this->define( 'FLRT_QUERY_TERMS_SEPARATOR', ';' );
41 - $this->define( 'FLRT_STATUS_COOKIE_NAME', 'wpcContainersStatus' );
40 + $this->define( 'FLRT_DATE_TIME_SEPARATOR', 't' );
41 + $this->define( 'FLRT_FOLDING_COOKIE_NAME', 'wpcContainersStatus' );
42 + $this->define( 'FLRT_MORELESS_COOKIE_NAME', 'wpcMoreLessStatus' );
42 43 $this->define( 'FLRT_HIERARCHY_LIST_COOKIE_NAME', 'wpcHierarchyListStatus' );
43 44 $this->define( 'FLRT_OPEN_CLOSE_BUTTON_COOKIE_NAME', 'wpcWidgetStatus' );
44 45 $this->define( 'FLRT_APPLY_BUTTON_META_KEY', 'wpc_filter_set_apply_button_post_name' );
45 46 $this->define( 'FLRT_TRANSIENT_PERIOD_HOURS', 12 );
47 + $this->define( 'FLRT_BEAVER_BUILDER_VAR', 'fl_builder' );
48 + $this->define( 'FLRT_LICENSE_KEY', 'wpc_filter_license' );
49 + $this->define( 'FLRT_MARKET', 'codecanyon' );
50 + $this->define( 'FLRT_RELEASER', 'stepasiuk' );
51 + $this->define( 'FLRT_APPROVED', 'victor' );
52 + $this->define( 'FLRT_ITERATION', 'first' );
53 + $this->define( 'FLRT_PRO_PRICE', '$69' );
46 54
47 - require_once FLRT_PLUGIN_DIR . 'src/wpc-helpers.php';
55 + if ( ! defined('FLRT_RANGE_LIST_LIMIT')){
56 + $this->define( 'FLRT_RANGE_LIST_LIMIT', 20 );
57 + }
48 58
49 - flrt_include('src/wpc-compat.php');
50 - flrt_include('src/wpc-default-hooks.php');
51 - flrt_include('src/wpc-third-party.php');
52 59
53 - flrt_include('src/Plugin.php');
54 - flrt_include('src/PostTypes.php');
55 - flrt_include('src/Settings/TabInterface.php');
56 - flrt_include('src/Settings/BaseSettings.php');
57 - flrt_include('src/Settings/TabRenderer.php');
58 - flrt_include('src/Settings/Container.php');
60 + if ( ! defined('FLRT_XML_PATH')){
61 + $wp_upload_dir = wp_upload_dir();
62 + $upload_dir_basepath = $wp_upload_dir['basedir'];
59 63
60 - flrt_include('src/Entities/Entity.php');
64 + $path = $upload_dir_basepath . '/filter-everything/xml/';
65 + define( 'FLRT_XML_PATH', $path );
66 + }
61 67
62 - flrt_include('src/Entities/TaxonomyEntity.php');
63 - flrt_include('src/Entities/PostMetaEntity.php');
64 - flrt_include('src/Entities/PostMetaNumEntity.php');
65 - flrt_include('src/Entities/AuthorEntity.php');
68 + require_once FLRT_PLUGIN_DIR_PATH . 'src/wpc-helpers.php';
66 69
67 - // Include PRO
68 -// flrt_include('pro/filters-pro.php');
70 + // Thematic helper files split out of wpc-helpers.php (same functions, no renames)
71 + flrt_include('src/helpers/dates.php');
72 + flrt_include('src/helpers/colors.php');
73 + flrt_include('src/helpers/cache-keys.php');
74 + flrt_include('src/helpers/ui.php');
75 + flrt_include('src/helpers/migrations.php');
76 + flrt_include('src/helpers/instant-recount.php');
69 77
70 - flrt_include('src/Entities/DefaultEntity.php');
71 - flrt_include('src/Entities/EntityManager.php');
78 + // Class autoloading (src/classmap.php + PSR-4 fallback for new sub-namespaced code).
79 + // Only side-effect-free class files are autoloaded; see bin/build-classmap.php.
80 + require_once FLRT_PLUGIN_DIR_PATH . 'src/Autoloader.php';
81 + \FilterEverything\Filter\Autoloader::register();
82 + \FilterEverything\Filter\Autoloader::addClassMap( require FLRT_PLUGIN_DIR_PATH . 'src/classmap.php', FLRT_PLUGIN_DIR_PATH . 'src' );
83 + \FilterEverything\Filter\Autoloader::addNamespace( 'FilterEverything\\Filter', FLRT_PLUGIN_DIR_PATH . 'src' );
72 84
73 - flrt_include('src/Settings/Tabs/SettingsTab.php');
74 - flrt_include('src/Settings/Tabs/PermalinksTab.php');
75 - flrt_include('src/Settings/Tabs/ExperimentalTab.php');
76 - flrt_include('src/Settings/Tabs/AboutProTab.php');
85 + // Files that do work at include time (functions, hooks, instantiation) — kept explicit, in order.
86 + flrt_include('src/wpc-compat.php');
87 + flrt_include('src/wpc-utility-functions.php');
88 + flrt_include('src/wpc-default-hooks.php');
89 + flrt_include('src/wpc-third-party.php');
90 + flrt_include('src/PostTypes.php');
77 91
78 - flrt_include('src/Settings/Filter.php');
92 + // PRO bootstrap. Comment out this single line (or ship without the pro/ folder)
93 + // to run the plugin as the free version: it is the only place that registers
94 + // PRO classes, constants and hooks.
95 +// flrt_include('pro/filters-pro.php');
79 96
80 - flrt_include('src/RequestParser.php');
81 - flrt_include('src/UrlManager.php');
82 - flrt_include('src/Chips.php');
83 - flrt_include('src/Sorting.php');
84 -
85 - flrt_include('src/Walkers/WalkerCheckbox.php');
86 -
87 - flrt_include('src/TemplateManager.php');
88 - flrt_include('src/WpManager.php');
89 -
90 - flrt_include('src/Admin/FilterSet.php');
91 - flrt_include('src/Admin/FilterFields.php');
92 - flrt_include('src/Admin/Admin.php');
97 + flrt_include('src/RobotsTxt.php');
98 + flrt_include('src/Swatches.php');
93 99 flrt_include('src/Admin/AdminHooks.php');
100 + flrt_include('src/Admin/AdminNotices.php');
101 + flrt_include('src/Admin/WhatsNew.php');
102 + flrt_include('src/Admin/ReviewRequest.php');
94 103 flrt_include('src/Admin/MetaBoxes.php');
95 - flrt_include('src/Admin/Widgets/FiltersWidget.php');
96 - flrt_include('src/Admin/Widgets/ChipsWidget.php');
97 - flrt_include('src/Admin/Widgets/SortingWidget.php');
98 - flrt_include('src/Admin/Widgets.php');
99 - flrt_include('src/Admin/Shortcodes.php');
100 - flrt_include('src/Admin/Validator.php');
101 -
102 - flrt_include('src/FormFields/Input.php');
104 + flrt_include('src/Frontend/Widgets.php');
103 105 flrt_include('src/wpc-api.php');
106 + flrt_include('src/Frontend/Builders/gutenberg/gutenberg.php');
104 107
105 108 $this->registerHooks();
106 109
110 + $this->initSettings();
111 +
112 + flrt_check_update_mobile_settings();
113 +
107 114 if( flrt_get_experimental_option( 'disable_woo_orderby' ) === 'on' ) {
108 115 if( ! function_exists('woocommerce_catalog_ordering') ){
109 116 function woocommerce_catalog_ordering()
110 117 {
@@ -115,22 +122,21 @@
115 122 }
116 123
117 124 public function registerHooks()
118 125 {
119 - // Convert old post_name format to new. Since v1.1.24
120 - add_action( 'init', [$this, 'convertSetLocations'], -1 );
121 -
122 126 // Backward compatibility. From v1.3.2
123 - add_action( 'init', [$this, 'convertShowChipsInContent'], -1 );
127 + add_action( 'init', [ $this, 'convertShowChipsInContent' ], -1 );
124 128
125 129 add_action( 'init', [ $this, 'oneTwoThreeGo' ] );
126 130
127 - add_action( 'init', [$this, 'loadTextdomain'], 0 );
131 + add_action( 'init', [ $this, 'loadTextdomain' ], 0 );
128 132
129 133 add_action( 'after_setup_theme', [$this, 'afterSetupTheme'] );
130 134
131 135 register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']);
132 136
137 + register_deactivation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'deactivate']);
138 +
133 139 register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']);
134 140
135 141 add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] );
136 142 }
@@ -139,86 +145,64 @@
139 145 {
140 146 // Backward compatibility. From v1.3.2
141 147 $filter_settings = get_option('wpc_filter_settings');
142 148
143 - if (isset($filter_settings['show_terms_in_content']) && $filter_settings['show_terms_in_content'] === 'on') {
149 + if ( isset( $filter_settings['show_terms_in_content'] ) && $filter_settings['show_terms_in_content'] === 'on' ) {
144 150 $new_chips_hooks = [];
145 151 $theme_dependencies = flrt_get_theme_dependencies();
146 152
147 - if (flrt_is_woocommerce()) {
153 + if ( flrt_is_woocommerce() ) {
148 154 $new_chips_hooks[] = 'woocommerce_no_products_found';
149 155 $new_chips_hooks[] = 'woocommerce_archive_description';
150 156 }
151 157
152 - if (isset($theme_dependencies['chips_hook']) && is_array($theme_dependencies['chips_hook'])) {
153 - foreach ($theme_dependencies['chips_hook'] as $compat_chips_hook) {
158 + if ( isset( $theme_dependencies['chips_hook'] ) && is_array($theme_dependencies['chips_hook'] ) ) {
159 + foreach ( $theme_dependencies['chips_hook'] as $compat_chips_hook ) {
154 160 $new_chips_hooks[] = $compat_chips_hook;
155 161 }
156 162 }
157 163
158 164 $filter_settings['show_terms_in_content'] = $new_chips_hooks;
159 - update_option('wpc_filter_settings', $filter_settings);
165 + update_option('wpc_filter_settings', $filter_settings );
160 166 }
161 167 }
162 168
163 - public function convertSetLocations()
169 + public function loadTextdomain()
164 170 {
165 - if( is_admin() ) {
171 + add_filter( 'load_textdomain_mofile', [ $this, 'preferBundledMofile' ], 10, 2 );
172 + load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' );
173 + }
166 174
167 - global $wpdb;
175 + /**
176 + * Prefer translations bundled in the plugin's /lang folder over those
177 + * auto-downloaded by WordPress.org into /wp-content/languages/plugins/.
178 + * Our bundled translations are 100% complete and curated; the .org ones
179 + * are community-contributed and often partial or lower quality.
180 + */
181 + public function preferBundledMofile( $mofile, $domain )
182 + {
183 + if ( $domain !== 'filter-everything' ) {
184 + return $mofile;
185 + }
168 186
169 - // Convert separator from ":" to "___" and from -1 to 1
170 - $sql = [];
171 - $sql[] = "SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_name";
172 - $sql[] = "FROM {$wpdb->posts}";
173 - $sql[] = "WHERE {$wpdb->posts}.post_type = '%s'";
174 - $sql[] = "AND {$wpdb->posts}.post_name REGEXP '[\:]+'";
175 - $sql[] = "OR {$wpdb->posts}.post_name = '-1'";
187 + if ( strpos( $mofile, WP_LANG_DIR . '/plugins/' ) === false ) {
188 + return $mofile;
189 + }
176 190
177 - $sql = implode(" ", $sql);
178 - $sql = $wpdb->prepare($sql, FLRT_FILTERS_SET_POST_TYPE);
191 + $locale = function_exists( 'determine_locale' ) ? determine_locale() : get_locale();
192 + $bundled = FLRT_PLUGIN_DIR_PATH . 'lang/filter-everything-' . $locale . '.mo';
179 193
180 - $results = $wpdb->get_results($sql, ARRAY_A);
181 -
182 - if (!empty($results)) {
183 -
184 - foreach ($results as $row) {
185 - $update = [];
186 -
187 - if (!isset($row['post_name']) || !isset($row['ID'])) {
188 - continue;
189 - }
190 -
191 - if( $row['post_name'] == '-1' ){
192 - $new_post_name = '1';
193 - }else{
194 - $new_post_name = str_replace(":", "___", $row['post_name']);
195 - }
196 -
197 - $update[] = "UPDATE {$wpdb->posts}";
198 - $update[] = "SET {$wpdb->posts}.post_name = '%s'";
199 - $update[] = "WHERE {$wpdb->posts}.ID = %s";
200 -
201 - $updateSql = implode(" ", $update);
202 -
203 - $updateSql = $wpdb->prepare($updateSql, $new_post_name, $row['ID']);
204 -
205 - $wpdb->query($updateSql);
206 - }
207 - }
208 -
194 + if ( is_readable( $bundled ) ) {
195 + return $bundled;
209 196 }
210 197
198 + return $mofile;
211 199 }
212 200
213 - public function loadTextdomain()
214 - {
215 - load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' );
216 - }
217 -
218 201 public function oneTwoThreeGo()
219 202 {
220 - new \FilterEverything\Filter\Plugin();
203 + global $flrt_plugin;
204 + $flrt_plugin = new \FilterEverything\Filter\Plugin();
221 205 }
222 206
223 207 /**
224 208 * @since 1.6.1
@@ -225,8 +209,41 @@
225 209 */
226 210 public function afterSetupTheme()
227 211 {
228 212 $this->define( 'FLRT_ALLOW_PLL_TRANSLATIONS', true );
213 + }
214 +
215 + private function initSettings(){
216 + $container = \FilterEverything\Filter\Container::instance();
217 +
218 + $settings['php_to_js_date_formats'] = array(
219 + 'Y' => 'yy',
220 + 'y' => 'y',
221 + 'm' => 'mm',
222 + 'n' => 'm',
223 + 'F' => 'MM',
224 + 'M' => 'M',
225 + 'l' => 'DD',
226 + 'D' => 'D',
227 + 'd' => 'dd',
228 + 'j' => 'd',
229 + 'S' => '',
230 + );
231 +
232 + $settings['php_to_js_time_formats'] = array(
233 + 'a' => 'tt',
234 + 'A' => 'TT',
235 + 'h' => 'hh',
236 + 'g' => 'h',
237 + 'H' => 'HH',
238 + 'G' => 'H',
239 + 'i' => 'mm',
240 + 's' => 'ss',
241 + );
242 +
243 + foreach ( $settings as $key => $value ) {
244 + $container->storeParam( $key, $value );
245 + }
229 246 }
230 247
231 248 public function define( $name, $value = true )
232 249 {