PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.2.2
Filter Everything — WordPress & WooCommerce Filters v1.9.2.2
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.2.2, at filter-everything.php

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