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

246 lines 8.8 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.0
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.0' );
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
48 require_once FLRT_PLUGIN_DIR . 'src/wpc-helpers.php';
49
50 flrt_include('src/wpc-compat.php');
51 flrt_include('src/wpc-default-hooks.php');
52 flrt_include('src/wpc-third-party.php');
53
54 flrt_include('src/Plugin.php');
55 flrt_include('src/PostTypes.php');
56 flrt_include('src/Settings/TabInterface.php');
57 flrt_include('src/Settings/BaseSettings.php');
58 flrt_include('src/Settings/TabRenderer.php');
59 flrt_include('src/Settings/Container.php');
60
61 flrt_include('src/Entities/Entity.php');
62
63 flrt_include('src/Entities/TaxonomyEntity.php');
64 flrt_include('src/Entities/PostMetaEntity.php');
65 flrt_include('src/Entities/PostMetaNumEntity.php');
66 flrt_include('src/Entities/AuthorEntity.php');
67
68 // Include PRO
69 // flrt_include('pro/filters-pro.php');
70
71 flrt_include('src/Entities/DefaultEntity.php');
72 flrt_include('src/Entities/EntityManager.php');
73
74 flrt_include('src/Settings/Tabs/SettingsTab.php');
75 flrt_include('src/Settings/Tabs/PermalinksTab.php');
76 flrt_include('src/Settings/Tabs/ExperimentalTab.php');
77 flrt_include('src/Settings/Tabs/AboutProTab.php');
78
79 flrt_include('src/Settings/Filter.php');
80
81 flrt_include('src/RequestParser.php');
82 flrt_include('src/UrlManager.php');
83 flrt_include('src/Chips.php');
84 flrt_include('src/Sorting.php');
85
86 flrt_include('src/Walkers/WalkerCheckbox.php');
87
88 flrt_include('src/TemplateManager.php');
89 flrt_include('src/WpManager.php');
90
91 flrt_include('src/Admin/FilterSet.php');
92 flrt_include('src/Admin/FilterFields.php');
93 flrt_include('src/Admin/Admin.php');
94 flrt_include('src/Admin/AdminHooks.php');
95 flrt_include('src/Admin/MetaBoxes.php');
96 flrt_include('src/Admin/Widgets/FiltersWidget.php');
97 flrt_include('src/Admin/Widgets/ChipsWidget.php');
98 flrt_include('src/Admin/Widgets/SortingWidget.php');
99 flrt_include('src/Admin/Widgets.php');
100 flrt_include('src/Admin/Shortcodes.php');
101 flrt_include('src/Admin/Validator.php');
102
103 flrt_include('src/FormFields/Input.php');
104 flrt_include('src/wpc-api.php');
105
106 $this->registerHooks();
107
108 if( flrt_get_experimental_option( 'disable_woo_orderby' ) === 'on' ) {
109 if( ! function_exists('woocommerce_catalog_ordering') ){
110 function woocommerce_catalog_ordering()
111 {
112 return false;
113 }
114 }
115 }
116 }
117
118 public function registerHooks()
119 {
120 // Convert old post_name format to new. Since v1.1.24
121 add_action( 'init', [$this, 'convertSetLocations'], -1 );
122
123 // Backward compatibility. From v1.3.2
124 add_action( 'init', [$this, 'convertShowChipsInContent'], -1 );
125
126 add_action( 'init', [ $this, 'oneTwoThreeGo' ] );
127
128 add_action( 'init', [$this, 'loadTextdomain'], 0 );
129
130 register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']);
131
132 register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']);
133
134 add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] );
135 }
136
137 public function convertShowChipsInContent()
138 {
139 // Backward compatibility. From v1.3.2
140 $filter_settings = get_option('wpc_filter_settings');
141
142 if (isset($filter_settings['show_terms_in_content']) && $filter_settings['show_terms_in_content'] === 'on') {
143 $new_chips_hooks = [];
144 $theme_dependencies = flrt_get_theme_dependencies();
145
146 if (flrt_is_woocommerce()) {
147 $new_chips_hooks[] = 'woocommerce_no_products_found';
148 $new_chips_hooks[] = 'woocommerce_archive_description';
149 }
150
151 if (isset($theme_dependencies['chips_hook']) && is_array($theme_dependencies['chips_hook'])) {
152 foreach ($theme_dependencies['chips_hook'] as $compat_chips_hook) {
153 $new_chips_hooks[] = $compat_chips_hook;
154 }
155 }
156
157 $filter_settings['show_terms_in_content'] = $new_chips_hooks;
158 update_option('wpc_filter_settings', $filter_settings);
159 }
160 }
161
162 public function convertSetLocations()
163 {
164 if( is_admin() ) {
165
166 global $wpdb;
167
168 // Convert separator from ":" to "___" and from -1 to 1
169 $sql = [];
170 $sql[] = "SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_name";
171 $sql[] = "FROM {$wpdb->posts}";
172 $sql[] = "WHERE {$wpdb->posts}.post_type = '%s'";
173 $sql[] = "AND {$wpdb->posts}.post_name REGEXP '[\:]+'";
174 $sql[] = "OR {$wpdb->posts}.post_name = '-1'";
175
176 $sql = implode(" ", $sql);
177 $sql = $wpdb->prepare($sql, FLRT_FILTERS_SET_POST_TYPE);
178
179 $results = $wpdb->get_results($sql, ARRAY_A);
180
181 if (!empty($results)) {
182
183 foreach ($results as $row) {
184 $update = [];
185
186 if (!isset($row['post_name']) || !isset($row['ID'])) {
187 continue;
188 }
189
190 if( $row['post_name'] == '-1' ){
191 $new_post_name = '1';
192 }else{
193 $new_post_name = str_replace(":", "___", $row['post_name']);
194 }
195
196 $update[] = "UPDATE {$wpdb->posts}";
197 $update[] = "SET {$wpdb->posts}.post_name = '%s'";
198 $update[] = "WHERE {$wpdb->posts}.ID = %s";
199
200 $updateSql = implode(" ", $update);
201
202 $updateSql = $wpdb->prepare($updateSql, $new_post_name, $row['ID']);
203
204 $wpdb->query($updateSql);
205 }
206 }
207
208 }
209
210 }
211
212 public function loadTextdomain()
213 {
214 load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' );
215 }
216
217 public function oneTwoThreeGo()
218 {
219 new \FilterEverything\Filter\Plugin();
220 }
221
222 public function define( $name, $value = true )
223 {
224 if( ! defined( $name ) ) {
225 define( $name, $value );
226 }
227 }
228
229 }
230
231 function flrt_filter()
232 {
233 global $wpcFilter;
234
235 if( ! isset( $wpcFilter ) ) {
236 $wpcFilter = new FlrtFilter();
237 $wpcFilter->init();
238 }
239
240 return $wpcFilter;
241
242 }
243
244 flrt_filter();
245
246 endif;