PluginProbe
WP Directory Kit / trunk
WP Directory Kit vtrunk
1.5.6 1.5.5 1.5.4 1.5.3 trunk 1.1.0 1.1.6 1.1.8 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.8 1.4.0 1.4.1 All 35 releases
wpdirectorykit / filters.php

filters.php in WP Directory Kit trunk, at filters.php

981 lines 39.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if (! defined('ABSPATH')) {
3 exit; // Exit if accessed directly.
4 }
5
6 /* fix for redirect */
7 add_action('init', 'wdk_do_output_buffer');
8 function wdk_do_output_buffer()
9 {
10 ob_start();
11 }
12
13 /* add elementor body class */
14 add_filter('body_class', function ($classes) {
15 global $wp_query;
16 global $wdk_listing_id;
17 global $wdk_listing_page_id;
18 if (isset($wp_query->post))
19 if ($wp_query->post->post_type == 'wdk-listing') {
20 $wdk_listing_id = $wp_query->post->ID;
21 $wdk_listing_page_id = get_option('wdk_listing_page');
22 if (!empty($wdk_listing_page_id) && get_post_status($wdk_listing_page_id) == 'publish') {
23 return array_merge($classes, array('elementor-page-' . $wdk_listing_page_id));
24 }
25 }
26
27 return array_merge($classes, array('class-name'));
28 });
29
30 add_filter('the_content', 'wdk_content');
31
32 function wdk_content($content)
33 {
34 global $wp_query;
35 global $wdk_listing_id;
36 global $wdk_listing_page_id;
37 if (isset($wp_query->post))
38 if ($wp_query->post->post_type == 'wdk-listing') {
39 $wdk_listing_id = $wp_query->post->ID;
40 $wdk_listing_page_id = get_option('wdk_listing_page');
41 if (!empty($wdk_listing_page_id) && get_post_status($wdk_listing_page_id) == 'publish') {
42 global $Winter_MVC_WDK;
43 $Winter_MVC_WDK->load_helper('listing');
44
45 if (
46 (
47 wdk_field_value('is_activated', $wdk_listing_id, false) && wdk_field_value('is_approved', $wdk_listing_id, false)) ||
48 (get_current_user_id() != 0 && get_current_user_id() == wdk_field_value('user_id_editor', $wdk_listing_id, false)) ||
49 (get_current_user_id() != 0 && wmvc_user_in_role('administrator'))
50 ) {
51
52 $Winter_MVC_WDK->model('listing_m');
53 $Winter_MVC_WDK->listing_m->update_counter($wdk_listing_id);
54
55 if (wdk_get_option('wdk_membership_is_enable_subscriptions') && wdk_get_option('wdk_membership_subscriptions_view_listing_enabled') && function_exists('run_wdk_membership')) {
56 /* if required subscription with View details listing */
57
58 /* if not login, return alert for ask login */
59 if (is_user_logged_in()) {
60
61 global $Winter_MVC_wdk_membership;
62 $Winter_MVC_wdk_membership->model('subscription_m');
63 $Winter_MVC_wdk_membership->model('subscription_user_m');
64 $user_subscriptions_listings_view = $Winter_MVC_wdk_membership->subscription_user_m->get_pagination(NULL, FALSE, array('is_activated' => 1, 'is_view_private_listings' => 1));
65
66 /* if not allow subscription, return alert for subscription on dash page */
67 if (empty($user_subscriptions_listings_view)) {
68 $content = '<div style="margin: 35px auto;max-width:768px"><p class="wdk_alert wdk_alert-danger">' . esc_html__('Required subscription for "View Listings Details", please', 'wpdirectorykit') . ' <a href="' . esc_url(wdk_dash_url('dash_page=membership')) . '">' . esc_html__('purchase subscription here', 'wpdirectorykit') . '</a></p></div>';
69 } else {
70 if (class_exists('Elementor\Plugin')) {
71 $content = '';
72 $elementor_instance = Elementor\Plugin::instance();
73 $content = $elementor_instance->frontend->get_builder_content_for_display($wdk_listing_page_id);
74 }
75 }
76 } else {
77 $content = '<div style="margin: 35px auto;max-width:768px"><p class="wdk_alert wdk_alert-danger">' . esc_html__('Required subscription for "View Listings Details", please', 'wpdirectorykit') . ' <a href="' . wdk_login_url(wdk_server_current_url(), esc_html__('Login for open Listing', 'wpdirectorykit')) . '">' . esc_html__('register or login here', 'wpdirectorykit') . '</a></p></div>';
78 }
79 }
80 /* if login required */ elseif (get_option('wdk_membership_login_required_listing_preview') && !is_user_logged_in()) {
81 if (get_option('wdk_membership_login_page')) {
82 wp_redirect(wdk_url_suffix(get_permalink(get_option('wdk_membership_login_page')), 'redirect_to=' . urlencode(wdk_current_url()) . '&custom_message=' . urlencode(esc_html__('Please login for open Listing', 'wpdirectorykit'))));
83 // exit();
84 } else {
85 wp_redirect(wp_login_url(wdk_current_url()));
86 }
87 } else {
88 if (class_exists('Elementor\Plugin')) {
89 $content = '';
90
91 if (!wdk_field_value('is_approved', $wdk_listing_id, false) || !wdk_field_value('is_activated', $wdk_listing_id, false)) {
92 $content = '<div style="margin: 35px auto;max-width:768px;margin-bottom: 35px"><p class="wdk_alert wdk_alert-danger">' . esc_html__('Listing is not activated/approved and not visible for public', 'wpdirectorykit') . '</p></div>';
93 }
94
95 $elementor_instance = Elementor\Plugin::instance();
96 $content .= $elementor_instance->frontend->get_builder_content_for_display($wdk_listing_page_id);
97
98 $custom_css = '';
99
100 $wdk_listing_id;
101 $Winter_MVC_WDK->model('field_m');
102
103 $Winter_MVC_WDK->db->where(array('field_type !=' => 'SECTION'));
104 $fields = $Winter_MVC_WDK->field_m->get();
105
106 foreach ($fields as $field) {
107 if (wdk_field_value($field->idfield, $wdk_listing_id)) continue;
108
109 if (!empty($custom_css)) $custom_css .= ',';
110
111 $custom_css .= '.wdk_' . $field->idfield . '_hide_empty';
112 }
113
114 if (!wdk_field_value('lat', $wdk_listing_id, false) || !wdk_field_value('lng', $wdk_listing_id)) {
115 if (!empty($custom_css)) $custom_css .= ',';
116 $custom_css .= '.wdk_map_hide_empty';
117 }
118
119 if (!wdk_field_value('is_featured', $wdk_listing_id, false)) {
120 if (!empty($custom_css)) $custom_css .= ',';
121 $custom_css .= '.wdk_is_featured_hide_empty';
122 }
123
124 $custom_css .= '{display: none !important}';
125
126 wp_enqueue_style('wdk-custom-inline', WPDIRECTORYKIT_URL . 'public/css/custom-inline.css');
127 wp_add_inline_style('wdk-custom-inline', $custom_css);
128 }
129 }
130 } else {
131 $content = '<div style="margin: 35px auto;max-width:768px"><p class="wdk_alert wdk_alert-danger">' . esc_html__('Listing missing or not activated', 'wpdirectorykit') . ', <a href="' . get_home_url() . '">' . esc_html__('return to Homepage', 'wpdirectorykit') . '</a></p></div>';
132 }
133 } else {
134 $content = '<div style="margin: 35px auto;max-width:768px"><p class="wdk_alert wdk_alert-danger">' . esc_html__('Missing listing Preview Page', 'wpdirectorykit') . ', <a href="' . esc_url(get_admin_url()) . 'admin.php?page=wdk_settings&function=import_demo">' . esc_html__('Import demo Page', 'wpdirectorykit') . '</a></p></div>';
135 }
136 }
137 return $content;
138 }
139
140 function wdk_do_header()
141 {
142 // get all elementor pro builder conditions
143 $pro_theme_builder_conditions = get_option('elementor_pro_theme_builder_conditions');
144 $listing_page_id = get_option('wdk_listing_page');
145
146 if (!empty($pro_theme_builder_conditions)) {
147 foreach ($pro_theme_builder_conditions['header'] as $header_post_id => $header_on_pages) {
148 foreach ($header_on_pages as $pages) {
149 $accepted_page_id = substr($pages, strrpos($pages, '/') + 1);
150
151 if ($accepted_page_id == $listing_page_id) {
152 // render header content
153
154 $elementor_instance = \Elementor\Plugin::instance();
155 $content = $elementor_instance->frontend->get_builder_content_for_display($header_post_id);
156
157 echo wp_kses_post($content);
158 return;
159 }
160 }
161 }
162 }
163 }
164
165 function wdk_do_footer()
166 {
167 // get all elementor pro builder conditions
168 $pro_theme_builder_conditions = get_option('elementor_pro_theme_builder_conditions');
169 $listing_page_id = get_option('wdk_listing_page');
170
171 if (!empty($pro_theme_builder_conditions)) {
172 foreach ($pro_theme_builder_conditions['footer'] as $footer_post_id => $footer_on_pages) {
173 foreach ($footer_on_pages as $pages) {
174 $accepted_page_id = substr($pages, strrpos($pages, '/') + 1);
175
176 if ($accepted_page_id == $listing_page_id) {
177 // render footer content
178
179 $elementor_instance = \Elementor\Plugin::instance();
180 $content = $elementor_instance->frontend->get_builder_content_for_display($footer_post_id);
181
182 echo wp_kses_post($content);
183 return;
184 }
185 }
186 }
187 }
188 }
189
190 function wdk_do_body_class($classes)
191 {
192 if (class_exists('Elementor\Plugin')) {
193 $elementor_instance = \Elementor\Plugin::instance();
194 $classes = $elementor_instance->frontend->body_class();
195 }
196
197 return $classes;
198 }
199
200 function wdk_page_template($template)
201 {
202 global $wp_query;
203 if (isset($wp_query->post))
204 if ($wp_query->post->post_type == 'wdk-listing') {
205 $listing_page_id = get_option('wdk_listing_page');
206 $template_elem = get_post_meta($listing_page_id, '_wp_page_template', true);
207
208 if ($template_elem == 'elementor_theme') {
209 // for elementor pro theme builder basic support
210 $template_elem = 'elementor_canvas';
211
212 add_filter('body_class', 'wdk_do_body_class');
213 add_action('elementor/page_templates/canvas/before_content', 'wdk_do_header', 0);
214 add_action('elementor/page_templates/canvas/after_content', 'wdk_do_footer', 0);
215 }
216
217 if ($template_elem == 'elementor_canvas' || $template_elem == 'elementor_header_footer') {
218 /**
219 * @var \Elementor\Modules\PageTemplates\Module $page_templates_module
220 */
221 if (class_exists('Elementor\Plugin')) {
222 $page_templates_module = Elementor\Plugin::instance()->modules_manager->get_modules('page-templates');
223 $template = $page_templates_module->get_template_path($template_elem);
224 }
225 }
226 }
227 return $template;
228 }
229 add_filter('single_template', 'wdk_page_template');
230
231 add_action('admin_bar_menu', 'wdk_add_toolbar_items', 100);
232 function wdk_add_toolbar_items($admin_bar)
233 {
234 global $wp_query;
235 if (isset($wp_query->post))
236 if ($wp_query->post->post_type == 'wdk-listing') {
237 $admin_bar->add_menu(array(
238 'id' => 'edit',
239 'title' => __('Edit Listing', 'wpdirectorykit'),
240 'href' => admin_url('admin.php?page=wdk_listing&id=' . $wp_query->post->ID),
241 ));
242 }
243 }
244
245 if (get_option('wdk_slug_listing_preview_page')) {
246 function wdk_custom_listing_preview_page_slug($args, $post_type)
247 {
248
249 if (get_option('wdk_slug_listing_preview_page_changed')) {
250 update_option('wdk_slug_listing_preview_page_changed', 0);
251 flush_rewrite_rules();
252 }
253
254 /*item post type slug*/
255 if ('wdk-listing' === $post_type) {
256 $args['rewrite']['slug'] = get_option('wdk_slug_listing_preview_page');
257 }
258
259 return $args;
260 }
261 add_filter('register_post_type_args', 'wdk_custom_listing_preview_page_slug', 10, 2);
262 }
263
264 // Hook example, custom page title for
265 add_filter('document_title_parts', function ($title_parts_array) {
266 global $wp_query;
267 if (isset($wp_query->post) && $wp_query->post->post_type === 'wdk-listing') {
268 $title_parts_array['title'] = wdk_listing_seo_title();
269 }
270 return $title_parts_array;
271 });
272
273 /* seo wdk feature, wp overwrite wp_head */
274 add_action('wp_head', 'wdk_seo_metatags');
275 function wdk_seo_metatags()
276 {
277 global $wp_query;
278 if (isset($wp_query->post))
279 if ($wp_query->post->post_type == 'wdk-listing') {
280 $wdk_listing_id = $wp_query->post->ID;
281 if ($wdk_listing_id) {
282 global $Winter_MVC_WDK;
283 $Winter_MVC_WDK->model('field_m');
284 $Winter_MVC_WDK->load_helper('listing');
285
286 $seo_title = wp_get_document_title();
287
288 echo '<meta name="title" content="' . esc_attr($seo_title) . '">' . PHP_EOL;
289 echo '<meta property="og:type" content="' . esc_attr(get_post_type()) . '" />' . PHP_EOL;
290 echo '<meta property="og:title" content="' . esc_attr($seo_title) . '" />' . PHP_EOL;
291
292 if (get_option('wdk_seo_description')) {
293 echo '<meta name="description" content="' . esc_attr(wp_trim_words(wp_strip_all_tags(wpautop(wdk_field_value(get_option('wdk_seo_description'), $wdk_listing_id))), 20)) . '">' . PHP_EOL;
294 echo '<meta property="og:description" content="' . esc_attr(wp_trim_words(wp_strip_all_tags(wpautop(wdk_field_value(get_option('wdk_seo_description'), $wdk_listing_id))), 20)) . '">' . PHP_EOL;
295 }
296
297 if (get_option('wdk_seo_keywords')) {
298 echo '<meta name="keywords" content="' . esc_attr(wp_trim_words(wp_strip_all_tags(wpautop(wdk_field_value(get_option('wdk_seo_keywords'), $wdk_listing_id))), 20)) . '">' . PHP_EOL;
299 }
300
301 if (!in_array('wordpress-seo/wp-seo.php', apply_filters('active_plugins', get_option('active_plugins')))) {
302 echo '<meta property="og:image" content="' . esc_url(wdk_image_src(array('listing_images' => wdk_field_value('listing_images', $wdk_listing_id)), 'full')) . '" />' . PHP_EOL;
303 }
304 }
305 }
306 }
307
308 /* disable some sw_seo feature if Yost seo plugin detected, for only for listing preview page and profile page */
309 add_action('template_redirect', 'wdk_disable_seo');
310 function wdk_disable_seo()
311 {
312 global $wp_query;
313 if (isset($wp_query->post))
314 if ($wp_query->post->post_type == 'wdk-listing') {
315 if (in_array('wordpress-seo/wp-seo.php', apply_filters('active_plugins', get_option('active_plugins')))) {
316 add_filter('wpseo_title', '__return_false');
317 add_filter('wpseo_metadesc', '__return_false');
318 add_filter('wpseo_opengraph_url', '__return_false');
319 add_filter('wpseo_opengraph_title', '__return_false');
320 add_filter('wpseo_opengraph_image', '__return_false');
321 add_filter('wpseo_opengraph_type', '__return_false');
322 add_filter('wpseo_opengraph_desc', '__return_false');
323 }
324 }
325 }
326
327 function wdk_yoast_presentation($presentation)
328 {
329 global $wp_query;
330 if (isset($wp_query->post))
331 if ($wp_query->post->post_type == 'wdk-listing') {
332 $wdk_listing_id = $wp_query->post->ID;
333 if ($wdk_listing_id) {
334 global $Winter_MVC_WDK;
335 $Winter_MVC_WDK->model('field_m');
336 $Winter_MVC_WDK->load_helper('listing');
337
338 $presentation->open_graph_images = [
339 [
340 'url' => esc_url(wdk_image_src(array('listing_images' => wdk_field_value('listing_images', $wdk_listing_id)), 'full')),
341 ]
342 ];
343 }
344 }
345 return $presentation;
346 }
347 add_filter('wpseo_frontend_presentation', 'wdk_yoast_presentation', 30);
348
349 add_filter('wp_kses_allowed_html', 'wpdirectorykit_wpkses_post_iframe', 10, 2);
350 function wpdirectorykit_wpkses_post_iframe($tags, $context)
351 {
352 if ('post' === $context) {
353 $tags['iframe'] = array(
354 'src' => true,
355 'height' => true,
356 'width' => true,
357 'frameborder' => true,
358 'allowfullscreen' => true,
359 );
360 }
361 return $tags;
362 }
363
364 add_action('wdk-membership/dash/homepage/widgets', function () {
365 if (!current_user_can('edit_own_listings') && !wmvc_user_in_role('administrator')) return false;
366
367 global $Winter_MVC_WDK;
368 $Winter_MVC_WDK->model('listing_m');
369 $total_items = $Winter_MVC_WDK->listing_m->total(array(), TRUE, get_current_user_id());
370 if (function_exists('wdk_dash_url')) {
371 ?>
372 <div class="wdk-col-12 wdk-col-md-3 wdk-membership-dash-widget_listings">
373 <a href="<?php echo esc_url(wdk_dash_url('dash_page=listings')); ?>" class="wdk-membership-dash-widget">
374 <span class="wdk-content">
375 <span class="icon"><span class="dashicons dashicons-location"></span></span>
376 </span>
377 <span class="wdk-side">
378 <span class="title"><?php echo esc_html__('Listings', 'wpdirectorykit'); ?></span>
379 <span class="wdk-count"><?php echo esc_html($total_items); ?></span>
380 </span>
381 </a>
382 </div>
383 <?php
384 }
385 }, 1);
386
387 add_action('wdk-membership/dash/homepage/widgets', function () {
388 global $Winter_MVC_WDK;
389 $Winter_MVC_WDK->model('messages_m');
390 $total_items = $Winter_MVC_WDK->messages_m->total_merge(array(), TRUE, get_current_user_id());
391 if (function_exists('wdk_dash_url')) {
392 ?>
393 <div class="wdk-col-12 wdk-col-md-3 wdk-membership-dash-widget_messsages">
394 <a href="<?php echo esc_url(wdk_dash_url('dash_page=messages')); ?>" class="wdk-membership-dash-widget">
395 <span class="wdk-content">
396 <span class="icon"><span class="dashicons dashicons-email"></span></span>
397 </span>
398 <span class="wdk-side">
399 <span class="title"><?php echo esc_html__('Messages', 'wpdirectorykit'); ?></span>
400 <span class="wdk-count"><?php echo esc_html($total_items); ?></span>
401 </span>
402 </a>
403 </div>
404 <?php
405 }
406 });
407
408 add_filter('woocommerce_enable_setup_wizard', '__return_false');
409
410
411 /* detected in smart search location and replace to location id */
412 add_action('template_redirect', 'wdk_search_parameters');
413 function wdk_search_parameters()
414 {
415 global $wp_query;
416 if (!empty($_GET['field_search'])) {
417 global $Winter_MVC_WDK;
418 $Winter_MVC_WDK->model('location_m');
419 $location = $Winter_MVC_WDK->location_m->get_by(array('location_title' => wdk_esc_sql(sanitize_text_field($_GET['field_search']))), TRUE);
420 if ($location) {
421 $url = $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"];
422
423 $query_link = substr($url, strpos($url, '?') + 1);
424 $clear_link = substr($url, 0, strpos($url, '?'));
425
426 $string_par = array();
427 parse_str($query_link, $string_par);
428 unset($string_par['field_search']);
429 $string_par['search_location'] = $location->idlocation;
430
431 $new_url = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . '://' . $clear_link . '?' . http_build_query($string_par);
432 wp_redirect($new_url);
433 exit;
434 }
435 }
436 }
437
438 add_filter('plugin_action_links_wpdirectorykit/wpdirectorykit.php', 'wdk_buy_link');
439 function wdk_buy_link($links)
440 {
441 // Build and escape the URL.
442 $url = esc_url(get_admin_url() . 'admin.php?page=wdk_addons');
443 // Create the link.
444 $settings_link = "<a style=\"color:rgb(0, 163, 42);font-weight:bold;\" href='$url'>" . __('Check Premium Features', 'wpdirectorykit') . '</a>';
445 // Adds the link to the end of the array.
446 $links[] = $settings_link;
447 return $links;
448 }
449
450
451 add_filter('wpdirectorykit/listing/field/value', 'wdk_filter_field_format_date', 2, 10);
452 if (!function_exists('wdk_filter_field_format_date')) {
453 function wdk_filter_field_format_date($field_value = '', $field_id = NULL, $number_format = TRUE)
454 {
455 if (in_array($field_id, array('date', 'date-modified'))) {
456 $field_value = wdk_get_date($field_value, TRUE);
457 }
458
459 return $field_value;
460 }
461 }
462
463
464 // fix sitemap issue
465 function wdk_modify_sitemap_index($content)
466 {
467 // Modify the $content as needed
468 // For example, replace & with &amp;
469 $content = str_replace('&', '&amp;', $content);
470 return $content;
471 }
472
473 // Hook the filter to the wpseo_sitemap_index filter hook
474 add_filter('wpseo_sitemap_index', 'wdk_modify_sitemap_index');
475
476 if (false) {
477 // Hook example, custom page title for
478 add_filter('document_title_parts', function ($title_parts_array) {
479 global $wp_query;
480 if (isset($wp_query->post))
481 if ($wp_query->post->post_type == 'wdk-listing') {
482 $wdk_listing_id = $wp_query->post->ID;
483 if ($wdk_listing_id) {
484 global $Winter_MVC_WDK;
485 $Winter_MVC_WDK->model('field_m');
486 $Winter_MVC_WDK->load_helper('listing');
487
488 $title_parts_array['title'] = wp_strip_all_tags(wpautop(wdk_field_value('post_title', $wdk_listing_id) . ' - ' . wdk_field_value('address', $wdk_listing_id)));
489 }
490 }
491 return $title_parts_array;
492 });
493 }
494
495 add_filter('tiny_mce_before_init', function ($init) {
496 if (get_option('wdk_disable_toolbar_on_content_editor')) {
497 $init['wpautop'] = false;
498 $init['toolbar'] = false;
499 }
500
501 return $init;
502 });
503
504 /*
505 * configuration number_format_i18n
506 */
507 add_filter('init', function ($init) {
508
509 if (!get_option('wdk_disable_custom_muber_format'))
510 if (get_option('wdk_number_format_decimal_point') || get_option('wdk_number_format_thousands_sep')) {
511 global $wp_locale;
512 if (get_option('wdk_number_format_decimal_point'))
513 $wp_locale->number_format['decimal_point'] = get_option('wdk_number_format_decimal_point');
514
515 if (get_option('wdk_number_format_thousands_sep'))
516 $wp_locale->number_format['thousands_sep'] = get_option('wdk_number_format_thousands_sep');
517 }
518 });
519
520 add_filter('wdk/listings/results', function ($listings) {
521 global $Winter_MVC_WDK;
522 $Winter_MVC_WDK->model('field_m');
523 $Winter_MVC_WDK->load_helper('listing');
524
525 $listings_ids = array();
526 foreach ($listings as $listing) {
527 $listings_ids[] = $listing->post_id;
528 }
529
530 if (!empty($listings_ids)) {
531 $Winter_MVC_WDK->listing_m->update_listings_views($listings_ids);
532 }
533
534 return $listings;
535 });
536
537 add_filter('body_class', function ($classes) {
538
539 if (isset($_GET['popup'])) {
540 $classes[] = 'popup-mode';
541 }
542
543 return $classes;
544 });
545
546 add_action('init', function () {
547 $required_version = '1.0.5';
548 $plugin_file = 'wdk-membership/wdk-membership.php';
549
550 if (!file_exists(WP_PLUGIN_DIR . '/' . $plugin_file)) {
551 return;
552 }
553
554 if (! function_exists('get_plugins')) {
555 require_once ABSPATH . 'wp-admin/includes/plugin.php';
556 }
557
558 $plugin_data = get_plugin_data(WP_PLUGIN_DIR . '/' . $plugin_file);
559
560 if (is_plugin_active($plugin_file) && isset($plugin_data['Version']) && version_compare($plugin_data['Version'], $required_version, '<')) {
561
562 if (isset($_GET['page']) && !empty($plugin_data['TextDomain']) && strpos($_GET['page'], $plugin_data['TextDomain']) === 0) {
563 $message = '<span class="dashicons dashicons-warning"></span> &nbsp;&nbsp;' . esc_html__('Important!', 'wpdirectorykit') . '<br>';
564 $message .= wdk_sprintf(
565 __('%1$sYou need to update WDK Membership Addon to ensure compatibility with the latest plugin version. You can download the latest addons from your Gumroad account: %4$shttps://gumroad.com/library%3$s%2$s or update via freemius, depends where you purchased our premium plugin.
566 %1$sIf you prefer to continue using older plugin versions, please note that this increases security risks and is not recommended. However, you can roll back to a previous version using the following plugin: %5$shttps://wordpress.org/plugins/wp-rollback/%3$s%2$s
567 %1$sIf you experience any issues or need assistance, feel free to contact us through any available channel. We continue to provide fully human-based support: %6$shttps://wpdirectorykit.com/contact/%3$s%2$s', 'wpdirectorykit'),
568 '<p>',
569 '</p>',
570 '</a>',
571 '<a target="_blank" href="https://gumroad.com/library">',
572 '<a target="_blank" href="https://wordpress.org/plugins/wp-rollback/">',
573 '<a target="_blank" href="https://wpdirectorykit.com/contact/">'
574 );
575 wdk_notify_admin('wdk_notify_wpdirectorykit_required_version_' . $plugin_data['TextDomain'], $message, '', 'notice notice-error wdk-notice-upgrade');
576 }
577 }
578 });
579
580
581
582 add_action('admin_footer', function () {
583
584 if (file_exists(WPDIRECTORYKIT_PATH . 'premium_functions.php')) {
585 return;
586 }
587
588 if (!current_user_can('manage_options')) {
589 return;
590 }
591
592 $user_id = get_current_user_id();
593 $last_closed = (int) get_user_meta($user_id, '_wdk_admin_popup_closed', true);
594
595 // 14 days = 1209600 seconds
596 if ($last_closed && (time() - $last_closed) < 1209600) {
597 return;
598 }
599 ?>
600 <div id="wdk-admin-popup">
601 <div class="wdk-admin-popup-inner">
602 <button id="wdk-admin-popup-close" class="wdk-admin-popup-close">&times;</button>
603
604 <div class="wdk-popup-header">
605 <h2>🚀 <?php echo esc_html__('Welcome to our free WP Directory Kit plugin!', 'wpdirectorykit'); ?></h2>
606 </div>
607
608 <div class="wdk-popup-content">
609
610 <p>💬 <?php echo esc_html__('If you encounter any issues, please contact us via Telegram, WhatsApp, or email.', 'wpdirectorykit'); ?></p>
611
612 <p class="wdk-contact">
613 <strong>📩 <?php echo esc_html__('Telegram', 'wpdirectorykit'); ?>:</strong>
614 <a href="https://t.me/wpdirectorykit" target="_blank">https://t.me/wpdirectorykit</a><br>
615
616 <strong>📱 <?php echo esc_html__('WhatsApp', 'wpdirectorykit'); ?>:</strong>
617 <a href="https://wa.me/+385959055516" target="_blank">https://wa.me/+385959055516</a>
618 </p>
619
620 <p class="wdk-links">
621 <?php echo esc_html__('Check out our premium features here:', 'wpdirectorykit'); ?><br>
622 <a href="https://wpdirectorykit.com/plugins/" target="_blank">https://wpdirectorykit.com/plugins/</a>
623 </p>
624
625 <p class="wdk-links">
626 🎨 <?php echo esc_html__('and other cool designs here:', 'wpdirectorykit'); ?><br>
627 <a href="https://wpdirectorykit.com/themes/" target="_blank">https://wpdirectorykit.com/themes/</a>
628 </p>
629
630 <p class="wdk-features">
631 ⚙️ <?php echo esc_html__('We offer everything you need for a professional directory website, including login and registration, a front-end dashboard, agent search, individual agent pages, booking, multi-currency support, import tools, favorites, reviews, listing comparisons, SVG maps, live chat, and much more!', 'wpdirectorykit'); ?>
632 </p>
633
634 <p class="wdk-footer-note">
635 ❤️ <?php echo esc_html__('Please consider supporting our work by purchasing one of our premium features — we’ll do our very best to assist you!', 'wpdirectorykit'); ?>
636 </p>
637
638 <!-- ACTION BUTTONS -->
639 <div class="wdk-actions">
640 <button class="wdk-btn wdk-dismiss wdk-admin-popup-close"><?php echo esc_html__('Not interested', 'wpdirectorykit'); ?></button>
641
642 <a href="https://wpdirectorykit.com/plugins/" target="_blank" class="wdk-btn wdk-primary wdk-premium">
643 <?php echo esc_html__('Check premium plugins', 'wpdirectorykit'); ?>
644 </a>
645 </div>
646
647 </div>
648 </div>
649
650 <?php
651 $popup_css = '
652 #wdk-admin-popup {
653 position: fixed;
654 inset: 0;
655 background: rgba(0,0,0,0.6);
656 backdrop-filter: blur(6px);
657 display: flex;
658 justify-content: center;
659 align-items: center;
660 z-index: 99999;
661 opacity: 0;
662 visibility: hidden;
663 transition: all .3s ease;
664 }
665 #wdk-admin-popup.show {
666 opacity: 1;
667 visibility: visible;
668 }
669 .wdk-admin-popup-inner {
670 background: linear-gradient(135deg, #ffffff, #f9fafb);
671 padding: 35px;
672 width: 700px;
673 max-width: calc(100% - 30px);
674 border-radius: 16px;
675 box-shadow: 0 20px 60px rgba(0,0,0,0.25);
676 transform: translateY(20px);
677 transition: all .3s ease;
678 position: relative;
679 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
680 line-height: 1.6;
681 }
682 #wdk-admin-popup.show .wdk-admin-popup-inner {
683 transform: translateY(0);
684 }
685 #wdk-admin-popup-close {
686 position: absolute;
687 top: 12px;
688 right: 14px;
689 border: none;
690 background: transparent;
691 font-size: 22px;
692 cursor: pointer;
693 opacity: .6;
694 }
695 #wdk-admin-popup-close:hover {
696 opacity: 1;
697 }
698 .wdk-popup-header h2 {
699 margin: 0 0 15px;
700 font-size: 22px;
701 }
702 .wdk-popup-content p {
703 margin: 12px 0;
704 color: #444;
705 }
706 .wdk-contact {
707 background: #f3f4f6;
708 padding: 12px;
709 border-radius: 10px;
710 }
711 .wdk-links {
712 background: #eef2ff;
713 padding: 12px;
714 border-radius: 10px;
715 }
716 .wdk-features {
717 font-size: 13px;
718 color: #555;
719 }
720 .wdk-footer-note {
721 font-size: 13px;
722 color: #777;
723 }
724 .wdk-popup-content a {
725 color: #4f46e5;
726 text-decoration: none;
727 word-break: break-all;
728 }
729 .wdk-popup-content a:hover {
730 text-decoration: underline;
731 }
732 .wdk-actions {
733 margin-top: 25px;
734 display: flex;
735 justify-content: flex-start;
736 gap: 10px;
737 }
738 .wdk-btn {
739 padding: 10px 16px;
740 border-radius: 8px;
741 border: none;
742 cursor: pointer;
743 font-weight: 600;
744 text-decoration: none;
745 transition: all .15s;
746 }
747 .wdk-btn:hover {
748 filter: brightness(0.95);
749 text-decoration: none;
750 }
751 .wdk-dismiss {
752 background: #eee;
753 }
754 .wdk-popup-content .wdk-primary {
755 background: #4f46e5;
756 color: #fff;
757 text-decoration: none;
758 }
759 ';
760
761 // Enqueue a WordPress built-in style to attach inline CSS to, or register a custom handle.
762 wp_register_style('wdk-admin-popup', false);
763 wp_enqueue_style('wdk-admin-popup');
764 wp_add_inline_style('wdk-admin-popup', $popup_css);
765 ?>
766 <?php
767 $popup_js = "
768 document.addEventListener('DOMContentLoaded', function() {
769 const popup = document.getElementById('wdk-admin-popup');
770
771 if (popup) {
772 setTimeout(() => popup.classList.add('show'), 2000);
773
774 const closeBtns = document.querySelectorAll('.wdk-admin-popup-close');
775
776 function closePopup() {
777 popup.classList.remove('show');
778
779 fetch(ajaxurl, {
780 method: 'POST',
781 headers: {
782 'Content-Type': 'application/x-www-form-urlencoded'
783 },
784 body: 'action=wdk_close_popup'
785 });
786 }
787
788 if (closeBtns && closeBtns.length > 0) {
789 closeBtns.forEach(btn => {
790 btn.addEventListener('click', closePopup);
791 });
792 }
793
794 popup.addEventListener('click', function(e) {
795 if (e.target === popup) {
796 closePopup();
797 }
798 });
799
800 }
801 });
802 ";
803 wp_register_script('wdk-admin-popup', false);
804 wp_enqueue_script('wdk-admin-popup');
805 wp_add_inline_script('wdk-admin-popup', $popup_js);
806 ?>
807 </div>
808 <?php
809 });
810
811 add_action('wp_ajax_wdk_close_popup', function () {
812 if (!current_user_can('manage_options')) {
813 wp_die();
814 }
815
816 update_user_meta(get_current_user_id(), '_wdk_admin_popup_closed', time());
817
818 wp_die();
819 });
820
821
822 add_filter('body_class', function ($classes) {
823 if (get_option('wdk_disable_outline_on_focus')) {
824 $classes[] = 'wdk_disable_outline_on_focus';
825 }
826 return $classes;
827 });
828
829
830
831
832 add_action('wdk/listing/edit/aboveform', function () {
833
834 if (function_exists('fpai_register_settings')) return false;
835
836
837 $popup_css = '
838 .fpai-ai-button {
839 display: inline-flex;
840 align-items: center;
841 gap: 8px;
842 background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
843 color: white;
844 padding: 12px 20px;
845 border-radius: 25px;
846 cursor: pointer;
847 font-weight: 600;
848 font-size: 14px;
849 box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
850 transition: all 0.3s ease;
851 margin-bottom: 15px;
852 border: none;
853 position: relative;
854 overflow: hidden;
855 }
856
857 .fpai-ai-button .fpai-button-text {
858 color: #fff;
859 }
860
861 .fpai-ai-button:hover {
862 transform: translateY(-2px);
863 box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
864 background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
865 }
866
867 .fpai-ai-button:active {
868 transform: translateY(0);
869 }
870
871 .fpai-ai-button.active {
872 background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
873 transform: translateY(-1px);
874 }
875
876 /* Stars Container with Animation */
877 .fpai-stars-container {
878 display: flex;
879 gap: 2px;
880 }
881
882 .fpai-star {
883 display: inline-block;
884 animation: sparkle 2s infinite;
885 font-size: 12px;
886 }
887
888 .fpai-star:nth-child(1) {
889 animation-delay: 0s;
890 }
891
892 .fpai-star:nth-child(2) {
893 animation-delay: 0.7s;
894 }
895
896 .fpai-star:nth-child(3) {
897 animation-delay: 1.4s;
898 }
899
900 @keyframes sparkle {
901
902 0%,
903 100% {
904 opacity: 0.3;
905 transform: scale(0.8) rotate(0deg);
906 }
907
908 50% {
909 opacity: 1;
910 transform: scale(1.2) rotate(180deg);
911 }
912 }
913
914 ';
915
916 // Enqueue a WordPress built-in style to attach inline CSS to, or register a custom handle.
917 wp_register_style('wdk-admin-popup', false);
918 wp_enqueue_style('wdk-admin-popup');
919 wp_add_inline_style('wdk-admin-popup', $popup_css);
920
921 wp_enqueue_script('thickbox');
922 wp_enqueue_style('thickbox');
923 ?>
924 <a class="fpai-ai-button fpai-pro"
925 <?php if (!file_exists(ABSPATH . 'wp-content/plugins/form-populate-with-ai/form-populate-with-ai.php')): ?>
926 data-button-succuss="<?php echo esc_attr__('Install', 'wpdirectorykit'); ?>"
927 data-title="<?php echo esc_attr__('Form Populate with AI', 'wpdirectorykit'); ?>"
928 data-content="<?php echo esc_attr__('Please install our free plugin AI Form Populate to use this feature and button should open our website with plugin details', 'wpdirectorykit'); ?>"
929 data-action="<?php echo esc_url(admin_url('plugin-install.php?tab=plugin-information&plugin=form-populate-with-ai&TB_iframe=true&width=600&height=550' )); ?>"
930 <?php elseif (file_exists(ABSPATH . 'wp-content/plugins/form-populate-with-ai/form-populate-with-ai.php') && !function_exists('fpai_register_settings')): ?>
931 data-button-succuss="<?php echo esc_attr__('Activate', 'wpdirectorykit'); ?>"
932 data-title="<?php echo esc_attr__('Form Populate with AI', 'wpdirectorykit'); ?>"
933 data-content="<?php echo esc_attr__('Please install our free plugin AI Form Populate to use this feature and button should open our website with plugin details', 'wpdirectorykit'); ?>"
934
935 data-action="<?php echo esc_url(admin_url('plugin-install.php?tab=plugin-information&plugin=form-populate-with-ai&TB_iframe=true&width=600&height=550' )); ?>"
936 <?php endif; ?>
937 >
938 <span class="fpai-stars-container">
939 <span class="fpai-star"></span>
940 <span class="fpai-star"></span>
941 <span class="fpai-star">🌟</span>
942 </span>
943 <span class="fpai-button-text"><?php echo esc_html__('Populate with AI', 'wpdirectorykit'); ?></span>
944 </a>
945
946 <script>
947 jQuery(document).ready(function ($) {
948 if (typeof jQuery.fn.confirm == 'function') {
949 jQuery('.fpai-pro').off().on('click', function (e) {
950 e.preventDefault();
951 var self = jQuery(this)
952 jQuery.confirm({
953 boxWidth: '400px',
954 useBootstrap: false,
955 title: self.data('title'),
956 content: self.data('content'),
957 buttons: {
958 cancel: function () {
959 return true;
960 },
961 somethingElse: {
962 text: self.data('button-succuss'),
963 btnClass: 'btn-blue activate-now',
964 keys: ['enter', 'shift'],
965 action: function () {
966 tb_show(
967 self.data('title'),
968 self.data('action')
969 );
970 }
971 }
972 }
973 });
974 return false;
975 });
976 }
977 });
978 </script>
979
980 <?php
981 });