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 +265 -51 1.3.0 → 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 }
@@ -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'])
@@ -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 ) {
@@ -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,14 +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',
1295 - 'counter_views' => rand(20,250),
1507 + 'counter_views' => wp_rand(20,250),
1296 1508 'user_id_editor' => NULL,
1297 1509 );
1298 1510
1299 1511 $data_listing = array_intersect_key(array_merge($data_listing, $listing), $data_listing);
@@ -1322,19 +1534,19 @@
1322 1534 if(count($values) > 0)
1323 1535 {
1324 1536 $start=0;
1325 1537 if(empty($values[0]))$start=1;
1326 - $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)];
1327 1539 }
1328 1540 }
1329 1541 elseif($field_data->field_type == 'NUMBER')
1330 1542 {
1331 - $data_listings_fields['field_'.$field_data->idfield] = rand(2,499);
1543 + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(2,499);
1332 1544
1333 1545 }
1334 1546 elseif($field_data->field_type == 'CHECKBOX')
1335 1547 {
1336 - $data_listings_fields['field_'.$field_data->idfield] = rand(0,1);
1548 + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(0,1);
1337 1549 }
1338 1550 elseif($field_data->field_type == 'TEXTAREA')
1339 1551 {
1340 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.';
@@ -1342,11 +1554,11 @@
1342 1554 }
1343 1555 }
1344 1556
1345 1557 /* add files */
1346 - $count_images = 2;
1558 +
1347 1559 if($purpose == 'car-dealer.xml') {
1348 - $count_images = 1;
1560 + $this->import_count_images = 1;
1349 1561 }
1350 1562 if(isset($listing['images']) && !empty($listing['images'])) {
1351 1563
1352 1564 foreach (explode(',', $listing['images']) as $key => $file_name) {
@@ -1375,9 +1587,9 @@
1375 1587 }
1376 1588
1377 1589 $image_url = wp_get_attachment_image_url($image_id, 'large');
1378 1590 if($image_url) {
1379 - $parsed = parse_url($image_url);
1591 + $parsed = wp_parse_url($image_url);
1380 1592 $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8);
1381 1593
1382 1594 if(!empty($data_listing['listing_images_path_medium']))
1383 1595 $data_listing['listing_images_path_medium'] .= ',';
@@ -1387,9 +1599,9 @@
1387 1599 }
1388 1600
1389 1601 } else {
1390 1602 /* auto import images */
1391 - 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++) {
1392 1604 if($image_num >= count($files))
1393 1605 $image_num = 0;
1394 1606
1395 1607 if(!empty($data_listing['listing_images']))
@@ -1416,9 +1628,9 @@
1416 1628 }
1417 1629
1418 1630 $image_url = wp_get_attachment_image_url($image_id, 'large');
1419 1631 if($image_url) {
1420 - $parsed = parse_url($image_url);
1632 + $parsed = wp_parse_url($image_url);
1421 1633 $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8);
1422 1634
1423 1635 if(!empty($data_listing['listing_images_path_medium']))
1424 1636 $data_listing['listing_images_path_medium'] .= ',';
@@ -1447,10 +1659,10 @@
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 - $listing_data['counter_views'] = rand(20,250);
1663 + $listing_data['date_modified'] = gmdate('Y-m-d H:i:s');
1664 + $listing_data['counter_views'] = wp_rand(20,250);
1453 1665
1454 1666 $this->listing_m->insert($listing_data, NULL);
1455 1667
1456 1668 $data_listings_fields['post_id'] = $id;
@@ -1456,13 +1668,13 @@
1456 1668 $data_listings_fields['post_id'] = $id;
1457 1669 $this->listingfield_m->insert_custom_fields($fields, $data_listings_fields, NULL);
1458 1670 }
1459 1671
1460 - $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>';
1461 1673 return true;
1462 1674 }
1463 -
1464 - $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>';
1465 1677 return false;
1466 1678 }
1467 1679
1468 1680 protected function xmlstr_to_array($xmlstr) {
@@ -1601,10 +1813,12 @@
1601 1813 update_option('wdk_install_images_sizes_disable', 0);
1602 1814 return true;
1603 1815 }
1604 1816
1605 - public function _api_import()
1817 + public function _api_import($import_count_images = 2)
1606 1818 {
1819 + $this->import_count_images = $import_count_images;
1820 +
1607 1821 wdk_access_check('settings_m', 1);
1608 1822 update_option('wdk_install_images_sizes_disable', 1);
1609 1823 ini_set('max_execution_time', 900);
1610 1824 $this->data['import_log'] = '';
@@ -1646,9 +1860,9 @@
1646 1860
1647 1861 update_option( 'wdk_is_category_enabled', '1' );
1648 1862 update_option( 'wdk_is_location_enabled', '1' );
1649 1863 update_option( 'wdk_is_address_enabled', '1' );
1650 - update_option( 'wdk_is_results_page_require', '1' );
1864 + update_option( 'wdk_is_results_page_require', 0 );
1651 1865 update_option( 'wdk_seo_description', '2' );
1652 1866 update_option( 'wdk_seo_keywords', '3' );
1653 1867 update_option( 'wdk_card_slider_enable', '1' );
1654 1868 update_option('elementor_load_fa4_shim', 'yes');
@@ -1668,9 +1882,9 @@
1668 1882 $page_title_message = $custom_message_title;
1669 1883 }
1670 1884
1671 1885 if(!empty($option) && (get_option($option)) && get_post_status(get_option($option)) =='publish'){
1672 - // $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>';
1673 1887 // return false;
1674 1888 }
1675 1889
1676 1890 add_action('wdk-membership/elementor-elements/register_widget', function($self){
@@ -1706,9 +1920,9 @@
1706 1920 // Assign page.
1707 1921 if($page && !empty($option))
1708 1922 update_option( $option, $page->ID, TRUE);
1709 1923
1710 - $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>';
1711 1925
1712 1926 return $page->ID;
1713 1927 }
1714 1928