PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.6.1
Filter Everything — WordPress & WooCommerce Filters v1.6.1
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
filter-everything / filter-everything.php

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

255 lines 9.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;— WooCoomerce Product & WordPress Filter
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
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('WPINC') ) {
15 wp_die();
16 }
17
18 if( ! class_exists( 'FlrtFilter' ) ):
19
20 class FlrtFilter{
21
22 public function init()
23 {
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__ ) );
31 $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' );
34 $this->define( 'FLRT_PLUGIN_DEBUG', false );
35 $this->define( 'FLRT_TEMPLATES_DIR_NAME', 'filters' );
36
37 $this->define( 'FLRT_FILTERS_SET_POST_TYPE', 'filter-set' );
38 $this->define( 'FLRT_FILTERS_POST_TYPE', 'filter-field' );
39 $this->define( 'FLRT_PREFIX_SEPARATOR', '-' );
40 $this->define( 'FLRT_QUERY_TERMS_SEPARATOR', ';' );
41 $this->define( 'FLRT_STATUS_COOKIE_NAME', 'wpcContainersStatus' );
42 $this->define( 'FLRT_HIERARCHY_LIST_COOKIE_NAME', 'wpcHierarchyListStatus' );
43 $this->define( 'FLRT_OPEN_CLOSE_BUTTON_COOKIE_NAME', 'wpcWidgetStatus' );
44 $this->define( 'FLRT_APPLY_BUTTON_META_KEY', 'wpc_filter_set_apply_button_post_name' );
45 $this->define( 'FLRT_TRANSIENT_PERIOD_HOURS', 12 );
46
47 require_once FLRT_PLUGIN_DIR . 'src/wpc-helpers.php';
48
49 flrt_include('src/wpc-compat.php');
50 flrt_include('src/wpc-default-hooks.php');
51 flrt_include('src/wpc-third-party.php');
52
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');
59
60 flrt_include('src/Entities/Entity.php');
61
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');
66
67 // Include PRO
68 // flrt_include('pro/filters-pro.php');
69
70 flrt_include('src/Entities/DefaultEntity.php');
71 flrt_include('src/Entities/EntityManager.php');
72
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');
77
78 flrt_include('src/Settings/Filter.php');
79
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');
93 flrt_include('src/Admin/AdminHooks.php');
94 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');
103 flrt_include('src/wpc-api.php');
104
105 $this->registerHooks();
106
107 if( flrt_get_experimental_option( 'disable_woo_orderby' ) === 'on' ) {
108 if( ! function_exists('woocommerce_catalog_ordering') ){
109 function woocommerce_catalog_ordering()
110 {
111 return false;
112 }
113 }
114 }
115 }
116
117 public function registerHooks()
118 {
119 // Convert old post_name format to new. Since v1.1.24
120 add_action( 'init', [$this, 'convertSetLocations'], -1 );
121
122 // Backward compatibility. From v1.3.2
123 add_action( 'init', [$this, 'convertShowChipsInContent'], -1 );
124
125 add_action( 'init', [ $this, 'oneTwoThreeGo' ] );
126
127 add_action( 'init', [$this, 'loadTextdomain'], 0 );
128
129 add_action( 'after_setup_theme', [$this, 'afterSetupTheme'] );
130
131 register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']);
132
133 register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']);
134
135 add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] );
136 }
137
138 public function convertShowChipsInContent()
139 {
140 // Backward compatibility. From v1.3.2
141 $filter_settings = get_option('wpc_filter_settings');
142
143 if (isset($filter_settings['show_terms_in_content']) && $filter_settings['show_terms_in_content'] === 'on') {
144 $new_chips_hooks = [];
145 $theme_dependencies = flrt_get_theme_dependencies();
146
147 if (flrt_is_woocommerce()) {
148 $new_chips_hooks[] = 'woocommerce_no_products_found';
149 $new_chips_hooks[] = 'woocommerce_archive_description';
150 }
151
152 if (isset($theme_dependencies['chips_hook']) && is_array($theme_dependencies['chips_hook'])) {
153 foreach ($theme_dependencies['chips_hook'] as $compat_chips_hook) {
154 $new_chips_hooks[] = $compat_chips_hook;
155 }
156 }
157
158 $filter_settings['show_terms_in_content'] = $new_chips_hooks;
159 update_option('wpc_filter_settings', $filter_settings);
160 }
161 }
162
163 public function convertSetLocations()
164 {
165 if( is_admin() ) {
166
167 global $wpdb;
168
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'";
176
177 $sql = implode(" ", $sql);
178 $sql = $wpdb->prepare($sql, FLRT_FILTERS_SET_POST_TYPE);
179
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
209 }
210
211 }
212
213 public function loadTextdomain()
214 {
215 load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' );
216 }
217
218 public function oneTwoThreeGo()
219 {
220 new \FilterEverything\Filter\Plugin();
221 }
222
223 /**
224 * @since 1.6.1
225 */
226 public function afterSetupTheme()
227 {
228 $this->define( 'FLRT_ALLOW_PLL_TRANSLATIONS', true );
229 }
230
231 public function define( $name, $value = true )
232 {
233 if( ! defined( $name ) ) {
234 define( $name, $value );
235 }
236 }
237
238 }
239
240 function flrt_filter()
241 {
242 global $wpcFilter;
243
244 if( ! isset( $wpcFilter ) ) {
245 $wpcFilter = new FlrtFilter();
246 $wpcFilter->init();
247 }
248
249 return $wpcFilter;
250
251 }
252
253 flrt_filter();
254
255 endif;