| 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.7 |
| 7 |
Requires at least: 6.0 |
| 8 |
Requires PHP: 7.4 |
| 9 |
Author: Andrii Stepasiuk |
| 10 |
Author URI: https://filtereverything.pro/about/ |
| 11 |
Text Domain: filter-everything |
| 12 |
Domain Path: /lang |
| 13 |
*/ |
| 14 |
|
| 15 |
// If this file is called directly, abort. |
| 16 |
if ( ! defined('ABSPATH') ) { |
| 17 |
exit; |
| 18 |
} |
| 19 |
|
| 20 |
if( ! class_exists( 'FlrtFilter' ) ): |
| 21 |
|
| 22 |
class FlrtFilter{ |
| 23 |
|
| 24 |
public function init() |
| 25 |
{ |
| 26 |
$this->define( 'FLRT_PLUGIN_DIR_PATH', plugin_dir_path( __FILE__ ) ); |
| 27 |
$this->define( 'FLRT_PLUGIN_DIR_URL', plugin_dir_url( __FILE__ ) ); |
| 28 |
$this->define( 'FLRT_PLUGIN_BASENAME', plugin_basename(__FILE__) ); |
| 29 |
$this->define( 'FLRT_PLUGIN_SLUG', 'filter-everything-pro' ); |
| 30 |
$this->define( 'FLRT_PLUGIN_VER', '1.9.7' ); |
| 31 |
$this->define( 'FLRT_PLUGIN_URL', 'https://filtereverything.pro' ); |
| 32 |
$this->define( 'FLRT_PLUGIN_TESTED_TO', '7.1' ); |
| 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_DATE_TIME_SEPARATOR', 't' ); |
| 41 |
$this->define( 'FLRT_FOLDING_COOKIE_NAME', 'wpcContainersStatus' ); |
| 42 |
$this->define( 'FLRT_MORELESS_COOKIE_NAME', 'wpcMoreLessStatus' ); |
| 43 |
$this->define( 'FLRT_HIERARCHY_LIST_COOKIE_NAME', 'wpcHierarchyListStatus' ); |
| 44 |
$this->define( 'FLRT_OPEN_CLOSE_BUTTON_COOKIE_NAME', 'wpcWidgetStatus' ); |
| 45 |
$this->define( 'FLRT_APPLY_BUTTON_META_KEY', 'wpc_filter_set_apply_button_post_name' ); |
| 46 |
$this->define( 'FLRT_TRANSIENT_PERIOD_HOURS', 12 ); |
| 47 |
$this->define( 'FLRT_BEAVER_BUILDER_VAR', 'fl_builder' ); |
| 48 |
$this->define( 'FLRT_LICENSE_KEY', 'wpc_filter_license' ); |
| 49 |
$this->define( 'FLRT_MARKET', 'codecanyon' ); |
| 50 |
$this->define( 'FLRT_RELEASER', 'stepasiuk' ); |
| 51 |
$this->define( 'FLRT_APPROVED', 'victor' ); |
| 52 |
$this->define( 'FLRT_ITERATION', 'first' ); |
| 53 |
$this->define( 'FLRT_PRO_PRICE', '$69' ); |
| 54 |
|
| 55 |
if ( ! defined('FLRT_RANGE_LIST_LIMIT')){ |
| 56 |
$this->define( 'FLRT_RANGE_LIST_LIMIT', 20 ); |
| 57 |
} |
| 58 |
|
| 59 |
|
| 60 |
if ( ! defined('FLRT_XML_PATH')){ |
| 61 |
$wp_upload_dir = wp_upload_dir(); |
| 62 |
$upload_dir_basepath = $wp_upload_dir['basedir']; |
| 63 |
|
| 64 |
$path = $upload_dir_basepath . '/filter-everything/xml/'; |
| 65 |
define( 'FLRT_XML_PATH', $path ); |
| 66 |
} |
| 67 |
|
| 68 |
require_once FLRT_PLUGIN_DIR_PATH . 'src/wpc-helpers.php'; |
| 69 |
|
| 70 |
// Thematic helper files split out of wpc-helpers.php (same functions, no renames) |
| 71 |
flrt_include('src/helpers/dates.php'); |
| 72 |
flrt_include('src/helpers/colors.php'); |
| 73 |
flrt_include('src/helpers/cache-keys.php'); |
| 74 |
flrt_include('src/helpers/ui.php'); |
| 75 |
flrt_include('src/helpers/migrations.php'); |
| 76 |
flrt_include('src/helpers/instant-recount.php'); |
| 77 |
|
| 78 |
// Class autoloading (src/classmap.php + PSR-4 fallback for new sub-namespaced code). |
| 79 |
// Only side-effect-free class files are autoloaded; see bin/build-classmap.php. |
| 80 |
require_once FLRT_PLUGIN_DIR_PATH . 'src/Autoloader.php'; |
| 81 |
\FilterEverything\Filter\Autoloader::register(); |
| 82 |
\FilterEverything\Filter\Autoloader::addClassMap( require FLRT_PLUGIN_DIR_PATH . 'src/classmap.php', FLRT_PLUGIN_DIR_PATH . 'src' ); |
| 83 |
\FilterEverything\Filter\Autoloader::addNamespace( 'FilterEverything\\Filter', FLRT_PLUGIN_DIR_PATH . 'src' ); |
| 84 |
|
| 85 |
// Files that do work at include time (functions, hooks, instantiation) — kept explicit, in order. |
| 86 |
flrt_include('src/wpc-compat.php'); |
| 87 |
flrt_include('src/wpc-utility-functions.php'); |
| 88 |
flrt_include('src/wpc-default-hooks.php'); |
| 89 |
flrt_include('src/wpc-third-party.php'); |
| 90 |
flrt_include('src/PostTypes.php'); |
| 91 |
|
| 92 |
// PRO bootstrap. Comment out this single line (or ship without the pro/ folder) |
| 93 |
// to run the plugin as the free version: it is the only place that registers |
| 94 |
// PRO classes, constants and hooks. |
| 95 |
// flrt_include('pro/filters-pro.php'); |
| 96 |
|
| 97 |
flrt_include('src/RobotsTxt.php'); |
| 98 |
flrt_include('src/Swatches.php'); |
| 99 |
flrt_include('src/Admin/AdminHooks.php'); |
| 100 |
flrt_include('src/Admin/AdminNotices.php'); |
| 101 |
flrt_include('src/Admin/WhatsNew.php'); |
| 102 |
flrt_include('src/Admin/ReviewRequest.php'); |
| 103 |
flrt_include('src/Admin/MetaBoxes.php'); |
| 104 |
flrt_include('src/Frontend/Widgets.php'); |
| 105 |
flrt_include('src/wpc-api.php'); |
| 106 |
flrt_include('src/Frontend/Builders/gutenberg/gutenberg.php'); |
| 107 |
|
| 108 |
$this->registerHooks(); |
| 109 |
|
| 110 |
$this->initSettings(); |
| 111 |
|
| 112 |
flrt_check_update_mobile_settings(); |
| 113 |
|
| 114 |
if( flrt_get_experimental_option( 'disable_woo_orderby' ) === 'on' ) { |
| 115 |
if( ! function_exists('woocommerce_catalog_ordering') ){ |
| 116 |
function woocommerce_catalog_ordering() |
| 117 |
{ |
| 118 |
return false; |
| 119 |
} |
| 120 |
} |
| 121 |
} |
| 122 |
} |
| 123 |
|
| 124 |
public function registerHooks() |
| 125 |
{ |
| 126 |
// Backward compatibility. From v1.3.2 |
| 127 |
add_action( 'init', [ $this, 'convertShowChipsInContent' ], -1 ); |
| 128 |
|
| 129 |
add_action( 'init', [ $this, 'oneTwoThreeGo' ] ); |
| 130 |
|
| 131 |
add_action( 'init', [ $this, 'loadTextdomain' ], 0 ); |
| 132 |
|
| 133 |
add_action( 'after_setup_theme', [$this, 'afterSetupTheme'] ); |
| 134 |
|
| 135 |
register_activation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'activate']); |
| 136 |
|
| 137 |
register_deactivation_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'deactivate']); |
| 138 |
|
| 139 |
register_uninstall_hook(__FILE__, ['FilterEverything\Filter\Plugin', 'uninstall']); |
| 140 |
|
| 141 |
add_action('after_switch_theme', ['FilterEverything\Filter\Plugin', 'switchTheme'] ); |
| 142 |
} |
| 143 |
|
| 144 |
public function convertShowChipsInContent() |
| 145 |
{ |
| 146 |
// Backward compatibility. From v1.3.2 |
| 147 |
$filter_settings = get_option('wpc_filter_settings'); |
| 148 |
|
| 149 |
if ( isset( $filter_settings['show_terms_in_content'] ) && $filter_settings['show_terms_in_content'] === 'on' ) { |
| 150 |
$new_chips_hooks = []; |
| 151 |
$theme_dependencies = flrt_get_theme_dependencies(); |
| 152 |
|
| 153 |
if ( flrt_is_woocommerce() ) { |
| 154 |
$new_chips_hooks[] = 'woocommerce_no_products_found'; |
| 155 |
$new_chips_hooks[] = 'woocommerce_archive_description'; |
| 156 |
} |
| 157 |
|
| 158 |
if ( isset( $theme_dependencies['chips_hook'] ) && is_array($theme_dependencies['chips_hook'] ) ) { |
| 159 |
foreach ( $theme_dependencies['chips_hook'] as $compat_chips_hook ) { |
| 160 |
$new_chips_hooks[] = $compat_chips_hook; |
| 161 |
} |
| 162 |
} |
| 163 |
|
| 164 |
$filter_settings['show_terms_in_content'] = $new_chips_hooks; |
| 165 |
update_option('wpc_filter_settings', $filter_settings ); |
| 166 |
} |
| 167 |
} |
| 168 |
|
| 169 |
public function loadTextdomain() |
| 170 |
{ |
| 171 |
add_filter( 'load_textdomain_mofile', [ $this, 'preferBundledMofile' ], 10, 2 ); |
| 172 |
load_plugin_textdomain( 'filter-everything', false, dirname(FLRT_PLUGIN_BASENAME) . '/lang' ); |
| 173 |
} |
| 174 |
|
| 175 |
/** |
| 176 |
* Prefer translations bundled in the plugin's /lang folder over those |
| 177 |
* auto-downloaded by WordPress.org into /wp-content/languages/plugins/. |
| 178 |
* Our bundled translations are 100% complete and curated; the .org ones |
| 179 |
* are community-contributed and often partial or lower quality. |
| 180 |
*/ |
| 181 |
public function preferBundledMofile( $mofile, $domain ) |
| 182 |
{ |
| 183 |
if ( $domain !== 'filter-everything' ) { |
| 184 |
return $mofile; |
| 185 |
} |
| 186 |
|
| 187 |
if ( strpos( $mofile, WP_LANG_DIR . '/plugins/' ) === false ) { |
| 188 |
return $mofile; |
| 189 |
} |
| 190 |
|
| 191 |
$locale = function_exists( 'determine_locale' ) ? determine_locale() : get_locale(); |
| 192 |
$bundled = FLRT_PLUGIN_DIR_PATH . 'lang/filter-everything-' . $locale . '.mo'; |
| 193 |
|
| 194 |
if ( is_readable( $bundled ) ) { |
| 195 |
return $bundled; |
| 196 |
} |
| 197 |
|
| 198 |
return $mofile; |
| 199 |
} |
| 200 |
|
| 201 |
public function oneTwoThreeGo() |
| 202 |
{ |
| 203 |
global $flrt_plugin; |
| 204 |
$flrt_plugin = new \FilterEverything\Filter\Plugin(); |
| 205 |
} |
| 206 |
|
| 207 |
/** |
| 208 |
* @since 1.6.1 |
| 209 |
*/ |
| 210 |
public function afterSetupTheme() |
| 211 |
{ |
| 212 |
$this->define( 'FLRT_ALLOW_PLL_TRANSLATIONS', true ); |
| 213 |
} |
| 214 |
|
| 215 |
private function initSettings(){ |
| 216 |
$container = \FilterEverything\Filter\Container::instance(); |
| 217 |
|
| 218 |
$settings['php_to_js_date_formats'] = array( |
| 219 |
'Y' => 'yy', |
| 220 |
'y' => 'y', |
| 221 |
'm' => 'mm', |
| 222 |
'n' => 'm', |
| 223 |
'F' => 'MM', |
| 224 |
'M' => 'M', |
| 225 |
'l' => 'DD', |
| 226 |
'D' => 'D', |
| 227 |
'd' => 'dd', |
| 228 |
'j' => 'd', |
| 229 |
'S' => '', |
| 230 |
); |
| 231 |
|
| 232 |
$settings['php_to_js_time_formats'] = array( |
| 233 |
'a' => 'tt', |
| 234 |
'A' => 'TT', |
| 235 |
'h' => 'hh', |
| 236 |
'g' => 'h', |
| 237 |
'H' => 'HH', |
| 238 |
'G' => 'H', |
| 239 |
'i' => 'mm', |
| 240 |
's' => 'ss', |
| 241 |
); |
| 242 |
|
| 243 |
foreach ( $settings as $key => $value ) { |
| 244 |
$container->storeParam( $key, $value ); |
| 245 |
} |
| 246 |
} |
| 247 |
|
| 248 |
public function define( $name, $value = true ) |
| 249 |
{ |
| 250 |
if( ! defined( $name ) ) { |
| 251 |
define( $name, $value ); |
| 252 |
} |
| 253 |
} |
| 254 |
|
| 255 |
} |
| 256 |
|
| 257 |
function flrt_filter() |
| 258 |
{ |
| 259 |
global $wpcFilter; |
| 260 |
|
| 261 |
if( ! isset( $wpcFilter ) ) { |
| 262 |
$wpcFilter = new FlrtFilter(); |
| 263 |
$wpcFilter->init(); |
| 264 |
} |
| 265 |
|
| 266 |
return $wpcFilter; |
| 267 |
|
| 268 |
} |
| 269 |
|
| 270 |
flrt_filter(); |
| 271 |
|
| 272 |
endif; |