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

245 lines 8.7 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.4.9
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.4.9' );
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_TRANSIENT_PERIOD_HOURS', 12 );
45
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 register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']);
130
131 register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']);
132
133 add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] );
134 }
135
136 public function convertShowChipsInContent()
137 {
138 // Backward compatibility. From v1.3.2
139 $filter_settings = get_option('wpc_filter_settings');
140
141 if (isset($filter_settings['show_terms_in_content']) && $filter_settings['show_terms_in_content'] === 'on') {
142 $new_chips_hooks = [];
143 $theme_dependencies = flrt_get_theme_dependencies();
144
145 if (flrt_is_woocommerce()) {
146 $new_chips_hooks[] = 'woocommerce_no_products_found';
147 $new_chips_hooks[] = 'woocommerce_archive_description';
148 }
149
150 if (isset($theme_dependencies['chips_hook']) && is_array($theme_dependencies['chips_hook'])) {
151 foreach ($theme_dependencies['chips_hook'] as $compat_chips_hook) {
152 $new_chips_hooks[] = $compat_chips_hook;
153 }
154 }
155
156 $filter_settings['show_terms_in_content'] = $new_chips_hooks;
157 update_option('wpc_filter_settings', $filter_settings);
158 }
159 }
160
161 public function convertSetLocations()
162 {
163 if( is_admin() ) {
164
165 global $wpdb;
166
167 // Convert separator from ":" to "___" and from -1 to 1
168 $sql = [];
169 $sql[] = "SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_name";
170 $sql[] = "FROM {$wpdb->posts}";
171 $sql[] = "WHERE {$wpdb->posts}.post_type = '%s'";
172 $sql[] = "AND {$wpdb->posts}.post_name REGEXP '[\:]+'";
173 $sql[] = "OR {$wpdb->posts}.post_name = '-1'";
174
175 $sql = implode(" ", $sql);
176 $sql = $wpdb->prepare($sql, FLRT_FILTERS_SET_POST_TYPE);
177
178 $results = $wpdb->get_results($sql, ARRAY_A);
179
180 if (!empty($results)) {
181
182 foreach ($results as $row) {
183 $update = [];
184
185 if (!isset($row['post_name']) || !isset($row['ID'])) {
186 continue;
187 }
188
189 if( $row['post_name'] == '-1' ){
190 $new_post_name = '1';
191 }else{
192 $new_post_name = str_replace(":", "___", $row['post_name']);
193 }
194
195 $update[] = "UPDATE {$wpdb->posts}";
196 $update[] = "SET {$wpdb->posts}.post_name = '%s'";
197 $update[] = "WHERE {$wpdb->posts}.ID = %s";
198
199 $updateSql = implode(" ", $update);
200
201 $updateSql = $wpdb->prepare($updateSql, $new_post_name, $row['ID']);
202
203 $wpdb->query($updateSql);
204 }
205 }
206
207 }
208
209 }
210
211 public function loadTextdomain()
212 {
213 load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' );
214 }
215
216 public function oneTwoThreeGo()
217 {
218 new \FilterEverything\Filter\Plugin();
219 }
220
221 public function define( $name, $value = true )
222 {
223 if( ! defined( $name ) ) {
224 define( $name, $value );
225 }
226 }
227
228 }
229
230 function flrt_filter()
231 {
232 global $wpcFilter;
233
234 if( ! isset( $wpcFilter ) ) {
235 $wpcFilter = new FlrtFilter();
236 $wpcFilter->init();
237 }
238
239 return $wpcFilter;
240
241 }
242
243 flrt_filter();
244
245 endif;