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