PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.4
Filter Everything — WordPress & WooCommerce Filters v1.9.4
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 1.6.3 All 51 releases
filter-everything / filter-everything.php

filter-everything.php in Filter Everything — WordPress & WooCommerce Filters 1.9.4, at filter-everything.php

308 lines 11.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Filter Everything&nbsp;— WordPress & WooCommerce Filters
4 Plugin URI: https://filtereverything.pro
5 Description: Instantly filter any WordPress content & WooCommerce products by attributes, taxonomies, custom fields + AJAX, Elementor, automatic filter creation.
6 Version: 1.9.4
7 Requires PHP: 7.4
8 Author: Andrii Stepasiuk
9 Author URI: https://filtereverything.pro/about/
10 Text Domain: filter-everything
11 Domain Path: /lang
12 */
13
14 // If this file is called directly, abort.
15 if ( ! defined('ABSPATH') ) {
16 exit;
17 }
18
19 if( ! class_exists( 'FlrtFilter' ) ):
20
21 class FlrtFilter{
22
23 public function init()
24 {
25 global $flrt_sets, $wpc_not_fired, $chips_count, $flrt_json_data;
26
27 $chips_count = 0;
28 $wpc_not_fired = true;
29 $flrt_sets = [];
30
31 $this->define( 'FLRT_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) );
32 $this->define( 'FLRT_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) );
33 $this->define( 'FLRT_PLUGIN_BASENAME', plugin_basename(__FILE__) );
34 $this->define( 'FLRT_PLUGIN_SLUG', 'filter-everything-pro' );
35 $this->define( 'FLRT_PLUGIN_VER', '1.9.4' );
36 $this->define( 'FLRT_PLUGIN_URL', 'https://filtereverything.pro' );
37 $this->define( 'FLRT_PLUGIN_TESTED_TO', '7.0.2' );
38 $this->define( 'FLRT_PLUGIN_DEBUG', false );
39 $this->define( 'FLRT_TEMPLATES_DIR_NAME', 'filters' );
40
41 $this->define( 'FLRT_FILTERS_SET_POST_TYPE', 'filter-set' );
42 $this->define( 'FLRT_FILTERS_POST_TYPE', 'filter-field' );
43 $this->define( 'FLRT_PREFIX_SEPARATOR', '-' );
44 $this->define( 'FLRT_QUERY_TERMS_SEPARATOR', ';' );
45 $this->define( 'FLRT_DATE_TIME_SEPARATOR', 't' );
46 $this->define( 'FLRT_FOLDING_COOKIE_NAME', 'wpcContainersStatus' );
47 $this->define( 'FLRT_MORELESS_COOKIE_NAME', 'wpcMoreLessStatus' );
48 $this->define( 'FLRT_HIERARCHY_LIST_COOKIE_NAME', 'wpcHierarchyListStatus' );
49 $this->define( 'FLRT_OPEN_CLOSE_BUTTON_COOKIE_NAME', 'wpcWidgetStatus' );
50 $this->define( 'FLRT_APPLY_BUTTON_META_KEY', 'wpc_filter_set_apply_button_post_name' );
51 $this->define( 'FLRT_TRANSIENT_PERIOD_HOURS', 12 );
52 $this->define( 'FLRT_BEAVER_BUILDER_VAR', 'fl_builder' );
53 $this->define( 'FLRT_LICENSE_KEY', 'wpc_filter_license' );
54 $this->define( 'FLRT_MARKET', 'codecanyon' );
55 $this->define( 'FLRT_RELEASER', 'stepasiuk' );
56 $this->define( 'FLRT_APPROVED', 'victor' );
57 $this->define( 'FLRT_ITERATION', 'first' );
58 $this->define( 'FLRT_PRO_PRICE', '$69' );
59
60 if ( ! defined('FLRT_RANGE_LIST_LIMIT')){
61 $this->define( 'FLRT_RANGE_LIST_LIMIT', 20 );
62 }
63
64
65 if ( ! defined('FLRT_XML_PATH')){
66 $wp_upload_dir = wp_upload_dir();
67 $upload_dir_basepath = $wp_upload_dir['basedir'];
68
69 $path = $upload_dir_basepath . '/filter-everything/xml/';
70 define( 'FLRT_XML_PATH', $path );
71 }
72
73 require_once FLRT_PLUGIN_DIR_PATH . 'src/wpc-helpers.php';
74
75 flrt_include('src/wp_query_source_detector.php');
76 flrt_include('src/wpc-compat.php');
77 flrt_include('src/wpc-utility-functions.php');
78 flrt_include('src/wpc-default-hooks.php');
79 flrt_include('src/wpc-third-party.php');
80 flrt_include('src/PluginHelpers.php');
81
82 flrt_include('src/Plugin.php');
83 flrt_include('src/PostTypes.php');
84 flrt_include('src/Settings/TabInterface.php');
85 flrt_include('src/Settings/BaseSettings.php');
86 flrt_include('src/Settings/TabRenderer.php');
87 flrt_include('src/Settings/Container.php');
88
89 flrt_include('src/Entities/Entity.php');
90 flrt_include('src/Entities/PostMetaTrait.php');
91
92 flrt_include('src/Entities/TaxonomyEntity.php');
93 flrt_include('src/Entities/PostMetaEntity.php');
94 flrt_include('src/Entities/PostMetaNumEntity.php');
95 flrt_include('src/Entities/AuthorEntity.php');
96 flrt_include('src/Entities/PostDateEntity.php');
97 flrt_include('src/Entities/PostMetaDateEntity.php');
98 flrt_include('src/Settings/Tabs/SeoTabTrait.php');
99
100 // Include PRO
101 // flrt_include('pro/filters-pro.php');
102
103 flrt_include('src/Entities/DefaultEntity.php');
104 flrt_include('src/Entities/EntityManager.php');
105
106 flrt_include('src/Settings/DefaultSettings.php');
107 flrt_include('src/Settings/Tabs/SettingsTab.php');
108 flrt_include('src/Settings/Tabs/PermalinksTab.php');
109 flrt_include('src/Settings/Tabs/ImportExportTabFree.php');
110 flrt_include('src/Settings/Tabs/ExperimentalTab.php');
111 flrt_include('src/Settings/Tabs/AboutProTab.php');
112
113 flrt_include('src/Settings/Filter.php');
114
115 flrt_include('src/RequestParser.php');
116 flrt_include('src/UrlManager.php');
117 flrt_include('src/Chips.php');
118 flrt_include('src/Sorting.php');
119 flrt_include('src/Swatches.php');
120
121 flrt_include('src/Walkers/WalkerCheckbox.php');
122
123 flrt_include('src/TemplateManager.php');
124 flrt_include('src/WpManager.php');
125
126 flrt_include('src/Admin/FilterSet.php');
127 flrt_include('src/Admin/AutoFilterSet.php');
128 flrt_include('src/Admin/FilterFields.php');
129 flrt_include('src/Admin/Admin.php');
130 flrt_include('src/Admin/AdminHooks.php');
131 flrt_include('src/Admin/AdminNotices.php');
132 flrt_include('src/Admin/ReviewRequest.php');
133 flrt_include('src/Admin/MetaBoxes.php');
134 flrt_include('src/Admin/Widgets/FiltersWidget.php');
135 flrt_include('src/Admin/Widgets/ChipsWidget.php');
136 flrt_include('src/Admin/Widgets/SortingWidget.php');
137 flrt_include('src/Admin/Widgets.php');
138 flrt_include('src/Admin/Shortcodes.php');
139 flrt_include('src/Admin/Validator.php');
140 flrt_include('src/Admin/DuplicateFilterSet.php');
141
142 flrt_include('src/FormFields/Input.php');
143 flrt_include('src/wpc-api.php');
144 flrt_include('src/Admin/Widgets/gutenberg/gutenberg.php');
145
146 $this->registerHooks();
147
148 $this->initSettings();
149
150 flrt_check_update_mobile_settings();
151
152 if( flrt_get_experimental_option( 'disable_woo_orderby' ) === 'on' ) {
153 if( ! function_exists('woocommerce_catalog_ordering') ){
154 function woocommerce_catalog_ordering()
155 {
156 return false;
157 }
158 }
159 }
160 }
161
162 public function registerHooks()
163 {
164 // Backward compatibility. From v1.3.2
165 add_action( 'init', [ $this, 'convertShowChipsInContent' ], -1 );
166
167 add_action( 'init', [ $this, 'oneTwoThreeGo' ] );
168
169 add_action( 'init', [ $this, 'loadTextdomain' ], 0 );
170
171 add_action( 'after_setup_theme', [$this, 'afterSetupTheme'] );
172
173 register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']);
174
175 register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']);
176
177 add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] );
178 }
179
180 public function convertShowChipsInContent()
181 {
182 // Backward compatibility. From v1.3.2
183 $filter_settings = get_option('wpc_filter_settings');
184
185 if ( isset( $filter_settings['show_terms_in_content'] ) && $filter_settings['show_terms_in_content'] === 'on' ) {
186 $new_chips_hooks = [];
187 $theme_dependencies = flrt_get_theme_dependencies();
188
189 if ( flrt_is_woocommerce() ) {
190 $new_chips_hooks[] = 'woocommerce_no_products_found';
191 $new_chips_hooks[] = 'woocommerce_archive_description';
192 }
193
194 if ( isset( $theme_dependencies['chips_hook'] ) && is_array($theme_dependencies['chips_hook'] ) ) {
195 foreach ( $theme_dependencies['chips_hook'] as $compat_chips_hook ) {
196 $new_chips_hooks[] = $compat_chips_hook;
197 }
198 }
199
200 $filter_settings['show_terms_in_content'] = $new_chips_hooks;
201 update_option('wpc_filter_settings', $filter_settings );
202 }
203 }
204
205 public function loadTextdomain()
206 {
207 add_filter( 'load_textdomain_mofile', [ $this, 'preferBundledMofile' ], 10, 2 );
208 load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' );
209 }
210
211 /**
212 * Prefer translations bundled in the plugin's /lang folder over those
213 * auto-downloaded by WordPress.org into /wp-content/languages/plugins/.
214 * Our bundled translations are 100% complete and curated; the .org ones
215 * are community-contributed and often partial or lower quality.
216 */
217 public function preferBundledMofile( $mofile, $domain )
218 {
219 if ( $domain !== 'filter-everything' ) {
220 return $mofile;
221 }
222
223 if ( strpos( $mofile, WP_LANG_DIR . '/plugins/' ) === false ) {
224 return $mofile;
225 }
226
227 $locale = function_exists( 'determine_locale' ) ? determine_locale() : get_locale();
228 $bundled = FLRT_PLUGIN_DIR_PATH . 'lang/filter-everything-' . $locale . '.mo';
229
230 if ( is_readable( $bundled ) ) {
231 return $bundled;
232 }
233
234 return $mofile;
235 }
236
237 public function oneTwoThreeGo()
238 {
239 global $flrt_plugin;
240 $flrt_plugin = new \FilterEverything\Filter\Plugin();
241 }
242
243 /**
244 * @since 1.6.1
245 */
246 public function afterSetupTheme()
247 {
248 $this->define( 'FLRT_ALLOW_PLL_TRANSLATIONS', true );
249 }
250
251 private function initSettings(){
252 $container = \FilterEverything\Filter\Container::instance();
253
254 $settings['php_to_js_date_formats'] = array(
255 'Y' => 'yy',
256 'y' => 'y',
257 'm' => 'mm',
258 'n' => 'm',
259 'F' => 'MM',
260 'M' => 'M',
261 'l' => 'DD',
262 'D' => 'D',
263 'd' => 'dd',
264 'j' => 'd',
265 'S' => '',
266 );
267
268 $settings['php_to_js_time_formats'] = array(
269 'a' => 'tt',
270 'A' => 'TT',
271 'h' => 'hh',
272 'g' => 'h',
273 'H' => 'HH',
274 'G' => 'H',
275 'i' => 'mm',
276 's' => 'ss',
277 );
278
279 foreach ( $settings as $key => $value ) {
280 $container->storeParam( $key, $value );
281 }
282 }
283
284 public function define( $name, $value = true )
285 {
286 if( ! defined( $name ) ) {
287 define( $name, $value );
288 }
289 }
290
291 }
292
293 function flrt_filter()
294 {
295 global $wpcFilter;
296
297 if( ! isset( $wpcFilter ) ) {
298 $wpcFilter = new FlrtFilter();
299 $wpcFilter->init();
300 }
301
302 return $wpcFilter;
303
304 }
305
306 flrt_filter();
307
308 endif;