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

201 lines 7.0 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.2.4
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;
25
26 $flrt_sets = [];
27
28 $this->define( 'FLRT_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
29 $this->define( 'FLRT_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
30 $this->define( 'FLRT_PLUGIN_BASENAME', plugin_basename(__FILE__) );
31 $this->define( 'FLRT_PLUGIN_VER', '1.2.3' );
32 $this->define( 'FLRT_PLUGIN_LINK', 'https://filtereverything.pro' );
33 $this->define( 'FLRT_PLUGIN_DEBUG', false );
34 $this->define( 'FLRT_TEMPLATES_DIR_NAME', 'filters' );
35
36 $this->define( 'FLRT_FILTERS_SET_POST_TYPE', 'filter-set' );
37 $this->define( 'FLRT_FILTERS_POST_TYPE', 'filter-field' );
38 $this->define( 'FLRT_PREFIX_SEPARATOR', '-' );
39 $this->define( 'FLRT_QUERY_TERMS_SEPARATOR', ';' );
40 $this->define( 'FLRT_STATUS_COOKIE_NAME', 'wpcContainersStatus' );
41 $this->define( 'FLRT_HIERARCHY_LIST_COOKIE_NAME', 'wpcHierarchyListStatus' );
42 $this->define( 'FLRT_OPEN_CLOSE_BUTTON_COOKIE_NAME', 'wpcWidgetStatus' );
43
44 require_once FLRT_PLUGIN_DIR . 'src/wpc-helpers.php';
45
46 flrt_include('src/wpc-compat.php');
47 flrt_include('src/wpc-default-hooks.php');
48 flrt_include('src/wpc-third-party.php');
49
50 flrt_include('src/Plugin.php');
51 flrt_include('src/PostTypes.php');
52 flrt_include('src/Settings/TabInterface.php');
53 flrt_include('src/Settings/BaseSettings.php');
54 flrt_include('src/Settings/TabRenderer.php');
55 flrt_include('src/Settings/Container.php');
56
57 flrt_include('src/Entities/Entity.php');
58
59 flrt_include('src/Entities/TaxonomyEntity.php');
60 flrt_include('src/Entities/PostMetaEntity.php');
61 flrt_include('src/Entities/PostMetaNumEntity.php');
62 flrt_include('src/Entities/AuthorEntity.php');
63
64 // Include PRO
65 // flrt_include('pro/filters-pro.php');
66
67 flrt_include('src/Entities/DefaultEntity.php');
68 flrt_include('src/Entities/EntityManager.php');
69
70 flrt_include('src/Settings/Tabs/SettingsTab.php');
71 flrt_include('src/Settings/Tabs/PermalinksTab.php');
72 flrt_include('src/Settings/Tabs/ExperimentalTab.php');
73 flrt_include('src/Settings/Tabs/AboutProTab.php');
74
75 flrt_include('src/Settings/Filter.php');
76
77 flrt_include('src/RequestParser.php');
78 flrt_include('src/UrlManager.php');
79 flrt_include('src/Chips.php');
80
81 flrt_include('src/Walkers/WalkerCheckbox.php');
82
83 flrt_include('src/TemplateManager.php');
84 flrt_include('src/WpManager.php');
85
86 flrt_include('src/Admin/FilterSet.php');
87 flrt_include('src/Admin/FilterFields.php');
88 flrt_include('src/Admin/Admin.php');
89 flrt_include('src/Admin/AdminHooks.php');
90 flrt_include('src/Admin/MetaBoxes.php');
91 flrt_include('src/Admin/Widgets/FiltersWidget.php');
92 flrt_include('src/Admin/Widgets/ChipsWidget.php');
93 flrt_include('src/Admin/Widgets.php');
94 flrt_include('src/Admin/Shortcodes.php');
95 flrt_include('src/Admin/Validator.php');
96
97 flrt_include('src/FormFields/Input.php');
98 flrt_include('src/wpc-api.php');
99
100 $this->registerHooks();
101 }
102
103 public function registerHooks()
104 {
105 // Convert old post_name format to new. Since v1.1.24
106 add_action( 'init', [$this, 'convertSetLocations'], -1 );
107
108 add_action( 'init', [ $this, 'oneTwoThreeGo' ] );
109
110 add_action( 'init', [$this, 'loadTextdomain'], 0 );
111
112 register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']);
113
114 register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']);
115
116 add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] );
117 }
118
119 public function convertSetLocations()
120 {
121 if( is_admin() ) {
122
123 global $wpdb;
124
125 // Convert separator from ":" to "___" and from -1 to 1
126 $sql = [];
127 $sql[] = "SELECT {$wpdb->posts}.ID, {$wpdb->posts}.post_name";
128 $sql[] = "FROM {$wpdb->posts}";
129 $sql[] = "WHERE {$wpdb->posts}.post_type = '%s'";
130 $sql[] = "AND {$wpdb->posts}.post_name REGEXP '[\:]+'";
131 $sql[] = "OR {$wpdb->posts}.post_name = '-1'";
132
133 $sql = implode(" ", $sql);
134 $sql = $wpdb->prepare($sql, FLRT_FILTERS_SET_POST_TYPE);
135
136 $results = $wpdb->get_results($sql, ARRAY_A);
137
138 if (!empty($results)) {
139
140 foreach ($results as $row) {
141 $update = [];
142
143 if (!isset($row['post_name']) || !isset($row['ID'])) {
144 continue;
145 }
146
147 if( $row['post_name'] == '-1' ){
148 $new_post_name = '1';
149 }else{
150 $new_post_name = str_replace(":", "___", $row['post_name']);
151 }
152
153 $update[] = "UPDATE {$wpdb->posts}";
154 $update[] = "SET {$wpdb->posts}.post_name = '%s'";
155 $update[] = "WHERE {$wpdb->posts}.ID = %s";
156
157 $updateSql = implode(" ", $update);
158
159 $updateSql = $wpdb->prepare($updateSql, $new_post_name, $row['ID']);
160
161 $wpdb->query($updateSql);
162 }
163 }
164
165 }
166
167 }
168
169 public function loadTextdomain()
170 {
171 load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' );
172 }
173
174 public function oneTwoThreeGo()
175 {
176 new \FilterEverything\Filter\Plugin();
177 }
178
179 public function define( $name, $value = true )
180 {
181 if( ! defined( $name ) ) {
182 define( $name, $value );
183 }
184 }
185
186 }
187
188 function flrt_filter()
189 {
190 global $wpcFilter;
191
192 if( ! isset( $wpcFilter ) ) {
193 $wpcFilter = new FlrtFilter();
194 $wpcFilter->init();
195 }
196 return $wpcFilter;
197 }
198
199 flrt_filter();
200
201 endif;