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 | application/controllers/Wdk_settings.php +278 -56 1.2.6 → 1.5.9 View file →
@@ -16,8 +16,9 @@
16 16 public $info_log_message = '';
17 17 public $import_images_dir = WPDIRECTORYKIT_PATH.'demo-data/images/';
18 18 public $import_xml_file = '';
19 19 public $import_xml_file_locations = WPDIRECTORYKIT_PATH.'demo-data/locations.xml';
20 + public $import_count_images = 2;
20 21
21 22 public function __construct(){
22 23 parent::__construct();
23 24 }
@@ -31,9 +32,9 @@
31 32 $this->data['form'] = &$this->form;
32 33 $this->data['fields'] = $this->settings_m->fields_list;
33 34 $this->data['fields_list_tabs'] = $this->settings_m->fields_list_tabs;
34 35
35 - $this->form->add_error_message('wdk_slug_format', __('Custom Listing Preview Page Slug allowed only a-z 0-9 - _ ', 'wpdirectorykit'));
36 + $this->form->add_error_message('wdk_slug_format', __('Custom Listing Preview Page Slug allowed only a-z 0-9 - _', 'wpdirectorykit'));
36 37
37 38 if($this->form->run($this->data['fields']))
38 39 {
39 40
@@ -74,11 +75,213 @@
74 75 {
75 76 $this->data['db_data'][$field->option_name] = $field->option_value;
76 77 }
77 78
79 + $this->mailtemplates();
80 +
78 81 $this->load->view('wdk_settings/index', $this->data);
79 82 }
83 +
84 + // Edit listing method
85 + public function mailtemplate()
86 + {
80 87
88 + $view_file = $this->input->post_get('file');
89 +
90 + $file = false;
91 + $sourceFile = null;
92 +
93 + if(file_exists(WPDIRECTORYKIT_PATH.'application/views/email/'.$view_file.'.php'))
94 + {
95 + $sourceFile = WPDIRECTORYKIT_PATH.'application/views/email/'.$view_file.'.php';
96 + } else {
97 + exit('File Not Exists');
98 + }
99 +
100 + if(is_child_theme() && !file_exists(get_stylesheet_directory().'/wpdirectorykit/application/views/email/'.$view_file.'.php'))
101 + {
102 +
103 + // Create the destination directory if it doesn't exist
104 + if (!is_dir(get_stylesheet_directory().'/wpdirectorykit/application/views/email/')) {
105 + global $wp_filesystem;
106 + if (empty($wp_filesystem)) {
107 + require_once(ABSPATH . '/wp-admin/includes/file.php');
108 + WP_Filesystem();
109 + }
110 + $dir_path = get_stylesheet_directory() . '/wpdirectorykit/application/views/email/';
111 + if (!$wp_filesystem->is_dir($dir_path)) {
112 + $wp_filesystem->mkdir($dir_path, FS_CHMOD_DIR | 0777);
113 + }
114 +
115 + }
116 +
117 + $destinationFile = get_stylesheet_directory().'/wpdirectorykit/application/views/email/'.$view_file.'.php';
118 + copy($sourceFile, $destinationFile);
119 + }
120 + elseif(!is_child_theme() && !file_exists(get_template_directory().'/wpdirectorykit/application/views/email/'.$view_file.'.php'))
121 + {
122 + // Create the destination directory if it doesn't exist
123 + if (!is_dir(get_template_directory().'/wpdirectorykit/application/views/email/')) {
124 + global $wp_filesystem;
125 + if (empty($wp_filesystem)) {
126 + require_once(ABSPATH . '/wp-admin/includes/file.php');
127 + WP_Filesystem();
128 + }
129 + $dir_path = get_template_directory() . '/wpdirectorykit/application/views/email/';
130 + if (!$wp_filesystem->is_dir($dir_path)) {
131 + $wp_filesystem->mkdir($dir_path, FS_CHMOD_DIR | 0777);
132 + }
133 +
134 + }
135 +
136 + $destinationFile = get_template_directory().'/wpdirectorykit/application/views/email/'.$view_file.'.php';
137 + copy($sourceFile, $destinationFile);
138 + }
139 +
140 + $current_theme = wp_get_theme();
141 + $file = esc_url(get_admin_url() . "theme-editor.php?file=wpdirectorykit/application/views/email/".$view_file.".php&theme=".$current_theme->get('TextDomain'));
142 +
143 + if(!empty($file))
144 + {
145 + wp_redirect($file);
146 + exit;
147 + } else {
148 + exit('File Not Exists');
149 + }
150 +
151 + }
152 +
153 + public function mailtemplates()
154 + {
155 + $this->data['mailtemplates'] = array(
156 + array(
157 + 'description' => __('Contact email','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>',
158 + 'template' => 'contact_form',
159 + ),
160 + array(
161 + 'description' => __('Default layout','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>',
162 + 'template' => 'default',
163 + ),
164 + array(
165 + 'description' => __('Listing in favorites list updated','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $listing(object), $message(string), $data(sting|array)</em>',
166 + 'template' => 'favorites_listing_updated_alert',
167 + ),
168 + array(
169 + 'description' => __('Membership Contact with owner','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $user_profile(object), $data(sting|array)</em>',
170 + 'template' => 'membership_contact_owner',
171 + ),
172 + array(
173 + 'description' => __('Contact Visitot','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $user_profile(object), $data(sting|array)</em>',
174 + 'template' => 'membership_contact_visitor',
175 + ),
176 + array(
177 + 'description' => __('Membership Subscription Expired notify message','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $listing(object), $subscription_link(sting)</em>',
178 + 'template' => 'membership_expired_listing_cron',
179 + ),
180 + array(
181 + 'description' => __('Membership Listing Expired notify message','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $listing(object), $subscription_link(sting)</em>',
182 + 'template' => 'membership_expired_listing',
183 + ),
184 + array(
185 + 'description' => __('Membership Subscription purchased','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $user(object), $subscription_user(object)</em>',
186 + 'template' => 'membership_purchased',
187 + ),
188 + array(
189 + 'description' => __('Unread Messages notify','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $chat(array)</em>',
190 + 'template' => 'messages_unread_notify',
191 + ),
192 + array(
193 + 'description' => __('New claim message','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>',
194 + 'template' => 'new_claim',
195 + ),
196 + array(
197 + 'description' => __('New Listing waiting for approvement','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $post_id(sting)</em>',
198 + 'template' => 'new_listing_approve',
199 + ),
200 + array(
201 + 'description' => __('New Listing approved','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $post_id(sting)</em>',
202 + 'template' => 'new_listing_approved',
203 + ),
204 + array(
205 + 'description' => __('New message','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>',
206 + 'template' => 'new_message',
207 + ),
208 + array(
209 + 'description' => __('New report','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>',
210 + 'template' => 'new_report',
211 + ),
212 + array(
213 + 'description' => __('Review approved','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $link_review(string)</em>',
214 + 'template' => 'new_review_approved',
215 + ),
216 + array(
217 + 'description' => __('Message for new user about auto created account','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $login(string), $password(string)</em>',
218 + 'template' => 'new_user_auto_created',
219 + ),
220 + array(
221 + 'description' => __('Payment Package expired','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $listing(object), $package_link</em>',
222 + 'template' => 'payments_expired_listing',
223 + ),
224 + array(
225 + 'description' => __('Reservation approved, email for owner','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $user_owner(object), $user(object), $reservation_id(string), $listing(object)</em>',
226 + 'template' => 'reservation_approved_owner',
227 + ),
228 + array(
229 + 'description' => __('Reservation approved, email for client','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $user_owner(object), $user(object), $reservation_id(string), $listing(object)</em>',
230 + 'template' => 'reservation_approved_visitor',
231 + ),
232 + array(
233 + 'description' => __('Reservation changed, email for owner','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $user_owner(object), $user_visitor(object), $reservation_id(string), $listing(object)</em>',
234 + 'template' => 'reservation_changed_owner',
235 + ),
236 + array(
237 + 'description' => __('Reservation completed, email for owner','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $user_owner(object), $user_client(object), $reservation_id(string), $listing(object)</em>',
238 + 'template' => 'reservation_completed_owner',
239 + ),
240 + array(
241 + 'description' => __('Reservation completed, email for visitor','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $user_owner(object), $user_client(object), $reservation_id(string), $listing(object)</em>',
242 + 'template' => 'reservation_completed_visitor',
243 + ),
244 + array(
245 + 'description' => __('Reservation expired','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $reservation_id(string), $listing(object)</em>',
246 + 'template' => 'reservation_expired',
247 + ),
248 + array(
249 + 'description' => __('Reservation user payment not expired','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $reservation_id(string), $listing(object), $user_owner(object)</em>',
250 + 'template' => 'reservation_user_payment_notify_not_expired',
251 + ),
252 + array(
253 + 'description' => __('Reservation user payment notify','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $reservation_id(string), $listing(object), $user_owner(object), $hours_for_payment(string)</em>',
254 + 'template' => 'reservation_user_payment_notify',
255 + ),
256 + array(
257 + 'description' => __('Reservation waiting for approve to owner','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $reservation_id(string), $listing(object), $user_client(object), $user_owner(object)</em>',
258 + 'template' => 'reservation_waiting_for_approve_owner',
259 + ),
260 + array(
261 + 'description' => __('Reservation waiting for approve to client','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array), $reservation_id(string), $listing(object), $user_client(object), $user_owner(object)</em>',
262 + 'template' => 'reservation_waiting_for_approve_visitor',
263 + ),
264 + array(
265 + 'description' => __('Notify related new listings based on saved search','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $results(array), $search_link_edit(string)</em>',
266 + 'template' => 'save_search_new_listings',
267 + ),
268 + array(
269 + 'description' => __('User Email Confirmed','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>',
270 + 'template' => 'wdk_membership_confirm_email_user_confirmed',
271 + ),
272 + array(
273 + 'description' => __('User Email Confirm request','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>',
274 + 'template' => 'wdk_membership_confirm_email_user_request',
275 + ),
276 + array(
277 + 'description' => __('Agency agent invitation email (sent to agent when agency invites them)','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $agency_name(string), $agent_name(string), $agency_profile_link(string), $confirmation_link(string)</em>',
278 + 'template' => 'agency_agent_submit',
279 + ),
280 +
281 + );
282 + }
283 +
81 284 function reset_data () {
82 285
83 286 wdk_access_check('settings_m', 1);
84 287
@@ -144,9 +347,9 @@
144 347 }
145 348
146 349 $redirect_url = admin_url("admin.php?page=wdk_settings&is_updated");
147 350 if(isset($_GET['redirect_url']) && strpos($_GET['redirect_url'], 'http') === FALSE && strpos($_GET['redirect_url'], '//') === FALSE)
148 - $redirect_url = admin_url(sanitize_text_field($_GET['redirect_url']));
351 + $redirect_url = admin_url(sanitize_text_field(wp_unslash($_GET['redirect_url'])));
149 352
150 353 wp_redirect($redirect_url);
151 354 exit;
152 355 }
@@ -245,9 +448,9 @@
245 448
246 449 $this->data['db_data']['multipurpose'] = 'real-estate.xml';
247 450
248 451 if(isset($_GET['multipurpose']))
249 - $this->data['db_data']['multipurpose'] = sanitize_text_field($_GET['multipurpose']);
452 + $this->data['db_data']['multipurpose'] = sanitize_text_field(wp_unslash($_GET['multipurpose']));
250 453
251 454 $this->data['import_log'] = '';
252 455 $this->data['info_log_message'] = '';
253 456
@@ -295,9 +498,9 @@
295 498 );
296 499
297 500 $plugin = 'elementor/elementor.php';
298 501 if (in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ))) && !class_exists('Elementor\Plugin') ) {
299 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Your Elementor Plugin is not fully active, usually this happen because of old PHP version on server, in such case eventually you can try older Elementor Version or Update PHP on your server').'</div>';
502 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Your Elementor Plugin is not fully active, usually this happen because of old PHP version on server, in such case eventually you can try older Elementor Version or Update PHP on your server', 'wpdirectorykit').'</div>';
300 503 $this->data['required_plugins'] = true;
301 504 }
302 505
303 506 if(!$this->data['required_plugins'])
@@ -351,9 +554,9 @@
351 554 }
352 555
353 556 $this->replace_content_data($data['multipurpose']);
354 557
355 - $this->data['info_log_message'] .= '<div class="alert alert-info" role="alert">'.esc_html__('Import completed successfuly', 'wpdirectorykit').', <a href="'. esc_url((wdk_get_option('wdk_results_page')) ? get_permalink(wdk_get_option('wdk_results_page')): home_url()).'">'.__('Check your page now', 'wpdirectorykit').'</a></div>';
558 + $this->data['info_log_message'] .= '<div class="alert alert-info" role="alert">'.esc_html__('Import completed successfully', 'wpdirectorykit').', <a href="'. esc_url((wdk_get_option('wdk_results_page')) ? get_permalink(wdk_get_option('wdk_results_page')): home_url()).'">'.__('Check your page now', 'wpdirectorykit').'</a></div>';
356 559
357 560 $this->data['info_log_message'] = apply_filters('wdk/settings/import/run/info_log_message', $this->data['info_log_message'] , $data);
358 561
359 562 do_action('wdk/settings/import/run', $data);
@@ -391,9 +594,9 @@
391 594
392 595 /* remove fields */
393 596 $this->db->delete($this->location_m->_table_name);
394 597
395 - $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Locations removed').'</div>';
598 + $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Locations removed', 'wpdirectorykit').'</div>';
396 599 /* end remove fields */
397 600
398 601 /* remove fields */
399 602 $this->db->delete($this->category_m->_table_name);
@@ -398,9 +601,9 @@
398 601 /* remove fields */
399 602 $this->db->delete($this->category_m->_table_name);
400 603 $this->db->delete($this->dependfields_m->_table_name);
401 604
402 - $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Categories removed').'</div>';
605 + $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Categories removed', 'wpdirectorykit').'</div>';
403 606 /* end remove fields */
404 607
405 608 /* remove fields */
406 609 $this->db->delete($this->field_m->_table_name);
@@ -409,9 +612,9 @@
409 612 if(strpos($field_name, 'field_') ===FALSE) continue;
410 613 $this->db->query('ALTER TABLE '.$this->listingfield_m->_table_name.' DROP COLUMN '.$field_name.'');
411 614 }
412 615
413 - $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Fields removed').'</div>';
616 + $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Fields removed', 'wpdirectorykit').'</div>';
414 617 /* end remove fields */
415 618
416 619 /* remove listings */
417 620 $this->db->delete($this->listing_m->_table_name);
@@ -416,9 +619,9 @@
416 619 /* remove listings */
417 620 $this->db->delete($this->listing_m->_table_name);
418 621 $this->db->delete($this->listingfield_m->_table_name);
419 622
420 - $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listings removed').'</div>';
623 + $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listings removed', 'wpdirectorykit').'</div>';
421 624 /* end remove listings */
422 625
423 626
424 627 /* remove listings */
@@ -423,9 +626,9 @@
423 626
424 627 /* remove listings */
425 628 $this->db->delete($this->resultitem_m->_table_name);
426 629 $this->db->delete($this->searchform_m->_table_name);
427 - $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Result Card And Search form removed').'</div>';
630 + $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Result Card And Search form removed', 'wpdirectorykit').'</div>';
428 631 /* end remove listings */
429 632
430 633
431 634 /* reset autoincrement */
@@ -437,9 +640,9 @@
437 640 $this->db->query('TRUNCATE TABLE `'.$this->listing_m->_table_name.'`');
438 641 $this->db->query('TRUNCATE TABLE `'.$this->resultitem_m->_table_name.'`');
439 642 $this->db->query('TRUNCATE TABLE `'.$this->searchform_m->_table_name.'`');
440 643
441 - $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Tables reset').'</div>';
644 + $this->data['data_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Tables reset', 'wpdirectorykit').'</div>';
442 645 /* end reset autoincrement */
443 646
444 647 $wdk_posts = get_posts( array( 'post_type' => 'wdk-listing', 'numberposts' => -1));
445 648 foreach( $wdk_posts as $post ) {
@@ -449,9 +652,9 @@
449 652 }
450 653
451 654 if(isset($_GET['redirect_url']) && strpos($_GET['redirect_url'], 'http') === FALSE && strpos($_GET['redirect_url'], '//') === FALSE){
452 655 if(wmvc_xss_clean($_GET['redirect_url']) =='on_install') {
453 - $redirect_url = admin_url("admin.php?page=wdk_settings&function=import_demo&is_updated");
656 + $redirect_url = admin_url("admin.php?page=wdk_settings&function=import_demo&is_updated&multipurpose=".wmvc_show_data('multipurpose', $_GET, ''));
454 657 } else {
455 658 $redirect_url = admin_url(sanitize_text_field($_GET['redirect_url']));
456 659 }
457 660 wp_redirect($redirect_url);
@@ -462,9 +665,9 @@
462 665
463 666 /* add demo pages */
464 667 private function demo_pages($purpose = '') {
465 668
466 - // if(get_option('wdk_listing_page') || get_option('wdk_results_page')) return true;
669 + if(get_option('wdk_listing_page') || get_option('wdk_results_page')) return true;
467 670
468 671 add_action('wpdirectorykit/elementor-elements/register_widget', function($self){
469 672 $self->add_widget('Wdk\Elementor\Extensions\WdkContactFormExt');
470 673 });
@@ -617,9 +820,9 @@
617 820 $this->replace_meta($from, $to);
618 821
619 822 /* homepage */
620 823 $from = '2020';
621 - $to = date('Y');
824 + $to = gmdate('Y');
622 825 $this->replace_meta($from, $to);
623 826
624 827
625 828 /* replace in db */
@@ -644,9 +847,9 @@
644 847 /* add demo listing preview page */
645 848 private function demo_page_listing($purpose = '') {
646 849
647 850 if((get_option('wdk_listing_page')) && get_post_status(get_option('wdk_listing_page')) =='publish'){
648 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Listing Preview Page already exists').'</div>';
851 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Listing Preview Page already exists', 'wpdirectorykit').'</div>';
649 852 return false;
650 853 }
651 854
652 855 add_action('wpdirectorykit/elementor-elements/register_widget', function($self){
@@ -675,8 +878,9 @@
675 878 $self->add_widget('Wdk\Elementor\Widgets\WdkListingMap');
676 879 $self->add_widget('Wdk\Elementor\Widgets\WdkListinAgent');
677 880 $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField');
678 881 $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar');
882 + $self->add_widget('Wdk\Elementor\Widgets\WdkCoolListingCarousel');
679 883 });
680 884
681 885 // Import elementor templates
682 886 $page_listing_preview = $this->create_page(esc_html__('Listing Preview', 'wpdirectorykit'), '', 'elementor_canvas');
@@ -685,9 +889,9 @@
685 889 // Assign page.
686 890 if($page_listing_preview)
687 891 update_option( 'wdk_listing_page', $page_listing_preview->ID, TRUE);
688 892
689 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listing Preview Page imported').'</div>';
893 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listing Preview Page imported', 'wpdirectorykit').'</div>';
690 894
691 895 return true;
692 896 }
693 897
@@ -694,9 +898,9 @@
694 898 /* add demo results page */
695 899 private function demo_page_results($purpose = '') {
696 900
697 901 if((get_option('wdk_results_page')) && get_post_status(get_option('wdk_results_page')) == 'publish'){
698 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Results Listings Page already exists').'</div>';
902 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Results Listings Page already exists', 'wpdirectorykit').'</div>';
699 903 return false;
700 904 }
701 905
702 906 add_action('wpdirectorykit/elementor-elements/register_widget', function($self){
@@ -725,8 +929,9 @@
725 929 $self->add_widget('Wdk\Elementor\Widgets\WdkListingMap');
726 930 $self->add_widget('Wdk\Elementor\Widgets\WdkListinAgent');
727 931 $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField');
728 932 $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar');
933 + $self->add_widget('Wdk\Elementor\Widgets\WdkCoolListingCarousel');
729 934 });
730 935
731 936 $page_results = $this->create_page(esc_html__('Results Listings', 'wpdirectorykit'), '', 'elementor_canvas');
732 937 $this->elementor_assign($page_results->ID, 'page-results-listings.json');
@@ -736,9 +941,9 @@
736 941 update_option( 'page_on_front', $page_results->ID );
737 942
738 943 update_option( 'wdk_results_page', $page_results->ID, TRUE);
739 944
740 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Results Listings Page imported').'</div>';
945 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Results Listings Page imported', 'wpdirectorykit').'</div>';
741 946
742 947
743 948 $menus = get_registered_nav_menus();
744 949 // first menu defined by template
@@ -770,8 +975,11 @@
770 975 wp_update_nav_menu_item((int)$menu_id, 0, $itemData);
771 976
772 977 // assign menu to top menu
773 978 $locations = get_theme_mod( 'nav_menu_locations' );
979 + if ( ! is_array( $locations ) ) {
980 + $locations = array();
981 + }
774 982 $locations[$first_menu] = $menu_id;
775 983 set_theme_mod('nav_menu_locations', $locations);
776 984 }
777 985
@@ -911,13 +1119,13 @@
911 1119 $data['idresultitem'] = 1;
912 1120 $insert_id = $this->resultitem_m->insert($data, NULL);
913 1121 }
914 1122
915 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Search Form & Result Card imported').'</div>';
1123 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Search Form & Result Card imported', 'wpdirectorykit').'</div>';
916 1124 return true;
917 1125 }
918 -
919 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Missing xml file '.$this->import_xml_file, 'wpdirectorykit').'</div>';
1126 + /* translators: 1: XML file path. */
1127 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('Missing xml file %1$s', 'wpdirectorykit'), $this->import_xml_file).'</div>';
920 1128 return false;
921 1129
922 1130 }
923 1131
@@ -931,9 +1139,10 @@
931 1139
932 1140 if(file_exists($this->import_xml_file_locations)) {
933 1141 $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file_locations));
934 1142 if(!isset($dom_array['locations']['location']) && empty($dom_array['locations']['location'])) {
935 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('No fields in xml file '.$this->import_xml_file_locations, 'wpdirectorykit').'</div>';
1143 + /* translators: 1: XML file path. */
1144 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('No fields in xml file %1$s', 'wpdirectorykit'), $this->import_xml_file_locations).'</div>';
936 1145 return false;
937 1146 }
938 1147 foreach ($dom_array['locations']['location'] as $key => $location_data) {
939 1148 $this->_recursive_add_locations($location_data);
@@ -938,13 +1147,13 @@
938 1147 foreach ($dom_array['locations']['location'] as $key => $location_data) {
939 1148 $this->_recursive_add_locations($location_data);
940 1149 }
941 1150
942 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Locations imported').'</div>';
1151 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Locations imported', 'wpdirectorykit').'</div>';
943 1152 return true;
944 1153 }
945 -
946 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Missing xml file '.$this->import_xml_file_locations, 'wpdirectorykit').'</div>';
1154 + /* translators: 1: XML file path. */
1155 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('Missing xml file %1$s', 'wpdirectorykit'), $this->import_xml_file_locations).'</div>';
947 1156 return false;
948 1157 }
949 1158
950 1159 private function _recursive_add_locations ($data = array(), $parent_id = 0, $level = 0 ) {
@@ -998,9 +1207,10 @@
998 1207
999 1208 if(file_exists($this->import_xml_file)) {
1000 1209 $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file));
1001 1210 if(!isset($dom_array['categories']['category']) && empty($dom_array['categories']['category'])) {
1002 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('No fields in xml file '.$this->import_xml_file, 'wpdirectorykit').'</div>';
1211 + /* translators: 1: XML file path. */
1212 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('No fields in xml file %1$s', 'wpdirectorykit'), $this->import_xml_file).'</div>';
1003 1213 return false;
1004 1214 }
1005 1215
1006 1216 foreach ($dom_array['categories']['category'] as $key => $category_data) {
@@ -1017,13 +1227,13 @@
1017 1227 $order_index++;
1018 1228 }
1019 1229 $this->db->updateBatch( $this->category_m->_table_name, $values, 'idcategory');
1020 1230
1021 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Categories imported').'</div>';
1231 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Categories imported', 'wpdirectorykit').'</div>';
1022 1232 return true;
1023 1233 }
1024 -
1025 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Missing xml file '.$this->import_xml_file, 'wpdirectorykit').'</div>';
1234 + /* translators: 1: XML file path. */
1235 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('No fields in xml file %1$s', 'wpdirectorykit'), $this->import_xml_file).'</div>';
1026 1236 return false;
1027 1237 }
1028 1238
1029 1239 private function _recursive_add_categories ($data = array(), $parent_id = 0, $level = 0 ) {
@@ -1140,9 +1350,10 @@
1140 1350 'order_index' => '',
1141 1351 );
1142 1352
1143 1353 if(!isset($dom_array['fields']['field']) && empty($dom_array['fields']['field'])) {
1144 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('No fields in xml file '.$this->import_xml_file, 'wpdirectorykit').'</div>';
1354 + /* translators: 1: XML file path. */
1355 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('No fields in xml file %1$s', 'wpdirectorykit'),$this->import_xml_file).'</div>';
1145 1356 return false;
1146 1357 }
1147 1358
1148 1359 foreach ($dom_array['fields']['field'] as $key => $field) {
@@ -1194,13 +1405,13 @@
1194 1405 if(!empty($insert_id))
1195 1406 $this->listingfield_m->create_table_column($field_data, $insert_id);
1196 1407 }
1197 1408
1198 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Fields imported').'</div>';
1409 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Fields imported', 'wpdirectorykit').'</div>';
1199 1410 return true;
1200 1411 }
1201 -
1202 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Missing xml file '.$this->import_xml_file, 'wpdirectorykit').'</div>';
1412 + /* translators: 1: XML file path. */
1413 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('No fields in xml file %1$s', 'wpdirectorykit'), $this->import_xml_file).'</div>';
1203 1414 return false;
1204 1415 }
1205 1416
1206 1417 private function import_listings($purpose = '') {
@@ -1256,9 +1467,10 @@
1256 1467
1257 1468 if(file_exists($this->import_xml_file)) {
1258 1469 $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file));
1259 1470 if(!isset($dom_array['listings']['listing']) && empty($dom_array['listings']['listing'])) {
1260 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('No listings in xml file '.$this->import_xml_file, 'wpdirectorykit').'</div>';
1471 + /* translators: 1: XML file path. */
1472 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('No listings in xml file %1$s', 'wpdirectorykit'), $this->import_xml_file).'</div>';
1261 1473 return false;
1262 1474 }
1263 1475
1264 1476 /* demo agent add/get if exists */
@@ -1271,12 +1483,12 @@
1271 1483 $location_id = '';
1272 1484 $category_id = '';
1273 1485
1274 1486 if(!empty($categories))
1275 - $category_id = $categories[rand(0, count($categories)-1)];
1487 + $category_id = $categories[wp_rand(0, count($categories)-1)];
1276 1488
1277 1489 if(!empty($location))
1278 - $location_id = $locations[rand(0, count($locations)-1)];
1490 + $location_id = $locations[wp_rand(0, count($locations)-1)];
1279 1491
1280 1492 $data_listing = array(
1281 1493 'post_title' => '',
1282 1494 'post_content' => '',
@@ -1286,13 +1498,14 @@
1286 1498 'lat' => '',
1287 1499 'listing_images' => '',
1288 1500 'listing_images_path' => '',
1289 1501 'listing_images_path_medium' => '',
1290 - 'date_modified' => date('Y-m-d H:i:s'),
1502 + 'date_modified' => gmdate('Y-m-d H:i:s'),
1291 1503 'lng' => '',
1292 1504 'is_featured' => '',
1293 1505 'is_activated' => '1',
1294 1506 'is_approved' => '1',
1507 + 'counter_views' => wp_rand(20,250),
1295 1508 'user_id_editor' => NULL,
1296 1509 );
1297 1510
1298 1511 $data_listing = array_intersect_key(array_merge($data_listing, $listing), $data_listing);
@@ -1321,19 +1534,19 @@
1321 1534 if(count($values) > 0)
1322 1535 {
1323 1536 $start=0;
1324 1537 if(empty($values[0]))$start=1;
1325 - $data_listings_fields['field_'.$field_data->idfield] = $values[rand($start, count($values)-1)];
1538 + $data_listings_fields['field_'.$field_data->idfield] = $values[wp_rand($start, count($values)-1)];
1326 1539 }
1327 1540 }
1328 1541 elseif($field_data->field_type == 'NUMBER')
1329 1542 {
1330 - $data_listings_fields['field_'.$field_data->idfield] = rand(2,499);
1543 + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(2,499);
1331 1544
1332 1545 }
1333 1546 elseif($field_data->field_type == 'CHECKBOX')
1334 1547 {
1335 - $data_listings_fields['field_'.$field_data->idfield] = rand(0,1);
1548 + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(0,1);
1336 1549 }
1337 1550 elseif($field_data->field_type == 'TEXTAREA')
1338 1551 {
1339 1552 //$data_listings_fields['field_'.$field_data->idfield] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
@@ -1341,11 +1554,11 @@
1341 1554 }
1342 1555 }
1343 1556
1344 1557 /* add files */
1345 - $count_images = 2;
1558 +
1346 1559 if($purpose == 'car-dealer.xml') {
1347 - $count_images = 1;
1560 + $this->import_count_images = 1;
1348 1561 }
1349 1562 if(isset($listing['images']) && !empty($listing['images'])) {
1350 1563
1351 1564 foreach (explode(',', $listing['images']) as $key => $file_name) {
@@ -1374,9 +1587,9 @@
1374 1587 }
1375 1588
1376 1589 $image_url = wp_get_attachment_image_url($image_id, 'large');
1377 1590 if($image_url) {
1378 - $parsed = parse_url($image_url);
1591 + $parsed = wp_parse_url($image_url);
1379 1592 $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8);
1380 1593
1381 1594 if(!empty($data_listing['listing_images_path_medium']))
1382 1595 $data_listing['listing_images_path_medium'] .= ',';
@@ -1386,9 +1599,9 @@
1386 1599 }
1387 1600
1388 1601 } else {
1389 1602 /* auto import images */
1390 - for ($i=0,$image_num=$listing_num; $i<$count_images; $i++,$image_num++) {
1603 + for ($i=0,$image_num=$listing_num; $i<$this->import_count_images; $i++,$image_num++) {
1391 1604 if($image_num >= count($files))
1392 1605 $image_num = 0;
1393 1606
1394 1607 if(!empty($data_listing['listing_images']))
@@ -1415,9 +1628,9 @@
1415 1628 }
1416 1629
1417 1630 $image_url = wp_get_attachment_image_url($image_id, 'large');
1418 1631 if($image_url) {
1419 - $parsed = parse_url($image_url);
1632 + $parsed = wp_parse_url($image_url);
1420 1633 $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8);
1421 1634
1422 1635 if(!empty($data_listing['listing_images_path_medium']))
1423 1636 $data_listing['listing_images_path_medium'] .= ',';
@@ -1426,9 +1639,8 @@
1426 1639 }
1427 1640 }
1428 1641 }
1429 1642
1430 -
1431 1643 // Create post object
1432 1644 $listing_post = array(
1433 1645 'ID' => NULL,
1434 1646 'post_type' => 'wdk-listing',
@@ -1447,10 +1659,11 @@
1447 1659 if(isset( $data_listing[$field_name]))
1448 1660 $listing_data[$field_name] = $data_listing[$field_name];
1449 1661 }
1450 1662 $listing_data['user_id_editor'] = $user_ids[array_rand($user_ids)];
1451 - $listing_data['date_modified'] = date('Y-m-d H:i:s');
1452 -
1663 + $listing_data['date_modified'] = gmdate('Y-m-d H:i:s');
1664 + $listing_data['counter_views'] = wp_rand(20,250);
1665 +
1453 1666 $this->listing_m->insert($listing_data, NULL);
1454 1667
1455 1668 $data_listings_fields['post_id'] = $id;
1456 1669 $this->listingfield_m->insert_custom_fields($fields, $data_listings_fields, NULL);
@@ -1455,13 +1668,13 @@
1455 1668 $data_listings_fields['post_id'] = $id;
1456 1669 $this->listingfield_m->insert_custom_fields($fields, $data_listings_fields, NULL);
1457 1670 }
1458 1671
1459 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listings imported').'</div>';
1672 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listings imported', 'wpdirectorykit').'</div>';
1460 1673 return true;
1461 1674 }
1462 -
1463 - $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.esc_html__('Missing xml file '.$this->import_xml_file, 'wpdirectorykit').'</div>';
1675 + /* translators: 1: XML file path. */
1676 + $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.wdk_sprintf(esc_html__('No fields in xml file %1$s', 'wpdirectorykit'), $this->import_xml_file).'</div>';
1464 1677 return false;
1465 1678 }
1466 1679
1467 1680 protected function xmlstr_to_array($xmlstr) {
@@ -1551,9 +1764,9 @@
1551 1764 $this->import_listings($multipurpose);
1552 1765 $this->import_visual_data($multipurpose);
1553 1766 $this->demo_pages($multipurpose);
1554 1767
1555 - $message = urlencode(str_replace(" ", '+', __('Import completed successfuly', 'wpdirectorykit')).' <a href="'.esc_url((wdk_get_option('wdk_results_page')) ? get_permalink(wdk_get_option('wdk_results_page')): home_url()).'">'.__('Check your page now', 'wpdirectorykit').'</a>');
1768 + $message = urlencode(str_replace(" ", '+', __('Import completed successfully', 'wpdirectorykit')).' <a href="'.esc_url((wdk_get_option('wdk_results_page')) ? get_permalink(wdk_get_option('wdk_results_page')): home_url()).'">'.__('Check your page now', 'wpdirectorykit').'</a>');
1556 1769
1557 1770 do_action('wpdirectorykit/install/api');
1558 1771 do_action('wdk/settings/import/api_run', $multipurpose);
1559 1772 update_option('wdk_install_images_sizes_disable', 0);
@@ -1600,10 +1813,12 @@
1600 1813 update_option('wdk_install_images_sizes_disable', 0);
1601 1814 return true;
1602 1815 }
1603 1816
1604 - public function _api_import()
1817 + public function _api_import($import_count_images = 2)
1605 1818 {
1819 + $this->import_count_images = $import_count_images;
1820 +
1606 1821 wdk_access_check('settings_m', 1);
1607 1822 update_option('wdk_install_images_sizes_disable', 1);
1608 1823 ini_set('max_execution_time', 900);
1609 1824 $this->data['import_log'] = '';
@@ -1645,12 +1860,19 @@
1645 1860
1646 1861 update_option( 'wdk_is_category_enabled', '1' );
1647 1862 update_option( 'wdk_is_location_enabled', '1' );
1648 1863 update_option( 'wdk_is_address_enabled', '1' );
1649 - update_option( 'wdk_is_results_page_require', '1' );
1864 + update_option( 'wdk_is_results_page_require', 0 );
1650 1865 update_option( 'wdk_seo_description', '2' );
1651 1866 update_option( 'wdk_seo_keywords', '3' );
1652 1867 update_option( 'wdk_card_slider_enable', '1' );
1868 + update_option('elementor_load_fa4_shim', 'yes');
1869 +
1870 + /* disable elmentor experement feature */
1871 + update_option( 'elementor_experiment-e_font_icon_svg', 'inactive');
1872 + update_option( 'elementor_experiment-landing-pages', 'inactive' );
1873 + update_option( 'elementor_experiment-e_dom_optimization', 'inactive');
1874 +
1653 1875 return true;
1654 1876 }
1655 1877
1656 1878 /* add demo listing preview page */
@@ -1660,9 +1882,9 @@
1660 1882 $page_title_message = $custom_message_title;
1661 1883 }
1662 1884
1663 1885 if(!empty($option) && (get_option($option)) && get_post_status(get_option($option)) =='publish'){
1664 - // $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.$page_title_message.' '.esc_html__('Page already exists', 'wdk-membership').'</div>';
1886 + // $this->data['import_log'] .= '<div class="alert alert-danger" role="alert">'.$page_title_message.' '.esc_html__('Page already exists', 'wpdirectorykit').'</div>';
1665 1887 // return false;
1666 1888 }
1667 1889
1668 1890 add_action('wdk-membership/elementor-elements/register_widget', function($self){
@@ -1698,9 +1920,9 @@
1698 1920 // Assign page.
1699 1921 if($page && !empty($option))
1700 1922 update_option( $option, $page->ID, TRUE);
1701 1923
1702 - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.$page_title_message.' '.esc_html__('Page imported', 'wdk-membership').'</div>';
1924 + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.$page_title_message.' '.esc_html__('Page imported', 'wpdirectorykit').'</div>';
1703 1925
1704 1926 return $page->ID;
1705 1927 }
1706 1928