| @@ -101,9 +101,18 @@ | ||
| 101 | 101 | { |
| 102 | 102 | |
| 103 | 103 | // Create the destination directory if it doesn't exist |
| 104 | 104 | if (!is_dir(get_stylesheet_directory().'/wpdirectorykit/application/views/email/')) { |
| 105 | - mkdir(get_stylesheet_directory().'/wpdirectorykit/application/views/email/', 0777, true); | |
| 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 | + | |
| 106 | 115 | } |
| 107 | 116 | |
| 108 | 117 | $destinationFile = get_stylesheet_directory().'/wpdirectorykit/application/views/email/'.$view_file.'.php'; |
| 109 | 118 | copy($sourceFile, $destinationFile); |
| @@ -111,9 +120,18 @@ | ||
| 111 | 120 | elseif(!is_child_theme() && !file_exists(get_template_directory().'/wpdirectorykit/application/views/email/'.$view_file.'.php')) |
| 112 | 121 | { |
| 113 | 122 | // Create the destination directory if it doesn't exist |
| 114 | 123 | if (!is_dir(get_template_directory().'/wpdirectorykit/application/views/email/')) { |
| 115 | - mkdir(get_template_directory().'/wpdirectorykit/application/views/email/', 0777, true); | |
| 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 | + | |
| 116 | 134 | } |
| 117 | 135 | |
| 118 | 136 | $destinationFile = get_template_directory().'/wpdirectorykit/application/views/email/'.$view_file.'.php'; |
| 119 | 137 | copy($sourceFile, $destinationFile); |
| @@ -254,8 +272,13 @@ | ||
| 254 | 272 | array( |
| 255 | 273 | 'description' => __('User Email Confirm request','wpdirectorykit').'<br>'.'<em>Data vars $subject(string), $data(sting|array)</em>', |
| 256 | 274 | 'template' => 'wdk_membership_confirm_email_user_request', |
| 257 | 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 | + | |
| 258 | 281 | ); |
| 259 | 282 | } |
| 260 | 283 | |
| 261 | 284 | function reset_data () { |
| @@ -324,9 +347,9 @@ | ||
| 324 | 347 | } |
| 325 | 348 | |
| 326 | 349 | $redirect_url = admin_url("admin.php?page=wdk_settings&is_updated"); |
| 327 | 350 | if(isset($_GET['redirect_url']) && strpos($_GET['redirect_url'], 'http') === FALSE && strpos($_GET['redirect_url'], '//') === FALSE) |
| 328 | - $redirect_url = admin_url(sanitize_text_field($_GET['redirect_url'])); | |
| 351 | + $redirect_url = admin_url(sanitize_text_field(wp_unslash($_GET['redirect_url']))); | |
| 329 | 352 | |
| 330 | 353 | wp_redirect($redirect_url); |
| 331 | 354 | exit; |
| 332 | 355 | } |
| @@ -425,9 +448,9 @@ | ||
| 425 | 448 | |
| 426 | 449 | $this->data['db_data']['multipurpose'] = 'real-estate.xml'; |
| 427 | 450 | |
| 428 | 451 | if(isset($_GET['multipurpose'])) |
| 429 | - $this->data['db_data']['multipurpose'] = sanitize_text_field($_GET['multipurpose']); | |
| 452 | + $this->data['db_data']['multipurpose'] = sanitize_text_field(wp_unslash($_GET['multipurpose'])); | |
| 430 | 453 | |
| 431 | 454 | $this->data['import_log'] = ''; |
| 432 | 455 | $this->data['info_log_message'] = ''; |
| 433 | 456 | |
| @@ -475,9 +498,9 @@ | ||
| 475 | 498 | ); |
| 476 | 499 | |
| 477 | 500 | $plugin = 'elementor/elementor.php'; |
| 478 | 501 | if (in_array( $plugin, apply_filters( 'active_plugins', get_option( 'active_plugins' ))) && !class_exists('Elementor\Plugin') ) { |
| 479 | - $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>'; | |
| 480 | 503 | $this->data['required_plugins'] = true; |
| 481 | 504 | } |
| 482 | 505 | |
| 483 | 506 | if(!$this->data['required_plugins']) |
| @@ -571,9 +594,9 @@ | ||
| 571 | 594 | |
| 572 | 595 | /* remove fields */ |
| 573 | 596 | $this->db->delete($this->location_m->_table_name); |
| 574 | 597 | |
| 575 | - $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>'; | |
| 576 | 599 | /* end remove fields */ |
| 577 | 600 | |
| 578 | 601 | /* remove fields */ |
| 579 | 602 | $this->db->delete($this->category_m->_table_name); |
| @@ -578,9 +601,9 @@ | ||
| 578 | 601 | /* remove fields */ |
| 579 | 602 | $this->db->delete($this->category_m->_table_name); |
| 580 | 603 | $this->db->delete($this->dependfields_m->_table_name); |
| 581 | 604 | |
| 582 | - $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>'; | |
| 583 | 606 | /* end remove fields */ |
| 584 | 607 | |
| 585 | 608 | /* remove fields */ |
| 586 | 609 | $this->db->delete($this->field_m->_table_name); |
| @@ -589,9 +612,9 @@ | ||
| 589 | 612 | if(strpos($field_name, 'field_') ===FALSE) continue; |
| 590 | 613 | $this->db->query('ALTER TABLE '.$this->listingfield_m->_table_name.' DROP COLUMN '.$field_name.''); |
| 591 | 614 | } |
| 592 | 615 | |
| 593 | - $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>'; | |
| 594 | 617 | /* end remove fields */ |
| 595 | 618 | |
| 596 | 619 | /* remove listings */ |
| 597 | 620 | $this->db->delete($this->listing_m->_table_name); |
| @@ -596,9 +619,9 @@ | ||
| 596 | 619 | /* remove listings */ |
| 597 | 620 | $this->db->delete($this->listing_m->_table_name); |
| 598 | 621 | $this->db->delete($this->listingfield_m->_table_name); |
| 599 | 622 | |
| 600 | - $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>'; | |
| 601 | 624 | /* end remove listings */ |
| 602 | 625 | |
| 603 | 626 | |
| 604 | 627 | /* remove listings */ |
| @@ -603,9 +626,9 @@ | ||
| 603 | 626 | |
| 604 | 627 | /* remove listings */ |
| 605 | 628 | $this->db->delete($this->resultitem_m->_table_name); |
| 606 | 629 | $this->db->delete($this->searchform_m->_table_name); |
| 607 | - $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>'; | |
| 608 | 631 | /* end remove listings */ |
| 609 | 632 | |
| 610 | 633 | |
| 611 | 634 | /* reset autoincrement */ |
| @@ -617,9 +640,9 @@ | ||
| 617 | 640 | $this->db->query('TRUNCATE TABLE `'.$this->listing_m->_table_name.'`'); |
| 618 | 641 | $this->db->query('TRUNCATE TABLE `'.$this->resultitem_m->_table_name.'`'); |
| 619 | 642 | $this->db->query('TRUNCATE TABLE `'.$this->searchform_m->_table_name.'`'); |
| 620 | 643 | |
| 621 | - $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>'; | |
| 622 | 645 | /* end reset autoincrement */ |
| 623 | 646 | |
| 624 | 647 | $wdk_posts = get_posts( array( 'post_type' => 'wdk-listing', 'numberposts' => -1)); |
| 625 | 648 | foreach( $wdk_posts as $post ) { |
| @@ -797,9 +820,9 @@ | ||
| 797 | 820 | $this->replace_meta($from, $to); |
| 798 | 821 | |
| 799 | 822 | /* homepage */ |
| 800 | 823 | $from = '2020'; |
| 801 | - $to = date('Y'); | |
| 824 | + $to = gmdate('Y'); | |
| 802 | 825 | $this->replace_meta($from, $to); |
| 803 | 826 | |
| 804 | 827 | |
| 805 | 828 | /* replace in db */ |
| @@ -824,9 +847,9 @@ | ||
| 824 | 847 | /* add demo listing preview page */ |
| 825 | 848 | private function demo_page_listing($purpose = '') { |
| 826 | 849 | |
| 827 | 850 | if((get_option('wdk_listing_page')) && get_post_status(get_option('wdk_listing_page')) =='publish'){ |
| 828 | - $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>'; | |
| 829 | 852 | return false; |
| 830 | 853 | } |
| 831 | 854 | |
| 832 | 855 | add_action('wpdirectorykit/elementor-elements/register_widget', function($self){ |
| @@ -866,9 +889,9 @@ | ||
| 866 | 889 | // Assign page. |
| 867 | 890 | if($page_listing_preview) |
| 868 | 891 | update_option( 'wdk_listing_page', $page_listing_preview->ID, TRUE); |
| 869 | 892 | |
| 870 | - $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>'; | |
| 871 | 894 | |
| 872 | 895 | return true; |
| 873 | 896 | } |
| 874 | 897 | |
| @@ -875,9 +898,9 @@ | ||
| 875 | 898 | /* add demo results page */ |
| 876 | 899 | private function demo_page_results($purpose = '') { |
| 877 | 900 | |
| 878 | 901 | if((get_option('wdk_results_page')) && get_post_status(get_option('wdk_results_page')) == 'publish'){ |
| 879 | - $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>'; | |
| 880 | 903 | return false; |
| 881 | 904 | } |
| 882 | 905 | |
| 883 | 906 | add_action('wpdirectorykit/elementor-elements/register_widget', function($self){ |
| @@ -918,9 +941,9 @@ | ||
| 918 | 941 | update_option( 'page_on_front', $page_results->ID ); |
| 919 | 942 | |
| 920 | 943 | update_option( 'wdk_results_page', $page_results->ID, TRUE); |
| 921 | 944 | |
| 922 | - $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>'; | |
| 923 | 946 | |
| 924 | 947 | |
| 925 | 948 | $menus = get_registered_nav_menus(); |
| 926 | 949 | // first menu defined by template |
| @@ -1096,13 +1119,13 @@ | ||
| 1096 | 1119 | $data['idresultitem'] = 1; |
| 1097 | 1120 | $insert_id = $this->resultitem_m->insert($data, NULL); |
| 1098 | 1121 | } |
| 1099 | 1122 | |
| 1100 | - $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>'; | |
| 1101 | 1124 | return true; |
| 1102 | 1125 | } |
| 1103 | - | |
| 1104 | - $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>'; | |
| 1105 | 1128 | return false; |
| 1106 | 1129 | |
| 1107 | 1130 | } |
| 1108 | 1131 | |
| @@ -1116,9 +1139,10 @@ | ||
| 1116 | 1139 | |
| 1117 | 1140 | if(file_exists($this->import_xml_file_locations)) { |
| 1118 | 1141 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file_locations)); |
| 1119 | 1142 | if(!isset($dom_array['locations']['location']) && empty($dom_array['locations']['location'])) { |
| 1120 | - $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>'; | |
| 1121 | 1145 | return false; |
| 1122 | 1146 | } |
| 1123 | 1147 | foreach ($dom_array['locations']['location'] as $key => $location_data) { |
| 1124 | 1148 | $this->_recursive_add_locations($location_data); |
| @@ -1123,13 +1147,13 @@ | ||
| 1123 | 1147 | foreach ($dom_array['locations']['location'] as $key => $location_data) { |
| 1124 | 1148 | $this->_recursive_add_locations($location_data); |
| 1125 | 1149 | } |
| 1126 | 1150 | |
| 1127 | - $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>'; | |
| 1128 | 1152 | return true; |
| 1129 | 1153 | } |
| 1130 | - | |
| 1131 | - $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>'; | |
| 1132 | 1156 | return false; |
| 1133 | 1157 | } |
| 1134 | 1158 | |
| 1135 | 1159 | private function _recursive_add_locations ($data = array(), $parent_id = 0, $level = 0 ) { |
| @@ -1183,9 +1207,10 @@ | ||
| 1183 | 1207 | |
| 1184 | 1208 | if(file_exists($this->import_xml_file)) { |
| 1185 | 1209 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file)); |
| 1186 | 1210 | if(!isset($dom_array['categories']['category']) && empty($dom_array['categories']['category'])) { |
| 1187 | - $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>'; | |
| 1188 | 1213 | return false; |
| 1189 | 1214 | } |
| 1190 | 1215 | |
| 1191 | 1216 | foreach ($dom_array['categories']['category'] as $key => $category_data) { |
| @@ -1202,13 +1227,13 @@ | ||
| 1202 | 1227 | $order_index++; |
| 1203 | 1228 | } |
| 1204 | 1229 | $this->db->updateBatch( $this->category_m->_table_name, $values, 'idcategory'); |
| 1205 | 1230 | |
| 1206 | - $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>'; | |
| 1207 | 1232 | return true; |
| 1208 | 1233 | } |
| 1209 | - | |
| 1210 | - $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>'; | |
| 1211 | 1236 | return false; |
| 1212 | 1237 | } |
| 1213 | 1238 | |
| 1214 | 1239 | private function _recursive_add_categories ($data = array(), $parent_id = 0, $level = 0 ) { |
| @@ -1325,9 +1350,10 @@ | ||
| 1325 | 1350 | 'order_index' => '', |
| 1326 | 1351 | ); |
| 1327 | 1352 | |
| 1328 | 1353 | if(!isset($dom_array['fields']['field']) && empty($dom_array['fields']['field'])) { |
| 1329 | - $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>'; | |
| 1330 | 1356 | return false; |
| 1331 | 1357 | } |
| 1332 | 1358 | |
| 1333 | 1359 | foreach ($dom_array['fields']['field'] as $key => $field) { |
| @@ -1379,13 +1405,13 @@ | ||
| 1379 | 1405 | if(!empty($insert_id)) |
| 1380 | 1406 | $this->listingfield_m->create_table_column($field_data, $insert_id); |
| 1381 | 1407 | } |
| 1382 | 1408 | |
| 1383 | - $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>'; | |
| 1384 | 1410 | return true; |
| 1385 | 1411 | } |
| 1386 | - | |
| 1387 | - $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>'; | |
| 1388 | 1414 | return false; |
| 1389 | 1415 | } |
| 1390 | 1416 | |
| 1391 | 1417 | private function import_listings($purpose = '') { |
| @@ -1441,9 +1467,10 @@ | ||
| 1441 | 1467 | |
| 1442 | 1468 | if(file_exists($this->import_xml_file)) { |
| 1443 | 1469 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file)); |
| 1444 | 1470 | if(!isset($dom_array['listings']['listing']) && empty($dom_array['listings']['listing'])) { |
| 1445 | - $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>'; | |
| 1446 | 1473 | return false; |
| 1447 | 1474 | } |
| 1448 | 1475 | |
| 1449 | 1476 | /* demo agent add/get if exists */ |
| @@ -1456,12 +1483,12 @@ | ||
| 1456 | 1483 | $location_id = ''; |
| 1457 | 1484 | $category_id = ''; |
| 1458 | 1485 | |
| 1459 | 1486 | if(!empty($categories)) |
| 1460 | - $category_id = $categories[rand(0, count($categories)-1)]; | |
| 1487 | + $category_id = $categories[wp_rand(0, count($categories)-1)]; | |
| 1461 | 1488 | |
| 1462 | 1489 | if(!empty($location)) |
| 1463 | - $location_id = $locations[rand(0, count($locations)-1)]; | |
| 1490 | + $location_id = $locations[wp_rand(0, count($locations)-1)]; | |
| 1464 | 1491 | |
| 1465 | 1492 | $data_listing = array( |
| 1466 | 1493 | 'post_title' => '', |
| 1467 | 1494 | 'post_content' => '', |
| @@ -1471,14 +1498,14 @@ | ||
| 1471 | 1498 | 'lat' => '', |
| 1472 | 1499 | 'listing_images' => '', |
| 1473 | 1500 | 'listing_images_path' => '', |
| 1474 | 1501 | 'listing_images_path_medium' => '', |
| 1475 | - 'date_modified' => date('Y-m-d H:i:s'), | |
| 1502 | + 'date_modified' => gmdate('Y-m-d H:i:s'), | |
| 1476 | 1503 | 'lng' => '', |
| 1477 | 1504 | 'is_featured' => '', |
| 1478 | 1505 | 'is_activated' => '1', |
| 1479 | 1506 | 'is_approved' => '1', |
| 1480 | - 'counter_views' => rand(20,250), | |
| 1507 | + 'counter_views' => wp_rand(20,250), | |
| 1481 | 1508 | 'user_id_editor' => NULL, |
| 1482 | 1509 | ); |
| 1483 | 1510 | |
| 1484 | 1511 | $data_listing = array_intersect_key(array_merge($data_listing, $listing), $data_listing); |
| @@ -1507,19 +1534,19 @@ | ||
| 1507 | 1534 | if(count($values) > 0) |
| 1508 | 1535 | { |
| 1509 | 1536 | $start=0; |
| 1510 | 1537 | if(empty($values[0]))$start=1; |
| 1511 | - $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)]; | |
| 1512 | 1539 | } |
| 1513 | 1540 | } |
| 1514 | 1541 | elseif($field_data->field_type == 'NUMBER') |
| 1515 | 1542 | { |
| 1516 | - $data_listings_fields['field_'.$field_data->idfield] = rand(2,499); | |
| 1543 | + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(2,499); | |
| 1517 | 1544 | |
| 1518 | 1545 | } |
| 1519 | 1546 | elseif($field_data->field_type == 'CHECKBOX') |
| 1520 | 1547 | { |
| 1521 | - $data_listings_fields['field_'.$field_data->idfield] = rand(0,1); | |
| 1548 | + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(0,1); | |
| 1522 | 1549 | } |
| 1523 | 1550 | elseif($field_data->field_type == 'TEXTAREA') |
| 1524 | 1551 | { |
| 1525 | 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.'; |
| @@ -1560,9 +1587,9 @@ | ||
| 1560 | 1587 | } |
| 1561 | 1588 | |
| 1562 | 1589 | $image_url = wp_get_attachment_image_url($image_id, 'large'); |
| 1563 | 1590 | if($image_url) { |
| 1564 | - $parsed = parse_url($image_url); | |
| 1591 | + $parsed = wp_parse_url($image_url); | |
| 1565 | 1592 | $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8); |
| 1566 | 1593 | |
| 1567 | 1594 | if(!empty($data_listing['listing_images_path_medium'])) |
| 1568 | 1595 | $data_listing['listing_images_path_medium'] .= ','; |
| @@ -1601,9 +1628,9 @@ | ||
| 1601 | 1628 | } |
| 1602 | 1629 | |
| 1603 | 1630 | $image_url = wp_get_attachment_image_url($image_id, 'large'); |
| 1604 | 1631 | if($image_url) { |
| 1605 | - $parsed = parse_url($image_url); | |
| 1632 | + $parsed = wp_parse_url($image_url); | |
| 1606 | 1633 | $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8); |
| 1607 | 1634 | |
| 1608 | 1635 | if(!empty($data_listing['listing_images_path_medium'])) |
| 1609 | 1636 | $data_listing['listing_images_path_medium'] .= ','; |
| @@ -1632,10 +1659,10 @@ | ||
| 1632 | 1659 | if(isset( $data_listing[$field_name])) |
| 1633 | 1660 | $listing_data[$field_name] = $data_listing[$field_name]; |
| 1634 | 1661 | } |
| 1635 | 1662 | $listing_data['user_id_editor'] = $user_ids[array_rand($user_ids)]; |
| 1636 | - $listing_data['date_modified'] = date('Y-m-d H:i:s'); | |
| 1637 | - $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); | |
| 1638 | 1665 | |
| 1639 | 1666 | $this->listing_m->insert($listing_data, NULL); |
| 1640 | 1667 | |
| 1641 | 1668 | $data_listings_fields['post_id'] = $id; |
| @@ -1641,13 +1668,13 @@ | ||
| 1641 | 1668 | $data_listings_fields['post_id'] = $id; |
| 1642 | 1669 | $this->listingfield_m->insert_custom_fields($fields, $data_listings_fields, NULL); |
| 1643 | 1670 | } |
| 1644 | 1671 | |
| 1645 | - $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>'; | |
| 1646 | 1673 | return true; |
| 1647 | 1674 | } |
| 1648 | - | |
| 1649 | - $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>'; | |
| 1650 | 1677 | return false; |
| 1651 | 1678 | } |
| 1652 | 1679 | |
| 1653 | 1680 | protected function xmlstr_to_array($xmlstr) { |