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/AdminHooks.php +92 -14 1.3.21.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 AdminHooks
11 11 {
@@ -14,8 +14,11 @@
14 14 {
15 15 add_filter( 'manage_edit-'.FLRT_FILTERS_SET_POST_TYPE.'_columns', array( $this, 'filterSetPostTypeCol' ) );
16 16 add_action( 'manage_'.FLRT_FILTERS_SET_POST_TYPE.'_posts_custom_column', array( $this, 'filterSetPostTypeColContent'), 10, 2 );
17 17
18 + add_filter( 'manage_edit-'.FLRT_FILTERS_SET_POST_TYPE.'_columns', array( $this, 'filterSetWhereFilterCol' ), 1 );
19 + add_action( 'manage_'.FLRT_FILTERS_SET_POST_TYPE.'_posts_custom_column', array( $this, 'filterSetWhereFilterColContent'), 10, 2 );
20 +
18 21 add_filter( 'manage_edit-'.FLRT_FILTERS_SET_POST_TYPE.'_sortable_columns', array( $this, 'filterSetSortableColumn') );
19 22 add_action( 'pre_get_posts', array( $this, 'filterSetOrderby' ) );
20 23
21 24 add_action('admin_notices', [$this, 'adminNotices'] );
@@ -28,20 +31,23 @@
28 31 }
29 32
30 33 public function aboutPro()
31 34 {
32 - if( ! defined('FLRT_FILTERS_PRO') ){
33 - echo '<a class="wpc-tab wpc-get-pro" href="'.admin_url('edit.php?post_type=filter-set&page=filters-settings&tab=aboutpro').'">'.esc_html__( 'About PRO', 'filter-everything' ).'</a>'."\r\n";
34 - echo '<a class="wpc-tab wpc-get-pro button button-primary" href="'.esc_url(FLRT_PLUGIN_LINK .'/?get_pro=true').'" target="_blank">'.esc_html__( 'Get PRO', 'filter-everything' ).'</a>'."\r\n";
35 + if ( ! defined('FLRT_FILTERS_PRO') ) {
36 + echo '<a class="wpc-tab wpc-get-pro" href="'.admin_url( 'edit.php?post_type=filter-set&page=filters-settings&tab=aboutpro' ).'"><span>'.esc_html__( 'PRO benefits', 'filter-everything' ).'</span>' . flrt_diamond_icon() . "</a>\r\n";;
37 + echo '<a class="wpc-tab wpc-get-pro wpc-get-pro-background button button-primary" href="'. esc_url(flrt_unlock_pro_link( 'hero_upgrade_btn' )).'" target="_blank">'.esc_html__( 'Upgrade to PRO', 'filter-everything' ).' '. flrt_crown_icon() .'</a>'."\r\n";
35 38 }
36 -
37 39 $this->addHelpTab();
40 + }
38 41
39 - }
40 42
41 43 public function addHelpTab() {
42 44 $screen = get_current_screen();
43 45
46 + if( is_null( $screen ) ){
47 + return false;
48 + }
49 +
44 50 // Overview tab.
45 51 $screen->add_help_tab(
46 52 array(
47 53 'id' => 'overview',
@@ -47,10 +53,10 @@
47 53 'id' => 'overview',
48 54 'title' => esc_html__( 'Overview', 'filter-everything' ),
49 55 'content' =>
50 56 '<p><strong>' . esc_html__( 'Overview', 'filter-everything' ) . '</strong></p>' .
51 - '<p>' . esc_html__( 'Filter Everything — WordPress & WooCommerce product filter plugin, that allows to design any filtering system.', 'filter-everything' ) . '</p>'.
52 - '<p>' . esc_html__( 'It is fast, convenient and intuitive, and also contains unique features for SEO (in PRO version).', 'filter-everything' ) . '</p>'
57 + '<p>' . esc_html__( 'Filter Everything — WordPress & WooCommerce product filter plugin that allows you to design a flexible filtering system.', 'filter-everything' ) . '</p>'.
58 + '<p>' . esc_html__( 'It is fast, convenient, intuitive, and contains unique SEO features (in the PRO version).', 'filter-everything' ) . '</p>'
53 59 )
54 60 );
55 61
56 62 // Help tab.
@@ -61,9 +67,9 @@
61 67 'content' =>
62 68 '<p><strong>' . esc_html__( 'Help & Support', 'filter-everything' ) . '</strong></p>' .
63 69 '<ul>' .
64 70 '<li>' . wp_kses( sprintf(
65 - __( '<a href="%s" target="_blank">Documentation</a>. Common information how to work with the plugin can be found in our documentation.', 'filter-everything' ),
71 + __( '<a href="%s" target="_blank">Documentation</a>. Common information on how to work with the plugin can be found in our documentation.', 'filter-everything' ),
66 72 'https://filtereverything.pro/resources/'
67 73 ),
68 74 array(
69 75 'a' => array( 'href' => true, 'target' => true )
@@ -119,9 +125,9 @@
119 125
120 126 $actions = array_merge( $actionsLink, $actions );
121 127
122 128 if( ! defined( 'FLRT_FILTERS_PRO' ) ){
123 - $actions[] = '<a href="' . esc_url(FLRT_PLUGIN_LINK .'/?get_pro=true') . '" class="wpc-go-pro" target="_blank">'.esc_html__('Get PRO', 'filter-everything').'</a>';
129 + $actions[] = '<a href="' . esc_url(FLRT_PLUGIN_URL .'/pricing/?utm_source=free_plugin&utm_medium=internal&utm_campaign=free_plugin_upgrade&utm_content=plugin_actions_lnk') . '" class="wpc-go-pro" target="_blank">'.esc_html__('Get PRO', 'filter-everything').'</a>';
124 130 }
125 131
126 132 return $actions;
127 133 }
@@ -129,8 +135,16 @@
129 135 public function checkForbiddenPrefixes()
130 136 {
131 137 $forbiddenPrefixes = flrt_get_forbidden_prefixes();
132 138 $savedPrefixes = get_option( 'wpc_filter_permalinks', [] );
139 +
140 + if ( ! is_array( $savedPrefixes ) ) {
141 + $savedPrefixes = maybe_unserialize( $savedPrefixes );
142 + }
143 + if ( ! is_array( $savedPrefixes ) ) {
144 + $savedPrefixes = []; // If still not an array, default to an empty array
145 + }
146 +
133 147 $warningPrefixes = [];
134 148
135 149 foreach( $forbiddenPrefixes as $prefix ){
136 150 if( in_array( $prefix, $savedPrefixes ) ){
@@ -137,9 +151,9 @@
137 151 $warningPrefixes[] = $prefix;
138 152 }
139 153 }
140 154
141 - $permalinkOptionsUrl = admin_url( 'edit.php?post_type=filter-set&page=filters-settings&tab=permalinks' );
155 + $permalinkOptionsUrl = admin_url( 'edit.php?post_type=filter-set&page=filters-settings&tab=prefixes' );
142 156 $permalinksTab = new PermalinksTab();
143 157 $permalinksTabLabel = strtolower( $permalinksTab->getLabel() );
144 158
145 159 if( ! empty( $warningPrefixes ) ){
@@ -171,15 +185,24 @@
171 185
172 186 public function adminNotices()
173 187 {
174 188 $get = Container::instance()->getTheGet();
175 -
189 + /**
190 + * string
191 + */
176 192 if( ! isset( $get['message'] ) ){
177 193 return false;
178 194 }
179 195
180 196 $messageNum = sanitize_key($get['message']); // no need to escape
181 - $errors = FilterFields::getErrorsList();
197 + $limit = null;
198 + if ($messageNum === '92' && !empty($get['post'])) {
199 + $filterSet = Container::instance()->getFilterSetService();
200 + $post_type_field = $filterSet->getPostTypeField((int) $get['post']);
201 + $post_type = !empty($post_type_field['post_type']['value']) ? $post_type_field['post_type']['value'] : '';
202 + $limit = $filterSet->getFreeLimitForPostType($post_type);
203 + }
204 + $errors = FilterFields::getErrorsList($limit);
182 205
183 206 ?>
184 207 <?php foreach ( $errors as $id => $message ) : ?>
185 208 <?php if( isset( $errors[$messageNum] ) ): // no need to escape ?>
@@ -240,8 +263,27 @@
240 263
241 264 return $newColumns;
242 265 }
243 266
267 + public function filterSetWhereFilterCol( $columns )
268 + {
269 + $newColumns = [];
270 +
271 + foreach ( $columns as $columnId => $columnName ) {
272 +
273 + if( $columnId === 'date' ){
274 + continue;
275 + }
276 +
277 + $newColumns[$columnId] = $columnName;
278 + if( $columnId === 'title' ){
279 + $newColumns['where_filter'] = "<div>" . esc_html__( 'Open', 'filter-everything' ) . flrt_open_in_new_tab_icon() . '</div>';
280 + }
281 + }
282 +
283 + return $newColumns;
284 + }
285 +
244 286 public function filterSetPostTypeColContent( $column_name, $post_id )
245 287 {
246 288 if( 'set_post_type' == $column_name ){
247 289 $fss = Container::instance()->getFilterSetService();
@@ -254,7 +296,43 @@
254 296 echo esc_html( $postType );
255 297 }
256 298 }
257 299
300 + public function filterSetWhereFilterColContent( $column_name, $post_id )
301 + {
302 + $fss = Container::instance()->getFilterSetService();
303 + $theSet = $fss->getSet( $post_id );
304 + $filterSet = Container::instance()->getFilterSetService();
305 + $under_limit_filter_set = $filterSet->under_limit_filter_set($post_id);
306 + $link = '';
307 + $html = '';
308 +
309 + if ('where_filter' == $column_name) {
310 + $link = flrt_filter_set_front_link($post_id);
311 +
312 + if ($under_limit_filter_set) {
313 + $post_type_field = $filterSet->getPostTypeField($post_id);
314 + $post_type = !empty($post_type_field['post_type']['value']) ? $post_type_field['post_type']['value'] : '';
315 + $limit = $filterSet->getFreeLimitForPostType($post_type);
316 + $tip_text = wp_kses(
317 + sprintf(
318 + /* translators: %d: maximum number of free filter sets per post type */
319 + __('This Filter Set is inactive.<br>The Free version allows up to %d Filter Sets per post type.<br>Upgrade to PRO to activate unlimited Filter Sets.', 'filter-everything'),
320 + $limit
321 + ),
322 + array('br' => array())
323 + );
324 + $html = '<div class="wpc-pro-filter-set-badge"><span class="wpc-alert-emoji wpc-icon-help-tip" data-tip="' . esc_attr($tip_text) . '">' . flrt_unlock_icon('20px', '20px', '#3858E9') . '</span><a class="wpc-pro-badge-text" href="' . esc_url(flrt_vailable_in_pro_attr_link()) . '">' . esc_html__('Unlock with PRO', 'filter-everything') . '</a></div>';
325 + } else {
326 + if (!empty($link)) {
327 + $html = '<a class="wpc-location-preview" target="_blank" href="' . esc_url($link) . '"><span class="dashicons dashicons-visibility"></span></a>';
328 + } else {
329 + $html = '—';
330 + }
331 + }
332 +
333 + echo $html;
334 + }
335 + }
258 336 }
259 337
260 338 new AdminHooks();