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

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