| @@ -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); |
| @@ -802,9 +820,9 @@ | ||
| 802 | 820 | $this->replace_meta($from, $to); |
| 803 | 821 | |
| 804 | 822 | /* homepage */ |
| 805 | 823 | $from = '2020'; |
| 806 | - $to = date('Y'); | |
| 824 | + $to = gmdate('Y'); | |
| 807 | 825 | $this->replace_meta($from, $to); |
| 808 | 826 | |
| 809 | 827 | |
| 810 | 828 | /* replace in db */ |
| @@ -1104,10 +1122,10 @@ | ||
| 1104 | 1122 | |
| 1105 | 1123 | $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Search Form & Result Card imported', 'wpdirectorykit').'</div>'; |
| 1106 | 1124 | return true; |
| 1107 | 1125 | } |
| 1108 | - | |
| 1109 | - $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>'; | |
| 1110 | 1128 | return false; |
| 1111 | 1129 | |
| 1112 | 1130 | } |
| 1113 | 1131 | |
| @@ -1121,9 +1139,10 @@ | ||
| 1121 | 1139 | |
| 1122 | 1140 | if(file_exists($this->import_xml_file_locations)) { |
| 1123 | 1141 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file_locations)); |
| 1124 | 1142 | if(!isset($dom_array['locations']['location']) && empty($dom_array['locations']['location'])) { |
| 1125 | - $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>'; | |
| 1126 | 1145 | return false; |
| 1127 | 1146 | } |
| 1128 | 1147 | foreach ($dom_array['locations']['location'] as $key => $location_data) { |
| 1129 | 1148 | $this->_recursive_add_locations($location_data); |
| @@ -1131,10 +1150,10 @@ | ||
| 1131 | 1150 | |
| 1132 | 1151 | $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Locations imported', 'wpdirectorykit').'</div>'; |
| 1133 | 1152 | return true; |
| 1134 | 1153 | } |
| 1135 | - | |
| 1136 | - $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>'; | |
| 1137 | 1156 | return false; |
| 1138 | 1157 | } |
| 1139 | 1158 | |
| 1140 | 1159 | private function _recursive_add_locations ($data = array(), $parent_id = 0, $level = 0 ) { |
| @@ -1188,9 +1207,10 @@ | ||
| 1188 | 1207 | |
| 1189 | 1208 | if(file_exists($this->import_xml_file)) { |
| 1190 | 1209 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file)); |
| 1191 | 1210 | if(!isset($dom_array['categories']['category']) && empty($dom_array['categories']['category'])) { |
| 1192 | - $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>'; | |
| 1193 | 1213 | return false; |
| 1194 | 1214 | } |
| 1195 | 1215 | |
| 1196 | 1216 | foreach ($dom_array['categories']['category'] as $key => $category_data) { |
| @@ -1210,10 +1230,10 @@ | ||
| 1210 | 1230 | |
| 1211 | 1231 | $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Categories imported', 'wpdirectorykit').'</div>'; |
| 1212 | 1232 | return true; |
| 1213 | 1233 | } |
| 1214 | - | |
| 1215 | - $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>'; | |
| 1216 | 1236 | return false; |
| 1217 | 1237 | } |
| 1218 | 1238 | |
| 1219 | 1239 | private function _recursive_add_categories ($data = array(), $parent_id = 0, $level = 0 ) { |
| @@ -1330,9 +1350,10 @@ | ||
| 1330 | 1350 | 'order_index' => '', |
| 1331 | 1351 | ); |
| 1332 | 1352 | |
| 1333 | 1353 | if(!isset($dom_array['fields']['field']) && empty($dom_array['fields']['field'])) { |
| 1334 | - $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>'; | |
| 1335 | 1356 | return false; |
| 1336 | 1357 | } |
| 1337 | 1358 | |
| 1338 | 1359 | foreach ($dom_array['fields']['field'] as $key => $field) { |
| @@ -1387,10 +1408,10 @@ | ||
| 1387 | 1408 | |
| 1388 | 1409 | $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Fields imported', 'wpdirectorykit').'</div>'; |
| 1389 | 1410 | return true; |
| 1390 | 1411 | } |
| 1391 | - | |
| 1392 | - $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>'; | |
| 1393 | 1414 | return false; |
| 1394 | 1415 | } |
| 1395 | 1416 | |
| 1396 | 1417 | private function import_listings($purpose = '') { |
| @@ -1446,9 +1467,10 @@ | ||
| 1446 | 1467 | |
| 1447 | 1468 | if(file_exists($this->import_xml_file)) { |
| 1448 | 1469 | $dom_array = $this->xmlstr_to_array(file_get_contents($this->import_xml_file)); |
| 1449 | 1470 | if(!isset($dom_array['listings']['listing']) && empty($dom_array['listings']['listing'])) { |
| 1450 | - $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>'; | |
| 1451 | 1473 | return false; |
| 1452 | 1474 | } |
| 1453 | 1475 | |
| 1454 | 1476 | /* demo agent add/get if exists */ |
| @@ -1461,12 +1483,12 @@ | ||
| 1461 | 1483 | $location_id = ''; |
| 1462 | 1484 | $category_id = ''; |
| 1463 | 1485 | |
| 1464 | 1486 | if(!empty($categories)) |
| 1465 | - $category_id = $categories[rand(0, count($categories)-1)]; | |
| 1487 | + $category_id = $categories[wp_rand(0, count($categories)-1)]; | |
| 1466 | 1488 | |
| 1467 | 1489 | if(!empty($location)) |
| 1468 | - $location_id = $locations[rand(0, count($locations)-1)]; | |
| 1490 | + $location_id = $locations[wp_rand(0, count($locations)-1)]; | |
| 1469 | 1491 | |
| 1470 | 1492 | $data_listing = array( |
| 1471 | 1493 | 'post_title' => '', |
| 1472 | 1494 | 'post_content' => '', |
| @@ -1476,14 +1498,14 @@ | ||
| 1476 | 1498 | 'lat' => '', |
| 1477 | 1499 | 'listing_images' => '', |
| 1478 | 1500 | 'listing_images_path' => '', |
| 1479 | 1501 | 'listing_images_path_medium' => '', |
| 1480 | - 'date_modified' => date('Y-m-d H:i:s'), | |
| 1502 | + 'date_modified' => gmdate('Y-m-d H:i:s'), | |
| 1481 | 1503 | 'lng' => '', |
| 1482 | 1504 | 'is_featured' => '', |
| 1483 | 1505 | 'is_activated' => '1', |
| 1484 | 1506 | 'is_approved' => '1', |
| 1485 | - 'counter_views' => rand(20,250), | |
| 1507 | + 'counter_views' => wp_rand(20,250), | |
| 1486 | 1508 | 'user_id_editor' => NULL, |
| 1487 | 1509 | ); |
| 1488 | 1510 | |
| 1489 | 1511 | $data_listing = array_intersect_key(array_merge($data_listing, $listing), $data_listing); |
| @@ -1512,19 +1534,19 @@ | ||
| 1512 | 1534 | if(count($values) > 0) |
| 1513 | 1535 | { |
| 1514 | 1536 | $start=0; |
| 1515 | 1537 | if(empty($values[0]))$start=1; |
| 1516 | - $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)]; | |
| 1517 | 1539 | } |
| 1518 | 1540 | } |
| 1519 | 1541 | elseif($field_data->field_type == 'NUMBER') |
| 1520 | 1542 | { |
| 1521 | - $data_listings_fields['field_'.$field_data->idfield] = rand(2,499); | |
| 1543 | + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(2,499); | |
| 1522 | 1544 | |
| 1523 | 1545 | } |
| 1524 | 1546 | elseif($field_data->field_type == 'CHECKBOX') |
| 1525 | 1547 | { |
| 1526 | - $data_listings_fields['field_'.$field_data->idfield] = rand(0,1); | |
| 1548 | + $data_listings_fields['field_'.$field_data->idfield] = wp_rand(0,1); | |
| 1527 | 1549 | } |
| 1528 | 1550 | elseif($field_data->field_type == 'TEXTAREA') |
| 1529 | 1551 | { |
| 1530 | 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.'; |
| @@ -1565,9 +1587,9 @@ | ||
| 1565 | 1587 | } |
| 1566 | 1588 | |
| 1567 | 1589 | $image_url = wp_get_attachment_image_url($image_id, 'large'); |
| 1568 | 1590 | if($image_url) { |
| 1569 | - $parsed = parse_url($image_url); | |
| 1591 | + $parsed = wp_parse_url($image_url); | |
| 1570 | 1592 | $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8); |
| 1571 | 1593 | |
| 1572 | 1594 | if(!empty($data_listing['listing_images_path_medium'])) |
| 1573 | 1595 | $data_listing['listing_images_path_medium'] .= ','; |
| @@ -1606,9 +1628,9 @@ | ||
| 1606 | 1628 | } |
| 1607 | 1629 | |
| 1608 | 1630 | $image_url = wp_get_attachment_image_url($image_id, 'large'); |
| 1609 | 1631 | if($image_url) { |
| 1610 | - $parsed = parse_url($image_url); | |
| 1632 | + $parsed = wp_parse_url($image_url); | |
| 1611 | 1633 | $next_path = substr($parsed['path'], strpos($parsed['path'], 'uploads/')+8); |
| 1612 | 1634 | |
| 1613 | 1635 | if(!empty($data_listing['listing_images_path_medium'])) |
| 1614 | 1636 | $data_listing['listing_images_path_medium'] .= ','; |
| @@ -1637,10 +1659,10 @@ | ||
| 1637 | 1659 | if(isset( $data_listing[$field_name])) |
| 1638 | 1660 | $listing_data[$field_name] = $data_listing[$field_name]; |
| 1639 | 1661 | } |
| 1640 | 1662 | $listing_data['user_id_editor'] = $user_ids[array_rand($user_ids)]; |
| 1641 | - $listing_data['date_modified'] = date('Y-m-d H:i:s'); | |
| 1642 | - $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); | |
| 1643 | 1665 | |
| 1644 | 1666 | $this->listing_m->insert($listing_data, NULL); |
| 1645 | 1667 | |
| 1646 | 1668 | $data_listings_fields['post_id'] = $id; |
| @@ -1649,10 +1671,10 @@ | ||
| 1649 | 1671 | |
| 1650 | 1672 | $this->data['import_log'] .= '<div class="alert alert-success" role="alert">'.esc_html__('Listings imported', 'wpdirectorykit').'</div>'; |
| 1651 | 1673 | return true; |
| 1652 | 1674 | } |
| 1653 | - | |
| 1654 | - $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>'; | |
| 1655 | 1677 | return false; |
| 1656 | 1678 | } |
| 1657 | 1679 | |
| 1658 | 1680 | protected function xmlstr_to_array($xmlstr) { |