| 1 |
<?php |
| 2 |
/* |
| 3 |
Plugin Name: Filter Everything — WordPress & WooCommerce Filters |
| 4 |
Plugin URI: https://filtereverything.pro |
| 5 |
Description: Instantly filter any WordPress content & WooCommerce products by attributes, taxonomies, custom fields + AJAX, Elementor, automatic filter creation. |
| 6 |
Version: 1.9.6 |
| 7 |
Requires PHP: 7.4 |
| 8 |
Author: Andrii Stepasiuk |
| 9 |
Author URI: https://filtereverything.pro/about/ |
| 10 |
Text Domain: filter-everything |
| 11 |
Domain Path: /lang |
| 12 |
*/ |
| 13 |
|
| 14 |
// If this file is called directly, abort. |
| 15 |
if ( ! defined('ABSPATH') ) { |
| 16 |
exit; |
| 17 |
} |
| 18 |
|
| 19 |
if( ! class_exists( 'FlrtFilter' ) ): |
| 20 |
|
| 21 |
class FlrtFilter{ |
| 22 |
|
| 23 |
public function init() |
| 24 |
{ |
| 25 |
global $flrt_sets, $wpc_not_fired, $chips_count, $flrt_json_data; |
| 26 |
|
| 27 |
$chips_count = 0; |
| 28 |
$wpc_not_fired = true; |
| 29 |
$flrt_sets = []; |
| 30 |
|
| 31 |
$this->define( 'FLRT_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 32 |
$this->define( 'FLRT_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 33 |
$this->define( 'FLRT_PLUGIN_BASENAME', plugin_basename(__FILE__) ); |
| 34 |
$this->define( 'FLRT_PLUGIN_SLUG', 'filter-everything-pro' ); |
| 35 |
$this->define( 'FLRT_PLUGIN_VER', '1.9.6' ); |
| 36 |
$this->define( 'FLRT_PLUGIN_URL', 'https://filtereverything.pro' ); |
| 37 |
$this->define( 'FLRT_PLUGIN_TESTED_TO', '7.1' ); |
| 38 |
$this->define( 'FLRT_PLUGIN_DEBUG', false ); |
| 39 |
$this->define( 'FLRT_TEMPLATES_DIR_NAME', 'filters' ); |
| 40 |
|
| 41 |
$this->define( 'FLRT_FILTERS_SET_POST_TYPE', 'filter-set' ); |
| 42 |
$this->define( 'FLRT_FILTERS_POST_TYPE', 'filter-field' ); |
| 43 |
$this->define( 'FLRT_PREFIX_SEPARATOR', '-' ); |
| 44 |
$this->define( 'FLRT_QUERY_TERMS_SEPARATOR', ';' ); |
| 45 |
$this->define( 'FLRT_DATE_TIME_SEPARATOR', 't' ); |
| 46 |
$this->define( 'FLRT_FOLDING_COOKIE_NAME', 'wpcContainersStatus' ); |
| 47 |
$this->define( 'FLRT_MORELESS_COOKIE_NAME', 'wpcMoreLessStatus' ); |
| 48 |
$this->define( 'FLRT_HIERARCHY_LIST_COOKIE_NAME', 'wpcHierarchyListStatus' ); |
| 49 |
$this->define( 'FLRT_OPEN_CLOSE_BUTTON_COOKIE_NAME', 'wpcWidgetStatus' ); |
| 50 |
$this->define( 'FLRT_APPLY_BUTTON_META_KEY', 'wpc_filter_set_apply_button_post_name' ); |
| 51 |
$this->define( 'FLRT_TRANSIENT_PERIOD_HOURS', 12 ); |
| 52 |
$this->define( 'FLRT_BEAVER_BUILDER_VAR', 'fl_builder' ); |
| 53 |
$this->define( 'FLRT_LICENSE_KEY', 'wpc_filter_license' ); |
| 54 |
$this->define( 'FLRT_MARKET', 'codecanyon' ); |
| 55 |
$this->define( 'FLRT_RELEASER', 'stepasiuk' ); |
| 56 |
$this->define( 'FLRT_APPROVED', 'victor' ); |
| 57 |
$this->define( 'FLRT_ITERATION', 'first' ); |
| 58 |
$this->define( 'FLRT_PRO_PRICE', '$69' ); |
| 59 |
|
| 60 |
if ( ! defined('FLRT_RANGE_LIST_LIMIT')){ |
| 61 |
$this->define( 'FLRT_RANGE_LIST_LIMIT', 20 ); |
| 62 |
} |
| 63 |
|
| 64 |
|
| 65 |
if ( ! defined('FLRT_XML_PATH')){ |
| 66 |
$wp_upload_dir = wp_upload_dir(); |
| 67 |
$upload_dir_basepath = $wp_upload_dir['basedir']; |
| 68 |
|
| 69 |
$path = $upload_dir_basepath . '/filter-everything/xml/'; |
| 70 |
define( 'FLRT_XML_PATH', $path ); |
| 71 |
} |
| 72 |
|
| 73 |
require_once FLRT_PLUGIN_DIR_PATH . 'src/wpc-helpers.php'; |
| 74 |
|
| 75 |
flrt_include('src/wp_query_source_detector.php'); |
| 76 |
flrt_include('src/wpc-compat.php'); |
| 77 |
flrt_include('src/wpc-utility-functions.php'); |
| 78 |
flrt_include('src/wpc-default-hooks.php'); |
| 79 |
flrt_include('src/wpc-third-party.php'); |
| 80 |
flrt_include('src/PluginHelpers.php'); |
| 81 |
|
| 82 |
flrt_include('src/Plugin.php'); |
| 83 |
flrt_include('src/PostTypes.php'); |
| 84 |
flrt_include('src/Settings/TabInterface.php'); |
| 85 |
flrt_include('src/Settings/BaseSettings.php'); |
| 86 |
flrt_include('src/Settings/TabRenderer.php'); |
| 87 |
flrt_include('src/Settings/Container.php'); |
| 88 |
|
| 89 |
flrt_include('src/Entities/Entity.php'); |
| 90 |
flrt_include('src/Entities/PostMetaTrait.php'); |
| 91 |
|
| 92 |
flrt_include('src/Entities/TaxonomyEntity.php'); |
| 93 |
flrt_include('src/Entities/PostMetaEntity.php'); |
| 94 |
flrt_include('src/Entities/PostMetaNumEntity.php'); |
| 95 |
flrt_include('src/Entities/AuthorEntity.php'); |
| 96 |
flrt_include('src/Entities/PostDateEntity.php'); |
| 97 |
flrt_include('src/Entities/PostMetaDateEntity.php'); |
| 98 |
flrt_include('src/Settings/Tabs/SeoTabTrait.php'); |
| 99 |
|
| 100 |
// Include PRO |
| 101 |
// flrt_include('pro/filters-pro.php'); |
| 102 |
|
| 103 |
flrt_include('src/Entities/DefaultEntity.php'); |
| 104 |
flrt_include('src/Entities/EntityManager.php'); |
| 105 |
|
| 106 |
flrt_include('src/Settings/DefaultSettings.php'); |
| 107 |
flrt_include('src/Settings/Tabs/SettingsTab.php'); |
| 108 |
flrt_include('src/RobotsTxt.php'); |
| 109 |
flrt_include('src/Settings/Tabs/PermalinksTab.php'); |
| 110 |
flrt_include('src/Settings/Tabs/ImportExportTabFree.php'); |
| 111 |
flrt_include('src/Settings/Tabs/ExperimentalTab.php'); |
| 112 |
flrt_include('src/Settings/Tabs/AboutProTab.php'); |
| 113 |
|
| 114 |
flrt_include('src/Settings/Filter.php'); |
| 115 |
|
| 116 |
flrt_include('src/RequestParser.php'); |
| 117 |
flrt_include('src/UrlManager.php'); |
| 118 |
flrt_include('src/Chips.php'); |
| 119 |
flrt_include('src/Sorting.php'); |
| 120 |
flrt_include('src/Swatches.php'); |
| 121 |
|
| 122 |
flrt_include('src/Walkers/WalkerCheckbox.php'); |
| 123 |
|
| 124 |
flrt_include('src/TemplateManager.php'); |
| 125 |
flrt_include('src/WpManager.php'); |
| 126 |
|
| 127 |
flrt_include('src/Admin/FilterSet.php'); |
| 128 |
flrt_include('src/Admin/AutoFilterSet.php'); |
| 129 |
flrt_include('src/Admin/FilterFields.php'); |
| 130 |
flrt_include('src/Admin/Admin.php'); |
| 131 |
flrt_include('src/Admin/AdminHooks.php'); |
| 132 |
flrt_include('src/Admin/AdminNotices.php'); |
| 133 |
flrt_include('src/Admin/WhatsNew.php'); |
| 134 |
flrt_include('src/Admin/ReviewRequest.php'); |
| 135 |
flrt_include('src/Admin/MetaBoxes.php'); |
| 136 |
flrt_include('src/Admin/Widgets/FiltersWidget.php'); |
| 137 |
flrt_include('src/Admin/Widgets/ChipsWidget.php'); |
| 138 |
flrt_include('src/Admin/Widgets/SortingWidget.php'); |
| 139 |
flrt_include('src/Admin/Widgets.php'); |
| 140 |
flrt_include('src/Admin/Shortcodes.php'); |
| 141 |
flrt_include('src/Admin/Validator.php'); |
| 142 |
flrt_include('src/Admin/DuplicateFilterSet.php'); |
| 143 |
|
| 144 |
flrt_include('src/FormFields/Input.php'); |
| 145 |
flrt_include('src/wpc-api.php'); |
| 146 |
flrt_include('src/Admin/Widgets/gutenberg/gutenberg.php'); |
| 147 |
|
| 148 |
$this->registerHooks(); |
| 149 |
|
| 150 |
$this->initSettings(); |
| 151 |
|
| 152 |
flrt_check_update_mobile_settings(); |
| 153 |
|
| 154 |
if( flrt_get_experimental_option( 'disable_woo_orderby' ) === 'on' ) { |
| 155 |
if( ! function_exists('woocommerce_catalog_ordering') ){ |
| 156 |
function woocommerce_catalog_ordering() |
| 157 |
{ |
| 158 |
return false; |
| 159 |
} |
| 160 |
} |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
public function registerHooks() |
| 165 |
{ |
| 166 |
// Backward compatibility. From v1.3.2 |
| 167 |
add_action( 'init', [ $this, 'convertShowChipsInContent' ], -1 ); |
| 168 |
|
| 169 |
add_action( 'init', [ $this, 'oneTwoThreeGo' ] ); |
| 170 |
|
| 171 |
add_action( 'init', [ $this, 'loadTextdomain' ], 0 ); |
| 172 |
|
| 173 |
add_action( 'after_setup_theme', [$this, 'afterSetupTheme'] ); |
| 174 |
|
| 175 |
register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']); |
| 176 |
|
| 177 |
register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']); |
| 178 |
|
| 179 |
add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] ); |
| 180 |
} |
| 181 |
|
| 182 |
public function convertShowChipsInContent() |
| 183 |
{ |
| 184 |
// Backward compatibility. From v1.3.2 |
| 185 |
$filter_settings = get_option('wpc_filter_settings'); |
| 186 |
|
| 187 |
if ( isset( $filter_settings['show_terms_in_content'] ) && $filter_settings['show_terms_in_content'] === 'on' ) { |
| 188 |
$new_chips_hooks = []; |
| 189 |
$theme_dependencies = flrt_get_theme_dependencies(); |
| 190 |
|
| 191 |
if ( flrt_is_woocommerce() ) { |
| 192 |
$new_chips_hooks[] = 'woocommerce_no_products_found'; |
| 193 |
$new_chips_hooks[] = 'woocommerce_archive_description'; |
| 194 |
} |
| 195 |
|
| 196 |
if ( isset( $theme_dependencies['chips_hook'] ) && is_array($theme_dependencies['chips_hook'] ) ) { |
| 197 |
foreach ( $theme_dependencies['chips_hook'] as $compat_chips_hook ) { |
| 198 |
$new_chips_hooks[] = $compat_chips_hook; |
| 199 |
} |
| 200 |
} |
| 201 |
|
| 202 |
$filter_settings['show_terms_in_content'] = $new_chips_hooks; |
| 203 |
update_option('wpc_filter_settings', $filter_settings ); |
| 204 |
} |
| 205 |
} |
| 206 |
|
| 207 |
public function loadTextdomain() |
| 208 |
{ |
| 209 |
add_filter( 'load_textdomain_mofile', [ $this, 'preferBundledMofile' ], 10, 2 ); |
| 210 |
load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' ); |
| 211 |
} |
| 212 |
|
| 213 |
/** |
| 214 |
* Prefer translations bundled in the plugin's /lang folder over those |
| 215 |
* auto-downloaded by WordPress.org into /wp-content/languages/plugins/. |
| 216 |
* Our bundled translations are 100% complete and curated; the .org ones |
| 217 |
* are community-contributed and often partial or lower quality. |
| 218 |
*/ |
| 219 |
public function preferBundledMofile( $mofile, $domain ) |
| 220 |
{ |
| 221 |
if ( $domain !== 'filter-everything' ) { |
| 222 |
return $mofile; |
| 223 |
} |
| 224 |
|
| 225 |
if ( strpos( $mofile, WP_LANG_DIR . '/plugins/' ) === false ) { |
| 226 |
return $mofile; |
| 227 |
} |
| 228 |
|
| 229 |
$locale = function_exists( 'determine_locale' ) ? determine_locale() : get_locale(); |
| 230 |
$bundled = FLRT_PLUGIN_DIR_PATH . 'lang/filter-everything-' . $locale . '.mo'; |
| 231 |
|
| 232 |
if ( is_readable( $bundled ) ) { |
| 233 |
return $bundled; |
| 234 |
} |
| 235 |
|
| 236 |
return $mofile; |
| 237 |
} |
| 238 |
|
| 239 |
public function oneTwoThreeGo() |
| 240 |
{ |
| 241 |
global $flrt_plugin; |
| 242 |
$flrt_plugin = new \FilterEverything\Filter\Plugin(); |
| 243 |
} |
| 244 |
|
| 245 |
/** |
| 246 |
* @since 1.6.1 |
| 247 |
*/ |
| 248 |
public function afterSetupTheme() |
| 249 |
{ |
| 250 |
$this->define( 'FLRT_ALLOW_PLL_TRANSLATIONS', true ); |
| 251 |
} |
| 252 |
|
| 253 |
private function initSettings(){ |
| 254 |
$container = \FilterEverything\Filter\Container::instance(); |
| 255 |
|
| 256 |
$settings['php_to_js_date_formats'] = array( |
| 257 |
'Y' => 'yy', |
| 258 |
'y' => 'y', |
| 259 |
'm' => 'mm', |
| 260 |
'n' => 'm', |
| 261 |
'F' => 'MM', |
| 262 |
'M' => 'M', |
| 263 |
'l' => 'DD', |
| 264 |
'D' => 'D', |
| 265 |
'd' => 'dd', |
| 266 |
'j' => 'd', |
| 267 |
'S' => '', |
| 268 |
); |
| 269 |
|
| 270 |
$settings['php_to_js_time_formats'] = array( |
| 271 |
'a' => 'tt', |
| 272 |
'A' => 'TT', |
| 273 |
'h' => 'hh', |
| 274 |
'g' => 'h', |
| 275 |
'H' => 'HH', |
| 276 |
'G' => 'H', |
| 277 |
'i' => 'mm', |
| 278 |
's' => 'ss', |
| 279 |
); |
| 280 |
|
| 281 |
foreach ( $settings as $key => $value ) { |
| 282 |
$container->storeParam( $key, $value ); |
| 283 |
} |
| 284 |
} |
| 285 |
|
| 286 |
public function define( $name, $value = true ) |
| 287 |
{ |
| 288 |
if( ! defined( $name ) ) { |
| 289 |
define( $name, $value ); |
| 290 |
} |
| 291 |
} |
| 292 |
|
| 293 |
} |
| 294 |
|
| 295 |
function flrt_filter() |
| 296 |
{ |
| 297 |
global $wpcFilter; |
| 298 |
|
| 299 |
if( ! isset( $wpcFilter ) ) { |
| 300 |
$wpcFilter = new FlrtFilter(); |
| 301 |
$wpcFilter->init(); |
| 302 |
} |
| 303 |
|
| 304 |
return $wpcFilter; |
| 305 |
|
| 306 |
} |
| 307 |
|
| 308 |
flrt_filter(); |
| 309 |
|
| 310 |
endif; |