| @@ -12,11 +12,13 @@ | ||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | class Wdk_settings extends Winter_MVC_Controller { |
| 15 | 15 | public $import_log = ''; |
| 16 | + public $info_log_message = ''; | |
| 16 | 17 | public $import_images_dir = WPDIRECTORYKIT_PATH.'demo-data/images/'; |
| 17 | 18 | public $import_xml_file = ''; |
| 18 | 19 | public $import_xml_file_locations = WPDIRECTORYKIT_PATH.'demo-data/locations.xml'; |
| 20 | + public $import_count_images = 2; | |
| 19 | 21 | |
| 20 | 22 | public function __construct(){ |
| 21 | 23 | parent::__construct(); |
| 22 | 24 | } |
| @@ -30,9 +32,9 @@ | ||
| 30 | 32 | $this->data['form'] = &$this->form; |
| 31 | 33 | $this->data['fields'] = $this->settings_m->fields_list; |
| 32 | 34 | $this->data['fields_list_tabs'] = $this->settings_m->fields_list_tabs; |
| 33 | 35 | |
| 34 | - $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')); | |
| 35 | 37 | |
| 36 | 38 | if($this->form->run($this->data['fields'])) |
| 37 | 39 | { |
| 38 | 40 | |
| @@ -73,11 +75,213 @@ | ||
| 73 | 75 | { |
| 74 | 76 | $this->data['db_data'][$field->option_name] = $field->option_value; |
| 75 | 77 | } |
| 76 | 78 | |
| 79 | + $this->mailtemplates(); | |
| 80 | + | |
| 77 | 81 | $this->load->view('wdk_settings/index', $this->data); |
| 78 | 82 | } |
| 83 | + | |
| 84 | + // Edit listing method | |
| 85 | + public function mailtemplate() | |
| 86 | + { | |
| 79 | 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 | + | |
| 80 | 284 | function reset_data () { |
| 81 | 285 | |
| 82 | 286 | wdk_access_check('settings_m', 1); |
| 83 | 287 | |
| @@ -143,9 +347,9 @@ | ||
| 143 | 347 | } |
| 144 | 348 | |
| 145 | 349 | $redirect_url = admin_url("admin.php?page=wdk_settings&is_updated"); |
| 146 | 350 | if(isset($_GET['redirect_url']) && strpos($_GET['redirect_url'], 'http') === FALSE && strpos($_GET['redirect_url'], '//') === FALSE) |
| 147 | - $redirect_url = admin_url(sanitize_text_field($_GET['redirect_url'])); | |
| 351 | + $redirect_url = admin_url(sanitize_text_field(wp_unslash($_GET['redirect_url']))); | |
| 148 | 352 | |
| 149 | 353 | wp_redirect($redirect_url); |
| 150 | 354 | exit; |
| 151 | 355 | } |
| @@ -153,9 +357,8 @@ | ||
| 153 | 357 | // Import demo data listing method |
| 154 | 358 | public function import_demo() |
| 155 | 359 | { |
| 156 | 360 | wdk_access_check('settings_m', 1); |
| 157 | - | |
| 158 | 361 | $this->load->model('field_m'); |
| 159 | 362 | $this->load->model('listingfield_m'); |
| 160 | 363 | $this->load->model('listing_m'); |
| 161 | 364 | $this->load->model('category_m'); |
| @@ -245,11 +448,13 @@ | ||
| 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'] = ''; |
| 455 | + $this->data['info_log_message'] = ''; | |
| 456 | + | |
| 252 | 457 | $rules = array( |
| 253 | 458 | array( |
| 254 | 459 | 'field' => 'import_locations', |
| 255 | 460 | 'label' => __('Locations', 'wpdirectorykit'), |
| @@ -293,9 +498,9 @@ | ||
| 293 | 498 | ); |
| 294 | 499 | |
| 295 | 500 | $plugin = 'elementor/elementor.php'; |
| 296 | 501 | if (in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ))) && !class_exists('Elementor\Plugin') ) { |
| 297 | - $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>'; | |
| 298 | 503 | $this->data['required_plugins'] = true; |
| 299 | 504 | } |
| 300 | 505 | |
| 301 | 506 | if(!$this->data['required_plugins']) |
| @@ -300,8 +505,10 @@ | ||
| 300 | 505 | |
| 301 | 506 | if(!$this->data['required_plugins']) |
| 302 | 507 | if($this->form->run($rules)) |
| 303 | 508 | { |
| 509 | + update_option('wdk_install_images_sizes_disable', 1); | |
| 510 | + | |
| 304 | 511 | // Check _wpnonce |
| 305 | 512 | check_admin_referer( 'wdk-settings_import', '_wpnonce' ); |
| 306 | 513 | |
| 307 | 514 | // Save procedure for basic data |
| @@ -347,10 +554,14 @@ | ||
| 347 | 554 | } |
| 348 | 555 | |
| 349 | 556 | $this->replace_content_data($data['multipurpose']); |
| 350 | 557 | |
| 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>'; | |
| 559 | + | |
| 560 | + $this->data['info_log_message'] = apply_filters('wdk/settings/import/run/info_log_message', $this->data['info_log_message'] , $data); | |
| 561 | + | |
| 351 | 562 | do_action('wdk/settings/import/run', $data); |
| 352 | - | |
| 563 | + update_option('wdk_install_images_sizes_disable', 0); | |
| 353 | 564 | } |
| 354 | 565 | |
| 355 | 566 | $this->load->view('wdk_install/index', $this->data); |
| 356 | 567 | } |
| @@ -383,9 +594,9 @@ | ||
| 383 | 594 | |
| 384 | 595 | /* remove fields */ |
| 385 | 596 | $this->db->delete($this->location_m->_table_name); |
| 386 | 597 | |
| 387 | - $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>'; | |
| 388 | 599 | /* end remove fields */ |
| 389 | 600 | |
| 390 | 601 | /* remove fields */ |
| 391 | 602 | $this->db->delete($this->category_m->_table_name); |
| @@ -390,9 +601,9 @@ | ||
| 390 | 601 | /* remove fields */ |
| 391 | 602 | $this->db->delete($this->category_m->_table_name); |
| 392 | 603 | $this->db->delete($this->dependfields_m->_table_name); |
| 393 | 604 | |
| 394 | - $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>'; | |
| 395 | 606 | /* end remove fields */ |
| 396 | 607 | |
| 397 | 608 | /* remove fields */ |
| 398 | 609 | $this->db->delete($this->field_m->_table_name); |
| @@ -401,9 +612,9 @@ | ||
| 401 | 612 | if(strpos($field_name, 'field_') ===FALSE) continue; |
| 402 | 613 | $this->db->query('ALTER TABLE '.$this->listingfield_m->_table_name.' DROP COLUMN '.$field_name.''); |
| 403 | 614 | } |
| 404 | 615 | |
| 405 | - $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>'; | |
| 406 | 617 | /* end remove fields */ |
| 407 | 618 | |
| 408 | 619 | /* remove listings */ |
| 409 | 620 | $this->db->delete($this->listing_m->_table_name); |
| @@ -408,9 +619,9 @@ | ||
| 408 | 619 | /* remove listings */ |
| 409 | 620 | $this->db->delete($this->listing_m->_table_name); |
| 410 | 621 | $this->db->delete($this->listingfield_m->_table_name); |
| 411 | 622 | |
| 412 | - $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>'; | |
| 413 | 624 | /* end remove listings */ |
| 414 | 625 | |
| 415 | 626 | |
| 416 | 627 | /* remove listings */ |
| @@ -415,9 +626,9 @@ | ||
| 415 | 626 | |
| 416 | 627 | /* remove listings */ |
| 417 | 628 | $this->db->delete($this->resultitem_m->_table_name); |
| 418 | 629 | $this->db->delete($this->searchform_m->_table_name); |
| 419 | - $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>'; | |
| 420 | 631 | /* end remove listings */ |
| 421 | 632 | |
| 422 | 633 | |
| 423 | 634 | /* reset autoincrement */ |
| @@ -429,9 +640,9 @@ | ||
| 429 | 640 | $this->db->query('TRUNCATE TABLE `'.$this->listing_m->_table_name.'`'); |
| 430 | 641 | $this->db->query('TRUNCATE TABLE `'.$this->resultitem_m->_table_name.'`'); |
| 431 | 642 | $this->db->query('TRUNCATE TABLE `'.$this->searchform_m->_table_name.'`'); |
| 432 | 643 | |
| 433 | - $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>'; | |
| 434 | 645 | /* end reset autoincrement */ |
| 435 | 646 | |
| 436 | 647 | $wdk_posts = get_posts( array( 'post_type' => 'wdk-listing', 'numberposts' => -1)); |
| 437 | 648 | foreach( $wdk_posts as $post ) { |
| @@ -441,9 +652,9 @@ | ||
| 441 | 652 | } |
| 442 | 653 | |
| 443 | 654 | if(isset($_GET['redirect_url']) && strpos($_GET['redirect_url'], 'http') === FALSE && strpos($_GET['redirect_url'], '//') === FALSE){ |
| 444 | 655 | if(wmvc_xss_clean($_GET['redirect_url']) =='on_install') { |
| 445 | - $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, '')); | |
| 446 | 657 | } else { |
| 447 | 658 | $redirect_url = admin_url(sanitize_text_field($_GET['redirect_url'])); |
| 448 | 659 | } |
| 449 | 660 | wp_redirect($redirect_url); |
| @@ -454,9 +665,9 @@ | ||
| 454 | 665 | |
| 455 | 666 | /* add demo pages */ |
| 456 | 667 | private function demo_pages($purpose = '') { |
| 457 | 668 | |
| 458 | - // 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; | |
| 459 | 670 | |
| 460 | 671 | add_action('wpdirectorykit/elementor-elements/register_widget', function($self){ |
| 461 | 672 | $self->add_widget('Wdk\Elementor\Extensions\WdkContactFormExt'); |
| 462 | 673 | }); |
| @@ -609,9 +820,9 @@ | ||
| 609 | 820 | $this->replace_meta($from, $to); |
| 610 | 821 | |
| 611 | 822 | /* homepage */ |
| 612 | 823 | $from = '2020'; |
| 613 | - $to = date('Y'); | |
| 824 | + $to = gmdate('Y'); | |
| 614 | 825 | $this->replace_meta($from, $to); |
| 615 | 826 | |
| 616 | 827 | |
| 617 | 828 | /* replace in db */ |
| @@ -636,9 +847,9 @@ | ||
| 636 | 847 | /* add demo listing preview page */ |
| 637 | 848 | private function demo_page_listing($purpose = '') { |
| 638 | 849 | |
| 639 | 850 | if((get_option('wdk_listing_page')) && get_post_status(get_option('wdk_listing_page')) =='publish'){ |
| 640 | - $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>'; | |
| 641 | 852 | return false; |
| 642 | 853 | } |
| 643 | 854 | |
| 644 | 855 | add_action('wpdirectorykit/elementor-elements/register_widget', function($self){ |
| @@ -667,8 +878,9 @@ | ||
| 667 | 878 | $self->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 668 | 879 | $self->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| 669 | 880 | $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField'); |
| 670 | 881 | $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar'); |
| 882 | + $self->add_widget('Wdk\Elementor\Widgets\WdkCoolListingCarousel'); | |
| 671 | 883 | }); |
| 672 | 884 | |
| 673 | 885 | // Import elementor templates |
| 674 | 886 | $page_listing_preview = $this->create_page(esc_html__('Listing Preview', 'wpdirectorykit'), '', 'elementor_canvas'); |
| @@ -677,9 +889,9 @@ | ||
| 677 | 889 | // Assign page. |
| 678 | 890 | if($page_listing_preview) |
| 679 | 891 | update_option( 'wdk_listing_page', $page_listing_preview->ID, TRUE); |
| 680 | 892 | |
| 681 | - $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>'; | |
| 682 | 894 | |
| 683 | 895 | return true; |
| 684 | 896 | } |
| 685 | 897 | |
| @@ -686,9 +898,9 @@ | ||
| 686 | 898 | /* add demo results page */ |
| 687 | 899 | private function demo_page_results($purpose = '') { |
| 688 | 900 | |
| 689 | 901 | if((get_option('wdk_results_page')) && get_post_status(get_option('wdk_results_page')) == 'publish'){ |
| 690 | - $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>'; | |
| 691 | 903 | return false; |
| 692 | 904 | } |
| 693 | 905 | |
| 694 | 906 | add_action('wpdirectorykit/elementor-elements/register_widget', function($self){ |
| @@ -717,8 +929,9 @@ | ||
| 717 | 929 | $self->add_widget('Wdk\Elementor\Widgets\WdkListingMap'); |
| 718 | 930 | $self->add_widget('Wdk\Elementor\Widgets\WdkListinAgent'); |
| 719 | 931 | $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentField'); |
| 720 | 932 | $self->add_widget('Wdk\Elementor\Widgets\WdkListingAgentAvatar'); |
| 933 | + $self->add_widget('Wdk\Elementor\Widgets\WdkCoolListingCarousel'); | |
| 721 | 934 | }); |
| 722 | 935 | |
| 723 | 936 | $page_results = $this->create_page(esc_html__('Results Listings', 'wpdirectorykit'), '', 'elementor_canvas'); |
| 724 | 937 | $this->elementor_assign($page_results->ID, 'page-results-listings.json'); |
| @@ -728,9 +941,9 @@ | ||
| 728 | 941 | update_option( 'page_on_front', $page_results->ID ); |
| 729 | 942 | |
| 730 | 943 | update_option( 'wdk_results_page', $page_results->ID, TRUE); |
| 731 | 944 | |
| 732 | - $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>'; | |
| 733 | 946 | |
| 734 | 947 | |
| 735 | 948 | $menus = get_registered_nav_menus(); |
| 736 | 949 | // first menu defined by template |
| @@ -762,8 +975,11 @@ | ||
| 762 | 975 | wp_update_nav_menu_item((int)$menu_id, 0, $itemData); |
| 763 | 976 | |
| 764 | 977 | // assign menu to top menu |
| 765 | 978 | $locations = get_theme_mod( 'nav_menu_locations' ); |
| 979 | + if ( ! is_array( $locations ) ) { | |
| 980 | + $locations = array(); | |
| 981 | + } | |
| 766 | 982 | $locations[$first_menu] = $menu_id; |
| 767 | 983 | set_theme_mod('nav_menu_locations', $locations); |
| 768 | 984 | } |
| 769 | 985 | |
| @@ -903,13 +1119,13 @@ | ||
| 903 | 1119 | $data['idresultitem'] = 1; |
| 904 | 1120 | $insert_id = $this->resultitem_m->insert($data, NULL); |
| 905 | 1121 | } |
| 906 | 1122 | |
| 907 | - $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>'; | |
| 908 | 1124 | return true; |
| 909 | 1125 | } |
| 910 | - | |
| 911 | - $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>'; | |
| 912 | 1128 | return false; |
| 913 | 1129 | |
| 914 | 1130 | } |
| 915 | 1131 | |
| @@ -923,9 +1139,10 @@ | ||
| 923 | 1139 | |
| 924 | 1140 | if(file_exists($this->import_xml_file_locations)) { |
| 925 | 1141 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file_locations)); |
| 926 | 1142 | if(!isset($dom_array['locations']['location']) && empty($dom_array['locations']['location'])) { |
| 927 | - $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>'; | |
| 928 | 1145 | return false; |
| 929 | 1146 | } |
| 930 | 1147 | foreach ($dom_array['locations']['location'] as $key => $location_data) { |
| 931 | 1148 | $this->_recursive_add_locations($location_data); |
| @@ -930,13 +1147,13 @@ | ||
| 930 | 1147 | foreach ($dom_array['locations']['location'] as $key => $location_data) { |
| 931 | 1148 | $this->_recursive_add_locations($location_data); |
| 932 | 1149 | } |
| 933 | 1150 | |
| 934 | - $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>'; | |
| 935 | 1152 | return true; |
| 936 | 1153 | } |
| 937 | - | |
| 938 | - $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>'; | |
| 939 | 1156 | return false; |
| 940 | 1157 | } |
| 941 | 1158 | |
| 942 | 1159 | private function _recursive_add_locations ($data = array(), $parent_id = 0, $level = 0 ) { |
| @@ -990,9 +1207,10 @@ | ||
| 990 | 1207 | |
| 991 | 1208 | if(file_exists($this->import_xml_file)) { |
| 992 | 1209 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file)); |
| 993 | 1210 | if(!isset($dom_array['categories']['category']) && empty($dom_array['categories']['category'])) { |
| 994 | - $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>'; | |
| 995 | 1213 | return false; |
| 996 | 1214 | } |
| 997 | 1215 | |
| 998 | 1216 | foreach ($dom_array['categories']['category'] as $key => $category_data) { |
| @@ -998,13 +1216,24 @@ | ||
| 998 | 1216 | foreach ($dom_array['categories']['category'] as $key => $category_data) { |
| 999 | 1217 | $this->_recursive_add_categories($category_data); |
| 1000 | 1218 | } |
| 1001 | 1219 | |
| 1002 | - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Categories imported').'</div>'; | |
| 1220 | + /* indexes by new order and reorder */ | |
| 1221 | + $results = $this->category_m->get_tree_table(); | |
| 1222 | + $values = array(); | |
| 1223 | + $order_index = 1; | |
| 1224 | + foreach( $results as $item) | |
| 1225 | + { | |
| 1226 | + $values[] = array('order_index' => $order_index, 'idcategory' => $item->idcategory); | |
| 1227 | + $order_index++; | |
| 1228 | + } | |
| 1229 | + $this->db->updateBatch( $this->category_m->_table_name, $values, 'idcategory'); | |
| 1230 | + | |
| 1231 | + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Categories imported', 'wpdirectorykit').'</div>'; | |
| 1003 | 1232 | return true; |
| 1004 | 1233 | } |
| 1005 | - | |
| 1006 | - $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>'; | |
| 1007 | 1236 | return false; |
| 1008 | 1237 | } |
| 1009 | 1238 | |
| 1010 | 1239 | private function _recursive_add_categories ($data = array(), $parent_id = 0, $level = 0 ) { |
| @@ -1121,9 +1350,10 @@ | ||
| 1121 | 1350 | 'order_index' => '', |
| 1122 | 1351 | ); |
| 1123 | 1352 | |
| 1124 | 1353 | if(!isset($dom_array['fields']['field']) && empty($dom_array['fields']['field'])) { |
| 1125 | - $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>'; | |
| 1126 | 1356 | return false; |
| 1127 | 1357 | } |
| 1128 | 1358 | |
| 1129 | 1359 | foreach ($dom_array['fields']['field'] as $key => $field) { |
| @@ -1175,13 +1405,13 @@ | ||
| 1175 | 1405 | if(!empty($insert_id)) |
| 1176 | 1406 | $this->listingfield_m->create_table_column($field_data, $insert_id); |
| 1177 | 1407 | } |
| 1178 | 1408 | |
| 1179 | - $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>'; | |
| 1180 | 1410 | return true; |
| 1181 | 1411 | } |
| 1182 | - | |
| 1183 | - $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>'; | |
| 1184 | 1414 | return false; |
| 1185 | 1415 | } |
| 1186 | 1416 | |
| 1187 | 1417 | private function import_listings($purpose = '') { |
| @@ -1237,9 +1467,10 @@ | ||
| 1237 | 1467 | |
| 1238 | 1468 | if(file_exists($this->import_xml_file)) { |
| 1239 | 1469 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file)); |
| 1240 | 1470 | if(!isset($dom_array['listings']['listing']) && empty($dom_array['listings']['listing'])) { |
| 1241 | - $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>'; | |
| 1242 | 1473 | return false; |
| 1243 | 1474 | } |
| 1244 | 1475 | |
| 1245 | 1476 | /* demo agent add/get if exists */ |
| @@ -1252,12 +1483,12 @@ | ||
| 1252 | 1483 | $location_id = ''; |
| 1253 | 1484 | $category_id = ''; |
| 1254 | 1485 | |
| 1255 | 1486 | if(!empty($categories)) |
| 1256 | - $category_id = $categories[rand(0, count($categories)-1)]; | |
| 1487 | + $category_id = $categories[wp_rand(0, count($categories)-1)]; | |
| 1257 | 1488 | |
| 1258 | 1489 | if(!empty($location)) |
| 1259 | - $location_id = $locations[rand(0, count($locations)-1)]; | |
| 1490 | + $location_id = $locations[wp_rand(0, count($locations)-1)]; | |
| 1260 | 1491 | |
| 1261 | 1492 | $data_listing = array( |
| 1262 | 1493 | 'post_title' => '', |
| 1263 | 1494 | 'post_content' => '', |
| @@ -1267,31 +1498,35 @@ | ||
| 1267 | 1498 | 'lat' => '', |
| 1268 | 1499 | 'listing_images' => '', |
| 1269 | 1500 | 'listing_images_path' => '', |
| 1270 | 1501 | 'listing_images_path_medium' => '', |
| 1271 | - 'date_modified' => date('Y-m-d H:i:s'), | |
| 1502 | + 'date_modified' => gmdate('Y-m-d H:i:s'), | |
| 1272 | 1503 | 'lng' => '', |
| 1273 | 1504 | 'is_featured' => '', |
| 1274 | 1505 | 'is_activated' => '1', |
| 1275 | 1506 | 'is_approved' => '1', |
| 1507 | + 'counter_views' => wp_rand(20,250), | |
| 1276 | 1508 | 'user_id_editor' => NULL, |
| 1277 | 1509 | ); |
| 1278 | - | |
| 1510 | + | |
| 1279 | 1511 | $data_listing = array_intersect_key(array_merge($data_listing, $listing), $data_listing); |
| 1280 | 1512 | array_walk($data_listing, function(&$item){$item = (is_array($item)) ? '' : trim(wmvc_xss_clean($item));}); |
| 1281 | - | |
| 1513 | + | |
| 1282 | 1514 | if(empty(wmvc_show_data('post_title', $data_listing))) { |
| 1283 | 1515 | continue; |
| 1284 | 1516 | } |
| 1285 | 1517 | |
| 1286 | - $hidden_fields_list = wdk_depend_get_hidden_fields($category_id); | |
| 1287 | - | |
| 1518 | + $hidden_fields_list = wdk_depend_get_hidden_fields($data_listing['category_id']); | |
| 1519 | + | |
| 1288 | 1520 | /*fields */ |
| 1521 | + $data_listings_fields = array(); | |
| 1289 | 1522 | foreach($fields as $field_data) { |
| 1290 | - if($hidden_fields_list && strpos(','.$hidden_fields_list.',', ','.$field_data->idfield.',')!==FALSE) continue; | |
| 1523 | + if(!empty($hidden_fields_list) && strpos(','.$hidden_fields_list.',', ','.$field_data->idfield.',')!==FALSE) { | |
| 1524 | + continue; | |
| 1525 | + } | |
| 1291 | 1526 | |
| 1292 | 1527 | if(isset($listing['field_'.$field_data->idfield])) { |
| 1293 | - $data_listing['field_'.$field_data->idfield] = $listing['field_'.$field_data->idfield]; | |
| 1528 | + $data_listings_fields['field_'.$field_data->idfield] = $listing['field_'.$field_data->idfield]; | |
| 1294 | 1529 | } else { |
| 1295 | 1530 | if($field_data->field_type == 'DROPDOWN' || $field_data->field_type == 'DROPDOWN_MULTIPLE') |
| 1296 | 1531 | { |
| 1297 | 1532 | if(empty($field_data->values_list)) continue; |
| @@ -1299,31 +1534,31 @@ | ||
| 1299 | 1534 | if(count($values) > 0) |
| 1300 | 1535 | { |
| 1301 | 1536 | $start=0; |
| 1302 | 1537 | if(empty($values[0]))$start=1; |
| 1303 | - $data_listing['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)]; | |
| 1304 | 1539 | } |
| 1305 | 1540 | } |
| 1306 | 1541 | elseif($field_data->field_type == 'NUMBER') |
| 1307 | 1542 | { |
| 1308 | - $data_listing['field_'.$field_data->idfield] = rand(2,499); | |
| 1543 | + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(2,499); | |
| 1309 | 1544 | |
| 1310 | 1545 | } |
| 1311 | 1546 | elseif($field_data->field_type == 'CHECKBOX') |
| 1312 | 1547 | { |
| 1313 | - $data_listing['field_'.$field_data->idfield] = rand(0,1); | |
| 1548 | + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(0,1); | |
| 1314 | 1549 | } |
| 1315 | 1550 | elseif($field_data->field_type == 'TEXTAREA') |
| 1316 | 1551 | { |
| 1317 | - //$data_listing['field_'.$field_data->idfield] = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.'; | |
| 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.'; | |
| 1318 | 1553 | } |
| 1319 | 1554 | } |
| 1320 | 1555 | } |
| 1321 | 1556 | |
| 1322 | 1557 | /* add files */ |
| 1323 | - $count_images = 2; | |
| 1558 | + | |
| 1324 | 1559 | if($purpose == 'car-dealer.xml') { |
| 1325 | - $count_images = 1; | |
| 1560 | + $this->import_count_images = 1; | |
| 1326 | 1561 | } |
| 1327 | 1562 | if(isset($listing['images']) && !empty($listing['images'])) { |
| 1328 | 1563 | |
| 1329 | 1564 | foreach (explode(',', $listing['images']) as $key => $file_name) { |
| @@ -1352,9 +1587,9 @@ | ||
| 1352 | 1587 | } |
| 1353 | 1588 | |
| 1354 | 1589 | $image_url = wp_get_attachment_image_url($image_id, 'large'); |
| 1355 | 1590 | if($image_url) { |
| 1356 | - $parsed = parse_url($image_url); | |
| 1591 | + $parsed = wp_parse_url($image_url); | |
| 1357 | 1592 | $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8); |
| 1358 | 1593 | |
| 1359 | 1594 | if(!empty($data_listing['listing_images_path_medium'])) |
| 1360 | 1595 | $data_listing['listing_images_path_medium'] .= ','; |
| @@ -1364,9 +1599,9 @@ | ||
| 1364 | 1599 | } |
| 1365 | 1600 | |
| 1366 | 1601 | } else { |
| 1367 | 1602 | /* auto import images */ |
| 1368 | - 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++) { | |
| 1369 | 1604 | if($image_num >= count($files)) |
| 1370 | 1605 | $image_num = 0; |
| 1371 | 1606 | |
| 1372 | 1607 | if(!empty($data_listing['listing_images'])) |
| @@ -1393,9 +1628,9 @@ | ||
| 1393 | 1628 | } |
| 1394 | 1629 | |
| 1395 | 1630 | $image_url = wp_get_attachment_image_url($image_id, 'large'); |
| 1396 | 1631 | if($image_url) { |
| 1397 | - $parsed = parse_url($image_url); | |
| 1632 | + $parsed = wp_parse_url($image_url); | |
| 1398 | 1633 | $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8); |
| 1399 | 1634 | |
| 1400 | 1635 | if(!empty($data_listing['listing_images_path_medium'])) |
| 1401 | 1636 | $data_listing['listing_images_path_medium'] .= ','; |
| @@ -1404,9 +1639,8 @@ | ||
| 1404 | 1639 | } |
| 1405 | 1640 | } |
| 1406 | 1641 | } |
| 1407 | 1642 | |
| 1408 | - | |
| 1409 | 1643 | // Create post object |
| 1410 | 1644 | $listing_post = array( |
| 1411 | 1645 | 'ID' => NULL, |
| 1412 | 1646 | 'post_type' => 'wdk-listing', |
| @@ -1425,19 +1659,22 @@ | ||
| 1425 | 1659 | if(isset( $data_listing[$field_name])) |
| 1426 | 1660 | $listing_data[$field_name] = $data_listing[$field_name]; |
| 1427 | 1661 | } |
| 1428 | 1662 | $listing_data['user_id_editor'] = $user_ids[array_rand($user_ids)]; |
| 1429 | - | |
| 1663 | + $listing_data['date_modified'] = gmdate('Y-m-d H:i:s'); | |
| 1664 | + $listing_data['counter_views'] = wp_rand(20,250); | |
| 1665 | + | |
| 1430 | 1666 | $this->listing_m->insert($listing_data, NULL); |
| 1431 | 1667 | |
| 1432 | - $data_listing['post_id'] = $id; | |
| 1433 | - $this->listingfield_m->insert_custom_fields($fields, $data_listing, NULL); | |
| 1668 | + $data_listings_fields['post_id'] = $id; | |
| 1669 | + $this->listingfield_m->insert_custom_fields($fields, $data_listings_fields, NULL); | |
| 1434 | 1670 | } |
| 1435 | - $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listings imported').'</div>'; | |
| 1671 | + | |
| 1672 | + $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listings imported', 'wpdirectorykit').'</div>'; | |
| 1436 | 1673 | return true; |
| 1437 | 1674 | } |
| 1438 | - | |
| 1439 | - $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>'; | |
| 1440 | 1677 | return false; |
| 1441 | 1678 | } |
| 1442 | 1679 | |
| 1443 | 1680 | protected function xmlstr_to_array($xmlstr) { |
| @@ -1502,10 +1739,10 @@ | ||
| 1502 | 1739 | wdk_access_check('settings_m', 1); |
| 1503 | 1740 | |
| 1504 | 1741 | // Check _wpnonce |
| 1505 | 1742 | check_admin_referer( 'wdk-import-data-run', '_wpnonce' ); |
| 1743 | + update_option('wdk_install_images_sizes_disable', 1); | |
| 1506 | 1744 | |
| 1507 | - | |
| 1508 | 1745 | ini_set('max_execution_time', 900); |
| 1509 | 1746 | $this->data['import_log'] = ''; |
| 1510 | 1747 | $multipurpose = 'real-estate.xml'; |
| 1511 | 1748 | if(isset($_GET['multipurpose'])) |
| @@ -1514,14 +1751,14 @@ | ||
| 1514 | 1751 | $redirect_url = admin_url("admin.php?page=wdk_fields&is_updated"); |
| 1515 | 1752 | if(isset($_GET['redirect_url']) && strpos($_GET['redirect_url'], 'http') === FALSE && strpos($_GET['redirect_url'], '//') === FALSE) |
| 1516 | 1753 | $redirect_url = admin_url(sanitize_text_field($_GET['redirect_url'])); |
| 1517 | 1754 | |
| 1518 | - | |
| 1519 | 1755 | $this->import_xml_file = WPDIRECTORYKIT_PATH.'demo-data/'.$multipurpose; |
| 1520 | 1756 | $this->import_images_dir = apply_filters('wdk/settings/import/api_run/import_images_dir', $this->import_images_dir, $multipurpose); |
| 1521 | 1757 | $this->import_xml_file = apply_filters('wdk/settings/import/api_run/import_xml_file', $this->import_xml_file, $multipurpose); |
| 1522 | 1758 | $this->import_xml_file_locations = apply_filters('wdk/settings/import/api_run/import_xml_file_locations', $this->import_xml_file_locations, $multipurpose); |
| 1523 | 1759 | |
| 1760 | + | |
| 1524 | 1761 | $this->import_locations(); |
| 1525 | 1762 | $this->import_categories($multipurpose); |
| 1526 | 1763 | $this->import_fields($multipurpose); |
| 1527 | 1764 | $this->import_listings($multipurpose); |
| @@ -1527,10 +1764,14 @@ | ||
| 1527 | 1764 | $this->import_listings($multipurpose); |
| 1528 | 1765 | $this->import_visual_data($multipurpose); |
| 1529 | 1766 | $this->demo_pages($multipurpose); |
| 1530 | 1767 | |
| 1531 | - $message = str_replace(" ", '+', __('Import completed successfuly', 'wpdirectorykit')); | |
| 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>'); | |
| 1532 | 1769 | |
| 1770 | + do_action('wpdirectorykit/install/api'); | |
| 1771 | + do_action('wdk/settings/import/api_run', $multipurpose); | |
| 1772 | + update_option('wdk_install_images_sizes_disable', 0); | |
| 1773 | + | |
| 1533 | 1774 | wp_redirect($redirect_url.'&message='.$message); |
| 1534 | 1775 | exit; |
| 1535 | 1776 | } |
| 1536 | 1777 | |
| @@ -1536,9 +1777,9 @@ | ||
| 1536 | 1777 | |
| 1537 | 1778 | public function api_import() |
| 1538 | 1779 | { |
| 1539 | 1780 | wdk_access_check('settings_m', 1); |
| 1540 | - | |
| 1781 | + update_option('wdk_install_images_sizes_disable', 1); | |
| 1541 | 1782 | /* block url access */ |
| 1542 | 1783 | if( |
| 1543 | 1784 | (isset($_GET['function']) && $_GET['function'] == 'api_import' ) || |
| 1544 | 1785 | (isset($_POST['function']) && $_POST['function'] == 'api_import' ) |
| @@ -1567,15 +1808,19 @@ | ||
| 1567 | 1808 | $this->import_settings(); |
| 1568 | 1809 | |
| 1569 | 1810 | /* action */ |
| 1570 | 1811 | do_action('wpdirectorykit/install/api'); |
| 1571 | - | |
| 1812 | + do_action('wdk/settings/import/api_run', $multipurpose); | |
| 1813 | + update_option('wdk_install_images_sizes_disable', 0); | |
| 1572 | 1814 | return true; |
| 1573 | 1815 | } |
| 1574 | 1816 | |
| 1575 | - public function _api_import() | |
| 1817 | + public function _api_import($import_count_images = 2) | |
| 1576 | 1818 | { |
| 1819 | + $this->import_count_images = $import_count_images; | |
| 1820 | + | |
| 1577 | 1821 | wdk_access_check('settings_m', 1); |
| 1822 | + update_option('wdk_install_images_sizes_disable', 1); | |
| 1578 | 1823 | ini_set('max_execution_time', 900); |
| 1579 | 1824 | $this->data['import_log'] = ''; |
| 1580 | 1825 | $multipurpose = 'real-estate.xml'; |
| 1581 | 1826 | if(isset($_GET['multipurpose'])) |
| @@ -1594,9 +1839,10 @@ | ||
| 1594 | 1839 | $this->import_settings(); |
| 1595 | 1840 | |
| 1596 | 1841 | /* action */ |
| 1597 | 1842 | do_action('wpdirectorykit/install/api'); |
| 1598 | - | |
| 1843 | + do_action('wdk/settings/import/api_run', $multipurpose); | |
| 1844 | + update_option('wdk_install_images_sizes_disable', 0); | |
| 1599 | 1845 | return true; |
| 1600 | 1846 | } |
| 1601 | 1847 | |
| 1602 | 1848 | private function replace_meta($from = '', $to = '') { |
| @@ -1614,12 +1860,19 @@ | ||
| 1614 | 1860 | |
| 1615 | 1861 | update_option( 'wdk_is_category_enabled', '1' ); |
| 1616 | 1862 | update_option( 'wdk_is_location_enabled', '1' ); |
| 1617 | 1863 | update_option( 'wdk_is_address_enabled', '1' ); |
| 1618 | - update_option( 'wdk_is_results_page_require', '1' ); | |
| 1864 | + update_option( 'wdk_is_results_page_require', 0 ); | |
| 1619 | 1865 | update_option( 'wdk_seo_description', '2' ); |
| 1620 | 1866 | update_option( 'wdk_seo_keywords', '3' ); |
| 1621 | 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 | + | |
| 1622 | 1875 | return true; |
| 1623 | 1876 | } |
| 1624 | 1877 | |
| 1625 | 1878 | /* add demo listing preview page */ |
| @@ -1629,9 +1882,9 @@ | ||
| 1629 | 1882 | $page_title_message = $custom_message_title; |
| 1630 | 1883 | } |
| 1631 | 1884 | |
| 1632 | 1885 | if(!empty($option) && (get_option($option)) && get_post_status(get_option($option)) =='publish'){ |
| 1633 | - // $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>'; | |
| 1634 | 1887 | // return false; |
| 1635 | 1888 | } |
| 1636 | 1889 | |
| 1637 | 1890 | add_action('wdk-membership/elementor-elements/register_widget', function($self){ |
| @@ -1667,9 +1920,9 @@ | ||
| 1667 | 1920 | // Assign page. |
| 1668 | 1921 | if($page && !empty($option)) |
| 1669 | 1922 | update_option( $option, $page->ID, TRUE); |
| 1670 | 1923 | |
| 1671 | - $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>'; | |
| 1672 | 1925 | |
| 1673 | 1926 | return $page->ID; |
| 1674 | 1927 | } |
| 1675 | 1928 | |
| @@ -1751,5 +2004,6 @@ | ||
| 1751 | 2004 | $document = Elementor\Plugin::$instance->documents->get( $page_id, false ); |
| 1752 | 2005 | // @codingStandardsIgnoreEnd |
| 1753 | 2006 | return $document->save( $data ); |
| 1754 | 2007 | } |
| 2008 | + | |
| 1755 | 2009 | } |