PluginProbe
Filter Everything — WordPress & WooCommerce Filters / 1.9.7
Filter Everything — WordPress & WooCommerce Filters v1.9.7
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
← All changes | src/Admin/Admin.php +125 -9 1.2.41.9.7 View file →
@@ -2,10 +2,10 @@
2 2
3 3
4 4 namespace FilterEverything\Filter;
5 5
6 -if ( ! defined('WPINC') ) {
7 - wp_die();
6 +if ( ! defined('ABSPATH') ) {
7 + exit;
8 8 }
9 9
10 10 class Admin
11 11 {
@@ -22,8 +22,13 @@
22 22
23 23 add_action( 'init', array( $this, 'initTabs' ), 11 );
24 24
25 25 add_action( 'admin_init', array( $this, 'init' ) );
26 +
27 + add_filter( 'wpc_general_filters_settings', [$this, 'generalFilterSettings'] );
28 +
29 + add_action('admin_head', array($this, 'addAdminStyles'));
30 +
26 31 }
27 32
28 33 public function init()
29 34 {
@@ -38,18 +43,43 @@
38 43 }
39 44
40 45 public function adminMenu()
41 46 {
47 + global $submenu;
42 48 $page = 'edit.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE;
43 49
44 - add_menu_page( esc_html__('Filters', 'filter-everything'), esc_html__('Filters', 'filter-everything'), 'manage_options', $page, false, $this->get_icon_svg(), '85');
50 + add_menu_page( esc_html__('Filters', 'filter-everything'), esc_html__('Filters', 'filter-everything'), 'manage_options', $page, false, 'none', '85');
45 51
46 52 add_submenu_page( $page, esc_html__('Filter Sets', 'filter-everything'), esc_html__('Filter Sets', 'filter-everything'), 'manage_options', $page);
47 53 add_submenu_page( $page, esc_html__('Add New', 'filter-everything'), esc_html__('Add New', 'filter-everything'), 'manage_options', 'post-new.php?post_type=' . FLRT_FILTERS_SET_POST_TYPE);
48 54
55 + if (!defined('FLRT_FILTERS_PRO')) {
56 + $settings = flrt_vailable_in_pro_attr_link();
57 +
58 + // Two PRO-only destinations in the menu, each with the PRO badge. They
59 + // were dropped in 1.9.6 to keep the menu short and are back since 1.9.7:
60 + // the owner saw fewer free → PRO visits without them — two PRO-badged
61 + // entries in the menu and the toolbar are a visible reminder of what
62 + // PRO adds.
63 + add_submenu_page($page, esc_html__('SEO Rules', 'filter-everything'), esc_html__('SEO Rules', 'filter-everything'), 'manage_options', $settings);
64 + add_submenu_page($page, esc_html__('Import/Export', 'filter-everything'), esc_html__('Import/Export', 'filter-everything'), 'manage_options', $settings);
65 +
66 + if (isset($submenu[$page])) {
67 + foreach ($submenu[$page] as $key => $details) {
68 + if ($details[2] === $settings) {
69 + $submenu[$page][$key][0] .= flrt_pro_promo_label(true);
70 + }
71 + }
72 + }
73 + }
74 +
49 75 do_action('wpc_add_submenu_pages');
50 76
51 77 add_submenu_page( $page, esc_html__('Settings', 'filter-everything'), esc_html__('Settings', 'filter-everything'), 'manage_options', 'filters-settings', array($this, 'filterSettingsPage'));
78 +
79 + // «What's new» is a Settings tab since 1.9.7 (WhatsNew), not a menu entry
80 + do_action('wpc_after_add_submenu_pages');
81 +
52 82 }
53 83
54 84 public function filterSettingsPage()
55 85 {
@@ -65,20 +95,64 @@
65 95
66 96 $this->tabRenderer->register(new ExperimentalTab());
67 97
68 98 if( ! defined('FLRT_FILTERS_PRO') ) {
69 - $this->tabRenderer->register(new AboutProTab());
99 + // Free: What's new goes BEFORE «PRO benefits», so the tab that sells
100 + // stays last and most visible (owner, 2026-09-22)
101 + do_action( 'wpc_settings_tabs_registered', $this->tabRenderer );
102 + $this->tabRenderer->register( new AboutProTab() );
103 +
104 + }else{
105 + $show_license_tab = false;
106 +
107 + if ( is_multisite() ) {
108 + if ( is_main_site() ) {
109 + $show_license_tab = true;
110 + }
111 + } else {
112 + $show_license_tab = true;
113 + }
114 +
115 + if ( $show_license_tab ) {
116 + $this->tabRenderer->register(new LicenseTab( FLRT_LICENSE_KEY ));
117 + }
70 118 }
71 119
120 + // PRO: What's new is the last tab, after License
121 + if ( defined('FLRT_FILTERS_PRO') ) {
122 + do_action( 'wpc_settings_tabs_registered', $this->tabRenderer );
123 + }
124 +
72 125 $this->tabRenderer->init();
73 126 }
74 127
75 - public function get_icon_svg()
128 + public function addAdminStyles()
76 129 {
77 - return flrt_get_icon_svg();
130 + if(defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO) {
131 + return;
132 + }
133 +
134 + if (!is_admin()) {
135 + return;
136 + }
137 + ?>
138 + <style type="text/css">
139 + .wpc-pro-badge {
140 + background: #3858E9;
141 + color: #fff;
142 + padding: 2px 6px;
143 + border-radius: 14px;
144 + margin-left: 6px;
145 + font-size: 10px;
146 + border: 1px solid #3858E9;
147 + position: absolute;
148 + }
149 + </style>
150 + <?php
78 151 }
79 152
80 - public function checkPermissions(){
153 + public function checkPermissions()
154 + {
81 155 $screen = get_current_screen();
82 156 $post_types = [ FLRT_FILTERS_SET_POST_TYPE, FLRT_FILTERS_POST_TYPE ];
83 157
84 158 if( defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO ){
@@ -84,12 +158,54 @@
84 158 if( defined('FLRT_FILTERS_PRO') && FLRT_FILTERS_PRO ){
85 159 $post_types[] = FLRT_SEO_RULES_POST_TYPE;
86 160 }
87 161
88 - if( isset( $screen->post_type ) && in_array( $screen->post_type, $post_types, true ) ){
89 - if( ! current_user_can( 'manage_options' ) ) {
162 + if( ! is_null( $screen ) && property_exists( $screen, 'post_type' ) && in_array( $screen->post_type, $post_types, true ) ){
163 + if( ! current_user_can( flrt_plugin_user_caps() ) ) {
90 164 wp_die( esc_html__( 'Sorry, you are not allowed to access this page.' ) );
91 165 }
92 166 }
167 + }
168 +
169 + public function generalFilterSettings( $settings )
170 + {
171 + $result_terms = [];
172 +
173 + // Chips hooks
174 + $maybe_saved_terms = flrt_get_option('show_terms_in_content', []);
175 + $theme_dependencies = flrt_get_theme_dependencies();
176 +
177 + $current_terms = $settings['common_settings']['fields']['show_terms_in_content']['options'];
178 +
179 + if( flrt_is_woocommerce() ){
180 + $woocommerce_terms = array(
181 + 'woocommerce_archive_description' => esc_html__('WooCommerce archive description', 'filter-everything' ),
182 + 'woocommerce_no_products_found' => esc_html__('WooCommerce no products found', 'filter-everything' ),
183 + 'woocommerce_before_shop_loop' => esc_html__('WooCommerce before Shop loop', 'filter-everything' ),
184 + 'woocommerce_before_main_content' => esc_html__('WooCommerce before main content', 'filter-everything' )
185 + );
186 +
187 + $result_terms = array_merge( $current_terms, $woocommerce_terms );
188 + }
189 +
190 + if( $maybe_saved_terms && is_array( $maybe_saved_terms )){
191 + foreach ($maybe_saved_terms as $hook ){
192 + if( ! in_array( $hook, array_keys( $result_terms ) ) ){
193 + $result_terms[$hook] = $hook;
194 + }
195 + }
196 + }
197 +
198 + if( isset( $theme_dependencies['chips_hook'] ) && ! empty( $theme_dependencies['chips_hook'] )){
199 + foreach ($theme_dependencies['chips_hook'] as $hook ){
200 + if( ! in_array( $hook, array_keys( $result_terms ) ) ){
201 + $result_terms[$hook] = $hook;
202 + }
203 + }
204 + }
205 +
206 + $settings['common_settings']['fields']['show_terms_in_content']['options'] = $result_terms;
207 +
208 + return $settings;
93 209 }
94 210
95 211 }