-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjpkcom-post-filter.php
More file actions
176 lines (149 loc) · 4.62 KB
/
jpkcom-post-filter.php
File metadata and controls
176 lines (149 loc) · 4.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php
/*
Plugin Name: JPKCom Post Filter
Plugin URI: https://github.com/JPKCom/jpkcom-post-filter
Description: Faceted navigation and filtering for Posts, Pages and Custom Post Types via WordPress taxonomies. Supports SEO-friendly URLs, AJAX filtering with history.pushState, and No-JS fallback.
Version: 1.1.3
Author: Jean Pierre Kolb <jpk@jpkc.com>
Author URI: https://www.jpkc.com/
Contributors: JPKCom
Tags: Taxonomy, Tags, Filters, Facets, Navigation
Requires at least: 6.9
Tested up to: 6.9
Requires PHP: 8.3
Stable tag: 1.1.3
License: GPL-2.0-or-later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: jpkcom-post-filter
Domain Path: /languages
*/
declare(strict_types=1);
if ( ! defined( constant_name: 'WPINC' ) ) {
die;
}
/**
* Plugin Constants
*
* All constants can be overridden in wp-config.php before the plugin loads.
*
* @since 1.0.0
*/
if ( ! defined( 'JPKCOM_POSTFILTER_VERSION' ) ) {
define( 'JPKCOM_POSTFILTER_VERSION', '1.1.3' );
}
if ( ! defined( 'JPKCOM_POSTFILTER_BASENAME' ) ) {
define( 'JPKCOM_POSTFILTER_BASENAME', plugin_basename( __FILE__ ) );
}
if ( ! defined( 'JPKCOM_POSTFILTER_PLUGIN_PATH' ) ) {
define( 'JPKCOM_POSTFILTER_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
}
if ( ! defined( 'JPKCOM_POSTFILTER_PLUGIN_URL' ) ) {
define( 'JPKCOM_POSTFILTER_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
}
if ( ! defined( 'JPKCOM_POSTFILTER_SETTINGS_DIR' ) ) {
define( 'JPKCOM_POSTFILTER_SETTINGS_DIR', WP_CONTENT_DIR . '/.ht.jpkcom-post-filter-settings' );
}
if ( ! defined( 'JPKCOM_POSTFILTER_CACHE_ENABLED' ) ) {
define( 'JPKCOM_POSTFILTER_CACHE_ENABLED', true );
}
if ( ! defined( 'JPKCOM_POSTFILTER_DEBUG' ) ) {
define( 'JPKCOM_POSTFILTER_DEBUG', defined( 'WP_DEBUG' ) && WP_DEBUG );
}
if ( ! defined( 'JPKCOM_POSTFILTER_URL_ENDPOINT' ) ) {
define( 'JPKCOM_POSTFILTER_URL_ENDPOINT', 'filter' );
}
/**
* Load plugin includes
*
* @since 1.0.0
*/
$jpkcom_postfilter_includes = [
'includes/helpers.php',
'includes/cache-manager.php',
'includes/settings.php',
'includes/template-loader.php',
'includes/taxonomies.php',
'includes/url-routing.php',
'includes/query-handler.php',
'includes/filter-injection.php',
'includes/shortcodes.php',
'includes/blocks.php',
'includes/elementor-widgets.php',
'includes/oxygen-elements.php',
'includes/assets-enqueue.php',
'includes/admin-pages.php',
];
foreach ( $jpkcom_postfilter_includes as $include_file ) {
$full_path = JPKCOM_POSTFILTER_PLUGIN_PATH . $include_file;
if ( file_exists( $full_path ) ) {
require_once $full_path;
} elseif ( JPKCOM_POSTFILTER_DEBUG ) {
error_log( "[jpkcom-post-filter] Missing include: {$include_file}" );
}
}
/**
* Initialize Plugin Updater
*
* Loads and initializes the GitHub-based plugin updater with SHA256 checksum verification.
*
* @since 1.0.0
* @return void
*/
add_action( 'init', static function (): void {
$updater_file = JPKCOM_POSTFILTER_PLUGIN_PATH . 'includes/class-plugin-updater.php';
if ( file_exists( $updater_file ) ) {
require_once $updater_file;
if ( class_exists( 'JPKComPostFilterGitUpdate\\JPKComGitPluginUpdater' ) ) {
new \JPKComPostFilterGitUpdate\JPKComGitPluginUpdater(
plugin_file: __FILE__,
current_version: JPKCOM_POSTFILTER_VERSION,
manifest_url: 'https://jpkcom.github.io/jpkcom-post-filter/plugin_jpkcom-post-filter.json'
);
}
}
}, 5 );
/**
* Load plugin text domain for translations
*
* Loads translation files from the /languages directory.
*
* @since 1.0.0
* @return void
*/
function jpkcom_postfilter_textdomain(): void {
load_plugin_textdomain(
'jpkcom-post-filter',
false,
dirname( path: JPKCOM_POSTFILTER_BASENAME ) . '/languages'
);
}
add_action( 'plugins_loaded', 'jpkcom_postfilter_textdomain' );
/**
* Plugin activation hook
*
* Sets up rewrite rules and settings cache directory on activation.
*
* @since 1.0.0
* @return void
*/
function jpkcom_postfilter_activate(): void {
// Ensure settings cache directory exists
if ( function_exists( 'jpkcom_postfilter_ensure_settings_dir' ) ) {
jpkcom_postfilter_ensure_settings_dir();
}
// Flush rewrite rules after activation
flush_rewrite_rules();
}
register_activation_hook( __FILE__, 'jpkcom_postfilter_activate' );
/**
* Plugin deactivation hook
*
* Flushes rewrite rules on deactivation.
*
* @since 1.0.0
* @return void
*/
function jpkcom_postfilter_deactivate(): void {
flush_rewrite_rules();
}
register_deactivation_hook( __FILE__, 'jpkcom_postfilter_deactivate' );