@@ -6537,7 +6537,7 @@ discard block |
||
| 6537 | 6537 | * |
| 6538 | 6538 | * @since 1.5.0 |
| 6539 | 6539 | * |
| 6540 | - * @return True if WPML is active else False. |
|
| 6540 | + * @return boolean if WPML is active else False. |
|
| 6541 | 6541 | */ |
| 6542 | 6542 | function geodir_is_wpml() {
|
| 6543 | 6543 | if (function_exists('icl_object_id')) {
|
@@ -6633,7 +6633,7 @@ discard block |
||
| 6633 | 6633 | * @param int $master_post_id Original Post ID. |
| 6634 | 6634 | * @param int $tr_post_id Translation Post ID. |
| 6635 | 6635 | * @param string $lang Language code for translating post. |
| 6636 | - * @return bool True for success, False for fail. |
|
| 6636 | + * @return boolean|null True for success, False for fail. |
|
| 6637 | 6637 | */ |
| 6638 | 6638 | function geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang) {
|
| 6639 | 6639 | global $sitepress, $wpdb; |
@@ -474,15 +474,15 @@ discard block |
||
| 474 | 474 | <?php |
| 475 | 475 | |
| 476 | 476 | $default_location = geodir_get_default_location(); |
| 477 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 478 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 479 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 480 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 481 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 477 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 478 | + $region = isset($default_location->region) ? $default_location->region : ''; |
|
| 479 | + $country = isset($default_location->country) ? $default_location->country : ''; |
|
| 480 | + $city_latitude = isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 481 | + $city_longitude = isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 482 | 482 | |
| 483 | 483 | ?> |
| 484 | 484 | var geocoder = new google.maps.Geocoder(); |
| 485 | - var CITY_ADDRESS = '<?php echo $city.','.$region.','.$country;?>'; |
|
| 485 | + var CITY_ADDRESS = '<?php echo $city . ',' . $region . ',' . $country; ?>'; |
|
| 486 | 486 | var bound_lat_lng; |
| 487 | 487 | var lat = <?php echo $city_latitude; ?>; |
| 488 | 488 | var lng = <?php echo $city_longitude; ?>; |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | ); |
| 520 | 520 | |
| 521 | 521 | } else {
|
| 522 | - alert("<?php _e('Geocode was not successful for the following reason:','geodirectory');?> " + status);
|
|
| 522 | + alert("<?php _e('Geocode was not successful for the following reason:', 'geodirectory'); ?> " + status);
|
|
| 523 | 523 | } |
| 524 | 524 | }); |
| 525 | 525 | |
@@ -532,7 +532,7 @@ discard block |
||
| 532 | 532 | var total_dummy_post_count = jQuery('#sub_' + active_tab).find('.selected_sample_data').val();
|
| 533 | 533 | |
| 534 | 534 | if (id == 'geodir_dummy_delete') {
|
| 535 | - if (confirm('<?php _e('Are you sure you want to delete dummy data?' , 'geodirectory'); ?>')) {
|
|
| 535 | + if (confirm('<?php _e('Are you sure you want to delete dummy data?', 'geodirectory'); ?>')) {
|
|
| 536 | 536 | jQuery('#sub_' + active_tab).find('.geodir_auto_install').hide();
|
| 537 | 537 | jQuery('#sub_' + active_tab).find('.geodir_show_progress').show();
|
| 538 | 538 | jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&_wpnonce=' + nonce,
|
@@ -551,7 +551,7 @@ discard block |
||
| 551 | 551 | jQuery.post('<?php echo geodir_get_ajax_url(); ?>&geodir_autofill=' + id + '&posttype=' + posttype + '&insert_dummy_post_index=' + dummy_post_index + '&city_bound_lat1=' + bound_lat_lng[0] + '&city_bound_lng1=' + bound_lat_lng[1] + '&city_bound_lat2=' + bound_lat_lng[2] + '&city_bound_lng2=' + bound_lat_lng[3] + '&_wpnonce=' + nonce,
|
| 552 | 552 | function (data) {
|
| 553 | 553 | |
| 554 | - jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:','geodirectory');?> ' + dummy_post_index + ' <?php _e('of' ,'geodirectory'); ?> ' + total_dummy_post_count + '');
|
|
| 554 | + jQuery(obj).closest('form').find('.dummy_post_inserted').html('<?php _e('Dummy post(s) inserted:', 'geodirectory'); ?> ' + dummy_post_index + ' <?php _e('of', 'geodirectory'); ?> ' + total_dummy_post_count + '');
|
|
| 555 | 555 | dummy_post_index++; |
| 556 | 556 | if (dummy_post_index <= total_dummy_post_count) |
| 557 | 557 | geodir_autoinstall(obj, id, nonce, posttype); |
@@ -662,7 +662,7 @@ discard block |
||
| 662 | 662 | else |
| 663 | 663 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
| 664 | 664 | $catname = str_replace(' ', '_', $catname);
|
| 665 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 665 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 666 | 666 | |
| 667 | 667 | if (empty($uploaded['error'])) {
|
| 668 | 668 | $new_path = $uploaded['file']; |
@@ -703,7 +703,7 @@ discard block |
||
| 703 | 703 | else |
| 704 | 704 | $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
| 705 | 705 | $catname = str_replace(' ', '_', $catname);
|
| 706 | - $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 706 | + $uploaded = (array) fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
|
| 707 | 707 | |
| 708 | 708 | if (empty($uploaded['error'])) {
|
| 709 | 709 | $new_path = $uploaded['file']; |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | */ |
| 1016 | 1016 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 1017 | 1017 | {
|
| 1018 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1018 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory') . ' <i class="fa fa-plug"></i>', 'url' => 'http://wpgeodirectory.com', 'target' => '_blank');
|
|
| 1019 | 1019 | return $tabs; |
| 1020 | 1020 | } |
| 1021 | 1021 | |
@@ -1168,7 +1168,7 @@ discard block |
||
| 1168 | 1168 | function geodir_post_information_save($post_id, $post) {
|
| 1169 | 1169 | global $wpdb, $current_user; |
| 1170 | 1170 | |
| 1171 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 1171 | + if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
|
|
| 1172 | 1172 | return; |
| 1173 | 1173 | } |
| 1174 | 1174 | |
@@ -1512,7 +1512,7 @@ discard block |
||
| 1512 | 1512 | jQuery('#gd-import-perc').text('0%');
|
| 1513 | 1513 | |
| 1514 | 1514 | jQuery('.gd-csv-form-table .filelist .file').remove();
|
| 1515 | - jQuery('#gd-import-msg').find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
|
|
| 1515 | + jQuery('#gd-import-msg').find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
|
|
| 1516 | 1516 | jQuery('#gd-import-msg').show();
|
| 1517 | 1517 | |
| 1518 | 1518 | return false; |
@@ -1680,38 +1680,38 @@ discard block |
||
| 1680 | 1680 | |
| 1681 | 1681 | var gdMsg = '<p></p>'; |
| 1682 | 1682 | if (gd_invalidcount == 0 && gd_blank_address == 0 && gd_invalid_post_type == 0 && gd_invalid_title == 0) {
|
| 1683 | - gdMsg += "<p><?php echo esc_attr( CSV_INSERT_DATA );?></p>"; |
|
| 1683 | + gdMsg += "<p><?php echo esc_attr(CSV_INSERT_DATA); ?></p>"; |
|
| 1684 | 1684 | } |
| 1685 | 1685 | |
| 1686 | - var msgParse = '<p><?php echo addslashes( CSV_TOTAL_RECORD );?></p>'; |
|
| 1686 | + var msgParse = '<p><?php echo addslashes(CSV_TOTAL_RECORD); ?></p>'; |
|
| 1687 | 1687 | gdMsg += msgParse.replace("%s", gd_rowcount);
|
| 1688 | 1688 | |
| 1689 | 1689 | if (gd_invalidcount > 0) {
|
| 1690 | - msgParse = msgParse = '<p><?php echo sprintf( CSV_INVALID_DEFUALT_ADDRESS, '%s', '%d' );?></p>'; |
|
| 1690 | + msgParse = msgParse = '<p><?php echo sprintf(CSV_INVALID_DEFUALT_ADDRESS, '%s', '%d'); ?></p>'; |
|
| 1691 | 1691 | msgParse = msgParse.replace("%s", gd_invalidcount);
|
| 1692 | 1692 | msgParse = msgParse.replace("%d", gd_total_records);
|
| 1693 | 1693 | gdMsg += msgParse; |
| 1694 | 1694 | } |
| 1695 | 1695 | if (gd_blank_address > 0) {
|
| 1696 | - msgParse = '<p><?php echo addslashes( sprintf( CSV_INVALID_TOTAL_RECORD, '%s', '%d' ) );?></p>'; |
|
| 1696 | + msgParse = '<p><?php echo addslashes(sprintf(CSV_INVALID_TOTAL_RECORD, '%s', '%d')); ?></p>'; |
|
| 1697 | 1697 | msgParse = msgParse.replace("%s", gd_blank_address);
|
| 1698 | 1698 | msgParse = msgParse.replace("%d", gd_total_records);
|
| 1699 | 1699 | gdMsg += msgParse; |
| 1700 | 1700 | } |
| 1701 | 1701 | if (gd_invalid_post_type > 0) {
|
| 1702 | - msgParse = '<p><?php echo addslashes( sprintf( CSV_INVALID_POST_TYPE, '%s', '%d' ) );?></p>'; |
|
| 1702 | + msgParse = '<p><?php echo addslashes(sprintf(CSV_INVALID_POST_TYPE, '%s', '%d')); ?></p>'; |
|
| 1703 | 1703 | msgParse = msgParse.replace("%s", gd_invalid_post_type);
|
| 1704 | 1704 | msgParse = msgParse.replace("%d", gd_total_records);
|
| 1705 | 1705 | gdMsg += msgParse; |
| 1706 | 1706 | } |
| 1707 | 1707 | if (gd_invalid_title > 0) {
|
| 1708 | - msgParse = '<p><?php echo addslashes( sprintf( CSV_BLANK_POST_TITLE, '%s', '%d' ) );?></p>'; |
|
| 1708 | + msgParse = '<p><?php echo addslashes(sprintf(CSV_BLANK_POST_TITLE, '%s', '%d')); ?></p>'; |
|
| 1709 | 1709 | msgParse = msgParse.replace("%s", gd_invalid_title);
|
| 1710 | 1710 | msgParse = msgParse.replace("%d", gd_total_records);
|
| 1711 | 1711 | gdMsg += msgParse; |
| 1712 | 1712 | } |
| 1713 | 1713 | if (gd_upload_files > 0) {
|
| 1714 | - gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>'; |
|
| 1714 | + gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>'; |
|
| 1715 | 1715 | } |
| 1716 | 1716 | gdMsg += '<p></p>'; |
| 1717 | 1717 | jQuery('#gd-import-msg').find('#message').removeClass('error').addClass('updated').html(gdMsg);
|
@@ -1721,7 +1721,7 @@ discard block |
||
| 1721 | 1721 | <table class="form-table gd-csv-form-table"> |
| 1722 | 1722 | <tbody> |
| 1723 | 1723 | <tr valign="top" class="single_select_page"> |
| 1724 | - <th class="titledesc" scope="row"><?php echo SELECT_CSV_FILE;?></th> |
|
| 1724 | + <th class="titledesc" scope="row"><?php echo SELECT_CSV_FILE; ?></th> |
|
| 1725 | 1725 | <td class="forminp"> |
| 1726 | 1726 | <div class="gtd-formfeild"> |
| 1727 | 1727 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox"> |
@@ -1756,12 +1756,12 @@ discard block |
||
| 1756 | 1756 | id="gd_import_data" class="button-primary" name="save"> |
| 1757 | 1757 | <input onclick="gdContinueImport()" type="button" value="Continue Import Data" |
| 1758 | 1758 | id="gd_continue_data" class="button-primary" style="display:none"/> |
| 1759 | - <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>"
|
|
| 1759 | + <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>"
|
|
| 1760 | 1760 | id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" |
| 1761 | 1761 | onclick="gdTerminateImport()"/> |
| 1762 | 1762 | |
| 1763 | 1763 | <div id="gd_process_data" style="display:none"><span class="spinner" |
| 1764 | - style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
|
|
| 1764 | + style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
|
|
| 1765 | 1765 | </div> |
| 1766 | 1766 | </div> |
| 1767 | 1767 | <div id="gd_importer" style="display:none"> |
@@ -1779,7 +1779,7 @@ discard block |
||
| 1779 | 1779 | <input type="hidden" id="gd_total_records" value="0"/> |
| 1780 | 1780 | </div> |
| 1781 | 1781 | <div class="gd-import-progress" id="gd-import-progress" style="display:none"> |
| 1782 | - <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
|
|
| 1782 | + <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
|
|
| 1783 | 1783 | id="gd-import-done">0</font> / <font id="gd-import-total">0</font> ( <font |
| 1784 | 1784 | id="gd-import-perc">0%</font> ) |
| 1785 | 1785 | <div class="gd-fileprogress"></div> |
@@ -2038,7 +2038,7 @@ discard block |
||
| 2038 | 2038 | $payment_info = array(); |
| 2039 | 2039 | $package_info = array(); |
| 2040 | 2040 | |
| 2041 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2041 | + $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2042 | 2042 | $package_id = ''; |
| 2043 | 2043 | if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
| 2044 | 2044 | $package_id = $gd_post_info['package_id']; |
@@ -2272,7 +2272,7 @@ discard block |
||
| 2272 | 2272 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 2273 | 2273 | id="<?php echo esc_attr($value['id']); ?>" |
| 2274 | 2274 | type="<?php echo esc_attr($value['type']); ?>" |
| 2275 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 2275 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 2276 | 2276 | style=" <?php echo esc_attr($value['css']); ?>" |
| 2277 | 2277 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2278 | 2278 | echo esc_attr(stripslashes(get_option($value['id']))); |
@@ -2289,7 +2289,7 @@ discard block |
||
| 2289 | 2289 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 2290 | 2290 | id="<?php echo esc_attr($value['id']); ?>" |
| 2291 | 2291 | type="<?php echo esc_attr($value['type']); ?>" |
| 2292 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 2292 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 2293 | 2293 | style="<?php echo esc_attr($value['css']); ?>" |
| 2294 | 2294 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2295 | 2295 | echo esc_attr(stripslashes(get_option($value['id']))); |
@@ -2390,7 +2390,7 @@ discard block |
||
| 2390 | 2390 | id="<?php echo esc_attr($value['id']); ?>" |
| 2391 | 2391 | style="<?php echo esc_attr($value['css']); ?>" |
| 2392 | 2392 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 2393 | - data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
|
| 2393 | + data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text']; ?>" |
|
| 2394 | 2394 | option-ajaxchosen="false"> |
| 2395 | 2395 | <?php |
| 2396 | 2396 | foreach ($value['options'] as $key => $val) {
|
@@ -2438,7 +2438,7 @@ discard block |
||
| 2438 | 2438 | ?> |
| 2439 | 2439 | |
| 2440 | 2440 | <tr valign="top"> |
| 2441 | - <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
|
| 2441 | + <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory'); ?></th>
|
|
| 2442 | 2442 | <td width="60%"> |
| 2443 | 2443 | <select name="geodir_default_map_language" style="width:60%"> |
| 2444 | 2444 | <?php |
@@ -2520,7 +2520,7 @@ discard block |
||
| 2520 | 2520 | |
| 2521 | 2521 | <tr valign="top"> |
| 2522 | 2522 | <th class="titledesc" |
| 2523 | - width="40%"><?php _e('Default post type search on map', 'geodirectory');?></th>
|
|
| 2523 | + width="40%"><?php _e('Default post type search on map', 'geodirectory'); ?></th>
|
|
| 2524 | 2524 | <td width="60%"> |
| 2525 | 2525 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 2526 | 2526 | <?php |
@@ -2561,7 +2561,7 @@ discard block |
||
| 2561 | 2561 | $cat_display = 'checkbox'; |
| 2562 | 2562 | $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
| 2563 | 2563 | $gd_cats = get_option('geodir_exclude_cat_on_map');
|
| 2564 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 2564 | + $gd_cats_upgrade = (int) get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 2565 | 2565 | $count = 1; |
| 2566 | 2566 | ?> |
| 2567 | 2567 | <table width="70%" class="widefat"> |
@@ -2590,7 +2590,7 @@ discard block |
||
| 2590 | 2590 | name="home_map_post_types[]" |
| 2591 | 2591 | id="<?php echo esc_attr($value['id']); ?>" |
| 2592 | 2592 | value="<?php echo $key; ?>" |
| 2593 | - class="map_post_type" <?php echo $checked;?> /> |
|
| 2593 | + class="map_post_type" <?php echo $checked; ?> /> |
|
| 2594 | 2594 | <?php echo $post_types_obj->labels->singular_name; ?></td> |
| 2595 | 2595 | <td width="40%"> |
| 2596 | 2596 | <div class="home_map_category" style="overflow:auto;width:200px;height:100px;" |
@@ -2648,12 +2648,12 @@ discard block |
||
| 2648 | 2648 | ?> |
| 2649 | 2649 | <fieldset> |
| 2650 | 2650 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 2651 | - <label for="<?php echo $value['id'];?>"> |
|
| 2651 | + <label for="<?php echo $value['id']; ?>"> |
|
| 2652 | 2652 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 2653 | 2653 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 2654 | 2654 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 2655 | 2655 | echo 'checked="checked"'; |
| 2656 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 2656 | + }elseif (get_option($value['id']) == '' && $value['std'] == $value['value']) {echo 'checked="checked"'; } ?> />
|
|
| 2657 | 2657 | <?php echo $value['desc']; ?></label><br> |
| 2658 | 2658 | </fieldset> |
| 2659 | 2659 | <?php |
@@ -2675,7 +2675,7 @@ discard block |
||
| 2675 | 2675 | <textarea |
| 2676 | 2676 | <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>" |
| 2677 | 2677 | id="<?php echo esc_attr($value['id']); ?>" |
| 2678 | - <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 2678 | + <?php if (isset($value['placeholder'])) {?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
|
| 2679 | 2679 | style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) echo esc_textarea(stripslashes(get_option($value['id']))); else echo esc_textarea($value['std']); ?></textarea><span |
| 2680 | 2680 | class="description"><?php echo $value['desc'] ?></span> |
| 2681 | 2681 | |
@@ -2722,7 +2722,7 @@ discard block |
||
| 2722 | 2722 | } |
| 2723 | 2723 | } |
| 2724 | 2724 | // |
| 2725 | - $page_setting = (int)get_option($value['id']); |
|
| 2725 | + $page_setting = (int) get_option($value['id']); |
|
| 2726 | 2726 | |
| 2727 | 2727 | $args = array('name' => $value['id'],
|
| 2728 | 2728 | 'id' => $value['id'], |
@@ -2749,7 +2749,7 @@ discard block |
||
| 2749 | 2749 | break; |
| 2750 | 2750 | case 'single_select_country' : |
| 2751 | 2751 | $countries = $geodirectory->countries->countries; |
| 2752 | - $country_setting = (string)get_option($value['id']); |
|
| 2752 | + $country_setting = (string) get_option($value['id']); |
|
| 2753 | 2753 | if (strstr($country_setting, ':')) : |
| 2754 | 2754 | $country = current(explode(':', $country_setting));
|
| 2755 | 2755 | $state = end(explode(':', $country_setting));
|
@@ -2772,7 +2772,7 @@ discard block |
||
| 2772 | 2772 | case 'multi_select_countries' : |
| 2773 | 2773 | $countries = $geodirectory->countries->countries; |
| 2774 | 2774 | asort($countries); |
| 2775 | - $selections = (array)get_option($value['id']); |
|
| 2775 | + $selections = (array) get_option($value['id']); |
|
| 2776 | 2776 | ?> |
| 2777 | 2777 | <tr valign="top"> |
| 2778 | 2778 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
@@ -2794,8 +2794,8 @@ discard block |
||
| 2794 | 2794 | break; |
| 2795 | 2795 | |
| 2796 | 2796 | case 'google_analytics' : |
| 2797 | - $selections = (array)get_option($value['id']); |
|
| 2798 | - if(get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret') ) {
|
|
| 2797 | + $selections = (array) get_option($value['id']); |
|
| 2798 | + if (get_option('geodir_ga_client_id') && get_option('geodir_ga_client_secret')) {
|
|
| 2799 | 2799 | ?> |
| 2800 | 2800 | <tr valign="top"> |
| 2801 | 2801 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
@@ -2806,10 +2806,10 @@ discard block |
||
| 2806 | 2806 | |
| 2807 | 2807 | $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
| 2808 | 2808 | $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
| 2809 | - $state = "&state=123";//any string |
|
| 2809 | + $state = "&state=123"; //any string |
|
| 2810 | 2810 | $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
| 2811 | 2811 | $response_type = "&response_type=code"; |
| 2812 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2812 | + $client_id = "&client_id=" . get_option('geodir_ga_client_id');
|
|
| 2813 | 2813 | $access_type = "&access_type=offline"; |
| 2814 | 2814 | $approval_prompt = "&approval_prompt=force"; |
| 2815 | 2815 | |
@@ -2819,7 +2819,7 @@ discard block |
||
| 2819 | 2819 | ?> |
| 2820 | 2820 | <script> |
| 2821 | 2821 | function gd_ga_popup() {
|
| 2822 | - var win = window.open("<?php echo $auth_url;?>", "Google Analytics", "");
|
|
| 2822 | + var win = window.open("<?php echo $auth_url; ?>", "Google Analytics", "");
|
|
| 2823 | 2823 | var pollTimer = window.setInterval(function () {
|
| 2824 | 2824 | if (win.closed !== false) { // !== is required for compatibility with Opera
|
| 2825 | 2825 | window.clearInterval(pollTimer); |
@@ -2841,7 +2841,7 @@ discard block |
||
| 2841 | 2841 | } else {
|
| 2842 | 2842 | ?> |
| 2843 | 2843 | <span class="button-primary" |
| 2844 | - onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory');?></span>
|
|
| 2844 | + onclick="gd_ga_popup();"><?php _e('Authorize', 'geodirectory'); ?></span>
|
|
| 2845 | 2845 | <?php |
| 2846 | 2846 | } |
| 2847 | 2847 | ?> |
@@ -2912,15 +2912,15 @@ discard block |
||
| 2912 | 2912 | |
| 2913 | 2913 | |
| 2914 | 2914 | <?php |
| 2915 | - if(isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') |
|
| 2915 | + if (isset($_REQUEST['active_tab']) && $_REQUEST['active_tab'] != '') |
|
| 2916 | 2916 | {
|
| 2917 | 2917 | |
| 2918 | 2918 | ?> |
| 2919 | 2919 | jQuery('.geodir_option_tabs').removeClass('gd-tab-active');
|
| 2920 | - jQuery('#<?php echo $_REQUEST['active_tab'];?>').addClass('gd-tab-active');
|
|
| 2920 | + jQuery('#<?php echo $_REQUEST['active_tab']; ?>').addClass('gd-tab-active');
|
|
| 2921 | 2921 | |
| 2922 | 2922 | jQuery('.gd-content-heading').hide();
|
| 2923 | - jQuery('#sub_<?php echo $_REQUEST['active_tab'];?>').show();
|
|
| 2923 | + jQuery('#sub_<?php echo $_REQUEST['active_tab']; ?>').show();
|
|
| 2924 | 2924 | |
| 2925 | 2925 | |
| 2926 | 2926 | <?php |
@@ -3069,7 +3069,7 @@ discard block |
||
| 3069 | 3069 | <div |
| 3070 | 3070 | class="plupload-upload-uic hide-if-no-js <?php if ($multiple): ?>plupload-upload-uic-multiple<?php endif; ?>" |
| 3071 | 3071 | id="<?php echo $id; ?>plupload-upload-ui"> |
| 3072 | - <h4><?php _e('Drop files to upload', 'geodirectory');?></h4>
|
|
| 3072 | + <h4><?php _e('Drop files to upload', 'geodirectory'); ?></h4>
|
|
| 3073 | 3073 | <input id="<?php echo $id; ?>plupload-browse-button" type="button" |
| 3074 | 3074 | value="<?php _e('Select Files', 'geodirectory'); ?>" class="button"/>
|
| 3075 | 3075 | <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce($id . 'pluploadan'); ?>"></span> |
@@ -3084,7 +3084,7 @@ discard block |
||
| 3084 | 3084 | id="<?php echo $id; ?>plupload-thumbs" style="border-top:1px solid #ccc; padding-top:10px;"> |
| 3085 | 3085 | </div> |
| 3086 | 3086 | <span |
| 3087 | - id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory');?></span>
|
|
| 3087 | + id="upload-msg"><?php _e('Please drag & drop the images to rearrange the order', 'geodirectory'); ?></span>
|
|
| 3088 | 3088 | <span id="<?php echo $id; ?>upload-error" style="display:none"></span> |
| 3089 | 3089 | </div> |
| 3090 | 3090 | |
@@ -3462,11 +3462,11 @@ discard block |
||
| 3462 | 3462 | function geodir_hide_admin_preview_button() {
|
| 3463 | 3463 | global $post_type; |
| 3464 | 3464 | $post_types = geodir_get_posttypes(); |
| 3465 | - if(in_array($post_type, $post_types)) |
|
| 3465 | + if (in_array($post_type, $post_types)) |
|
| 3466 | 3466 | echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
| 3467 | 3467 | } |
| 3468 | -add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
|
| 3469 | -add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
|
| 3468 | +add_action('admin_head-post-new.php', 'geodir_hide_admin_preview_button');
|
|
| 3469 | +add_action('admin_head-post.php', 'geodir_hide_admin_preview_button');
|
|
| 3470 | 3470 | |
| 3471 | 3471 | /** |
| 3472 | 3472 | * Add the tab in left sidebar menu fro import & export page. |
@@ -3476,8 +3476,8 @@ discard block |
||
| 3476 | 3476 | * |
| 3477 | 3477 | * @return array Array of tab data. |
| 3478 | 3478 | */ |
| 3479 | -function geodir_import_export_tab( $tabs ) {
|
|
| 3480 | - $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
|
| 3479 | +function geodir_import_export_tab($tabs) {
|
|
| 3480 | + $tabs['import_export'] = array('label' => __('Import & Export', 'geodirectory'));
|
|
| 3481 | 3481 | return $tabs; |
| 3482 | 3482 | } |
| 3483 | 3483 | |
@@ -3491,7 +3491,7 @@ discard block |
||
| 3491 | 3491 | * @return string Html content. |
| 3492 | 3492 | */ |
| 3493 | 3493 | function geodir_import_export_page() {
|
| 3494 | - $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
|
| 3494 | + $nonce = wp_create_nonce('geodir_import_export_nonce');
|
|
| 3495 | 3495 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
| 3496 | 3496 | /** |
| 3497 | 3497 | * Filter sample category data csv file url. |
@@ -3501,7 +3501,7 @@ discard block |
||
| 3501 | 3501 | * |
| 3502 | 3502 | * @param string $gd_cats_sample_csv Sample category data csv file url. |
| 3503 | 3503 | */ |
| 3504 | - $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
|
| 3504 | + $gd_cats_sample_csv = apply_filters('geodir_export_cats_sample_csv', $gd_cats_sample_csv);
|
|
| 3505 | 3505 | |
| 3506 | 3506 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
| 3507 | 3507 | /** |
@@ -3512,15 +3512,15 @@ discard block |
||
| 3512 | 3512 | * |
| 3513 | 3513 | * @param string $gd_posts_sample_csv Sample post data csv file url. |
| 3514 | 3514 | */ |
| 3515 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 3515 | + $gd_posts_sample_csv = apply_filters('geodir_export_posts_sample_csv', $gd_posts_sample_csv);
|
|
| 3516 | 3516 | |
| 3517 | - $gd_posttypes = geodir_get_posttypes( 'array' ); |
|
| 3517 | + $gd_posttypes = geodir_get_posttypes('array');
|
|
| 3518 | 3518 | |
| 3519 | 3519 | $gd_posttypes_option = ''; |
| 3520 | - foreach ( $gd_posttypes as $gd_posttype => $row ) {
|
|
| 3521 | - $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>'; |
|
| 3520 | + foreach ($gd_posttypes as $gd_posttype => $row) {
|
|
| 3521 | + $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int) geodir_get_terms_count($gd_posttype) . '" data-posts="' . (int) geodir_get_posts_count($gd_posttype) . '">' . __($row['labels']['name'], 'geodirectory') . '</option>'; |
|
| 3522 | 3522 | } |
| 3523 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 3523 | + wp_enqueue_script('jquery-ui-progressbar');
|
|
| 3524 | 3524 | |
| 3525 | 3525 | $gd_chunksize_options = array(); |
| 3526 | 3526 | $gd_chunksize_options[100] = 100; |
@@ -3542,7 +3542,7 @@ discard block |
||
| 3542 | 3542 | * |
| 3543 | 3543 | * @param string $gd_chunksize_options Entries options. |
| 3544 | 3544 | */ |
| 3545 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 3545 | + $gd_chunksize_options = apply_filters('geodir_export_csv_chunksize_options', $gd_chunksize_options);
|
|
| 3546 | 3546 | |
| 3547 | 3547 | $gd_chunksize_option = ''; |
| 3548 | 3548 | foreach ($gd_chunksize_options as $value => $title) {
|
@@ -3553,38 +3553,38 @@ discard block |
||
| 3553 | 3553 | ?> |
| 3554 | 3554 | </form> |
| 3555 | 3555 | <div class="inner_content_tab_main gd-import-export"> |
| 3556 | - <h3><?php _e( 'GD Import & Export CSV', 'geodirectory' ) ;?></h3> |
|
| 3557 | - <span class="description"><?php _e( 'Import & export csv for GD listings & categories.', 'geodirectory' ) ;?></span> |
|
| 3556 | + <h3><?php _e('GD Import & Export CSV', 'geodirectory'); ?></h3>
|
|
| 3557 | + <span class="description"><?php _e('Import & export csv for GD listings & categories.', 'geodirectory'); ?></span>
|
|
| 3558 | 3558 | <div class="gd-content-heading"> |
| 3559 | 3559 | |
| 3560 | 3560 | <?php |
| 3561 | 3561 | ini_set('max_execution_time', 999999);
|
| 3562 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 3562 | + $ini_max_execution_time_check = @ini_get('max_execution_time');
|
|
| 3563 | 3563 | ini_restore('max_execution_time');
|
| 3564 | 3564 | |
| 3565 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 3565 | + if ($ini_max_execution_time_check != 999999) { // only show these setting to the user if we can't change the ini setting
|
|
| 3566 | 3566 | ?> |
| 3567 | 3567 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 3568 | 3568 | <div class="meta-box-sortables ui-sortable"> |
| 3569 | 3569 | <div class="postbox"> |
| 3570 | - <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'PHP Requirements for GD Import & Export CSV', 'geodirectory' );?></span></h3> |
|
| 3570 | + <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('PHP Requirements for GD Import & Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 3571 | 3571 | <div class="inside"> |
| 3572 | - <span class="description"><?php echo __( 'Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory' );?></span> |
|
| 3572 | + <span class="description"><?php echo __('Note: In case GD import & export csv not working for larger data then please check and configure following php settings.', 'geodirectory'); ?></span>
|
|
| 3573 | 3573 | <table class="form-table"> |
| 3574 | 3574 | <thead> |
| 3575 | 3575 | <tr> |
| 3576 | - <th><?php _e( 'PHP Settings', 'geodirectory' );?></th><th><?php _e( 'Current Value', 'geodirectory' );?></th><th><?php _e( 'Recommended Value', 'geodirectory' );?></th> |
|
| 3576 | + <th><?php _e('PHP Settings', 'geodirectory'); ?></th><th><?php _e('Current Value', 'geodirectory'); ?></th><th><?php _e('Recommended Value', 'geodirectory'); ?></th>
|
|
| 3577 | 3577 | </tr> |
| 3578 | 3578 | </thead> |
| 3579 | 3579 | <tbody> |
| 3580 | 3580 | <tr> |
| 3581 | - <td>max_input_time</td><td><?php echo @ini_get( 'max_input_time' );?></td><td>3000</td> |
|
| 3581 | + <td>max_input_time</td><td><?php echo @ini_get('max_input_time'); ?></td><td>3000</td>
|
|
| 3582 | 3582 | </tr> |
| 3583 | 3583 | <tr> |
| 3584 | - <td>max_execution_time</td><td><?php echo @ini_get( 'max_execution_time' );?></td><td>3000</td> |
|
| 3584 | + <td>max_execution_time</td><td><?php echo @ini_get('max_execution_time'); ?></td><td>3000</td>
|
|
| 3585 | 3585 | </tr> |
| 3586 | 3586 | <tr> |
| 3587 | - <td>memory_limit</td><td><?php echo @ini_get( 'memory_limit' );?></td><td>256M</td> |
|
| 3587 | + <td>memory_limit</td><td><?php echo @ini_get('memory_limit'); ?></td><td>256M</td>
|
|
| 3588 | 3588 | </tr> |
| 3589 | 3589 | </tbody> |
| 3590 | 3590 | </table> |
@@ -3596,20 +3596,20 @@ discard block |
||
| 3596 | 3596 | <div id="gd_ie_imposts" class="metabox-holder"> |
| 3597 | 3597 | <div class="meta-box-sortables ui-sortable"> |
| 3598 | 3598 | <div id="gd_ie_im_posts" class="postbox"> |
| 3599 | - <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Import CSV', 'geodirectory' );?></span></h3> |
|
| 3599 | + <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Listings: Import CSV', 'geodirectory'); ?></span></h3>
|
|
| 3600 | 3600 | <div class="inside"> |
| 3601 | 3601 | <table class="form-table"> |
| 3602 | 3602 | <tbody> |
| 3603 | 3603 | <tr> |
| 3604 | 3604 | <td class="gd-imex-box"> |
| 3605 | 3605 | <div class="gd-im-choices"> |
| 3606 | - <p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e( 'Update listing if post with post_id already exists.', 'geodirectory' );?></label></p> |
|
| 3607 | - <p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e( 'Ignore listing if post with post_id already exists.', 'geodirectory' );?></label></p> |
|
| 3606 | + <p><input type="radio" value="update" name="gd_im_choicepost" id="gd_im_pchoice_u" /><label for="gd_im_pchoice_u"><?php _e('Update listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
|
|
| 3607 | + <p><input type="radio" checked="checked" value="skip" name="gd_im_choicepost" id="gd_im_pchoice_s" /><label for="gd_im_pchoice_s"><?php _e('Ignore listing if post with post_id already exists.', 'geodirectory'); ?></label></p>
|
|
| 3608 | 3608 | </div> |
| 3609 | 3609 | <div class="plupload-upload-uic hide-if-no-js" id="gd_im_postplupload-upload-ui"> |
| 3610 | 3610 | <input type="text" readonly="readonly" name="gd_im_post_file" class="gd-imex-file gd_im_post_file" id="gd_im_post" onclick="jQuery('#gd_im_postplupload-browse-button').trigger('click');" />
|
| 3611 | - <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample"> |
|
| 3612 | - <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" /> |
|
| 3611 | + <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample">
|
|
| 3612 | + <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv; ?>" /> |
|
| 3613 | 3613 | <?php |
| 3614 | 3614 | /** |
| 3615 | 3615 | * Called just after the sample CSV download link. |
@@ -3618,7 +3618,7 @@ discard block |
||
| 3618 | 3618 | */ |
| 3619 | 3619 | do_action('geodir_sample_csv_download_link');
|
| 3620 | 3620 | ?> |
| 3621 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span> |
|
| 3621 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_postpluploadan'); ?>"></span>
|
|
| 3622 | 3622 | <div class="filelist"></div> |
| 3623 | 3623 | </div> |
| 3624 | 3624 | <span id="gd_im_catupload-error" style="display:none"></span> |
@@ -3636,7 +3636,7 @@ discard block |
||
| 3636 | 3636 | <input type="hidden" id="gd_terminateaction" value="continue"/> |
| 3637 | 3637 | </div> |
| 3638 | 3638 | <div class="gd-import-progress" id="gd-import-progress" style="display:none"> |
| 3639 | - <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
|
|
| 3639 | + <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
|
|
| 3640 | 3640 | id="gd-import-done">0</font> / <font id="gd-import-total">0</font> ( <font |
| 3641 | 3641 | id="gd-import-perc">0%</font> ) |
| 3642 | 3642 | <div class="gd-fileprogress"></div> |
@@ -3648,10 +3648,10 @@ discard block |
||
| 3648 | 3648 | <div class="gd-imex-btns" style="display:none;"> |
| 3649 | 3649 | <input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/> |
| 3650 | 3650 | <input onclick="gd_imex_PrepareImport(this, 'post')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" /> |
| 3651 | - <input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/> |
|
| 3652 | - <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
|
|
| 3651 | + <input onclick="gd_imex_ContinueImport(this, 'post')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
|
|
| 3652 | + <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'post')"/>
|
|
| 3653 | 3653 | <div id="gd_process_data" style="display:none"> |
| 3654 | - <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
|
|
| 3654 | + <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
|
|
| 3655 | 3655 | </div> |
| 3656 | 3656 | </div> |
| 3657 | 3657 | </td> |
@@ -3665,25 +3665,25 @@ discard block |
||
| 3665 | 3665 | <div id="gd_ie_excategs" class="metabox-holder"> |
| 3666 | 3666 | <div class="meta-box-sortables ui-sortable"> |
| 3667 | 3667 | <div id="gd_ie_ex_posts" class="postbox"> |
| 3668 | - <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Listings: Export CSV', 'geodirectory' );?></span></h3> |
|
| 3668 | + <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Listings: Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 3669 | 3669 | <div class="inside"> |
| 3670 | 3670 | <table class="form-table"> |
| 3671 | 3671 | <tbody> |
| 3672 | 3672 | <tr> |
| 3673 | 3673 | <td class="fld"><label for="gd_post_type"> |
| 3674 | - <?php _e( 'Post Type:', 'geodirectory' );?> |
|
| 3674 | + <?php _e('Post Type:', 'geodirectory'); ?>
|
|
| 3675 | 3675 | </label></td> |
| 3676 | 3676 | <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"> |
| 3677 | - <?php echo $gd_posttypes_option;?> |
|
| 3677 | + <?php echo $gd_posttypes_option; ?> |
|
| 3678 | 3678 | </select></td> |
| 3679 | 3679 | </tr> |
| 3680 | 3680 | <tr> |
| 3681 | - <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td> |
|
| 3682 | - <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td> |
|
| 3681 | + <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
|
|
| 3682 | + <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
|
|
| 3683 | 3683 | </tr> |
| 3684 | 3684 | <tr> |
| 3685 | 3685 | <td class="fld" style="vertical-align:top"><label> |
| 3686 | - <?php _e( 'Progress:', 'geodirectory' );?> |
|
| 3686 | + <?php _e('Progress:', 'geodirectory'); ?>
|
|
| 3687 | 3687 | </label></td> |
| 3688 | 3688 | <td><div id='gd_progressbar_box'> |
| 3689 | 3689 | <div id="gd_progressbar" class="gd_progressbar"> |
@@ -3691,13 +3691,13 @@ discard block |
||
| 3691 | 3691 | </div> |
| 3692 | 3692 | </div> |
| 3693 | 3693 | <p style="display:inline-block"> |
| 3694 | - <?php _e( 'Elapsed Time:', 'geodirectory' );?> |
|
| 3694 | + <?php _e('Elapsed Time:', 'geodirectory'); ?>
|
|
| 3695 | 3695 | </p> |
| 3696 | 3696 | |
| 3697 | 3697 | <p id="gd_timer" class="gd_timer">00:00:00</p></td> |
| 3698 | 3698 | </tr> |
| 3699 | 3699 | <tr class="gd-ie-actions"> |
| 3700 | - <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit"> |
|
| 3700 | + <td style="vertical-align:top"><input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_exposts_submit" id="gd_ie_exposts_submit">
|
|
| 3701 | 3701 | </td> |
| 3702 | 3702 | <td id="gd_ie_ex_files" class="gd-ie-files"></td> |
| 3703 | 3703 | </tr> |
@@ -3710,20 +3710,20 @@ discard block |
||
| 3710 | 3710 | <div id="gd_ie_imcategs" class="metabox-holder"> |
| 3711 | 3711 | <div class="meta-box-sortables ui-sortable"> |
| 3712 | 3712 | <div id="gd_ie_imcats" class="postbox"> |
| 3713 | - <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Import CSV', 'geodirectory' );?></span></h3> |
|
| 3713 | + <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Categories: Import CSV', 'geodirectory'); ?></span></h3>
|
|
| 3714 | 3714 | <div class="inside"> |
| 3715 | 3715 | <table class="form-table"> |
| 3716 | 3716 | <tbody> |
| 3717 | 3717 | <tr> |
| 3718 | 3718 | <td class="gd-imex-box"> |
| 3719 | 3719 | <div class="gd-im-choices"> |
| 3720 | - <p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e( 'Update item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p> |
|
| 3721 | - <p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e( 'Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory' );?></label></p> |
|
| 3720 | + <p><input type="radio" value="update" name="gd_im_choicecat" id="gd_im_cchoice_u" /><label for="gd_im_cchoice_u"><?php _e('Update item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
|
|
| 3721 | + <p><input type="radio" checked="checked" value="skip" name="gd_im_choicecat" id="gd_im_cchoice_s" /><label for="gd_im_cchoice_s"><?php _e('Ignore item if item with cat_id/cat_slug already exists.', 'geodirectory'); ?></label></p>
|
|
| 3722 | 3722 | </div> |
| 3723 | 3723 | <div class="plupload-upload-uic hide-if-no-js" id="gd_im_catplupload-upload-ui"> |
| 3724 | 3724 | <input type="text" readonly="readonly" name="gd_im_cat_file" class="gd-imex-file gd_im_cat_file" id="gd_im_cat" onclick="jQuery('#gd_im_catplupload-browse-button').trigger('click');" />
|
| 3725 | - <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample"> |
|
| 3726 | - <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" /> |
|
| 3725 | + <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr(__('Download Sample CSV', 'geodirectory')); ?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample">
|
|
| 3726 | + <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv; ?>" /> |
|
| 3727 | 3727 | <?php |
| 3728 | 3728 | /** |
| 3729 | 3729 | * Called just after the sample CSV download link. |
@@ -3733,7 +3733,7 @@ discard block |
||
| 3733 | 3733 | */ |
| 3734 | 3734 | do_action('geodir_sample_cats_csv_download_link');
|
| 3735 | 3735 | ?> |
| 3736 | - <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span> |
|
| 3736 | + <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce('gd_im_catpluploadan'); ?>"></span>
|
|
| 3737 | 3737 | <div class="filelist"></div> |
| 3738 | 3738 | </div> |
| 3739 | 3739 | <span id="gd_im_catupload-error" style="display:none"></span> |
@@ -3750,7 +3750,7 @@ discard block |
||
| 3750 | 3750 | <input type="hidden" id="gd_terminateaction" value="continue"/> |
| 3751 | 3751 | </div> |
| 3752 | 3752 | <div class="gd-import-progress" id="gd-import-progress" style="display:none"> |
| 3753 | - <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory');?> </b><font
|
|
| 3753 | + <div class="gd-import-file"><b><?php _e("Import Data Status :", 'geodirectory'); ?> </b><font
|
|
| 3754 | 3754 | id="gd-import-done">0</font> / <font id="gd-import-total">0</font> ( <font |
| 3755 | 3755 | id="gd-import-perc">0%</font> ) |
| 3756 | 3756 | <div class="gd-fileprogress"></div> |
@@ -3762,10 +3762,10 @@ discard block |
||
| 3762 | 3762 | <div class="gd-imex-btns" style="display:none;"> |
| 3763 | 3763 | <input type="hidden" class="geodir_import_file" name="geodir_import_file" value="save"/> |
| 3764 | 3764 | <input onclick="gd_imex_PrepareImport(this, 'cat')" type="button" value="<?php echo CSV_IMPORT_DATA; ?>" id="gd_import_data" class="button-primary" /> |
| 3765 | - <input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e( "Continue Import Data", 'geodirectory' );?>" id="gd_continue_data" class="button-primary" style="display:none"/> |
|
| 3766 | - <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory');?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
|
|
| 3765 | + <input onclick="gd_imex_ContinueImport(this, 'cat')" type="button" value="<?php _e("Continue Import Data", 'geodirectory'); ?>" id="gd_continue_data" class="button-primary" style="display:none"/>
|
|
| 3766 | + <input type="button" value="<?php _e("Terminate Import Data", 'geodirectory'); ?>" id="gd_stop_import" class="button-primary" name="gd_stop_import" style="display:none" onclick="gd_imex_TerminateImport(this, 'cat')"/>
|
|
| 3767 | 3767 | <div id="gd_process_data" style="display:none"> |
| 3768 | - <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory');?>
|
|
| 3768 | + <span class="spinner is-active" style="display:inline-block;margin:0 5px 0 5px;float:left"></span><?php _e("Wait, processing import data...", 'geodirectory'); ?>
|
|
| 3769 | 3769 | </div> |
| 3770 | 3770 | </div> |
| 3771 | 3771 | </td> |
@@ -3779,25 +3779,25 @@ discard block |
||
| 3779 | 3779 | <div id="gd_ie_excategs" class="metabox-holder"> |
| 3780 | 3780 | <div class="meta-box-sortables ui-sortable"> |
| 3781 | 3781 | <div id="gd_ie_ex_cats" class="postbox"> |
| 3782 | - <h3 class="hndle"><span style='vertical-align:top;'><?php echo __( 'GD Categories: Export CSV', 'geodirectory' );?></span></h3> |
|
| 3782 | + <h3 class="hndle"><span style='vertical-align:top;'><?php echo __('GD Categories: Export CSV', 'geodirectory'); ?></span></h3>
|
|
| 3783 | 3783 | <div class="inside"> |
| 3784 | 3784 | <table class="form-table"> |
| 3785 | 3785 | <tbody> |
| 3786 | 3786 | <tr> |
| 3787 | - <td class="fld"><label for="gd_post_type"><?php _e( 'Post Type:', 'geodirectory' );?></label></td> |
|
| 3788 | - <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option;?></select></td> |
|
| 3787 | + <td class="fld"><label for="gd_post_type"><?php _e('Post Type:', 'geodirectory'); ?></label></td>
|
|
| 3788 | + <td><select name="gd_post_type" id="gd_post_type" style="min-width:140px"><?php echo $gd_posttypes_option; ?></select></td> |
|
| 3789 | 3789 | </tr> |
| 3790 | 3790 | <tr> |
| 3791 | - <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e( 'Max entries per csv file:', 'geodirectory' );?></label></td> |
|
| 3792 | - <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option;?></select><span class="description"><?php _e( 'Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory' );?></span></td> |
|
| 3791 | + <td class="fld" style="vertical-align:top"><label for="gd_chunk_size"><?php _e('Max entries per csv file:', 'geodirectory'); ?></label></td>
|
|
| 3792 | + <td><select name="gd_chunk_size" id="gd_chunk_size" style="min-width:140px"><?php echo $gd_chunksize_option; ?></select><span class="description"><?php _e('Please select the maximum number of entries per csv file (defaults to 5000, you might want to lower this to prevent memory issues on some installs)', 'geodirectory'); ?></span></td>
|
|
| 3793 | 3793 | </tr> |
| 3794 | 3794 | <tr> |
| 3795 | - <td class="fld" style="vertical-align:top"><label><?php _e( 'Progress:', 'geodirectory' );?></label></td> |
|
| 3796 | - <td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e( 'Elapsed Time:', 'geodirectory' );?></p> <p id="gd_timer" class="gd_timer">00:00:00</p></td> |
|
| 3795 | + <td class="fld" style="vertical-align:top"><label><?php _e('Progress:', 'geodirectory'); ?></label></td>
|
|
| 3796 | + <td><div id='gd_progressbar_box'><div id="gd_progressbar" class="gd_progressbar"><div class="gd-progress-label"></div></div></div><p style="display:inline-block"><?php _e('Elapsed Time:', 'geodirectory'); ?></p> <p id="gd_timer" class="gd_timer">00:00:00</p></td>
|
|
| 3797 | 3797 | </tr> |
| 3798 | 3798 | <tr class="gd-ie-actions"> |
| 3799 | 3799 | <td style="vertical-align:top"> |
| 3800 | - <input type="submit" value="<?php echo esc_attr( __( 'Export CSV', 'geodirectory' ) );?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit"> |
|
| 3800 | + <input type="submit" value="<?php echo esc_attr(__('Export CSV', 'geodirectory')); ?>" class="button-primary" name="gd_ie_excats_submit" id="gd_ie_excats_submit">
|
|
| 3801 | 3801 | </td> |
| 3802 | 3802 | <td id="gd_ie_ex_files" class="gd-ie-files"></td> |
| 3803 | 3803 | </tr> |
@@ -3819,7 +3819,7 @@ discard block |
||
| 3819 | 3819 | * @param array $gd_chunksize_options File chunk size options. |
| 3820 | 3820 | * @param string $nonce Wordpress security token for GD import & export. |
| 3821 | 3821 | */ |
| 3822 | - do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
|
| 3822 | + do_action('geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce);
|
|
| 3823 | 3823 | ?> |
| 3824 | 3824 | </div> |
| 3825 | 3825 | </div> |
@@ -3838,7 +3838,7 @@ discard block |
||
| 3838 | 3838 | jQuery.ajax({
|
| 3839 | 3839 | url: ajaxurl, |
| 3840 | 3840 | type: "POST", |
| 3841 | - data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce;?>', |
|
| 3841 | + data: 'action=geodir_import_export&task=prepare_import&_pt=' + type + '&_file=' + uploadedFile + '&_nonce=<?php echo $nonce; ?>', |
|
| 3842 | 3842 | dataType: 'json', |
| 3843 | 3843 | cache: false, |
| 3844 | 3844 | success: function(data) {
|
@@ -3890,7 +3890,7 @@ discard block |
||
| 3890 | 3890 | |
| 3891 | 3891 | jQuery(cont).find('.filelist .file').remove();
|
| 3892 | 3892 | |
| 3893 | - jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr( PLZ_SELECT_CSV_FILE );?></p>");
|
|
| 3893 | + jQuery('#gd-import-msg', cont).find('#message').removeClass('updated').addClass('error').html("<p><?php echo esc_attr(PLZ_SELECT_CSV_FILE); ?></p>");
|
|
| 3894 | 3894 | jQuery('#gd-import-msg', cont).show();
|
| 3895 | 3895 | |
| 3896 | 3896 | return false; |
@@ -3949,7 +3949,7 @@ discard block |
||
| 3949 | 3949 | jQuery.ajax({
|
| 3950 | 3950 | url: ajaxurl, |
| 3951 | 3951 | type: "POST", |
| 3952 | - data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce;?>', |
|
| 3952 | + data: 'action=geodir_import_export&task=import_' + type + '&_pt=' + type + '&_file=' + uploadedFile + gddata + '&_ch=' + choice + '&_nonce=<?php echo $nonce; ?>', |
|
| 3953 | 3953 | dataType : 'json', |
| 3954 | 3954 | cache: false, |
| 3955 | 3955 | success: function (data) {
|
@@ -4125,27 +4125,27 @@ discard block |
||
| 4125 | 4125 | |
| 4126 | 4126 | var gdMsg = '<p></p>'; |
| 4127 | 4127 | if ( processed > 0 ) {
|
| 4128 | - var msgParse = '<p><?php echo addslashes( sprintf( __( 'Total %s item(s) found.', 'geodirectory' ), '%s' ) );?></p>'; |
|
| 4128 | + var msgParse = '<p><?php echo addslashes(sprintf(__('Total %s item(s) found.', 'geodirectory'), '%s')); ?></p>';
|
|
| 4129 | 4129 | msgParse = msgParse.replace("%s", processed);
|
| 4130 | 4130 | gdMsg += msgParse; |
| 4131 | 4131 | } |
| 4132 | 4132 | |
| 4133 | 4133 | if ( updated > 0 ) {
|
| 4134 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) updated.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 4134 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) updated.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 4135 | 4135 | msgParse = msgParse.replace("%s", updated);
|
| 4136 | 4136 | msgParse = msgParse.replace("%d", processed);
|
| 4137 | 4137 | gdMsg += msgParse; |
| 4138 | 4138 | } |
| 4139 | 4139 | |
| 4140 | 4140 | if ( created > 0 ) {
|
| 4141 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) added.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 4141 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) added.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 4142 | 4142 | msgParse = msgParse.replace("%s", created);
|
| 4143 | 4143 | msgParse = msgParse.replace("%d", processed);
|
| 4144 | 4144 | gdMsg += msgParse; |
| 4145 | 4145 | } |
| 4146 | 4146 | |
| 4147 | 4147 | if ( skipped > 0 ) {
|
| 4148 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) ignored due to already exists.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 4148 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) ignored due to already exists.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 4149 | 4149 | msgParse = msgParse.replace("%s", skipped);
|
| 4150 | 4150 | msgParse = msgParse.replace("%d", processed);
|
| 4151 | 4151 | gdMsg += msgParse; |
@@ -4155,21 +4155,21 @@ discard block |
||
| 4155 | 4155 | if (type=='loc') {
|
| 4156 | 4156 | invalid_addr = invalid; |
| 4157 | 4157 | } |
| 4158 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 4158 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 4159 | 4159 | msgParse = msgParse.replace("%s", invalid_addr);
|
| 4160 | 4160 | msgParse = msgParse.replace("%d", total);
|
| 4161 | 4161 | gdMsg += msgParse; |
| 4162 | 4162 | } |
| 4163 | 4163 | |
| 4164 | 4164 | if (invalid > 0 && type!='loc') {
|
| 4165 | - var msgParse = '<p><?php echo addslashes( sprintf( __( '%s / %s item(s) could not be added due to blank title/invalid post type.', 'geodirectory' ), '%s', '%d' ) );?></p>'; |
|
| 4165 | + var msgParse = '<p><?php echo addslashes(sprintf(__('%s / %s item(s) could not be added due to blank title/invalid post type.', 'geodirectory'), '%s', '%d')); ?></p>';
|
|
| 4166 | 4166 | msgParse = msgParse.replace("%s", invalid);
|
| 4167 | 4167 | msgParse = msgParse.replace("%d", total);
|
| 4168 | 4168 | gdMsg += msgParse; |
| 4169 | 4169 | } |
| 4170 | 4170 | |
| 4171 | 4171 | if (images > 0) {
|
| 4172 | - gdMsg += '<p><?php echo addslashes( sprintf( CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'] ) );?></p>'; |
|
| 4172 | + gdMsg += '<p><?php echo addslashes(sprintf(CSV_TRANSFER_IMG_FOLDER, $uploads['subdir'])); ?></p>'; |
|
| 4173 | 4173 | } |
| 4174 | 4174 | gdMsg += '<p></p>'; |
| 4175 | 4175 | jQuery('#gd-import-msg', cont).find('#message').removeClass('error').addClass('updated').html(gdMsg);
|
@@ -4318,7 +4318,7 @@ discard block |
||
| 4318 | 4318 | |
| 4319 | 4319 | function gd_process_export_posts(el, post_type, total_posts, chunk_size, pages, page) {
|
| 4320 | 4320 | if (page < 2) {
|
| 4321 | - gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>'); |
|
| 4321 | + gd_progressbar(el, 0, '0% (0 / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 4322 | 4322 | jQuery(el).find('#gd_timer').text('00:00:01');
|
| 4323 | 4323 | jQuery('#gd_ie_ex_files', el).html('');
|
| 4324 | 4324 | } |
@@ -4326,7 +4326,7 @@ discard block |
||
| 4326 | 4326 | jQuery.ajax({
|
| 4327 | 4327 | url: ajaxurl, |
| 4328 | 4328 | type: "POST", |
| 4329 | - data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page, |
|
| 4329 | + data: 'action=geodir_import_export&task=export_posts&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page, |
|
| 4330 | 4330 | dataType : 'json', |
| 4331 | 4331 | cache: false, |
| 4332 | 4332 | beforeSend: function (jqXHR, settings) {},
|
@@ -4340,11 +4340,11 @@ discard block |
||
| 4340 | 4340 | } else {
|
| 4341 | 4341 | if (pages < page || pages == page) {
|
| 4342 | 4342 | window.clearInterval(timer_posts); |
| 4343 | - gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
|
|
| 4343 | + gd_progressbar(el, 100, '100% (' + total_posts + ' / ' + total_posts + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
|
|
| 4344 | 4344 | } else {
|
| 4345 | 4345 | var percentage = Math.ceil(( page / pages ) * 100); |
| 4346 | 4346 | percentage = percentage > 100 ? 100 : percentage; |
| 4347 | - gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>');
|
|
| 4347 | + gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_posts + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 4348 | 4348 | } |
| 4349 | 4349 | if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
|
| 4350 | 4350 | var obj_files = data.files; |
@@ -4374,7 +4374,7 @@ discard block |
||
| 4374 | 4374 | |
| 4375 | 4375 | function gd_process_export_cats(el, post_type, total_cats, chunk_size, pages, page) {
|
| 4376 | 4376 | if (page < 2) {
|
| 4377 | - gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr( __( 'Exporting...', 'geodirectory' ) );?>'); |
|
| 4377 | + gd_progressbar(el, 0, '0% (0 / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php echo esc_attr(__('Exporting...', 'geodirectory')); ?>');
|
|
| 4378 | 4378 | jQuery(el).find('#gd_timer').text('00:00:01');
|
| 4379 | 4379 | jQuery('#gd_ie_ex_files', el).html('');
|
| 4380 | 4380 | } |
@@ -4382,7 +4382,7 @@ discard block |
||
| 4382 | 4382 | jQuery.ajax({
|
| 4383 | 4383 | url: ajaxurl, |
| 4384 | 4384 | type: "POST", |
| 4385 | - data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce;?>&_p=' + page, |
|
| 4385 | + data: 'action=geodir_import_export&task=export_cats&_pt=' + post_type + '&_n=' + chunk_size + '&_nonce=<?php echo $nonce; ?>&_p=' + page, |
|
| 4386 | 4386 | dataType : 'json', |
| 4387 | 4387 | cache: false, |
| 4388 | 4388 | beforeSend: function (jqXHR, settings) {},
|
@@ -4396,11 +4396,11 @@ discard block |
||
| 4396 | 4396 | } else {
|
| 4397 | 4397 | if (pages < page || pages == page) {
|
| 4398 | 4398 | window.clearInterval(timer_cats); |
| 4399 | - gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr( __( 'Complete!', 'geodirectory' ) );?>');
|
|
| 4399 | + gd_progressbar(el, 100, '100% (' + total_cats + ' / ' + total_cats + ') <i class="fa fa-check"></i><?php echo esc_attr(__('Complete!', 'geodirectory')); ?>');
|
|
| 4400 | 4400 | } else {
|
| 4401 | 4401 | var percentage = Math.ceil(( page / pages ) * 100); |
| 4402 | 4402 | percentage = percentage > 100 ? 100 : percentage; |
| 4403 | - gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e( 'Exporting...', 'geodirectory' );?>');
|
|
| 4403 | + gd_progressbar(el, percentage, '' + percentage + '% (' + ( page * chunk_size ) + ' / ' + total_cats + ') <i class="fa fa-refresh fa-spin"></i><?php esc_attr_e('Exporting...', 'geodirectory'); ?>');
|
|
| 4404 | 4404 | } |
| 4405 | 4405 | if (typeof data.files != 'undefined' && jQuery(data.files).length ) {
|
| 4406 | 4406 | var obj_files = data.files; |
@@ -4457,8 +4457,8 @@ discard block |
||
| 4457 | 4457 | function geodir_init_filesystem() |
| 4458 | 4458 | {
|
| 4459 | 4459 | |
| 4460 | - if(!function_exists('get_filesystem_method')){
|
|
| 4461 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 4460 | + if (!function_exists('get_filesystem_method')) {
|
|
| 4461 | + require_once(ABSPATH . "/wp-admin/includes/file.php"); |
|
| 4462 | 4462 | } |
| 4463 | 4463 | $access_type = get_filesystem_method(); |
| 4464 | 4464 | if ($access_type === 'direct') {
|
@@ -4511,7 +4511,7 @@ discard block |
||
| 4511 | 4511 | * @package GeoDirectory |
| 4512 | 4512 | */ |
| 4513 | 4513 | function geodir_filesystem_notice() |
| 4514 | -{ if ( defined( 'DOING_AJAX' ) ){return;}
|
|
| 4514 | +{ if (defined('DOING_AJAX')) {return; }
|
|
| 4515 | 4515 | $access_type = get_filesystem_method(); |
| 4516 | 4516 | if ($access_type === 'direct') {
|
| 4517 | 4517 | } elseif (!defined('FTP_USER')) {
|
@@ -4546,18 +4546,18 @@ discard block |
||
| 4546 | 4546 | // try to set higher limits for import |
| 4547 | 4547 | $max_input_time = ini_get('max_input_time');
|
| 4548 | 4548 | $max_execution_time = ini_get('max_execution_time');
|
| 4549 | - $memory_limit= ini_get('memory_limit');
|
|
| 4549 | + $memory_limit = ini_get('memory_limit');
|
|
| 4550 | 4550 | |
| 4551 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 4551 | + if (!$max_input_time || $max_input_time < 3000) {
|
|
| 4552 | 4552 | @ini_set('max_input_time', 3000);
|
| 4553 | 4553 | } |
| 4554 | 4554 | |
| 4555 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 4555 | + if (!$max_execution_time || $max_execution_time < 3000) {
|
|
| 4556 | 4556 | @ini_set('max_execution_time', 3000);
|
| 4557 | 4557 | } |
| 4558 | 4558 | |
| 4559 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 4560 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 4559 | + if ($memory_limit && str_replace('M', '', $memory_limit)) {
|
|
| 4560 | + if (str_replace('M', '', $memory_limit) < 256) {
|
|
| 4561 | 4561 | @ini_set('memory_limit', '256M');
|
| 4562 | 4562 | } |
| 4563 | 4563 | } |
@@ -4566,43 +4566,43 @@ discard block |
||
| 4566 | 4566 | |
| 4567 | 4567 | $json = array(); |
| 4568 | 4568 | |
| 4569 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 4570 | - wp_send_json( $json ); |
|
| 4569 | + if (!current_user_can('manage_options')) {
|
|
| 4570 | + wp_send_json($json); |
|
| 4571 | 4571 | } |
| 4572 | 4572 | |
| 4573 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 4574 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 4575 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 4573 | + $task = isset($_REQUEST['task']) ? $_REQUEST['task'] : NULL; |
|
| 4574 | + $nonce = isset($_REQUEST['_nonce']) ? $_REQUEST['_nonce'] : NULL; |
|
| 4575 | + $stat = isset($_REQUEST['_st']) ? $_REQUEST['_st'] : false; |
|
| 4576 | 4576 | |
| 4577 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 4578 | - wp_send_json( $json ); |
|
| 4577 | + if (!wp_verify_nonce($nonce, 'geodir_import_export_nonce')) {
|
|
| 4578 | + wp_send_json($json); |
|
| 4579 | 4579 | } |
| 4580 | 4580 | |
| 4581 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 4582 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 4581 | + $post_type = isset($_REQUEST['_pt']) ? $_REQUEST['_pt'] : NULL; |
|
| 4582 | + $chunk_per_page = isset($_REQUEST['_n']) ? absint($_REQUEST['_n']) : NULL; |
|
| 4583 | 4583 | $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
| 4584 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 4584 | + $chunk_page_no = isset($_REQUEST['_p']) ? absint($_REQUEST['_p']) : 1; |
|
| 4585 | 4585 | |
| 4586 | 4586 | $wp_filesystem = geodir_init_filesystem(); |
| 4587 | 4587 | if (!$wp_filesystem) {
|
| 4588 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 4589 | - wp_send_json( $json ); |
|
| 4588 | + $json['error'] = __('Filesystem ERROR: Could not access filesystem.', 'geodirectory');
|
|
| 4589 | + wp_send_json($json); |
|
| 4590 | 4590 | } |
| 4591 | 4591 | |
| 4592 | 4592 | if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
| 4593 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 4594 | - wp_send_json( $json ); |
|
| 4593 | + $json['error'] = __('Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory');
|
|
| 4594 | + wp_send_json($json); |
|
| 4595 | 4595 | } |
| 4596 | 4596 | |
| 4597 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 4598 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 4599 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 4600 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4601 | - wp_send_json( $json ); |
|
| 4597 | + $csv_file_dir = geodir_path_import_export(false); |
|
| 4598 | + if (!$wp_filesystem->is_dir($csv_file_dir)) {
|
|
| 4599 | + if (!$wp_filesystem->mkdir($csv_file_dir, FS_CHMOD_DIR)) {
|
|
| 4600 | + $json['error'] = __('ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 4601 | + wp_send_json($json); |
|
| 4602 | 4602 | } |
| 4603 | 4603 | } |
| 4604 | 4604 | |
| 4605 | - switch ( $task ) {
|
|
| 4605 | + switch ($task) {
|
|
| 4606 | 4606 | case 'export_posts': {
|
| 4607 | 4607 | // WPML |
| 4608 | 4608 | $is_wpml = geodir_is_wpml(); |
@@ -4613,12 +4613,12 @@ discard block |
||
| 4613 | 4613 | $sitepress->switch_lang('all', true);
|
| 4614 | 4614 | } |
| 4615 | 4615 | // WPML |
| 4616 | - if ( $post_type == 'gd_event' ) {
|
|
| 4616 | + if ($post_type == 'gd_event') {
|
|
| 4617 | 4617 | //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 ); |
| 4618 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 4618 | + add_filter('geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2);
|
|
| 4619 | 4619 | } |
| 4620 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 4621 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 4620 | + $file_name = $post_type . '_' . date('dmyHi');
|
|
| 4621 | + $posts_count = geodir_get_posts_count($post_type); |
|
| 4622 | 4622 | $file_url_base = geodir_path_import_export() . '/'; |
| 4623 | 4623 | $file_url = $file_url_base . $file_name . '.csv'; |
| 4624 | 4624 | $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
@@ -4626,10 +4626,10 @@ discard block |
||
| 4626 | 4626 | |
| 4627 | 4627 | $chunk_file_paths = array(); |
| 4628 | 4628 | |
| 4629 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4630 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4631 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 4632 | - $percentage = min( $percentage, 100 ); |
|
| 4629 | + if (isset($_REQUEST['_st'])) {
|
|
| 4630 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 4631 | + $percentage = count($posts_count) > 0 && $line_count > 0 ? ceil($line_count / $posts_count) * 100 : 0; |
|
| 4632 | + $percentage = min($percentage, 100); |
|
| 4633 | 4633 | |
| 4634 | 4634 | $json['percentage'] = $percentage; |
| 4635 | 4635 | // WPML |
@@ -4637,49 +4637,49 @@ discard block |
||
| 4637 | 4637 | $sitepress->switch_lang($active_lang, true); |
| 4638 | 4638 | } |
| 4639 | 4639 | // WPML |
| 4640 | - wp_send_json( $json ); |
|
| 4640 | + wp_send_json($json); |
|
| 4641 | 4641 | exit; |
| 4642 | 4642 | } else {
|
| 4643 | - if ( !$posts_count > 0 ) {
|
|
| 4644 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4643 | + if (!$posts_count > 0) {
|
|
| 4644 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 4645 | 4645 | } else {
|
| 4646 | 4646 | $total_posts = $posts_count; |
| 4647 | 4647 | if ($chunk_per_page > $total_posts) {
|
| 4648 | 4648 | $chunk_per_page = $total_posts; |
| 4649 | 4649 | } |
| 4650 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 4650 | + $chunk_total_pages = ceil($total_posts / $chunk_per_page); |
|
| 4651 | 4651 | |
| 4652 | 4652 | $j = $chunk_page_no; |
| 4653 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 4653 | + $chunk_save_posts = geodir_imex_get_posts($post_type, $chunk_per_page, $j); |
|
| 4654 | 4654 | |
| 4655 | 4655 | $per_page = 500; |
| 4656 | 4656 | if ($per_page > $chunk_per_page) {
|
| 4657 | 4657 | $per_page = $chunk_per_page; |
| 4658 | 4658 | } |
| 4659 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4659 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 4660 | 4660 | |
| 4661 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4662 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 4661 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 4662 | + $save_posts = array_slice($chunk_save_posts, ($i * $per_page), $per_page); |
|
| 4663 | 4663 | |
| 4664 | 4664 | $clear = $i == 0 ? true : false; |
| 4665 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 4665 | + geodir_save_csv_data($file_path_temp, $save_posts, $clear); |
|
| 4666 | 4666 | } |
| 4667 | 4667 | |
| 4668 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4668 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 4669 | 4669 | $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
| 4670 | 4670 | $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
| 4671 | 4671 | $file_path = $csv_file_dir . '/' . $chunk_file_name; |
| 4672 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4672 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 4673 | 4673 | |
| 4674 | 4674 | $file_url = $file_url_base . $chunk_file_name; |
| 4675 | 4675 | $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
| 4676 | 4676 | } |
| 4677 | 4677 | |
| 4678 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4678 | + if (!empty($chunk_file_paths)) {
|
|
| 4679 | 4679 | $json['total'] = $posts_count; |
| 4680 | 4680 | $json['files'] = $chunk_file_paths; |
| 4681 | 4681 | } else {
|
| 4682 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4682 | + $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 4683 | 4683 | } |
| 4684 | 4684 | } |
| 4685 | 4685 | // WPML |
@@ -4687,7 +4687,7 @@ discard block |
||
| 4687 | 4687 | $sitepress->switch_lang($active_lang, true); |
| 4688 | 4688 | } |
| 4689 | 4689 | // WPML |
| 4690 | - wp_send_json( $json ); |
|
| 4690 | + wp_send_json($json); |
|
| 4691 | 4691 | } |
| 4692 | 4692 | } |
| 4693 | 4693 | break; |
@@ -4701,9 +4701,9 @@ discard block |
||
| 4701 | 4701 | $sitepress->switch_lang('all', true);
|
| 4702 | 4702 | } |
| 4703 | 4703 | // WPML |
| 4704 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 4704 | + $file_name = $post_type . 'category_' . date('dmyHi');
|
|
| 4705 | 4705 | |
| 4706 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 4706 | + $terms_count = geodir_get_terms_count($post_type); |
|
| 4707 | 4707 | $file_url_base = geodir_path_import_export() . '/'; |
| 4708 | 4708 | $file_url = $file_url_base . $file_name . '.csv'; |
| 4709 | 4709 | $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
@@ -4711,10 +4711,10 @@ discard block |
||
| 4711 | 4711 | |
| 4712 | 4712 | $chunk_file_paths = array(); |
| 4713 | 4713 | |
| 4714 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4715 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4716 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 4717 | - $percentage = min( $percentage, 100 ); |
|
| 4714 | + if (isset($_REQUEST['_st'])) {
|
|
| 4715 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 4716 | + $percentage = count($terms_count) > 0 && $line_count > 0 ? ceil($line_count / $terms_count) * 100 : 0; |
|
| 4717 | + $percentage = min($percentage, 100); |
|
| 4718 | 4718 | |
| 4719 | 4719 | $json['percentage'] = $percentage; |
| 4720 | 4720 | // WPML |
@@ -4722,48 +4722,48 @@ discard block |
||
| 4722 | 4722 | $sitepress->switch_lang($active_lang, true); |
| 4723 | 4723 | } |
| 4724 | 4724 | // WPML |
| 4725 | - wp_send_json( $json ); |
|
| 4725 | + wp_send_json($json); |
|
| 4726 | 4726 | } else {
|
| 4727 | - if ( !$terms_count > 0 ) {
|
|
| 4728 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4727 | + if (!$terms_count > 0) {
|
|
| 4728 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 4729 | 4729 | } else {
|
| 4730 | 4730 | $total_terms = $terms_count; |
| 4731 | 4731 | if ($chunk_per_page > $terms_count) {
|
| 4732 | 4732 | $chunk_per_page = $terms_count; |
| 4733 | 4733 | } |
| 4734 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 4734 | + $chunk_total_pages = ceil($total_terms / $chunk_per_page); |
|
| 4735 | 4735 | |
| 4736 | 4736 | $j = $chunk_page_no; |
| 4737 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 4737 | + $chunk_save_terms = geodir_imex_get_terms($post_type, $chunk_per_page, $j); |
|
| 4738 | 4738 | |
| 4739 | 4739 | $per_page = 500; |
| 4740 | 4740 | if ($per_page > $chunk_per_page) {
|
| 4741 | 4741 | $per_page = $chunk_per_page; |
| 4742 | 4742 | } |
| 4743 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4743 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 4744 | 4744 | |
| 4745 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4746 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 4745 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 4746 | + $save_terms = array_slice($chunk_save_terms, ($i * $per_page), $per_page); |
|
| 4747 | 4747 | |
| 4748 | 4748 | $clear = $i == 0 ? true : false; |
| 4749 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 4749 | + geodir_save_csv_data($file_path_temp, $save_terms, $clear); |
|
| 4750 | 4750 | } |
| 4751 | 4751 | |
| 4752 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4752 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 4753 | 4753 | $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
| 4754 | 4754 | $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
| 4755 | 4755 | $file_path = $csv_file_dir . '/' . $chunk_file_name; |
| 4756 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4756 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 4757 | 4757 | |
| 4758 | 4758 | $file_url = $file_url_base . $chunk_file_name; |
| 4759 | 4759 | $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
| 4760 | 4760 | } |
| 4761 | 4761 | |
| 4762 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4762 | + if (!empty($chunk_file_paths)) {
|
|
| 4763 | 4763 | $json['total'] = $terms_count; |
| 4764 | 4764 | $json['files'] = $chunk_file_paths; |
| 4765 | 4765 | } else {
|
| 4766 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4766 | + $json['error'] = __('ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory');
|
|
| 4767 | 4767 | } |
| 4768 | 4768 | } |
| 4769 | 4769 | // WPML |
@@ -4771,67 +4771,67 @@ discard block |
||
| 4771 | 4771 | $sitepress->switch_lang($active_lang, true); |
| 4772 | 4772 | } |
| 4773 | 4773 | // WPML |
| 4774 | - wp_send_json( $json ); |
|
| 4774 | + wp_send_json($json); |
|
| 4775 | 4775 | } |
| 4776 | 4776 | } |
| 4777 | 4777 | break; |
| 4778 | 4778 | case 'export_locations': {
|
| 4779 | 4779 | $file_url_base = geodir_path_import_export() . '/'; |
| 4780 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 4780 | + $file_name = 'gd_locations_' . date('dmyHi');
|
|
| 4781 | 4781 | $file_url = $file_url_base . $file_name . '.csv'; |
| 4782 | 4782 | $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
| 4783 | 4783 | $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
| 4784 | 4784 | |
| 4785 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 4785 | + $items_count = (int) geodir_location_imex_count_locations(); |
|
| 4786 | 4786 | |
| 4787 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4788 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4789 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 4790 | - $percentage = min( $percentage, 100 ); |
|
| 4787 | + if (isset($_REQUEST['_st'])) {
|
|
| 4788 | + $line_count = (int) geodir_import_export_line_count($file_path_temp); |
|
| 4789 | + $percentage = count($items_count) > 0 && $line_count > 0 ? ceil($line_count / $items_count) * 100 : 0; |
|
| 4790 | + $percentage = min($percentage, 100); |
|
| 4791 | 4791 | |
| 4792 | 4792 | $json['percentage'] = $percentage; |
| 4793 | - wp_send_json( $json ); |
|
| 4793 | + wp_send_json($json); |
|
| 4794 | 4794 | } else {
|
| 4795 | 4795 | $chunk_file_paths = array(); |
| 4796 | 4796 | |
| 4797 | - if ( !$items_count > 0 ) {
|
|
| 4798 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4797 | + if (!$items_count > 0) {
|
|
| 4798 | + $json['error'] = __('No records to export.', 'geodirectory');
|
|
| 4799 | 4799 | } else {
|
| 4800 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 4801 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 4800 | + $chunk_per_page = min($chunk_per_page, $items_count); |
|
| 4801 | + $chunk_total_pages = ceil($items_count / $chunk_per_page); |
|
| 4802 | 4802 | |
| 4803 | 4803 | $j = $chunk_page_no; |
| 4804 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 4804 | + $chunk_save_items = geodir_location_imex_locations_data($chunk_per_page, $j); |
|
| 4805 | 4805 | |
| 4806 | 4806 | $per_page = 500; |
| 4807 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 4808 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4807 | + $per_page = min($per_page, $chunk_per_page); |
|
| 4808 | + $total_pages = ceil($chunk_per_page / $per_page); |
|
| 4809 | 4809 | |
| 4810 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4811 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 4810 | + for ($i = 0; $i <= $total_pages; $i++) {
|
|
| 4811 | + $save_items = array_slice($chunk_save_items, ($i * $per_page), $per_page); |
|
| 4812 | 4812 | |
| 4813 | 4813 | $clear = $i == 0 ? true : false; |
| 4814 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 4814 | + geodir_save_csv_data($file_path_temp, $save_items, $clear); |
|
| 4815 | 4815 | } |
| 4816 | 4816 | |
| 4817 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4817 | + if ($wp_filesystem->exists($file_path_temp)) {
|
|
| 4818 | 4818 | $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
| 4819 | 4819 | $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
| 4820 | 4820 | $file_path = $csv_file_dir . '/' . $chunk_file_name; |
| 4821 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4821 | + $wp_filesystem->move($file_path_temp, $file_path, true); |
|
| 4822 | 4822 | |
| 4823 | 4823 | $file_url = $file_url_base . $chunk_file_name; |
| 4824 | 4824 | $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
| 4825 | 4825 | } |
| 4826 | 4826 | |
| 4827 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4827 | + if (!empty($chunk_file_paths)) {
|
|
| 4828 | 4828 | $json['total'] = $items_count; |
| 4829 | 4829 | $json['files'] = $chunk_file_paths; |
| 4830 | 4830 | } else {
|
| 4831 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 4831 | + $json['error'] = __('Fail, something wrong to create csv file.', 'geodirectory');
|
|
| 4832 | 4832 | } |
| 4833 | 4833 | } |
| 4834 | - wp_send_json( $json ); |
|
| 4834 | + wp_send_json($json); |
|
| 4835 | 4835 | } |
| 4836 | 4836 | } |
| 4837 | 4837 | break; |
@@ -4847,32 +4847,32 @@ discard block |
||
| 4847 | 4847 | } |
| 4848 | 4848 | // WPML |
| 4849 | 4849 | |
| 4850 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 4850 | + ini_set('auto_detect_line_endings', true);
|
|
| 4851 | 4851 | |
| 4852 | 4852 | $uploads = wp_upload_dir(); |
| 4853 | 4853 | $uploads_dir = $uploads['path']; |
| 4854 | 4854 | $uploads_subdir = $uploads['subdir']; |
| 4855 | 4855 | |
| 4856 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 4857 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4856 | + $csv_file = isset($_POST['_file']) ? $_POST['_file'] : NULL; |
|
| 4857 | + $import_choice = isset($_REQUEST['_ch']) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4858 | 4858 | |
| 4859 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 4860 | - $csv_filename = end( $csv_file_arr ); |
|
| 4859 | + $csv_file_arr = explode('/', $csv_file);
|
|
| 4860 | + $csv_filename = end($csv_file_arr); |
|
| 4861 | 4861 | $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
| 4862 | 4862 | |
| 4863 | 4863 | $json['file'] = $csv_file; |
| 4864 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4864 | + $json['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
|
| 4865 | 4865 | |
| 4866 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4867 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4866 | + if ($csv_file && $wp_filesystem->is_file($target_path) && $wp_filesystem->exists($target_path)) {
|
|
| 4867 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $csv_filename); |
|
| 4868 | 4868 | |
| 4869 | 4869 | if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
| 4870 | 4870 | $json['error'] = NULL; |
| 4871 | 4871 | $json['rows'] = 0; |
| 4872 | 4872 | |
| 4873 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4874 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4875 | - if ( !empty( $data ) ) {
|
|
| 4873 | + if (($handle = fopen($target_path, "r")) !== FALSE) {
|
|
| 4874 | + while (($data = fgetcsv($handle, 100000, ",")) !== FALSE) {
|
|
| 4875 | + if (!empty($data)) {
|
|
| 4876 | 4876 | $file[] = $data; |
| 4877 | 4877 | } |
| 4878 | 4878 | } |
@@ -4885,19 +4885,19 @@ discard block |
||
| 4885 | 4885 | $json['error'] = __('No data found in csv file.', 'geodirectory');
|
| 4886 | 4886 | } |
| 4887 | 4887 | } else {
|
| 4888 | - wp_send_json( $json ); |
|
| 4888 | + wp_send_json($json); |
|
| 4889 | 4889 | } |
| 4890 | 4890 | } else {
|
| 4891 | - wp_send_json( $json ); |
|
| 4891 | + wp_send_json($json); |
|
| 4892 | 4892 | } |
| 4893 | 4893 | |
| 4894 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4895 | - wp_send_json( $json ); |
|
| 4894 | + if ($task == 'prepare_import' || !empty($json['error'])) {
|
|
| 4895 | + wp_send_json($json); |
|
| 4896 | 4896 | } |
| 4897 | 4897 | |
| 4898 | 4898 | $total = $json['rows']; |
| 4899 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4900 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4899 | + $limit = isset($_POST['limit']) ? (int) $_POST['limit'] : 1; |
|
| 4900 | + $processed = isset($_POST['processed']) ? (int) $_POST['processed'] : 0; |
|
| 4901 | 4901 | |
| 4902 | 4902 | $count = $limit; |
| 4903 | 4903 | $requested_limit = $limit; |
@@ -4926,13 +4926,13 @@ discard block |
||
| 4926 | 4926 | |
| 4927 | 4927 | $post_types = geodir_get_posttypes(); |
| 4928 | 4928 | |
| 4929 | - if ( $task == 'import_cat' ) {
|
|
| 4929 | + if ($task == 'import_cat') {
|
|
| 4930 | 4930 | if (!empty($file)) {
|
| 4931 | 4931 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 4932 | 4932 | |
| 4933 | 4933 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 4934 | 4934 | $json['error'] = CSV_INVAILD_FILE; |
| 4935 | - wp_send_json( $json ); |
|
| 4935 | + wp_send_json($json); |
|
| 4936 | 4936 | exit; |
| 4937 | 4937 | } |
| 4938 | 4938 | |
@@ -4941,7 +4941,7 @@ discard block |
||
| 4941 | 4941 | |
| 4942 | 4942 | if (isset($file[$index])) {
|
| 4943 | 4943 | $row = $file[$index]; |
| 4944 | - $row = array_map( 'trim', $row ); |
|
| 4944 | + $row = array_map('trim', $row);
|
|
| 4945 | 4945 | //$row = array_map( 'utf8_encode', $row ); |
| 4946 | 4946 | |
| 4947 | 4947 | $cat_id = ''; |
@@ -4957,26 +4957,26 @@ discard block |
||
| 4957 | 4957 | $cat_language = ''; |
| 4958 | 4958 | |
| 4959 | 4959 | $c = 0; |
| 4960 | - foreach ($columns as $column ) {
|
|
| 4961 | - if ( $column == 'cat_id' ) {
|
|
| 4962 | - $cat_id = (int)$row[$c]; |
|
| 4963 | - } else if ( $column == 'cat_name' ) {
|
|
| 4960 | + foreach ($columns as $column) {
|
|
| 4961 | + if ($column == 'cat_id') {
|
|
| 4962 | + $cat_id = (int) $row[$c]; |
|
| 4963 | + } else if ($column == 'cat_name') {
|
|
| 4964 | 4964 | $cat_name = $row[$c]; |
| 4965 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4965 | + } else if ($column == 'cat_slug') {
|
|
| 4966 | 4966 | $cat_slug = $row[$c]; |
| 4967 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4967 | + } else if ($column == 'cat_posttype') {
|
|
| 4968 | 4968 | $cat_posttype = $row[$c]; |
| 4969 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4969 | + } else if ($column == 'cat_parent') {
|
|
| 4970 | 4970 | $cat_parent = trim($row[$c]); |
| 4971 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4971 | + } else if ($column == 'cat_schema' && $row[$c] != '') {
|
|
| 4972 | 4972 | $cat_schema = $row[$c]; |
| 4973 | - } else if ( $column == 'cat_description' ) {
|
|
| 4973 | + } else if ($column == 'cat_description') {
|
|
| 4974 | 4974 | $cat_description = $row[$c]; |
| 4975 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4975 | + } else if ($column == 'cat_top_description') {
|
|
| 4976 | 4976 | $cat_top_description = $row[$c]; |
| 4977 | - } else if ( $column == 'cat_image' ) {
|
|
| 4977 | + } else if ($column == 'cat_image') {
|
|
| 4978 | 4978 | $cat_image = $row[$c]; |
| 4979 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4979 | + } else if ($column == 'cat_icon') {
|
|
| 4980 | 4980 | $cat_icon = $row[$c]; |
| 4981 | 4981 | } |
| 4982 | 4982 | // WPML |
@@ -4987,7 +4987,7 @@ discard block |
||
| 4987 | 4987 | $c++; |
| 4988 | 4988 | } |
| 4989 | 4989 | |
| 4990 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4990 | + if ($cat_name == '' || !in_array($cat_posttype, $post_types)) {
|
|
| 4991 | 4991 | $invalid++; |
| 4992 | 4992 | continue; |
| 4993 | 4993 | } |
@@ -5004,8 +5004,8 @@ discard block |
||
| 5004 | 5004 | $term_data['description'] = $cat_description; |
| 5005 | 5005 | $term_data['cat_schema'] = $cat_schema; |
| 5006 | 5006 | $term_data['top_description'] = $cat_top_description; |
| 5007 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 5008 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 5007 | + $term_data['image'] = $cat_image != '' ? basename($cat_image) : ''; |
|
| 5008 | + $term_data['icon'] = $cat_icon != '' ? basename($cat_icon) : ''; |
|
| 5009 | 5009 | |
| 5010 | 5010 | //$term_data = array_map( 'utf8_encode', $term_data ); |
| 5011 | 5011 | |
@@ -5014,14 +5014,14 @@ discard block |
||
| 5014 | 5014 | $term_data['taxonomy'] = $taxonomy; |
| 5015 | 5015 | |
| 5016 | 5016 | $term_parent_id = 0; |
| 5017 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 5017 | + if ($cat_parent != "" || (int) $cat_parent > 0) {
|
|
| 5018 | 5018 | $term_parent = ''; |
| 5019 | 5019 | |
| 5020 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 5020 | + if ($term_parent = get_term_by('name', $cat_parent, $taxonomy)) {
|
|
| 5021 | 5021 | $term_parent = $term_parent; |
| 5022 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 5022 | + } else if ($term_parent = get_term_by('slug', $cat_parent, $taxonomy)) {
|
|
| 5023 | 5023 | $term_parent = $term_parent; |
| 5024 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 5024 | + } else if ($term_parent = get_term_by('id', $cat_parent, $taxonomy)) {
|
|
| 5025 | 5025 | $term_parent = $term_parent; |
| 5026 | 5026 | } else {
|
| 5027 | 5027 | $term_parent_data = array(); |
@@ -5029,47 +5029,47 @@ discard block |
||
| 5029 | 5029 | //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
| 5030 | 5030 | $term_parent_data['taxonomy'] = $taxonomy; |
| 5031 | 5031 | |
| 5032 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 5032 | + $term_parent_id = (int) geodir_imex_insert_term($taxonomy, $term_parent_data); |
|
| 5033 | 5033 | } |
| 5034 | 5034 | |
| 5035 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 5036 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 5035 | + if (!empty($term_parent) && !is_wp_error($term_parent)) {
|
|
| 5036 | + $term_parent_id = (int) $term_parent->term_id; |
|
| 5037 | 5037 | } |
| 5038 | 5038 | } |
| 5039 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 5039 | + $term_data['parent'] = (int) $term_parent_id; |
|
| 5040 | 5040 | |
| 5041 | 5041 | $term_id = NULL; |
| 5042 | - if ( $import_choice == 'update' ) {
|
|
| 5043 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5042 | + if ($import_choice == 'update') {
|
|
| 5043 | + if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
|
|
| 5044 | 5044 | $term_data['term_id'] = $term['term_id']; |
| 5045 | 5045 | |
| 5046 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5046 | + if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
|
|
| 5047 | 5047 | $updated++; |
| 5048 | 5048 | } else {
|
| 5049 | 5049 | $invalid++; |
| 5050 | 5050 | } |
| 5051 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5051 | + } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 5052 | 5052 | $term_data['term_id'] = $term['term_id']; |
| 5053 | 5053 | |
| 5054 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5054 | + if ($term_id = geodir_imex_update_term($taxonomy, $term_data)) {
|
|
| 5055 | 5055 | $updated++; |
| 5056 | 5056 | } else {
|
| 5057 | 5057 | $invalid++; |
| 5058 | 5058 | } |
| 5059 | 5059 | } else {
|
| 5060 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5060 | + if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
|
|
| 5061 | 5061 | $created++; |
| 5062 | 5062 | } else {
|
| 5063 | 5063 | $invalid++; |
| 5064 | 5064 | } |
| 5065 | 5065 | } |
| 5066 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5067 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5066 | + } else if ($import_choice == 'skip') {
|
|
| 5067 | + if ($cat_id > 0 && $term = (array) term_exists($cat_id, $taxonomy)) {
|
|
| 5068 | 5068 | $skipped++; |
| 5069 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5069 | + } else if ($term_data['slug'] != '' && $term = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 5070 | 5070 | $skipped++; |
| 5071 | 5071 | } else {
|
| 5072 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5072 | + if ($term_id = geodir_imex_insert_term($taxonomy, $term_data)) {
|
|
| 5073 | 5073 | $created++; |
| 5074 | 5074 | } else {
|
| 5075 | 5075 | $invalid++; |
@@ -5079,37 +5079,37 @@ discard block |
||
| 5079 | 5079 | $invalid++; |
| 5080 | 5080 | } |
| 5081 | 5081 | |
| 5082 | - if ( $term_id ) {
|
|
| 5083 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 5084 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 5082 | + if ($term_id) {
|
|
| 5083 | + if (isset($term_data['top_description'])) {
|
|
| 5084 | + update_tax_meta($term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype); |
|
| 5085 | 5085 | } |
| 5086 | 5086 | |
| 5087 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 5088 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 5087 | + if (isset($term_data['cat_schema'])) {
|
|
| 5088 | + update_tax_meta($term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype); |
|
| 5089 | 5089 | } |
| 5090 | 5090 | |
| 5091 | 5091 | $attachment = false; |
| 5092 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 5093 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 5094 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5092 | + if (isset($term_data['image']) && $term_data['image'] != '') {
|
|
| 5093 | + $cat_image = geodir_get_default_catimage($term_id, $cat_posttype); |
|
| 5094 | + $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; |
|
| 5095 | 5095 | |
| 5096 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 5096 | + if (basename($cat_image) != $term_data['image']) {
|
|
| 5097 | 5097 | $attachment = true; |
| 5098 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 5098 | + update_tax_meta($term_id, 'ct_cat_default_img', array('id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image']), $cat_posttype);
|
|
| 5099 | 5099 | } |
| 5100 | 5100 | } |
| 5101 | 5101 | |
| 5102 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 5103 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 5104 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5102 | + if (isset($term_data['icon']) && $term_data['icon'] != '') {
|
|
| 5103 | + $cat_icon = get_tax_meta($term_id, 'ct_cat_icon', false, $cat_posttype); |
|
| 5104 | + $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : ''; |
|
| 5105 | 5105 | |
| 5106 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 5106 | + if (basename($cat_icon) != $term_data['icon']) {
|
|
| 5107 | 5107 | $attachment = true; |
| 5108 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 5108 | + update_tax_meta($term_id, 'ct_cat_icon', array('id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon']), $cat_posttype);
|
|
| 5109 | 5109 | } |
| 5110 | 5110 | } |
| 5111 | 5111 | |
| 5112 | - if ( $attachment ) {
|
|
| 5112 | + if ($attachment) {
|
|
| 5113 | 5113 | $images++; |
| 5114 | 5114 | } |
| 5115 | 5115 | } |
@@ -5131,14 +5131,14 @@ discard block |
||
| 5131 | 5131 | $json['invalid'] = $invalid; |
| 5132 | 5132 | $json['images'] = $images; |
| 5133 | 5133 | |
| 5134 | - wp_send_json( $json ); |
|
| 5134 | + wp_send_json($json); |
|
| 5135 | 5135 | exit; |
| 5136 | - } else if ( $task == 'import_post' ) {
|
|
| 5136 | + } else if ($task == 'import_post') {
|
|
| 5137 | 5137 | |
| 5138 | 5138 | //run some stuff to make the import quicker |
| 5139 | - wp_defer_term_counting( true ); |
|
| 5140 | - wp_defer_comment_counting( true ); |
|
| 5141 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 5139 | + wp_defer_term_counting(true); |
|
| 5140 | + wp_defer_comment_counting(true); |
|
| 5141 | + $wpdb->query('SET autocommit = 0;');
|
|
| 5142 | 5142 | |
| 5143 | 5143 | //remove_all_actions('publish_post');
|
| 5144 | 5144 | //remove_all_actions('transition_post_status');
|
@@ -5148,26 +5148,26 @@ discard block |
||
| 5148 | 5148 | if (!empty($file)) {
|
| 5149 | 5149 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
| 5150 | 5150 | $default_status = 'publish'; |
| 5151 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 5151 | + $current_date = date_i18n('Y-m-d', time());
|
|
| 5152 | 5152 | |
| 5153 | 5153 | $columns = isset($file[0]) ? $file[0] : NULL; |
| 5154 | 5154 | |
| 5155 | 5155 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 5156 | 5156 | $json['error'] = CSV_INVAILD_FILE; |
| 5157 | - wp_send_json( $json ); |
|
| 5157 | + wp_send_json($json); |
|
| 5158 | 5158 | exit; |
| 5159 | 5159 | } |
| 5160 | 5160 | |
| 5161 | - $processed_actual=0; |
|
| 5161 | + $processed_actual = 0; |
|
| 5162 | 5162 | for ($i = 1; $i <= $limit; $i++) {
|
| 5163 | 5163 | $index = $processed + $i; |
| 5164 | 5164 | $gd_post = array(); |
| 5165 | 5165 | |
| 5166 | 5166 | if (isset($file[$index])) {$processed_actual++;
|
| 5167 | 5167 | $row = $file[$index]; |
| 5168 | - $row = array_map( 'trim', $row ); |
|
| 5168 | + $row = array_map('trim', $row);
|
|
| 5169 | 5169 | //$row = array_map( 'utf8_encode', $row ); |
| 5170 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 5170 | + $row = array_map('addslashes_gpc', $row);
|
|
| 5171 | 5171 | |
| 5172 | 5172 | $post_id = ''; |
| 5173 | 5173 | $post_title = ''; |
@@ -5201,73 +5201,73 @@ discard block |
||
| 5201 | 5201 | $original_post_id = ''; |
| 5202 | 5202 | |
| 5203 | 5203 | $c = 0; |
| 5204 | - foreach ($columns as $column ) {
|
|
| 5204 | + foreach ($columns as $column) {
|
|
| 5205 | 5205 | $gd_post[$column] = $row[$c]; |
| 5206 | 5206 | |
| 5207 | - if ( $column == 'post_id' ) {
|
|
| 5207 | + if ($column == 'post_id') {
|
|
| 5208 | 5208 | $post_id = $row[$c]; |
| 5209 | - } else if ( $column == 'post_title' ) {
|
|
| 5209 | + } else if ($column == 'post_title') {
|
|
| 5210 | 5210 | $post_title = $row[$c]; |
| 5211 | - } else if ( $column == 'post_author' ) {
|
|
| 5211 | + } else if ($column == 'post_author') {
|
|
| 5212 | 5212 | $post_author = $row[$c]; |
| 5213 | - } else if ( $column == 'post_content' ) {
|
|
| 5213 | + } else if ($column == 'post_content') {
|
|
| 5214 | 5214 | $post_content = $row[$c]; |
| 5215 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 5216 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 5217 | - } else if ( $column == 'default_category' ) {
|
|
| 5215 | + } else if ($column == 'post_category' && $row[$c] != '') {
|
|
| 5216 | + $post_category_arr = explode(',', $row[$c]);
|
|
| 5217 | + } else if ($column == 'default_category') {
|
|
| 5218 | 5218 | $default_category = wp_kses_normalize_entities($row[$c]); |
| 5219 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 5220 | - $post_tags = explode( ',', $row[$c] ); |
|
| 5221 | - } else if ( $column == 'post_type' ) {
|
|
| 5219 | + } else if ($column == 'post_tags' && $row[$c] != '') {
|
|
| 5220 | + $post_tags = explode(',', $row[$c]);
|
|
| 5221 | + } else if ($column == 'post_type') {
|
|
| 5222 | 5222 | $post_type = $row[$c]; |
| 5223 | - } else if ( $column == 'post_status' ) {
|
|
| 5224 | - $post_status = sanitize_key( $row[$c] ); |
|
| 5225 | - } else if ( $column == 'is_featured' ) {
|
|
| 5226 | - $is_featured = (int)$row[$c]; |
|
| 5227 | - } else if ( $column == 'geodir_video' ) {
|
|
| 5223 | + } else if ($column == 'post_status') {
|
|
| 5224 | + $post_status = sanitize_key($row[$c]); |
|
| 5225 | + } else if ($column == 'is_featured') {
|
|
| 5226 | + $is_featured = (int) $row[$c]; |
|
| 5227 | + } else if ($column == 'geodir_video') {
|
|
| 5228 | 5228 | $geodir_video = $row[$c]; |
| 5229 | - } else if ( $column == 'post_address' ) {
|
|
| 5229 | + } else if ($column == 'post_address') {
|
|
| 5230 | 5230 | $post_address = $row[$c]; |
| 5231 | - } else if ( $column == 'post_city' ) {
|
|
| 5231 | + } else if ($column == 'post_city') {
|
|
| 5232 | 5232 | $post_city = $row[$c]; |
| 5233 | - } else if ( $column == 'post_region' ) {
|
|
| 5233 | + } else if ($column == 'post_region') {
|
|
| 5234 | 5234 | $post_region = $row[$c]; |
| 5235 | - } else if ( $column == 'post_country' ) {
|
|
| 5235 | + } else if ($column == 'post_country') {
|
|
| 5236 | 5236 | $post_country = $row[$c]; |
| 5237 | - } else if ( $column == 'post_zip' ) {
|
|
| 5237 | + } else if ($column == 'post_zip') {
|
|
| 5238 | 5238 | $post_zip = $row[$c]; |
| 5239 | - } else if ( $column == 'post_latitude' ) {
|
|
| 5239 | + } else if ($column == 'post_latitude') {
|
|
| 5240 | 5240 | $post_latitude = $row[$c]; |
| 5241 | - } else if ( $column == 'post_longitude' ) {
|
|
| 5241 | + } else if ($column == 'post_longitude') {
|
|
| 5242 | 5242 | $post_longitude = $row[$c]; |
| 5243 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 5243 | + } else if ($column == 'geodir_timing') {
|
|
| 5244 | 5244 | $geodir_timing = $row[$c]; |
| 5245 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 5245 | + } else if ($column == 'geodir_contact') {
|
|
| 5246 | 5246 | $geodir_contact = $row[$c]; |
| 5247 | - } else if ( $column == 'geodir_email' ) {
|
|
| 5247 | + } else if ($column == 'geodir_email') {
|
|
| 5248 | 5248 | $geodir_email = $row[$c]; |
| 5249 | - } else if ( $column == 'geodir_website' ) {
|
|
| 5249 | + } else if ($column == 'geodir_website') {
|
|
| 5250 | 5250 | $geodir_website = $row[$c]; |
| 5251 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5251 | + } else if ($column == 'geodir_twitter') {
|
|
| 5252 | 5252 | $geodir_twitter = $row[$c]; |
| 5253 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 5253 | + } else if ($column == 'geodir_facebook') {
|
|
| 5254 | 5254 | $geodir_facebook = $row[$c]; |
| 5255 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5255 | + } else if ($column == 'geodir_twitter') {
|
|
| 5256 | 5256 | $geodir_twitter = $row[$c]; |
| 5257 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 5257 | + } else if ($column == 'IMAGE' && !empty($row[$c]) && $row[$c] != '') {
|
|
| 5258 | 5258 | $post_images[] = $row[$c]; |
| 5259 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 5260 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 5261 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 5259 | + } else if ($column == 'alive_days' && (int) $row[$c] > 0) {
|
|
| 5260 | + $expire_date = date_i18n('Y-m-d', strtotime($current_date . '+' . (int) $row[$c] . ' days'));
|
|
| 5261 | + } else if ($column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never') {
|
|
| 5262 | 5262 | $row[$c] = str_replace('/', '-', $row[$c]);
|
| 5263 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 5263 | + $expire_date = date_i18n('Y-m-d', strtotime($row[$c]));
|
|
| 5264 | 5264 | } |
| 5265 | 5265 | // WPML |
| 5266 | 5266 | if ($is_wpml) {
|
| 5267 | 5267 | if ($column == 'language') {
|
| 5268 | 5268 | $language = geodir_strtolower(trim($row[$c])); |
| 5269 | 5269 | } else if ($column == 'original_post_id') {
|
| 5270 | - $original_post_id = (int)$row[$c]; |
|
| 5270 | + $original_post_id = (int) $row[$c]; |
|
| 5271 | 5271 | } |
| 5272 | 5272 | } |
| 5273 | 5273 | // WPML |
@@ -5282,24 +5282,24 @@ discard block |
||
| 5282 | 5282 | |
| 5283 | 5283 | $gd_post['IMAGE'] = $post_images; |
| 5284 | 5284 | |
| 5285 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 5286 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 5285 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; |
|
| 5286 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; |
|
| 5287 | 5287 | |
| 5288 | 5288 | $valid = true; |
| 5289 | 5289 | |
| 5290 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 5290 | + if ($post_title == '' || !in_array($post_type, $post_types)) {
|
|
| 5291 | 5291 | $invalid++; |
| 5292 | 5292 | $valid = false; |
| 5293 | 5293 | } |
| 5294 | 5294 | |
| 5295 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5296 | - if ( $location_allowed ) {
|
|
| 5295 | + $location_allowed = function_exists('geodir_cpt_no_location') && geodir_cpt_no_location($post_type) ? false : true;
|
|
| 5296 | + if ($location_allowed) {
|
|
| 5297 | 5297 | $location_result = geodir_get_default_location(); |
| 5298 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 5298 | + if ($post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '') {
|
|
| 5299 | 5299 | $invalid_addr++; |
| 5300 | 5300 | $valid = false; |
| 5301 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 5302 | - if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
|
|
| 5301 | + } else if (!empty($location_result) && $location_result->location_id == 0) {
|
|
| 5302 | + if ((geodir_strtolower($post_city) != geodir_strtolower($location_result->city)) || (geodir_strtolower($post_region) != geodir_strtolower($location_result->region)) || (geodir_strtolower($post_country) != geodir_strtolower($location_result->country))) {
|
|
| 5303 | 5303 | $invalid_addr++; |
| 5304 | 5304 | $valid = false; |
| 5305 | 5305 | } else {
|
@@ -5310,7 +5310,7 @@ discard block |
||
| 5310 | 5310 | } |
| 5311 | 5311 | } |
| 5312 | 5312 | |
| 5313 | - if ( !$valid ) {
|
|
| 5313 | + if (!$valid) {
|
|
| 5314 | 5314 | continue; |
| 5315 | 5315 | } |
| 5316 | 5316 | |
@@ -5323,16 +5323,16 @@ discard block |
||
| 5323 | 5323 | |
| 5324 | 5324 | $post_category = array(); |
| 5325 | 5325 | $default_category_id = NULL; |
| 5326 | - if ( !empty( $post_category_arr ) ) {
|
|
| 5327 | - foreach ( $post_category_arr as $value ) {
|
|
| 5328 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 5326 | + if (!empty($post_category_arr)) {
|
|
| 5327 | + foreach ($post_category_arr as $value) {
|
|
| 5328 | + $category_name = wp_kses_normalize_entities(trim($value)); |
|
| 5329 | 5329 | |
| 5330 | - if ( $category_name != '' ) {
|
|
| 5330 | + if ($category_name != '') {
|
|
| 5331 | 5331 | $term_category = array(); |
| 5332 | 5332 | |
| 5333 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 5333 | + if ($term = get_term_by('name', $category_name, $cat_taxonomy)) {
|
|
| 5334 | 5334 | $term_category = $term; |
| 5335 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 5335 | + } else if ($term = get_term_by('slug', $category_name, $cat_taxonomy)) {
|
|
| 5336 | 5336 | $term_category = $term; |
| 5337 | 5337 | } else {
|
| 5338 | 5338 | $term_data = array(); |
@@ -5340,13 +5340,13 @@ discard block |
||
| 5340 | 5340 | //$term_data = array_map( 'utf8_encode', $term_data ); |
| 5341 | 5341 | $term_data['taxonomy'] = $cat_taxonomy; |
| 5342 | 5342 | |
| 5343 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 5344 | - if ( $term_id ) {
|
|
| 5345 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 5343 | + $term_id = geodir_imex_insert_term($cat_taxonomy, $term_data); |
|
| 5344 | + if ($term_id) {
|
|
| 5345 | + $term_category = get_term($term_id, $cat_taxonomy); |
|
| 5346 | 5346 | } |
| 5347 | 5347 | } |
| 5348 | 5348 | |
| 5349 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 5349 | + if (!empty($term_category) && !is_wp_error($term_category)) {
|
|
| 5350 | 5350 | //$post_category[] = $term_category->slug; |
| 5351 | 5351 | $post_category[] = intval($term_category->term_id); |
| 5352 | 5352 | |
@@ -5368,28 +5368,28 @@ discard block |
||
| 5368 | 5368 | $save_post['post_tags'] = $post_tags; |
| 5369 | 5369 | |
| 5370 | 5370 | $saved_post_id = NULL; |
| 5371 | - if ( $import_choice == 'update' ) {
|
|
| 5372 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5371 | + if ($import_choice == 'update') {
|
|
| 5372 | + if ($post_id > 0 && get_post($post_id)) {
|
|
| 5373 | 5373 | $save_post['ID'] = $post_id; |
| 5374 | 5374 | |
| 5375 | - if ( wp_update_post( $save_post ) ) {
|
|
| 5375 | + if (wp_update_post($save_post)) {
|
|
| 5376 | 5376 | $saved_post_id = $post_id; |
| 5377 | 5377 | $updated++; |
| 5378 | 5378 | } |
| 5379 | 5379 | } else {
|
| 5380 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5380 | + if ($saved_post_id = wp_insert_post($save_post)) {
|
|
| 5381 | 5381 | $created++; |
| 5382 | 5382 | } |
| 5383 | 5383 | } |
| 5384 | 5384 | |
| 5385 | - if ( !$saved_post_id > 0 ) {
|
|
| 5385 | + if (!$saved_post_id > 0) {
|
|
| 5386 | 5386 | $invalid++; |
| 5387 | 5387 | } |
| 5388 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5389 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5388 | + } else if ($import_choice == 'skip') {
|
|
| 5389 | + if ($post_id > 0 && get_post($post_id)) {
|
|
| 5390 | 5390 | $skipped++; |
| 5391 | 5391 | } else {
|
| 5392 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5392 | + if ($saved_post_id = wp_insert_post($save_post)) {
|
|
| 5393 | 5393 | $created++; |
| 5394 | 5394 | } else {
|
| 5395 | 5395 | $invalid++; |
@@ -5399,19 +5399,19 @@ discard block |
||
| 5399 | 5399 | $invalid++; |
| 5400 | 5400 | } |
| 5401 | 5401 | |
| 5402 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 5402 | + if ((int) $saved_post_id > 0) {
|
|
| 5403 | 5403 | // WPML |
| 5404 | 5404 | if ($is_wpml && $original_post_id > 0 && $language != '') {
|
| 5405 | 5405 | $wpml_post_type = 'post_' . $post_type; |
| 5406 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 5406 | + $source_language = geodir_get_language_for_element($original_post_id, $wpml_post_type); |
|
| 5407 | 5407 | $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
| 5408 | 5408 | |
| 5409 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 5409 | + $trid = $sitepress->get_element_trid($original_post_id, $wpml_post_type); |
|
| 5410 | 5410 | |
| 5411 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 5411 | + $sitepress->set_element_language_details($saved_post_id, $wpml_post_type, $trid, $language, $source_language); |
|
| 5412 | 5412 | } |
| 5413 | 5413 | // WPML |
| 5414 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 5414 | + $gd_post_info = geodir_get_post_info($saved_post_id); |
|
| 5415 | 5415 | |
| 5416 | 5416 | $gd_post['post_id'] = $saved_post_id; |
| 5417 | 5417 | $gd_post['ID'] = $saved_post_id; |
@@ -5423,7 +5423,7 @@ discard block |
||
| 5423 | 5423 | |
| 5424 | 5424 | // post location |
| 5425 | 5425 | $post_location_id = 0; |
| 5426 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 5426 | + if ($location_allowed && !empty($location_result) && $location_result->location_id > 0) {
|
|
| 5427 | 5427 | $post_location_info = array( |
| 5428 | 5428 | 'city' => $post_city, |
| 5429 | 5429 | 'region' => $post_region, |
@@ -5431,21 +5431,21 @@ discard block |
||
| 5431 | 5431 | 'geo_lat' => $post_latitude, |
| 5432 | 5432 | 'geo_lng' => $post_longitude |
| 5433 | 5433 | ); |
| 5434 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 5434 | + if ($location_id = (int) geodir_add_new_location($post_location_info)) {
|
|
| 5435 | 5435 | $post_location_id = $location_id; |
| 5436 | 5436 | } |
| 5437 | 5437 | } |
| 5438 | 5438 | $gd_post['post_location_id'] = $post_location_id; |
| 5439 | 5439 | |
| 5440 | 5440 | // post package info |
| 5441 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 5441 | + $package_id = isset($gd_post['package_id']) && !empty($gd_post['package_id']) ? (int) $gd_post['package_id'] : 0; |
|
| 5442 | 5442 | if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
| 5443 | 5443 | $package_id = $gd_post_info->package_id; |
| 5444 | 5444 | } |
| 5445 | 5445 | |
| 5446 | 5446 | $package_info = array(); |
| 5447 | 5447 | if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
| 5448 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 5448 | + $package_info = (array) geodir_get_package_info_by_id($package_id); |
|
| 5449 | 5449 | |
| 5450 | 5450 | if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
| 5451 | 5451 | $package_info = array(); |
@@ -5453,18 +5453,18 @@ discard block |
||
| 5453 | 5453 | } |
| 5454 | 5454 | |
| 5455 | 5455 | if (empty($package_info)) {
|
| 5456 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 5456 | + $package_info = (array) geodir_post_package_info(array(), '', $post_type); |
|
| 5457 | 5457 | } |
| 5458 | 5458 | |
| 5459 | - if (!empty($package_info)) {
|
|
| 5459 | + if (!empty($package_info)) {
|
|
| 5460 | 5460 | $package_id = $package_info['pid']; |
| 5461 | 5461 | |
| 5462 | 5462 | if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
| 5463 | 5463 | $gd_post['expire_date'] = $expire_date; |
| 5464 | 5464 | } else {
|
| 5465 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 5466 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 5467 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 5465 | + if (isset($package_info['days']) && (int) $package_info['days'] > 0) {
|
|
| 5466 | + $gd_post['alive_days'] = (int) $package_info['days']; |
|
| 5467 | + $gd_post['expire_date'] = date_i18n('Y-m-d', strtotime($current_date . '+' . (int) $package_info['days'] . ' days'));
|
|
| 5468 | 5468 | } else {
|
| 5469 | 5469 | $gd_post['expire_date'] = 'Never'; |
| 5470 | 5470 | } |
@@ -5484,28 +5484,28 @@ discard block |
||
| 5484 | 5484 | } |
| 5485 | 5485 | |
| 5486 | 5486 | // Export franchise fields |
| 5487 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5487 | + $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
|
|
| 5488 | 5488 | if ($is_franchise_active) {
|
| 5489 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 5489 | + if (isset($gd_post['gd_is_franchise']) && (int) $gd_post['gd_is_franchise'] == 1) {
|
|
| 5490 | 5490 | $gd_franchise_lock = array(); |
| 5491 | 5491 | |
| 5492 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 5493 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 5494 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 5495 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 5492 | + if (isset($gd_post['gd_franchise_lock'])) {
|
|
| 5493 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock']);
|
|
| 5494 | + $gd_franchise_lock = trim($gd_franchise_lock); |
|
| 5495 | + $gd_franchise_lock = explode(",", $gd_franchise_lock);
|
|
| 5496 | 5496 | } |
| 5497 | 5497 | |
| 5498 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 5499 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 5498 | + update_post_meta($saved_post_id, 'gd_is_franchise', 1); |
|
| 5499 | + update_post_meta($saved_post_id, 'gd_franchise_lock', $gd_franchise_lock); |
|
| 5500 | 5500 | } else {
|
| 5501 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 5502 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 5501 | + if (isset($gd_post['franchise']) && (int) $gd_post['franchise'] > 0 && geodir_franchise_check((int) $gd_post['franchise'])) {
|
|
| 5502 | + geodir_save_post_meta($saved_post_id, 'franchise', (int) $gd_post['franchise']); |
|
| 5503 | 5503 | } |
| 5504 | 5504 | } |
| 5505 | 5505 | } |
| 5506 | 5506 | |
| 5507 | 5507 | if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
| 5508 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 5508 | + $save_post['post_category'] = array_unique(array_map('intval', $save_post['post_category']));
|
|
| 5509 | 5509 | if ($default_category_id) {
|
| 5510 | 5510 | $save_post['post_default_category'] = $default_category_id; |
| 5511 | 5511 | $gd_post['default_category'] = $default_category_id; |
@@ -5514,12 +5514,12 @@ discard block |
||
| 5514 | 5514 | } |
| 5515 | 5515 | |
| 5516 | 5516 | // Save post info |
| 5517 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 5517 | + geodir_save_post_info($saved_post_id, $gd_post); |
|
| 5518 | 5518 | // post taxonomies |
| 5519 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 5520 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 5519 | + if (!empty($save_post['post_category'])) {
|
|
| 5520 | + wp_set_object_terms($saved_post_id, $save_post['post_category'], $cat_taxonomy); |
|
| 5521 | 5521 | |
| 5522 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 5522 | + $post_default_category = isset($save_post['post_default_category']) ? $save_post['post_default_category'] : ''; |
|
| 5523 | 5523 | if ($default_category_id) {
|
| 5524 | 5524 | $post_default_category = $default_category_id; |
| 5525 | 5525 | } |
@@ -5533,15 +5533,15 @@ discard block |
||
| 5533 | 5533 | |
| 5534 | 5534 | $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
| 5535 | 5535 | |
| 5536 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 5536 | + geodir_set_postcat_structure($saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str); |
|
| 5537 | 5537 | } |
| 5538 | 5538 | |
| 5539 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 5540 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 5539 | + if (!empty($save_post['post_tags'])) {
|
|
| 5540 | + wp_set_object_terms($saved_post_id, $save_post['post_tags'], $tags_taxonomy); |
|
| 5541 | 5541 | } |
| 5542 | 5542 | |
| 5543 | 5543 | // Post images |
| 5544 | - if ( !empty( $post_images ) ) {
|
|
| 5544 | + if (!empty($post_images)) {
|
|
| 5545 | 5545 | $post_images = array_unique($post_images); |
| 5546 | 5546 | |
| 5547 | 5547 | $old_post_images_arr = array(); |
@@ -5549,30 +5549,30 @@ discard block |
||
| 5549 | 5549 | |
| 5550 | 5550 | $order = 1; |
| 5551 | 5551 | |
| 5552 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 5552 | + $old_post_images = geodir_get_images($saved_post_id); |
|
| 5553 | 5553 | if (!empty($old_post_images)) {
|
| 5554 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 5554 | + foreach ($old_post_images as $old_post_image) {
|
|
| 5555 | 5555 | if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
| 5556 | 5556 | $old_post_images_arr[] = $old_post_image->file; |
| 5557 | 5557 | } |
| 5558 | 5558 | } |
| 5559 | 5559 | } |
| 5560 | 5560 | |
| 5561 | - foreach ( $post_images as $post_image ) {
|
|
| 5562 | - $image_name = basename( $post_image ); |
|
| 5561 | + foreach ($post_images as $post_image) {
|
|
| 5562 | + $image_name = basename($post_image); |
|
| 5563 | 5563 | $saved_post_images_arr[] = $image_name; |
| 5564 | 5564 | |
| 5565 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 5565 | + if (!empty($old_post_images_arr) && in_array($image_name, $old_post_images_arr)) {
|
|
| 5566 | 5566 | continue; // Skip if image already exists. |
| 5567 | 5567 | } |
| 5568 | 5568 | |
| 5569 | - $image_name_parts = explode( '.', $image_name ); |
|
| 5570 | - array_pop( $image_name_parts ); |
|
| 5571 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 5569 | + $image_name_parts = explode('.', $image_name);
|
|
| 5570 | + array_pop($image_name_parts); |
|
| 5571 | + $proper_image_name = implode('.', $image_name_parts);
|
|
| 5572 | 5572 | |
| 5573 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 5573 | + $arr_file_type = wp_check_filetype($image_name); |
|
| 5574 | 5574 | |
| 5575 | - if ( !empty( $arr_file_type ) ) {
|
|
| 5575 | + if (!empty($arr_file_type)) {
|
|
| 5576 | 5576 | $uploaded_file_type = $arr_file_type['type']; |
| 5577 | 5577 | |
| 5578 | 5578 | $attachment = array(); |
@@ -5585,46 +5585,46 @@ discard block |
||
| 5585 | 5585 | $attachment['is_featured'] = 0; |
| 5586 | 5586 | |
| 5587 | 5587 | $attachment_set = ''; |
| 5588 | - foreach ( $attachment as $key => $val ) {
|
|
| 5589 | - if ( $val != '' ) {
|
|
| 5588 | + foreach ($attachment as $key => $val) {
|
|
| 5589 | + if ($val != '') {
|
|
| 5590 | 5590 | $attachment_set .= $key . " = '" . $val . "', "; |
| 5591 | 5591 | } |
| 5592 | 5592 | } |
| 5593 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 5593 | + $attachment_set = trim($attachment_set, ", "); |
|
| 5594 | 5594 | |
| 5595 | 5595 | // Add new attachment |
| 5596 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 5596 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 5597 | 5597 | |
| 5598 | 5598 | $order++; |
| 5599 | 5599 | } |
| 5600 | 5600 | } |
| 5601 | 5601 | |
| 5602 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5602 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5603 | 5603 | // Remove previous attachment |
| 5604 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 5604 | + $wpdb->query("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int) $saved_post_id . " " . $saved_post_images_sql);
|
|
| 5605 | 5605 | |
| 5606 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 5606 | + if (!empty($saved_post_images_arr)) {
|
|
| 5607 | 5607 | $menu_order = 1; |
| 5608 | 5608 | |
| 5609 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 5610 | - $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 5609 | + foreach ($saved_post_images_arr as $img_name) {
|
|
| 5610 | + $wpdb->query($wpdb->prepare("UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array($menu_order, $saved_post_id, '%/' . $img_name)));
|
|
| 5611 | 5611 | |
| 5612 | - if( $menu_order == 1 ) {
|
|
| 5613 | - if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 5614 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 5612 | + if ($menu_order == 1) {
|
|
| 5613 | + if ($featured_image = $wpdb->get_var($wpdb->prepare("SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array($saved_post_id, '%/' . $img_name)))) {
|
|
| 5614 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array($featured_image, $saved_post_id)));
|
|
| 5615 | 5615 | } |
| 5616 | 5616 | } |
| 5617 | 5617 | $menu_order++; |
| 5618 | 5618 | } |
| 5619 | 5619 | } |
| 5620 | 5620 | |
| 5621 | - if ( $order > 1 ) {
|
|
| 5621 | + if ($order > 1) {
|
|
| 5622 | 5622 | $images++; |
| 5623 | 5623 | } |
| 5624 | 5624 | } |
| 5625 | 5625 | |
| 5626 | 5626 | /** This action is documented in geodirectory-functions/post-functions.php */ |
| 5627 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 5627 | + do_action('geodir_after_save_listing', $saved_post_id, $gd_post);
|
|
| 5628 | 5628 | |
| 5629 | 5629 | if (isset($is_featured)) {
|
| 5630 | 5630 | geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
@@ -5644,10 +5644,10 @@ discard block |
||
| 5644 | 5644 | } |
| 5645 | 5645 | |
| 5646 | 5646 | //undo some stuff to make the import quicker |
| 5647 | - wp_defer_term_counting( false ); |
|
| 5648 | - wp_defer_comment_counting( false ); |
|
| 5649 | - $wpdb->query( 'COMMIT;' ); |
|
| 5650 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 5647 | + wp_defer_term_counting(false); |
|
| 5648 | + wp_defer_comment_counting(false); |
|
| 5649 | + $wpdb->query('COMMIT;');
|
|
| 5650 | + $wpdb->query('SET autocommit = 1;');
|
|
| 5651 | 5651 | |
| 5652 | 5652 | $json = array(); |
| 5653 | 5653 | $json['processed'] = $processed_actual; |
@@ -5658,9 +5658,9 @@ discard block |
||
| 5658 | 5658 | $json['invalid_addr'] = $invalid_addr; |
| 5659 | 5659 | $json['images'] = $images; |
| 5660 | 5660 | |
| 5661 | - wp_send_json( $json ); |
|
| 5661 | + wp_send_json($json); |
|
| 5662 | 5662 | exit; |
| 5663 | - } else if ( $task == 'import_loc' ) {
|
|
| 5663 | + } else if ($task == 'import_loc') {
|
|
| 5664 | 5664 | global $gd_post_types; |
| 5665 | 5665 | $gd_post_types = $post_types; |
| 5666 | 5666 | |
@@ -5669,7 +5669,7 @@ discard block |
||
| 5669 | 5669 | |
| 5670 | 5670 | if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
| 5671 | 5671 | $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
| 5672 | - wp_send_json( $json ); |
|
| 5672 | + wp_send_json($json); |
|
| 5673 | 5673 | } |
| 5674 | 5674 | |
| 5675 | 5675 | for ($i = 1; $i <= $limit; $i++) {
|
@@ -5677,59 +5677,59 @@ discard block |
||
| 5677 | 5677 | |
| 5678 | 5678 | if (isset($file[$index])) {
|
| 5679 | 5679 | $row = $file[$index]; |
| 5680 | - $row = array_map( 'trim', $row ); |
|
| 5680 | + $row = array_map('trim', $row);
|
|
| 5681 | 5681 | $data = array(); |
| 5682 | 5682 | |
| 5683 | - foreach ($columns as $c => $column ) {
|
|
| 5683 | + foreach ($columns as $c => $column) {
|
|
| 5684 | 5684 | if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
| 5685 | 5685 | $data[$column] = $row[$c]; |
| 5686 | 5686 | } |
| 5687 | 5687 | } |
| 5688 | 5688 | |
| 5689 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 5689 | + if (empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 5690 | 5690 | $invalid++; |
| 5691 | 5691 | continue; |
| 5692 | 5692 | } |
| 5693 | 5693 | |
| 5694 | 5694 | $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
| 5695 | 5695 | |
| 5696 | - if ( $import_choice == 'update' ) {
|
|
| 5697 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5698 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5696 | + if ($import_choice == 'update') {
|
|
| 5697 | + if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
|
|
| 5698 | + if ($location_id = geodir_location_update_city($data, true, $location)) {
|
|
| 5699 | 5699 | $updated++; |
| 5700 | 5700 | } else {
|
| 5701 | 5701 | $invalid++; |
| 5702 | 5702 | } |
| 5703 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5704 | - $data['location_id'] = (int)$location->location_id; |
|
| 5703 | + } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
|
|
| 5704 | + $data['location_id'] = (int) $location->location_id; |
|
| 5705 | 5705 | |
| 5706 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 5707 | - $data['location_id'] = (int)$location->location_id; |
|
| 5708 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 5709 | - $data['location_id'] = (int)$location->location_id; |
|
| 5710 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 5711 | - $data['location_id'] = (int)$location->location_id; |
|
| 5706 | + if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region']))) {
|
|
| 5707 | + $data['location_id'] = (int) $location->location_id; |
|
| 5708 | + } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'region' => $data['region']))) {
|
|
| 5709 | + $data['location_id'] = (int) $location->location_id; |
|
| 5710 | + } else if ($location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug'], 'country' => $data['country']))) {
|
|
| 5711 | + $data['location_id'] = (int) $location->location_id; |
|
| 5712 | 5712 | } |
| 5713 | 5713 | |
| 5714 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5714 | + if ($location_id = geodir_location_update_city($data, true, $location)) {
|
|
| 5715 | 5715 | $updated++; |
| 5716 | 5716 | } else {
|
| 5717 | 5717 | $invalid++; |
| 5718 | 5718 | } |
| 5719 | 5719 | } else {
|
| 5720 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5720 | + if ($location_id = geodir_location_insert_city($data, true)) {
|
|
| 5721 | 5721 | $created++; |
| 5722 | 5722 | } else {
|
| 5723 | 5723 | $invalid++; |
| 5724 | 5724 | } |
| 5725 | 5725 | } |
| 5726 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5727 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5726 | + } elseif ($import_choice == 'skip') {
|
|
| 5727 | + if ((int) $data['location_id'] > 0 && $location = geodir_get_location_by_id('', (int) $data['location_id'])) {
|
|
| 5728 | 5728 | $skipped++; |
| 5729 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5729 | + } else if (!empty($data['city_slug']) && $location = geodir_get_location_by_slug('city', array('city_slug' => $data['city_slug']))) {
|
|
| 5730 | 5730 | $skipped++; |
| 5731 | 5731 | } else {
|
| 5732 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5732 | + if ($location_id = geodir_location_insert_city($data, true)) {
|
|
| 5733 | 5733 | $created++; |
| 5734 | 5734 | } else {
|
| 5735 | 5735 | $invalid++; |
@@ -5750,7 +5750,7 @@ discard block |
||
| 5750 | 5750 | $json['invalid'] = $invalid; |
| 5751 | 5751 | $json['images'] = $images; |
| 5752 | 5752 | |
| 5753 | - wp_send_json( $json ); |
|
| 5753 | + wp_send_json($json); |
|
| 5754 | 5754 | } |
| 5755 | 5755 | } |
| 5756 | 5756 | break; |
@@ -5794,29 +5794,29 @@ discard block |
||
| 5794 | 5794 | * } |
| 5795 | 5795 | * @return int|bool Term id when success, false when fail. |
| 5796 | 5796 | */ |
| 5797 | -function geodir_imex_insert_term( $taxonomy, $term_data ) {
|
|
| 5798 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5797 | +function geodir_imex_insert_term($taxonomy, $term_data) {
|
|
| 5798 | + if (empty($taxonomy) || empty($term_data)) {
|
|
| 5799 | 5799 | return false; |
| 5800 | 5800 | } |
| 5801 | 5801 | |
| 5802 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5802 | + $term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : ''; |
|
| 5803 | 5803 | $args = array(); |
| 5804 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5805 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5806 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5804 | + $args['description'] = isset($term_data['description']) ? $term_data['description'] : ''; |
|
| 5805 | + $args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : ''; |
|
| 5806 | + $args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : ''; |
|
| 5807 | 5807 | |
| 5808 | - if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
|
|
| 5809 | - $term_args = array_merge( $term_data, $args ); |
|
| 5810 | - $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 5811 | - $term_args = wp_parse_args( $term_args, $defaults ); |
|
| 5812 | - $term_args = sanitize_term( $term_args, $taxonomy, 'db' ); |
|
| 5813 | - $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
|
| 5808 | + if ((!empty($args['slug']) && term_exists($args['slug'], $taxonomy)) || empty($args['slug'])) {
|
|
| 5809 | + $term_args = array_merge($term_data, $args); |
|
| 5810 | + $defaults = array('alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => '');
|
|
| 5811 | + $term_args = wp_parse_args($term_args, $defaults); |
|
| 5812 | + $term_args = sanitize_term($term_args, $taxonomy, 'db'); |
|
| 5813 | + $args['slug'] = wp_unique_term_slug($args['slug'], (object) $term_args); |
|
| 5814 | 5814 | } |
| 5815 | 5815 | |
| 5816 | - if( !empty( $term ) ) {
|
|
| 5817 | - $result = wp_insert_term( $term, $taxonomy, $args ); |
|
| 5818 | - if( !is_wp_error( $result ) ) {
|
|
| 5819 | - return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5816 | + if (!empty($term)) {
|
|
| 5817 | + $result = wp_insert_term($term, $taxonomy, $args); |
|
| 5818 | + if (!is_wp_error($result)) {
|
|
| 5819 | + return $term_id = isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5820 | 5820 | } |
| 5821 | 5821 | } |
| 5822 | 5822 | |
@@ -5846,37 +5846,37 @@ discard block |
||
| 5846 | 5846 | * } |
| 5847 | 5847 | * @return int|bool Term id when success, false when fail. |
| 5848 | 5848 | */ |
| 5849 | -function geodir_imex_update_term( $taxonomy, $term_data ) {
|
|
| 5850 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5849 | +function geodir_imex_update_term($taxonomy, $term_data) {
|
|
| 5850 | + if (empty($taxonomy) || empty($term_data)) {
|
|
| 5851 | 5851 | return false; |
| 5852 | 5852 | } |
| 5853 | 5853 | |
| 5854 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5855 | - $term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0; |
|
| 5854 | + $term = isset($term_data['name']) && !empty($term_data['name']) ? $term_data['name'] : ''; |
|
| 5855 | + $term_id = isset($term_data['term_id']) && !empty($term_data['term_id']) ? $term_data['term_id'] : 0; |
|
| 5856 | 5856 | |
| 5857 | 5857 | $args = array(); |
| 5858 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5859 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5860 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5858 | + $args['description'] = isset($term_data['description']) ? $term_data['description'] : ''; |
|
| 5859 | + $args['slug'] = isset($term_data['slug']) ? $term_data['slug'] : ''; |
|
| 5860 | + $args['parent'] = isset($term_data['parent']) ? (int) $term_data['parent'] : ''; |
|
| 5861 | 5861 | |
| 5862 | - if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
|
|
| 5862 | + if ($term_id > 0 && $term_info = (array) get_term($term_id, $taxonomy)) {
|
|
| 5863 | 5863 | $term_data['term_id'] = $term_info['term_id']; |
| 5864 | 5864 | |
| 5865 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5865 | + $result = wp_update_term($term_data['term_id'], $taxonomy, $term_data); |
|
| 5866 | 5866 | |
| 5867 | - if( !is_wp_error( $result ) ) {
|
|
| 5868 | - return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5867 | + if (!is_wp_error($result)) {
|
|
| 5868 | + return $term_id = isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5869 | 5869 | } |
| 5870 | - } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5870 | + } else if ($term_data['slug'] != '' && $term_info = (array) term_exists($term_data['slug'], $taxonomy)) {
|
|
| 5871 | 5871 | $term_data['term_id'] = $term_info['term_id']; |
| 5872 | 5872 | |
| 5873 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5873 | + $result = wp_update_term($term_data['term_id'], $taxonomy, $term_data); |
|
| 5874 | 5874 | |
| 5875 | - if( !is_wp_error( $result ) ) {
|
|
| 5876 | - return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5875 | + if (!is_wp_error($result)) {
|
|
| 5876 | + return $term_id = isset($result['term_id']) ? $result['term_id'] : 0; |
|
| 5877 | 5877 | } |
| 5878 | 5878 | } else {
|
| 5879 | - return geodir_imex_insert_term( $taxonomy, $term_data ); |
|
| 5879 | + return geodir_imex_insert_term($taxonomy, $term_data); |
|
| 5880 | 5880 | } |
| 5881 | 5881 | |
| 5882 | 5882 | return false; |
@@ -5891,9 +5891,9 @@ discard block |
||
| 5891 | 5891 | * @param string $post_type Post type. |
| 5892 | 5892 | * @return int Posts count. |
| 5893 | 5893 | */ |
| 5894 | -function geodir_get_posts_count( $post_type ) {
|
|
| 5895 | - $posts_count = wp_count_posts( $post_type ); |
|
| 5896 | - $posts_count = array_sum( (array)$posts_count ); |
|
| 5894 | +function geodir_get_posts_count($post_type) {
|
|
| 5895 | + $posts_count = wp_count_posts($post_type); |
|
| 5896 | + $posts_count = array_sum((array) $posts_count); |
|
| 5897 | 5897 | |
| 5898 | 5898 | /** |
| 5899 | 5899 | * Modify returned post counts for the current post type. |
@@ -5904,7 +5904,7 @@ discard block |
||
| 5904 | 5904 | * @param int $posts_count Post counts. |
| 5905 | 5905 | * @param string $post_type Post type. |
| 5906 | 5906 | */ |
| 5907 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5907 | + $posts_count = apply_filters('geodir_imex_count_posts', $posts_count, $post_type);
|
|
| 5908 | 5908 | |
| 5909 | 5909 | return $posts_count; |
| 5910 | 5910 | } |
@@ -5922,8 +5922,8 @@ discard block |
||
| 5922 | 5922 | * @param string $post_type Post type. |
| 5923 | 5923 | * @return int Posts count. |
| 5924 | 5924 | */ |
| 5925 | -function geodir_imex_count_events( $posts_count, $post_type ) {
|
|
| 5926 | - if ( $post_type == 'gd_event' ) {
|
|
| 5925 | +function geodir_imex_count_events($posts_count, $post_type) {
|
|
| 5926 | + if ($post_type == 'gd_event') {
|
|
| 5927 | 5927 | global $wpdb, $plugin_prefix; |
| 5928 | 5928 | |
| 5929 | 5929 | $table = $plugin_prefix . $post_type . '_detail'; |
@@ -5931,7 +5931,7 @@ discard block |
||
| 5931 | 5931 | |
| 5932 | 5932 | $query = "SELECT COUNT({$wpdb->posts}.ID) AS total FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s";
|
| 5933 | 5933 | |
| 5934 | - $posts_count = (int)$wpdb->get_var( $wpdb->prepare( $query, $post_type ) ); |
|
| 5934 | + $posts_count = (int) $wpdb->get_var($wpdb->prepare($query, $post_type)); |
|
| 5935 | 5935 | } |
| 5936 | 5936 | |
| 5937 | 5937 | return $posts_count; |
@@ -5953,15 +5953,15 @@ discard block |
||
| 5953 | 5953 | * @param int $page_no Page number. Default 0. |
| 5954 | 5954 | * @return array Array of posts data. |
| 5955 | 5955 | */ |
| 5956 | -function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 5956 | +function geodir_imex_get_posts($post_type, $per_page = 0, $page_no = 0) {
|
|
| 5957 | 5957 | global $wp_filesystem; |
| 5958 | 5958 | |
| 5959 | - $posts = geodir_get_export_posts( $post_type, $per_page, $page_no ); |
|
| 5959 | + $posts = geodir_get_export_posts($post_type, $per_page, $page_no); |
|
| 5960 | 5960 | |
| 5961 | 5961 | $csv_rows = array(); |
| 5962 | 5962 | |
| 5963 | - if ( !empty( $posts ) ) {
|
|
| 5964 | - $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
|
| 5963 | + if (!empty($posts)) {
|
|
| 5964 | + $is_payment_plugin = is_plugin_active('geodir_payment_manager/geodir_payment_manager.php');
|
|
| 5965 | 5965 | |
| 5966 | 5966 | $csv_row = array(); |
| 5967 | 5967 | $csv_row[] = 'post_id'; |
@@ -5972,7 +5972,7 @@ discard block |
||
| 5972 | 5972 | $csv_row[] = 'default_category'; |
| 5973 | 5973 | $csv_row[] = 'post_tags'; |
| 5974 | 5974 | $csv_row[] = 'post_type'; |
| 5975 | - if ( $post_type == 'gd_event' ) {
|
|
| 5975 | + if ($post_type == 'gd_event') {
|
|
| 5976 | 5976 | $csv_row[] = 'event_date'; |
| 5977 | 5977 | $csv_row[] = 'event_enddate'; |
| 5978 | 5978 | $csv_row[] = 'starttime'; |
@@ -6021,15 +6021,15 @@ discard block |
||
| 6021 | 6021 | } |
| 6022 | 6022 | // WPML |
| 6023 | 6023 | |
| 6024 | - $custom_fields = geodir_imex_get_custom_fields( $post_type ); |
|
| 6025 | - if ( !empty( $custom_fields ) ) {
|
|
| 6026 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 6024 | + $custom_fields = geodir_imex_get_custom_fields($post_type); |
|
| 6025 | + if (!empty($custom_fields)) {
|
|
| 6026 | + foreach ($custom_fields as $custom_field) {
|
|
| 6027 | 6027 | $csv_row[] = $custom_field->htmlvar_name; |
| 6028 | 6028 | } |
| 6029 | 6029 | } |
| 6030 | 6030 | |
| 6031 | 6031 | // Export franchise fields |
| 6032 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 6032 | + $is_franchise_active = is_plugin_active('geodir_franchise/geodir_franchise.php') && geodir_franchise_enabled($post_type) ? true : false;
|
|
| 6033 | 6033 | if ($is_franchise_active) {
|
| 6034 | 6034 | $csv_row[] = 'gd_is_franchise'; |
| 6035 | 6035 | $csv_row[] = 'gd_franchise_lock'; |
@@ -6039,12 +6039,12 @@ discard block |
||
| 6039 | 6039 | $csv_rows[] = $csv_row; |
| 6040 | 6040 | |
| 6041 | 6041 | $images_count = 5; |
| 6042 | - $xx=0; |
|
| 6043 | - foreach ( $posts as $post ) {$xx++;
|
|
| 6042 | + $xx = 0; |
|
| 6043 | + foreach ($posts as $post) {$xx++;
|
|
| 6044 | 6044 | $post_id = $post['ID']; |
| 6045 | 6045 | |
| 6046 | - $gd_post_info = geodir_get_post_info( $post_id ); |
|
| 6047 | - $post_info = (array)$gd_post_info; |
|
| 6046 | + $gd_post_info = geodir_get_post_info($post_id); |
|
| 6047 | + $post_info = (array) $gd_post_info; |
|
| 6048 | 6048 | |
| 6049 | 6049 | $taxonomy_category = $post_type . 'category'; |
| 6050 | 6050 | $taxonomy_tags = $post_type . '_tags'; |
@@ -6053,14 +6053,14 @@ discard block |
||
| 6053 | 6053 | $default_category_id = $gd_post_info->default_category; |
| 6054 | 6054 | $default_category = ''; |
| 6055 | 6055 | $post_tags = ''; |
| 6056 | - $terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6056 | + $terms = wp_get_post_terms($post_id, array($taxonomy_category, $taxonomy_tags)); |
|
| 6057 | 6057 | |
| 6058 | - if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
|
|
| 6058 | + if (!empty($terms) && !is_wp_error($terms)) {
|
|
| 6059 | 6059 | $post_category = array(); |
| 6060 | 6060 | $post_tags = array(); |
| 6061 | 6061 | |
| 6062 | - foreach ( $terms as $term ) {
|
|
| 6063 | - if ( $term->taxonomy == $taxonomy_category ) {
|
|
| 6062 | + foreach ($terms as $term) {
|
|
| 6063 | + if ($term->taxonomy == $taxonomy_category) {
|
|
| 6064 | 6064 | $post_category[] = $term->name; |
| 6065 | 6065 | |
| 6066 | 6066 | if ($default_category_id == $term->term_id) {
|
@@ -6068,7 +6068,7 @@ discard block |
||
| 6068 | 6068 | } |
| 6069 | 6069 | } |
| 6070 | 6070 | |
| 6071 | - if ( $term->taxonomy == $taxonomy_tags ) {
|
|
| 6071 | + if ($term->taxonomy == $taxonomy_tags) {
|
|
| 6072 | 6072 | $post_tags[] = $term->name; |
| 6073 | 6073 | } |
| 6074 | 6074 | } |
@@ -6076,8 +6076,8 @@ discard block |
||
| 6076 | 6076 | if (empty($default_category) && !empty($post_category)) {
|
| 6077 | 6077 | $default_category = $post_category[0]; // Set first one as default category. |
| 6078 | 6078 | } |
| 6079 | - $post_category = !empty( $post_category ) ? implode( ',', $post_category ) : ''; |
|
| 6080 | - $post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : ''; |
|
| 6079 | + $post_category = !empty($post_category) ? implode(',', $post_category) : '';
|
|
| 6080 | + $post_tags = !empty($post_tags) ? implode(',', $post_tags) : '';
|
|
| 6081 | 6081 | } |
| 6082 | 6082 | |
| 6083 | 6083 | // Franchise data |
@@ -6085,42 +6085,42 @@ discard block |
||
| 6085 | 6085 | $franchise_info = array(); |
| 6086 | 6086 | $locked_fields = array(); |
| 6087 | 6087 | |
| 6088 | - if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
|
|
| 6088 | + if ($is_franchise_active && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 && geodir_franchise_check((int) $post_info['franchise'])) {
|
|
| 6089 | 6089 | $franchise_id = $post_info['franchise']; |
| 6090 | 6090 | $gd_franchise_info = geodir_get_post_info($franchise_id); |
| 6091 | 6091 | |
| 6092 | 6092 | if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
|
| 6093 | - $franchise_info = (array)$gd_franchise_info; |
|
| 6093 | + $franchise_info = (array) $gd_franchise_info; |
|
| 6094 | 6094 | $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true); |
| 6095 | 6095 | |
| 6096 | 6096 | if (!empty($locked_fields)) {
|
| 6097 | - foreach( $locked_fields as $locked_field) {
|
|
| 6097 | + foreach ($locked_fields as $locked_field) {
|
|
| 6098 | 6098 | if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
|
| 6099 | 6099 | $post_info[$locked_field] = $franchise_info[$locked_field]; |
| 6100 | 6100 | } |
| 6101 | 6101 | |
| 6102 | 6102 | if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
|
| 6103 | - $franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6103 | + $franchise_terms = wp_get_post_terms($franchise_id, array($taxonomy_category, $taxonomy_tags)); |
|
| 6104 | 6104 | |
| 6105 | - if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
|
|
| 6105 | + if (!empty($franchise_terms) && !is_wp_error($franchise_terms)) {
|
|
| 6106 | 6106 | $franchise_post_category = array(); |
| 6107 | 6107 | $franchise_post_tags = array(); |
| 6108 | 6108 | |
| 6109 | - foreach ( $franchise_terms as $franchise_term ) {
|
|
| 6110 | - if ( $franchise_term->taxonomy == $taxonomy_category ) {
|
|
| 6109 | + foreach ($franchise_terms as $franchise_term) {
|
|
| 6110 | + if ($franchise_term->taxonomy == $taxonomy_category) {
|
|
| 6111 | 6111 | $franchise_post_category[] = $franchise_term->name; |
| 6112 | 6112 | } |
| 6113 | 6113 | |
| 6114 | - if ( $franchise_term->taxonomy == $taxonomy_tags ) {
|
|
| 6114 | + if ($franchise_term->taxonomy == $taxonomy_tags) {
|
|
| 6115 | 6115 | $franchise_post_tags[] = $franchise_term->name; |
| 6116 | 6116 | } |
| 6117 | 6117 | } |
| 6118 | 6118 | |
| 6119 | 6119 | if (in_array($taxonomy_category, $locked_fields)) {
|
| 6120 | - $post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : ''; |
|
| 6120 | + $post_category = !empty($franchise_post_category) ? implode(',', $franchise_post_category) : '';
|
|
| 6121 | 6121 | } |
| 6122 | 6122 | if (in_array('post_tags', $locked_fields)) {
|
| 6123 | - $post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : ''; |
|
| 6123 | + $post_tags = !empty($franchise_post_tags) ? implode(',', $franchise_post_tags) : '';
|
|
| 6124 | 6124 | } |
| 6125 | 6125 | } |
| 6126 | 6126 | } |
@@ -6129,18 +6129,18 @@ discard block |
||
| 6129 | 6129 | } |
| 6130 | 6130 | } |
| 6131 | 6131 | |
| 6132 | - $post_images = geodir_get_images( $post_id ); |
|
| 6132 | + $post_images = geodir_get_images($post_id); |
|
| 6133 | 6133 | $current_images = array(); |
| 6134 | - if ( !empty( $post_images ) ) {
|
|
| 6135 | - foreach ( $post_images as $post_image ) {
|
|
| 6136 | - $post_image = (array)$post_image; |
|
| 6137 | - $image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : ''; |
|
| 6138 | - if ( $image ) {
|
|
| 6134 | + if (!empty($post_images)) {
|
|
| 6135 | + foreach ($post_images as $post_image) {
|
|
| 6136 | + $post_image = (array) $post_image; |
|
| 6137 | + $image = !empty($post_image) && isset($post_image['path']) && $wp_filesystem->is_file($post_image['path']) && $wp_filesystem->exists($post_image['path']) ? $post_image['src'] : ''; |
|
| 6138 | + if ($image) {
|
|
| 6139 | 6139 | $current_images[] = $image; |
| 6140 | 6140 | } |
| 6141 | 6141 | } |
| 6142 | 6142 | |
| 6143 | - $images_count = max( $images_count, count( $current_images ) ); |
|
| 6143 | + $images_count = max($images_count, count($current_images)); |
|
| 6144 | 6144 | } |
| 6145 | 6145 | |
| 6146 | 6146 | $csv_row = array(); |
@@ -6152,7 +6152,7 @@ discard block |
||
| 6152 | 6152 | $csv_row[] = $default_category; // default_category |
| 6153 | 6153 | $csv_row[] = $post_tags; // post_tags |
| 6154 | 6154 | $csv_row[] = $post_type; // post_type |
| 6155 | - if ( $post_type == 'gd_event' ) {
|
|
| 6155 | + if ($post_type == 'gd_event') {
|
|
| 6156 | 6156 | $event_data = geodir_imex_get_event_data($post, $gd_post_info); |
| 6157 | 6157 | $csv_row[] = $event_data['event_date']; // event_date |
| 6158 | 6158 | $csv_row[] = $event_data['event_enddate']; // enddate |
@@ -6173,9 +6173,9 @@ discard block |
||
| 6173 | 6173 | $csv_row[] = $event_data['recurring_end_date']; // repeat_end |
| 6174 | 6174 | } |
| 6175 | 6175 | $csv_row[] = $post_info['post_status']; // post_status |
| 6176 | - $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 6176 | + $csv_row[] = (int) $post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 6177 | 6177 | if ($is_payment_plugin) {
|
| 6178 | - $csv_row[] = (int)$post_info['package_id']; // package_id |
|
| 6178 | + $csv_row[] = (int) $post_info['package_id']; // package_id |
|
| 6179 | 6179 | $csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
|
| 6180 | 6180 | } |
| 6181 | 6181 | $csv_row[] = $post_info['geodir_video']; // geodir_video |
@@ -6196,14 +6196,14 @@ discard block |
||
| 6196 | 6196 | $csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers |
| 6197 | 6197 | // WPML |
| 6198 | 6198 | if ($is_wpml) {
|
| 6199 | - $csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type ); |
|
| 6200 | - $csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type ); |
|
| 6199 | + $csv_row[] = geodir_get_language_for_element($post_id, 'post_' . $post_type); |
|
| 6200 | + $csv_row[] = geodir_imex_original_post_id($post_id, 'post_' . $post_type); |
|
| 6201 | 6201 | } |
| 6202 | 6202 | // WPML |
| 6203 | 6203 | |
| 6204 | - if ( !empty( $custom_fields ) ) {
|
|
| 6205 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 6206 | - $csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 6204 | + if (!empty($custom_fields)) {
|
|
| 6205 | + foreach ($custom_fields as $custom_field) {
|
|
| 6206 | + $csv_row[] = isset($post_info[$custom_field->htmlvar_name]) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 6207 | 6207 | } |
| 6208 | 6208 | } |
| 6209 | 6209 | |
@@ -6214,26 +6214,26 @@ discard block |
||
| 6214 | 6214 | $franchise = ''; |
| 6215 | 6215 | |
| 6216 | 6216 | if (geodir_franchise_pkg_is_active($gd_post_info)) {
|
| 6217 | - $gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true ); |
|
| 6218 | - $locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : ''; |
|
| 6217 | + $gd_is_franchise = (int) get_post_meta($post_id, 'gd_is_franchise', true); |
|
| 6218 | + $locaked_fields = $gd_is_franchise ? get_post_meta($post_id, 'gd_franchise_lock', true) : ''; |
|
| 6219 | 6219 | $locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
|
| 6220 | - $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id |
|
| 6220 | + $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int) $post_info['franchise'] > 0 ? (int) $post_info['franchise'] : 0; // franchise id |
|
| 6221 | 6221 | } |
| 6222 | 6222 | |
| 6223 | - $csv_row[] = (int)$gd_is_franchise; // gd_is_franchise |
|
| 6223 | + $csv_row[] = (int) $gd_is_franchise; // gd_is_franchise |
|
| 6224 | 6224 | $csv_row[] = $locaked_fields; // gd_franchise_lock fields |
| 6225 | - $csv_row[] = (int)$franchise; // franchise id |
|
| 6225 | + $csv_row[] = (int) $franchise; // franchise id |
|
| 6226 | 6226 | } |
| 6227 | 6227 | |
| 6228 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6229 | - $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
|
| 6228 | + for ($c = 0; $c < $images_count; $c++) {
|
|
| 6229 | + $csv_row[] = isset($current_images[$c]) ? $current_images[$c] : ''; // IMAGE |
|
| 6230 | 6230 | } |
| 6231 | 6231 | |
| 6232 | 6232 | $csv_rows[] = $csv_row; |
| 6233 | 6233 | |
| 6234 | 6234 | } |
| 6235 | 6235 | |
| 6236 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6236 | + for ($c = 0; $c < $images_count; $c++) {
|
|
| 6237 | 6237 | $csv_rows[0][] = 'IMAGE'; |
| 6238 | 6238 | } |
| 6239 | 6239 | } |
@@ -6255,19 +6255,19 @@ discard block |
||
| 6255 | 6255 | * @param int $page_no Page number. Default 0. |
| 6256 | 6256 | * @return array Array of posts data. |
| 6257 | 6257 | */ |
| 6258 | -function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 6258 | +function geodir_get_export_posts($post_type, $per_page = 0, $page_no = 0) {
|
|
| 6259 | 6259 | global $wpdb, $plugin_prefix; |
| 6260 | 6260 | |
| 6261 | - if ( ! post_type_exists( $post_type ) ) |
|
| 6261 | + if (!post_type_exists($post_type)) |
|
| 6262 | 6262 | return new stdClass; |
| 6263 | 6263 | |
| 6264 | 6264 | $table = $plugin_prefix . $post_type . '_detail'; |
| 6265 | 6265 | |
| 6266 | 6266 | $limit = ''; |
| 6267 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6268 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 6267 | + if ($per_page > 0 && $page_no > 0) {
|
|
| 6268 | + $offset = ($page_no - 1) * $per_page; |
|
| 6269 | 6269 | |
| 6270 | - if ( $offset > 0 ) {
|
|
| 6270 | + if ($offset > 0) {
|
|
| 6271 | 6271 | $limit = " LIMIT " . $offset . "," . $per_page; |
| 6272 | 6272 | } else {
|
| 6273 | 6273 | $limit = " LIMIT " . $per_page; |
@@ -6284,9 +6284,9 @@ discard block |
||
| 6284 | 6284 | * @param int $query The SQL query. |
| 6285 | 6285 | * @param string $post_type Post type. |
| 6286 | 6286 | */ |
| 6287 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 6287 | + $query = apply_filters('geodir_imex_export_posts_query', $query, $post_type);
|
|
| 6288 | 6288 | |
| 6289 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 6289 | + $results = (array) $wpdb->get_results($wpdb->prepare($query, $post_type), ARRAY_A); |
|
| 6290 | 6290 | |
| 6291 | 6291 | /** |
| 6292 | 6292 | * Modify returned post results for the current post type. |
@@ -6297,7 +6297,7 @@ discard block |
||
| 6297 | 6297 | * @param object $results An object containing all post ids. |
| 6298 | 6298 | * @param string $post_type Post type. |
| 6299 | 6299 | */ |
| 6300 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 6300 | + return apply_filters('geodir_export_posts', $results, $post_type);
|
|
| 6301 | 6301 | } |
| 6302 | 6302 | |
| 6303 | 6303 | /** |
@@ -6314,8 +6314,8 @@ discard block |
||
| 6314 | 6314 | * @param string $post_type Post type. |
| 6315 | 6315 | * @return string The SQL query. |
| 6316 | 6316 | */ |
| 6317 | -function geodir_imex_get_events_query( $query, $post_type ) {
|
|
| 6318 | - if ( $post_type == 'gd_event' ) {
|
|
| 6317 | +function geodir_imex_get_events_query($query, $post_type) {
|
|
| 6318 | + if ($post_type == 'gd_event') {
|
|
| 6319 | 6319 | global $wpdb, $plugin_prefix; |
| 6320 | 6320 | |
| 6321 | 6321 | $table = $plugin_prefix . $post_type . '_detail'; |
@@ -6336,15 +6336,15 @@ discard block |
||
| 6336 | 6336 | * @param string $post_type Post type. |
| 6337 | 6337 | * @return int Total terms count. |
| 6338 | 6338 | */ |
| 6339 | -function geodir_get_terms_count( $post_type ) {
|
|
| 6340 | - $args = array( 'hide_empty' => 0 ); |
|
| 6339 | +function geodir_get_terms_count($post_type) {
|
|
| 6340 | + $args = array('hide_empty' => 0);
|
|
| 6341 | 6341 | |
| 6342 | - remove_all_filters( 'get_terms' ); |
|
| 6342 | + remove_all_filters('get_terms');
|
|
| 6343 | 6343 | |
| 6344 | 6344 | $taxonomy = $post_type . 'category'; |
| 6345 | 6345 | |
| 6346 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 6347 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 6346 | + $count_terms = wp_count_terms($taxonomy, $args); |
|
| 6347 | + $count_terms = !is_wp_error($count_terms) ? $count_terms : 0; |
|
| 6348 | 6348 | |
| 6349 | 6349 | return $count_terms; |
| 6350 | 6350 | } |
@@ -6361,23 +6361,23 @@ discard block |
||
| 6361 | 6361 | * @param int $page_no Page number. Default 0. |
| 6362 | 6362 | * @return array Array of terms data. |
| 6363 | 6363 | */ |
| 6364 | -function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
|
|
| 6365 | - $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); |
|
| 6364 | +function geodir_imex_get_terms($post_type, $per_page = 0, $page_no = 0) {
|
|
| 6365 | + $args = array('hide_empty' => 0, 'orderby' => 'id');
|
|
| 6366 | 6366 | |
| 6367 | - remove_all_filters( 'get_terms' ); |
|
| 6367 | + remove_all_filters('get_terms');
|
|
| 6368 | 6368 | |
| 6369 | 6369 | $taxonomy = $post_type . 'category'; |
| 6370 | 6370 | |
| 6371 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6372 | - $args['offset'] = ( $page_no - 1 ) * $per_page; |
|
| 6371 | + if ($per_page > 0 && $page_no > 0) {
|
|
| 6372 | + $args['offset'] = ($page_no - 1) * $per_page; |
|
| 6373 | 6373 | $args['number'] = $per_page; |
| 6374 | 6374 | } |
| 6375 | 6375 | |
| 6376 | - $terms = get_terms( $taxonomy, $args ); |
|
| 6376 | + $terms = get_terms($taxonomy, $args); |
|
| 6377 | 6377 | |
| 6378 | 6378 | $csv_rows = array(); |
| 6379 | 6379 | |
| 6380 | - if ( !empty( $terms ) ) {
|
|
| 6380 | + if (!empty($terms)) {
|
|
| 6381 | 6381 | $csv_row = array(); |
| 6382 | 6382 | $csv_row[] = 'cat_id'; |
| 6383 | 6383 | $csv_row[] = 'cat_name'; |
@@ -6398,16 +6398,16 @@ discard block |
||
| 6398 | 6398 | |
| 6399 | 6399 | $csv_rows[] = $csv_row; |
| 6400 | 6400 | |
| 6401 | - foreach ( $terms as $term ) {
|
|
| 6402 | - $cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); |
|
| 6403 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 6401 | + foreach ($terms as $term) {
|
|
| 6402 | + $cat_icon = get_tax_meta($term->term_id, 'ct_cat_icon', false, $post_type); |
|
| 6403 | + $cat_icon = !empty($cat_icon) && isset($cat_icon['src']) ? $cat_icon['src'] : ''; |
|
| 6404 | 6404 | |
| 6405 | - $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); |
|
| 6406 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 6405 | + $cat_image = geodir_get_default_catimage($term->term_id, $post_type); |
|
| 6406 | + $cat_image = !empty($cat_image) && isset($cat_image['src']) ? $cat_image['src'] : ''; |
|
| 6407 | 6407 | |
| 6408 | 6408 | $cat_parent = ''; |
| 6409 | - if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
|
|
| 6410 | - $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); |
|
| 6409 | + if (isset($term->parent) && (int) $term->parent > 0 && term_exists((int) $term->parent, $taxonomy)) {
|
|
| 6410 | + $parent_term = (array) get_term_by('id', (int) $term->parent, $taxonomy);
|
|
| 6411 | 6411 | $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; |
| 6412 | 6412 | } |
| 6413 | 6413 | |
@@ -6417,14 +6417,14 @@ discard block |
||
| 6417 | 6417 | $csv_row[] = $term->slug; |
| 6418 | 6418 | $csv_row[] = $post_type; |
| 6419 | 6419 | $csv_row[] = $cat_parent; |
| 6420 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
|
| 6420 | + $csv_row[] = get_tax_meta($term->term_id, 'ct_cat_schema', false, $post_type); |
|
| 6421 | 6421 | $csv_row[] = $term->description; |
| 6422 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); |
|
| 6422 | + $csv_row[] = get_tax_meta($term->term_id, 'ct_cat_top_desc', false, $post_type); |
|
| 6423 | 6423 | $csv_row[] = $cat_image; |
| 6424 | 6424 | $csv_row[] = $cat_icon; |
| 6425 | 6425 | // WPML |
| 6426 | 6426 | if ($is_wpml) {
|
| 6427 | - $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
|
| 6427 | + $csv_row[] = geodir_get_language_for_element($term->term_id, 'tax_' . $taxonomy); |
|
| 6428 | 6428 | } |
| 6429 | 6429 | // WPML |
| 6430 | 6430 | |
@@ -6443,7 +6443,7 @@ discard block |
||
| 6443 | 6443 | * @param bool $relative True for relative path & False for absolute path. |
| 6444 | 6444 | * @return string Path to the cache directory. |
| 6445 | 6445 | */ |
| 6446 | -function geodir_path_import_export( $relative = true ) {
|
|
| 6446 | +function geodir_path_import_export($relative = true) {
|
|
| 6447 | 6447 | $upload_dir = wp_upload_dir(); |
| 6448 | 6448 | |
| 6449 | 6449 | return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache'; |
@@ -6462,8 +6462,8 @@ discard block |
||
| 6462 | 6462 | * @param bool $clear If true then it overwrite data otherwise add rows at the end of file. |
| 6463 | 6463 | * @return bool true if success otherwise false. |
| 6464 | 6464 | */ |
| 6465 | -function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
|
|
| 6466 | - if ( empty( $csv_data ) ) {
|
|
| 6465 | +function geodir_save_csv_data($file_path, $csv_data = array(), $clear = true) {
|
|
| 6466 | + if (empty($csv_data)) {
|
|
| 6467 | 6467 | return false; |
| 6468 | 6468 | } |
| 6469 | 6469 | |
@@ -6471,17 +6471,17 @@ discard block |
||
| 6471 | 6471 | |
| 6472 | 6472 | $mode = $clear ? 'w+' : 'a+'; |
| 6473 | 6473 | |
| 6474 | - if ( function_exists( 'fputcsv' ) ) {
|
|
| 6475 | - $file = fopen( $file_path, $mode ); |
|
| 6476 | - foreach( $csv_data as $csv_row ) {
|
|
| 6474 | + if (function_exists('fputcsv')) {
|
|
| 6475 | + $file = fopen($file_path, $mode); |
|
| 6476 | + foreach ($csv_data as $csv_row) {
|
|
| 6477 | 6477 | //$csv_row = array_map( 'utf8_decode', $csv_row ); |
| 6478 | - $write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' ); |
|
| 6478 | + $write_successful = fputcsv($file, $csv_row, ",", $enclosure = '"'); |
|
| 6479 | 6479 | } |
| 6480 | - fclose( $file ); |
|
| 6480 | + fclose($file); |
|
| 6481 | 6481 | } else {
|
| 6482 | - foreach( $csv_data as $csv_row ) {
|
|
| 6482 | + foreach ($csv_data as $csv_row) {
|
|
| 6483 | 6483 | //$csv_row = array_map( 'utf8_decode', $csv_row ); |
| 6484 | - $wp_filesystem->put_contents( $file_path, $csv_row ); |
|
| 6484 | + $wp_filesystem->put_contents($file_path, $csv_row); |
|
| 6485 | 6485 | } |
| 6486 | 6486 | } |
| 6487 | 6487 | |
@@ -6499,14 +6499,14 @@ discard block |
||
| 6499 | 6499 | * @param string $file Full path to file. |
| 6500 | 6500 | * @return int No of file rows. |
| 6501 | 6501 | */ |
| 6502 | -function geodir_import_export_line_count( $file ) {
|
|
| 6502 | +function geodir_import_export_line_count($file) {
|
|
| 6503 | 6503 | global $wp_filesystem; |
| 6504 | 6504 | |
| 6505 | - if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
|
|
| 6506 | - $contents = $wp_filesystem->get_contents_array( $file ); |
|
| 6505 | + if ($wp_filesystem->is_file($file) && $wp_filesystem->exists($file)) {
|
|
| 6506 | + $contents = $wp_filesystem->get_contents_array($file); |
|
| 6507 | 6507 | |
| 6508 | - if ( !empty( $contents ) && is_array( $contents ) ) {
|
|
| 6509 | - return count( $contents ) - 1; |
|
| 6508 | + if (!empty($contents) && is_array($contents)) {
|
|
| 6509 | + return count($contents) - 1; |
|
| 6510 | 6510 | } |
| 6511 | 6511 | } |
| 6512 | 6512 | |
@@ -6523,11 +6523,11 @@ discard block |
||
| 6523 | 6523 | * @param string $post_type The post type. |
| 6524 | 6524 | * @return object Queried object. |
| 6525 | 6525 | */ |
| 6526 | -function geodir_imex_get_custom_fields( $post_type ) {
|
|
| 6526 | +function geodir_imex_get_custom_fields($post_type) {
|
|
| 6527 | 6527 | global $wpdb; |
| 6528 | 6528 | |
| 6529 | - $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
|
|
| 6530 | - $rows = $wpdb->get_results( $sql ); |
|
| 6529 | + $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array($post_type));
|
|
| 6530 | + $rows = $wpdb->get_results($sql); |
|
| 6531 | 6531 | |
| 6532 | 6532 | return $rows; |
| 6533 | 6533 | } |
@@ -6609,9 +6609,9 @@ discard block |
||
| 6609 | 6609 | $post_table = $plugin_prefix . $post_type . '_detail'; |
| 6610 | 6610 | |
| 6611 | 6611 | $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
| 6612 | - $data = (array)$wpdb->get_row($query); |
|
| 6612 | + $data = (array) $wpdb->get_row($query); |
|
| 6613 | 6613 | |
| 6614 | - if ( !empty( $data ) ) {
|
|
| 6614 | + if (!empty($data)) {
|
|
| 6615 | 6615 | $data['post_id'] = $tr_post_id; |
| 6616 | 6616 | unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
| 6617 | 6617 | |
@@ -6639,7 +6639,7 @@ discard block |
||
| 6639 | 6639 | global $sitepress, $wpdb; |
| 6640 | 6640 | $post_type = get_post_type($master_post_id); |
| 6641 | 6641 | |
| 6642 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6642 | + remove_filter('get_term', array($sitepress, 'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6643 | 6643 | |
| 6644 | 6644 | $taxonomies = get_object_taxonomies($post_type); |
| 6645 | 6645 | foreach ($taxonomies as $taxonomy) {
|
@@ -6648,9 +6648,9 @@ discard block |
||
| 6648 | 6648 | |
| 6649 | 6649 | if ($terms) {
|
| 6650 | 6650 | foreach ($terms as $term) {
|
| 6651 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 6651 | + $tr_id = apply_filters('translate_object_id', $term->term_id, $taxonomy, false, $lang);
|
|
| 6652 | 6652 | |
| 6653 | - if (!is_null($tr_id)){
|
|
| 6653 | + if (!is_null($tr_id)) {
|
|
| 6654 | 6654 | // not using get_term - unfiltered get_term |
| 6655 | 6655 | $translated_term = $wpdb->get_row($wpdb->prepare("
|
| 6656 | 6656 | SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
|
@@ -6659,8 +6659,8 @@ discard block |
||
| 6659 | 6659 | } |
| 6660 | 6660 | } |
| 6661 | 6661 | |
| 6662 | - if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 6663 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 6662 | + if (!is_taxonomy_hierarchical($taxonomy)) {
|
|
| 6663 | + $terms_array = array_unique(array_map('intval', $terms_array));
|
|
| 6664 | 6664 | } |
| 6665 | 6665 | |
| 6666 | 6666 | wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
@@ -6693,9 +6693,9 @@ discard block |
||
| 6693 | 6693 | $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
| 6694 | 6694 | $post_images = $wpdb->get_results($query); |
| 6695 | 6695 | |
| 6696 | - if ( !empty( $post_images ) ) {
|
|
| 6697 | - foreach ( $post_images as $post_image) {
|
|
| 6698 | - $image_data = (array)$post_image; |
|
| 6696 | + if (!empty($post_images)) {
|
|
| 6697 | + foreach ($post_images as $post_image) {
|
|
| 6698 | + $image_data = (array) $post_image; |
|
| 6699 | 6699 | unset($image_data['ID']); |
| 6700 | 6700 | $image_data['post_id'] = $tr_post_id; |
| 6701 | 6701 | |
@@ -6721,10 +6721,10 @@ discard block |
||
| 6721 | 6721 | * @return array Event data array. |
| 6722 | 6722 | */ |
| 6723 | 6723 | function geodir_imex_get_event_data($post, $gd_post_info) {
|
| 6724 | - $event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : ''; |
|
| 6724 | + $event_date = isset($post['event_date']) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($post['event_date'])) : '';
|
|
| 6725 | 6725 | $event_enddate = $event_date; |
| 6726 | - $starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : ''; |
|
| 6727 | - $endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : ''; |
|
| 6726 | + $starttime = isset($post['starttime']) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['starttime'])) : '';
|
|
| 6727 | + $endtime = isset($post['endtime']) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($post['endtime'])) : '';
|
|
| 6728 | 6728 | |
| 6729 | 6729 | $is_recurring_event = ''; |
| 6730 | 6730 | $event_duration_days = ''; |
@@ -6742,15 +6742,15 @@ discard block |
||
| 6742 | 6742 | |
| 6743 | 6743 | $recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array(); |
| 6744 | 6744 | if (!empty($recurring_data)) {
|
| 6745 | - $event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date; |
|
| 6746 | - $event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date; |
|
| 6747 | - $starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime; |
|
| 6748 | - $endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime; |
|
| 6745 | + $event_date = isset($recurring_data['event_start']) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_start'])) : $event_date;
|
|
| 6746 | + $event_enddate = isset($recurring_data['event_end']) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['event_end'])) : $event_date;
|
|
| 6747 | + $starttime = isset($recurring_data['starttime']) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['starttime'])) : $starttime;
|
|
| 6748 | + $endtime = isset($recurring_data['endtime']) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n('H:i', strtotime($recurring_data['endtime'])) : $endtime;
|
|
| 6749 | 6749 | $is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : ''; |
| 6750 | 6750 | $different_times = !empty($recurring_data['different_times']) ? true : false; |
| 6751 | 6751 | |
| 6752 | - $recurring_pkg = geodir_event_recurring_pkg( $gd_post_info ); |
|
| 6753 | - $is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true; |
|
| 6752 | + $recurring_pkg = geodir_event_recurring_pkg($gd_post_info); |
|
| 6753 | + $is_recurring = isset($gd_post_info->is_recurring) && (int) $gd_post_info->is_recurring == 0 ? false : true; |
|
| 6754 | 6754 | |
| 6755 | 6755 | if ($recurring_pkg && $is_recurring) {
|
| 6756 | 6756 | $recurring_dates = $event_date; |
@@ -6760,13 +6760,13 @@ discard block |
||
| 6760 | 6760 | $recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
|
| 6761 | 6761 | |
| 6762 | 6762 | if (!empty($recurring_data['event_recurring_dates'])) {
|
| 6763 | - $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 6763 | + $event_recurring_dates = explode(',', $recurring_data['event_recurring_dates']);
|
|
| 6764 | 6764 | |
| 6765 | 6765 | if (!empty($event_recurring_dates)) {
|
| 6766 | 6766 | $recurring_dates = array(); |
| 6767 | 6767 | |
| 6768 | 6768 | foreach ($event_recurring_dates as $date) {
|
| 6769 | - $recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) ); |
|
| 6769 | + $recurring_dates[] = date_i18n('d/m/Y', strtotime($date));
|
|
| 6770 | 6770 | } |
| 6771 | 6771 | |
| 6772 | 6772 | $recurring_dates = implode(",", $recurring_dates);
|
@@ -6782,7 +6782,7 @@ discard block |
||
| 6782 | 6782 | $times = array(); |
| 6783 | 6783 | |
| 6784 | 6784 | foreach ($recurring_data['starttimes'] as $time) {
|
| 6785 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6785 | + $times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
|
|
| 6786 | 6786 | } |
| 6787 | 6787 | |
| 6788 | 6788 | $event_starttimes = implode(",", $times);
|
@@ -6792,7 +6792,7 @@ discard block |
||
| 6792 | 6792 | $times = array(); |
| 6793 | 6793 | |
| 6794 | 6794 | foreach ($recurring_data['endtimes'] as $time) {
|
| 6795 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6795 | + $times[] = $time != '00:00:00' ? date_i18n('H:i', strtotime($time)) : '00:00';
|
|
| 6796 | 6796 | } |
| 6797 | 6797 | |
| 6798 | 6798 | $event_endtimes = implode(",", $times);
|
@@ -6804,8 +6804,8 @@ discard block |
||
| 6804 | 6804 | } |
| 6805 | 6805 | } |
| 6806 | 6806 | } else {
|
| 6807 | - $event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1; |
|
| 6808 | - $recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6807 | + $event_duration_days = isset($recurring_data['duration_x']) ? (int) $recurring_data['duration_x'] : 1; |
|
| 6808 | + $recurring_interval = !empty($recurring_data['repeat_x']) && (int) $recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6809 | 6809 | |
| 6810 | 6810 | if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
|
| 6811 | 6811 | $week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
@@ -6821,11 +6821,11 @@ discard block |
||
| 6821 | 6821 | } |
| 6822 | 6822 | |
| 6823 | 6823 | $recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
|
| 6824 | - if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
|
|
| 6825 | - $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : ''; |
|
| 6824 | + if (!empty($recurring_data['repeat_end_type']) && (int) $recurring_data['repeat_end_type'] == 1) {
|
|
| 6825 | + $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n('d/m/Y', strtotime($recurring_data['repeat_end'])) : '';
|
|
| 6826 | 6826 | $max_recurring_count = empty($recurring_end_date) ? 1 : ''; |
| 6827 | 6827 | } else {
|
| 6828 | - $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1); |
|
| 6828 | + $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int) $recurring_data['max_repeat'] > 0 ? (int) $recurring_data['max_repeat'] : 1); |
|
| 6829 | 6829 | } |
| 6830 | 6830 | } |
| 6831 | 6831 | } |
@@ -6889,9 +6889,9 @@ discard block |
||
| 6889 | 6889 | * @return array Event data array. |
| 6890 | 6890 | */ |
| 6891 | 6891 | function geodir_imex_process_event_data($gd_post) {
|
| 6892 | - $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); |
|
| 6892 | + $recurring_pkg = geodir_event_recurring_pkg((object) $gd_post); |
|
| 6893 | 6893 | |
| 6894 | - $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6894 | + $is_recurring = isset($gd_post['is_recurring_event']) && (int) $gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6895 | 6895 | $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : ''; |
| 6896 | 6896 | $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date; |
| 6897 | 6897 | $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; |
@@ -6938,17 +6938,17 @@ discard block |
||
| 6938 | 6938 | $event_recurring_dates = implode(",", $event_recurring_dates);
|
| 6939 | 6939 | } |
| 6940 | 6940 | } else {
|
| 6941 | - $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; |
|
| 6942 | - $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; |
|
| 6943 | - $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; |
|
| 6944 | - $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6941 | + $duration_x = !empty($gd_post['event_duration_days']) ? (int) $gd_post['event_duration_days'] : 1; |
|
| 6942 | + $repeat_x = !empty($gd_post['recurring_interval']) ? (int) $gd_post['recurring_interval'] : 1; |
|
| 6943 | + $max_repeat = !empty($gd_post['max_recurring_count']) ? (int) $gd_post['max_recurring_count'] : 1; |
|
| 6944 | + $repeat_end = !empty($gd_post['recurring_end_date']) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6945 | 6945 | |
| 6946 | 6946 | $repeat_end_type = $repeat_end != '' ? 1 : 0; |
| 6947 | 6947 | $max_repeat = $repeat_end != '' ? '' : $max_repeat; |
| 6948 | 6948 | |
| 6949 | 6949 | $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
|
| 6950 | 6950 | |
| 6951 | - $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6951 | + $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days']) != '' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6952 | 6952 | $repeat_days = array(); |
| 6953 | 6953 | if (!empty($a_repeat_days)) {
|
| 6954 | 6954 | foreach ($a_repeat_days as $repeat_day) {
|
@@ -6966,7 +6966,7 @@ discard block |
||
| 6966 | 6966 | $repeat_weeks = array(); |
| 6967 | 6967 | if (!empty($a_repeat_weeks)) {
|
| 6968 | 6968 | foreach ($a_repeat_weeks as $repeat_week) {
|
| 6969 | - $repeat_weeks[] = (int)$repeat_week; |
|
| 6969 | + $repeat_weeks[] = (int) $repeat_week; |
|
| 6970 | 6970 | } |
| 6971 | 6971 | |
| 6972 | 6972 | $repeat_weeks = array_unique($repeat_weeks); |
@@ -7087,7 +7087,7 @@ discard block |
||
| 7087 | 7087 | */ |
| 7088 | 7088 | function geodir_admin_upgrade_notice() {
|
| 7089 | 7089 | $class = "error"; |
| 7090 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 7090 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.", "geodirectory");
|
|
| 7091 | 7091 | echo"<div class=\"$class\"> <p>$message</p></div>"; |
| 7092 | 7092 | } |
| 7093 | 7093 | |
@@ -7102,7 +7102,7 @@ discard block |
||
| 7102 | 7102 | * @param (object) $r |
| 7103 | 7103 | * @return (string) $output |
| 7104 | 7104 | */ |
| 7105 | -function geodire_admin_upgrade_notice( $plugin_data, $r ) |
|
| 7105 | +function geodire_admin_upgrade_notice($plugin_data, $r) |
|
| 7106 | 7106 | {
|
| 7107 | 7107 | // readme contents |
| 7108 | 7108 | $args = array( |
@@ -7110,7 +7110,7 @@ discard block |
||
| 7110 | 7110 | 'redirection' => 5 |
| 7111 | 7111 | ); |
| 7112 | 7112 | $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
| 7113 | - $data = wp_remote_get( $url, $args ); |
|
| 7113 | + $data = wp_remote_get($url, $args); |
|
| 7114 | 7114 | |
| 7115 | 7115 | if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
| 7116 | 7116 | |
@@ -7125,20 +7125,20 @@ discard block |
||
| 7125 | 7125 | function geodir_in_plugin_update_message($content) {
|
| 7126 | 7126 | // Output Upgrade Notice |
| 7127 | 7127 | $matches = null; |
| 7128 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 7128 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote(GEODIRECTORY_VERSION) . '\s*=|$)~Uis'; |
|
| 7129 | 7129 | $upgrade_notice = ''; |
| 7130 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 7131 | - if(empty($matches)){return;}
|
|
| 7130 | + if (preg_match($regexp, $content, $matches)) {
|
|
| 7131 | + if (empty($matches)) {return; }
|
|
| 7132 | 7132 | //print_r($matches ); |
| 7133 | - $version = trim( $matches[1] ); |
|
| 7134 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 7133 | + $version = trim($matches[1]); |
|
| 7134 | + if ($version && $version > GEODIRECTORY_VERSION) {
|
|
| 7135 | 7135 | |
| 7136 | 7136 | |
| 7137 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 7138 | - if ( version_compare( WC_VERSION, $version, '<' ) ) {
|
|
| 7137 | + $notices = (array) preg_split('~[\r\n]+~', trim($matches[2]));
|
|
| 7138 | + if (version_compare(WC_VERSION, $version, '<')) {
|
|
| 7139 | 7139 | $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
| 7140 | - foreach ( $notices as $index => $line ) {
|
|
| 7141 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 7140 | + foreach ($notices as $index => $line) {
|
|
| 7141 | + $upgrade_notice .= wp_kses_post(preg_replace('~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line));
|
|
| 7142 | 7142 | } |
| 7143 | 7143 | $upgrade_notice .= '</div> '; |
| 7144 | 7144 | } |
@@ -7162,7 +7162,7 @@ discard block |
||
| 7162 | 7162 | $default_language = $sitepress->get_default_language(); |
| 7163 | 7163 | if ($current_language != 'all' && $current_language != $default_language) {
|
| 7164 | 7164 | ?> |
| 7165 | - <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory');?></strong></p></div>
|
|
| 7165 | + <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory'); ?></strong></p></div>
|
|
| 7166 | 7166 | <?php |
| 7167 | 7167 | } |
| 7168 | 7168 | } |
@@ -177,8 +177,9 @@ discard block |
||
| 177 | 177 | |
| 178 | 178 | $thumb_img_arr = array(); |
| 179 | 179 | |
| 180 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 181 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 180 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
| 181 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 182 | + } |
|
| 182 | 183 | |
| 183 | 184 | $totImg = ''; |
| 184 | 185 | $image_limit = ''; |
@@ -234,7 +235,9 @@ discard block |
||
| 234 | 235 | {
|
| 235 | 236 | global $menu, $geodirectory; |
| 236 | 237 | |
| 237 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 238 | + if (current_user_can('manage_options')) { |
|
| 239 | + $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory'); |
|
| 240 | + } |
|
| 238 | 241 | |
| 239 | 242 | add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
| 240 | 243 | |
@@ -303,7 +306,9 @@ discard block |
||
| 303 | 306 | */ |
| 304 | 307 | function geodir_admin_custom_menu_order() |
| 305 | 308 | {
|
| 306 | - if (!current_user_can('manage_options')) return false;
|
|
| 309 | + if (!current_user_can('manage_options')) { |
|
| 310 | + return false; |
|
| 311 | + } |
|
| 307 | 312 | return true; |
| 308 | 313 | } |
| 309 | 314 | } |
@@ -334,10 +339,11 @@ discard block |
||
| 334 | 339 | case 'fail': |
| 335 | 340 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 336 | 341 | |
| 337 | - if ($gderr == 21) |
|
| 338 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 339 | - else |
|
| 340 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 342 | + if ($gderr == 21) { |
|
| 343 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>'; |
|
| 344 | + } else { |
|
| 345 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>'; |
|
| 346 | + } |
|
| 341 | 347 | break; |
| 342 | 348 | } |
| 343 | 349 | } |
@@ -374,8 +380,12 @@ discard block |
||
| 374 | 380 | include_once('option-pages/' . $current_tab . '_array.php');
|
| 375 | 381 | } |
| 376 | 382 | if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
| 377 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 378 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 383 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) { |
|
| 384 | + die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
| 385 | + } |
|
| 386 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) { |
|
| 387 | + die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
| 388 | + } |
|
| 379 | 389 | |
| 380 | 390 | /** |
| 381 | 391 | * Fires before updating geodirectory admin settings. |
@@ -387,8 +397,9 @@ discard block |
||
| 387 | 397 | */ |
| 388 | 398 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 389 | 399 | |
| 390 | - if (!empty($geodir_settings[$current_tab])) |
|
| 391 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 400 | + if (!empty($geodir_settings[$current_tab])) { |
|
| 401 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 402 | + } |
|
| 392 | 403 | |
| 393 | 404 | /** |
| 394 | 405 | * Called after GeoDirectory options settings are updated. |
@@ -456,8 +467,9 @@ discard block |
||
| 456 | 467 | $options_list = ''; |
| 457 | 468 | for ($option = 1; $option <= 30; $option++) {
|
| 458 | 469 | $selected = ''; |
| 459 | - if ($option == 10) |
|
| 460 | - $selected = 'selected="selected"'; |
|
| 470 | + if ($option == 10) { |
|
| 471 | + $selected = 'selected="selected"'; |
|
| 472 | + } |
|
| 461 | 473 | |
| 462 | 474 | $options_list .= '<option ' . $selected . ' value="' . $option . '">' . $option . '</option>'; |
| 463 | 475 | } |
@@ -657,10 +669,11 @@ discard block |
||
| 657 | 669 | } |
| 658 | 670 | |
| 659 | 671 | |
| 660 | - if (geodir_dummy_folder_exists()) |
|
| 661 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 662 | - else |
|
| 663 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 672 | + if (geodir_dummy_folder_exists()) { |
|
| 673 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 674 | + } else { |
|
| 675 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 676 | + } |
|
| 664 | 677 | $catname = str_replace(' ', '_', $catname);
|
| 665 | 678 | $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
| 666 | 679 | |
@@ -698,10 +711,11 @@ discard block |
||
| 698 | 711 | if (!term_exists($catname, 'gd_placecategory')) {
|
| 699 | 712 | $last_catid = wp_insert_term($catname, 'gd_placecategory'); |
| 700 | 713 | |
| 701 | - if (geodir_dummy_folder_exists()) |
|
| 702 | - $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 703 | - else |
|
| 704 | - $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 714 | + if (geodir_dummy_folder_exists()) { |
|
| 715 | + $dummy_image_url = geodir_plugin_url() . "/geodirectory-admin/dummy/cat_icon"; |
|
| 716 | + } else { |
|
| 717 | + $dummy_image_url = 'http://www.wpgeodirectory.com/dummy/cat_icon'; |
|
| 718 | + } |
|
| 705 | 719 | $catname = str_replace(' ', '_', $catname);
|
| 706 | 720 | $uploaded = (array)fetch_remote_file("$dummy_image_url/" . $catname . ".png");
|
| 707 | 721 | |
@@ -753,11 +767,14 @@ discard block |
||
| 753 | 767 | {
|
| 754 | 768 | // print_r($_POST); print_r($options); exit; |
| 755 | 769 | |
| 756 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 770 | + if ((!isset($_POST) || !$_POST) && !$dummy) { |
|
| 771 | + return false; |
|
| 772 | + } |
|
| 757 | 773 | |
| 758 | 774 | foreach ($options as $value) {
|
| 759 | - if ($dummy && isset($value['std'])) |
|
| 760 | - $_POST[$value['id']] = $value['std']; |
|
| 775 | + if ($dummy && isset($value['std'])) { |
|
| 776 | + $_POST[$value['id']] = $value['std']; |
|
| 777 | + } |
|
| 761 | 778 | |
| 762 | 779 | |
| 763 | 780 | if (isset($value['type']) && $value['type'] == 'checkbox') : |
@@ -766,25 +783,23 @@ discard block |
||
| 766 | 783 | update_option($value['id'], $_POST[$value['id']]); |
| 767 | 784 | } else {
|
| 768 | 785 | update_option($value['id'], 0); |
| 769 | - } |
|
| 770 | - |
|
| 771 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 786 | + } elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 772 | 787 | |
| 773 | 788 | if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
| 774 | 789 | update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
| 775 | 790 | update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
| 776 | 791 | if (isset($_POST[$value['id'] . '_crop'])) : |
| 777 | 792 | update_option($value['id'] . '_crop', 1); |
| 778 | - else : |
|
| 779 | - update_option($value['id'] . '_crop', 0); |
|
| 793 | + else { |
|
| 794 | + : |
|
| 795 | + update_option($value['id'] . '_crop', 0); |
|
| 796 | + } |
|
| 780 | 797 | endif; |
| 781 | 798 | } else {
|
| 782 | 799 | update_option($value['id'] . '_width', $value['std']); |
| 783 | 800 | update_option($value['id'] . '_height', $value['std']); |
| 784 | 801 | update_option($value['id'] . '_crop', 1); |
| 785 | - } |
|
| 786 | - |
|
| 787 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 802 | + } elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 788 | 803 | $post_types = array(); |
| 789 | 804 | $categories = array(); |
| 790 | 805 | $i = 0; |
@@ -830,8 +845,9 @@ discard block |
||
| 830 | 845 | $image_name_arr = explode('/', get_option($value['id']));
|
| 831 | 846 | $noimg_name = end($image_name_arr); |
| 832 | 847 | $img_path = $uploads['path'] . '/' . $noimg_name; |
| 833 | - if (file_exists($img_path)) |
|
| 834 | - unlink($img_path); |
|
| 848 | + if (file_exists($img_path)) { |
|
| 849 | + unlink($img_path); |
|
| 850 | + } |
|
| 835 | 851 | } |
| 836 | 852 | |
| 837 | 853 | update_option($value['id'], ''); |
@@ -847,8 +863,10 @@ discard block |
||
| 847 | 863 | foreach ($uploadedfile as $key => $uplaod): |
| 848 | 864 | if ($key == 'name'): |
| 849 | 865 | $uplaods[$key] = $filename; |
| 850 | - else : |
|
| 851 | - $uplaods[$key] = $uplaod; |
|
| 866 | + else { |
|
| 867 | + : |
|
| 868 | + $uplaods[$key] = $uplaod; |
|
| 869 | + } |
|
| 852 | 870 | endif; |
| 853 | 871 | endforeach; |
| 854 | 872 | |
@@ -858,8 +876,9 @@ discard block |
||
| 858 | 876 | $image_name_arr = explode('/', get_option($value['id']));
|
| 859 | 877 | $noimg_name = end($image_name_arr); |
| 860 | 878 | $img_path = $uploads['path'] . '/' . $noimg_name; |
| 861 | - if (file_exists($img_path)) |
|
| 862 | - unlink($img_path); |
|
| 879 | + if (file_exists($img_path)) { |
|
| 880 | + unlink($img_path); |
|
| 881 | + } |
|
| 863 | 882 | } |
| 864 | 883 | |
| 865 | 884 | $upload_overrides = array('test_form' => false);
|
@@ -874,10 +893,12 @@ discard block |
||
| 874 | 893 | endif; |
| 875 | 894 | |
| 876 | 895 | |
| 877 | - else : |
|
| 896 | + else { |
|
| 897 | + : |
|
| 878 | 898 | // same menu setting per theme. |
| 879 | 899 | if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
| 880 | - $theme = wp_get_theme(); |
|
| 900 | + $theme = wp_get_theme(); |
|
| 901 | + } |
|
| 881 | 902 | update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
| 882 | 903 | } |
| 883 | 904 | |
@@ -889,8 +910,9 @@ discard block |
||
| 889 | 910 | |
| 890 | 911 | endif; |
| 891 | 912 | } |
| 892 | - if ($dummy) |
|
| 893 | - unset($_POST); |
|
| 913 | + if ($dummy) { |
|
| 914 | + unset($_POST); |
|
| 915 | + } |
|
| 894 | 916 | return true; |
| 895 | 917 | |
| 896 | 918 | } |
@@ -1035,9 +1057,12 @@ discard block |
||
| 1035 | 1057 | $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
| 1036 | 1058 | 'categorys' => __('Categories', 'geodirectory'));
|
| 1037 | 1059 | |
| 1038 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 1060 | + if (($offset = array_search('author', array_keys($columns))) === false) { |
|
| 1061 | + // if the key doesn't exist |
|
| 1039 | 1062 | {
|
| 1040 | - $offset = 0; // should we prepend $array with $data? |
|
| 1063 | + $offset = 0; |
|
| 1064 | + } |
|
| 1065 | + // should we prepend $array with $data? |
|
| 1041 | 1066 | $offset = count($columns); // or should we append $array with $data? lets pick this one... |
| 1042 | 1067 | } |
| 1043 | 1068 | |
@@ -1097,11 +1122,13 @@ discard block |
||
| 1097 | 1122 | $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
| 1098 | 1123 | } |
| 1099 | 1124 | /* If no expire_date is found, output a default message. */ |
| 1100 | - if (empty($expire_date)) |
|
| 1101 | - echo __('Unknown', 'geodirectory');
|
|
| 1125 | + if (empty($expire_date)) { |
|
| 1126 | + echo __('Unknown', 'geodirectory'); |
|
| 1127 | + } |
|
| 1102 | 1128 | /* If there is a expire_date, append 'days left' to the text string. */ |
| 1103 | - else |
|
| 1104 | - echo $expire_date . $date_diff_text; |
|
| 1129 | + else { |
|
| 1130 | + echo $expire_date . $date_diff_text; |
|
| 1131 | + } |
|
| 1105 | 1132 | break; |
| 1106 | 1133 | |
| 1107 | 1134 | /* If displaying the 'categorys' column. */ |
@@ -1174,21 +1201,26 @@ discard block |
||
| 1174 | 1201 | |
| 1175 | 1202 | $geodir_posttypes = geodir_get_posttypes(); |
| 1176 | 1203 | |
| 1177 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 1178 | - return; |
|
| 1204 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { |
|
| 1205 | + return; |
|
| 1206 | + } |
|
| 1179 | 1207 | |
| 1180 | 1208 | if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
| 1181 | - if (isset($_REQUEST['_status'])) |
|
| 1182 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1209 | + if (isset($_REQUEST['_status'])) { |
|
| 1210 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 1211 | + } |
|
| 1183 | 1212 | |
| 1184 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 1185 | - return; |
|
| 1213 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) { |
|
| 1214 | + return; |
|
| 1215 | + } |
|
| 1186 | 1216 | |
| 1187 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 1188 | - return; |
|
| 1217 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) { |
|
| 1218 | + return; |
|
| 1219 | + } |
|
| 1189 | 1220 | |
| 1190 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 1191 | - return; |
|
| 1221 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) { |
|
| 1222 | + return; |
|
| 1223 | + } |
|
| 1192 | 1224 | |
| 1193 | 1225 | geodir_save_listing($_REQUEST); |
| 1194 | 1226 | } |
@@ -2024,8 +2056,9 @@ discard block |
||
| 2024 | 2056 | 'geo_lng' => $post_longitude); |
| 2025 | 2057 | |
| 2026 | 2058 | $post_location_info = $request_info['post_location']; |
| 2027 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 2028 | - $post_location_id = $location_id; |
|
| 2059 | + if ($location_id = geodir_add_new_location($post_location_info)) { |
|
| 2060 | + $post_location_id = $location_id; |
|
| 2061 | + } |
|
| 2029 | 2062 | |
| 2030 | 2063 | } else {
|
| 2031 | 2064 | $post_location_id = 0; |
@@ -2089,8 +2122,9 @@ discard block |
||
| 2089 | 2122 | $attachment_set = ''; |
| 2090 | 2123 | |
| 2091 | 2124 | foreach ($attachment as $key => $val) {
|
| 2092 | - if ($val != '') |
|
| 2093 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2125 | + if ($val != '') { |
|
| 2126 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2127 | + } |
|
| 2094 | 2128 | } |
| 2095 | 2129 | |
| 2096 | 2130 | $attachment_set = trim($attachment_set, ", "); |
@@ -2140,8 +2174,9 @@ discard block |
||
| 2140 | 2174 | fclose($fd); |
| 2141 | 2175 | //unlink($csv_target_path); |
| 2142 | 2176 | //rmdir($destination_path); |
| 2143 | - if (!empty($filename)) |
|
| 2144 | - geodir_remove_temp_images(); |
|
| 2177 | + if (!empty($filename)) { |
|
| 2178 | + geodir_remove_temp_images(); |
|
| 2179 | + } |
|
| 2145 | 2180 | |
| 2146 | 2181 | |
| 2147 | 2182 | echo $geodir_url = admin_url() . 'admin.php?page=geodirectory&tab=general_settings&active_tab=csv_upload_settings&msg=success&rowcount=' . $countpost . '&invalidcount=' . $address_invalid . '&blank_address=' . $blank_address . '&upload_files=' . $upload_files . '&invalid_post_type=' . $invalid_post_type . '&invalid_title=' . $invalid_title . '&total_records=' . $total_records; |
@@ -2174,10 +2209,18 @@ discard block |
||
| 2174 | 2209 | $tab_id = ''; |
| 2175 | 2210 | $i = 0; |
| 2176 | 2211 | foreach ($options as $value) : |
| 2177 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 2178 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 2179 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 2180 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 2212 | + if (!isset($value['name'])) { |
|
| 2213 | + $value['name'] = ''; |
|
| 2214 | + } |
|
| 2215 | + if (!isset($value['class'])) { |
|
| 2216 | + $value['class'] = ''; |
|
| 2217 | + } |
|
| 2218 | + if (!isset($value['css'])) { |
|
| 2219 | + $value['css'] = ''; |
|
| 2220 | + } |
|
| 2221 | + if (!isset($value['std'])) { |
|
| 2222 | + $value['std'] = ''; |
|
| 2223 | + } |
|
| 2181 | 2224 | $desc = ''; |
| 2182 | 2225 | switch ($value['type']) : |
| 2183 | 2226 | case 'dummy_installer': |
@@ -2196,11 +2239,13 @@ discard block |
||
| 2196 | 2239 | |
| 2197 | 2240 | $i++; |
| 2198 | 2241 | |
| 2199 | - if (isset($value['id']) && $value['id']) |
|
| 2200 | - $tab_id = $value['id']; |
|
| 2242 | + if (isset($value['id']) && $value['id']) { |
|
| 2243 | + $tab_id = $value['id']; |
|
| 2244 | + } |
|
| 2201 | 2245 | |
| 2202 | - if (isset($value['desc']) && $value['desc']) |
|
| 2203 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 2246 | + if (isset($value['desc']) && $value['desc']) { |
|
| 2247 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 2248 | + } |
|
| 2204 | 2249 | |
| 2205 | 2250 | if (isset($value['name']) && $value['name']) {
|
| 2206 | 2251 | if ($first_title === true) {
|
@@ -2231,10 +2276,12 @@ discard block |
||
| 2231 | 2276 | break; |
| 2232 | 2277 | |
| 2233 | 2278 | case 'sectionstart': |
| 2234 | - if (isset($value['desc']) && $value['desc']) |
|
| 2235 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 2236 | - if (isset($value['name']) && $value['name']) |
|
| 2237 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 2279 | + if (isset($value['desc']) && $value['desc']) { |
|
| 2280 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 2281 | + } |
|
| 2282 | + if (isset($value['name']) && $value['name']) { |
|
| 2283 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 2284 | + } |
|
| 2238 | 2285 | /** |
| 2239 | 2286 | * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
| 2240 | 2287 | * |
@@ -2242,7 +2289,9 @@ discard block |
||
| 2242 | 2289 | * |
| 2243 | 2290 | * @since 1.0.0 |
| 2244 | 2291 | */ |
| 2245 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 2292 | + if (isset($value['id']) && $value['id']) { |
|
| 2293 | + do_action('geodir_settings_' . sanitize_title($value['id']) . '_start'); |
|
| 2294 | + } |
|
| 2246 | 2295 | echo '<table class="form-table">' . "\n\n"; |
| 2247 | 2296 | |
| 2248 | 2297 | break; |
@@ -2254,7 +2303,9 @@ discard block |
||
| 2254 | 2303 | * |
| 2255 | 2304 | * @since 1.0.0 |
| 2256 | 2305 | */ |
| 2257 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 2306 | + if (isset($value['id']) && $value['id']) { |
|
| 2307 | + do_action('geodir_settings_' . sanitize_title($value['id']) . '_end'); |
|
| 2308 | + } |
|
| 2258 | 2309 | echo '</table>'; |
| 2259 | 2310 | /** |
| 2260 | 2311 | * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
@@ -2263,7 +2314,9 @@ discard block |
||
| 2263 | 2314 | * |
| 2264 | 2315 | * @since 1.0.0 |
| 2265 | 2316 | */ |
| 2266 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 2317 | + if (isset($value['id']) && $value['id']) { |
|
| 2318 | + do_action('geodir_settings_' . sanitize_title($value['id']) . '_after'); |
|
| 2319 | + } |
|
| 2267 | 2320 | break; |
| 2268 | 2321 | case 'text': |
| 2269 | 2322 | ?> |
@@ -2335,17 +2388,32 @@ discard block |
||
| 2335 | 2388 | <?php _e('Width', 'geodirectory'); ?> <input
|
| 2336 | 2389 | name="<?php echo esc_attr($value['id']); ?>_width" |
| 2337 | 2390 | id="<?php echo esc_attr($value['id']); ?>_width" type="text" size="3" |
| 2338 | - value="<?php if ($size = get_option($value['id'] . '_width')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 2391 | + value="<?php if ($size = get_option($value['id'] . '_width')) { |
|
| 2392 | + echo stripslashes($size); |
|
| 2393 | +} else { |
|
| 2394 | + echo $value['std']; |
|
| 2395 | +} |
|
| 2396 | +?>"/> |
|
| 2339 | 2397 | |
| 2340 | 2398 | <?php _e('Height', 'geodirectory'); ?> <input
|
| 2341 | 2399 | name="<?php echo esc_attr($value['id']); ?>_height" |
| 2342 | 2400 | id="<?php echo esc_attr($value['id']); ?>_height" type="text" size="3" |
| 2343 | - value="<?php if ($size = get_option($value['id'] . '_height')) echo stripslashes($size); else echo $value['std']; ?>"/> |
|
| 2401 | + value="<?php if ($size = get_option($value['id'] . '_height')) { |
|
| 2402 | + echo stripslashes($size); |
|
| 2403 | +} else { |
|
| 2404 | + echo $value['std']; |
|
| 2405 | +} |
|
| 2406 | +?>"/> |
|
| 2344 | 2407 | |
| 2345 | 2408 | <label><?php _e('Hard Crop', 'geodirectory'); ?> <input
|
| 2346 | 2409 | name="<?php echo esc_attr($value['id']); ?>_crop" |
| 2347 | 2410 | id="<?php echo esc_attr($value['id']); ?>_crop" |
| 2348 | - type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') checked(get_option($value['id'] . '_crop'), 1); else checked(1); ?> /></label> |
|
| 2411 | + type="checkbox" <?php if (get_option($value['id'] . '_crop') != '') { |
|
| 2412 | + checked(get_option($value['id'] . '_crop'), 1); |
|
| 2413 | +} else { |
|
| 2414 | + checked(1); |
|
| 2415 | +} |
|
| 2416 | +?> /></label> |
|
| 2349 | 2417 | |
| 2350 | 2418 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 2351 | 2419 | </tr><?php |
@@ -2357,17 +2425,22 @@ discard block |
||
| 2357 | 2425 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
| 2358 | 2426 | id="<?php echo esc_attr($value['id']); ?>" |
| 2359 | 2427 | style="<?php echo esc_attr($value['css']); ?>" |
| 2360 | - class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
|
| 2428 | + class="<?php if (isset($value['class'])) { |
|
| 2429 | + echo $value['class']; |
|
| 2430 | +} |
|
| 2431 | +?>" |
|
| 2361 | 2432 | option-ajaxchosen="false"> |
| 2362 | 2433 | <?php |
| 2363 | 2434 | foreach ($value['options'] as $key => $val) {
|
| 2364 | 2435 | $geodir_select_value = ''; |
| 2365 | 2436 | if (get_option($value['id']) != '') {
|
| 2366 | - if (get_option($value['id']) != '' && get_option($value['id']) == $key) |
|
| 2367 | - $geodir_select_value = ' selected="selected" '; |
|
| 2437 | + if (get_option($value['id']) != '' && get_option($value['id']) == $key) { |
|
| 2438 | + $geodir_select_value = ' selected="selected" '; |
|
| 2439 | + } |
|
| 2368 | 2440 | } else {
|
| 2369 | - if ($value['std'] == $key) |
|
| 2370 | - $geodir_select_value = ' selected="selected" '; |
|
| 2441 | + if ($value['std'] == $key) { |
|
| 2442 | + $geodir_select_value = ' selected="selected" '; |
|
| 2443 | + } |
|
| 2371 | 2444 | } |
| 2372 | 2445 | |
| 2373 | 2446 | |
@@ -2389,8 +2462,14 @@ discard block |
||
| 2389 | 2462 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
| 2390 | 2463 | id="<?php echo esc_attr($value['id']); ?>" |
| 2391 | 2464 | style="<?php echo esc_attr($value['css']); ?>" |
| 2392 | - class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
|
| 2393 | - data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
|
| 2465 | + class="<?php if (isset($value['class'])) { |
|
| 2466 | + echo $value['class']; |
|
| 2467 | +} |
|
| 2468 | +?>" |
|
| 2469 | + data-placeholder="<?php if (isset($value['placeholder_text'])) { |
|
| 2470 | + echo $value['placeholder_text']; |
|
| 2471 | +} |
|
| 2472 | +?>" |
|
| 2394 | 2473 | option-ajaxchosen="false"> |
| 2395 | 2474 | <?php |
| 2396 | 2475 | foreach ($value['options'] as $key => $val) {
|
@@ -2419,7 +2498,10 @@ discard block |
||
| 2419 | 2498 | <td class="forminp"> |
| 2420 | 2499 | <input type="file" name="<?php echo esc_attr($value['id']); ?>" |
| 2421 | 2500 | id="<?php echo esc_attr($value['id']); ?>" style="<?php echo esc_attr($value['css']); ?>" |
| 2422 | - class="<?php if (isset($value['class'])) echo $value['class']; ?>"/> |
|
| 2501 | + class="<?php if (isset($value['class'])) { |
|
| 2502 | + echo $value['class']; |
|
| 2503 | +} |
|
| 2504 | +?>"/> |
|
| 2423 | 2505 | <?php if (get_option($value['id'])) { ?>
|
| 2424 | 2506 | <input type="hidden" name="<?php echo esc_attr($value['id']); ?>_remove" |
| 2425 | 2507 | id="<?php echo esc_attr($value['id']); ?>_remove" value="0"> |
@@ -2500,13 +2582,15 @@ discard block |
||
| 2500 | 2582 | 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
| 2501 | 2583 | ); |
| 2502 | 2584 | $geodir_default_map_language = get_option('geodir_default_map_language');
|
| 2503 | - if (empty($geodir_default_map_language)) |
|
| 2504 | - $geodir_default_map_language = 'en'; |
|
| 2585 | + if (empty($geodir_default_map_language)) { |
|
| 2586 | + $geodir_default_map_language = 'en'; |
|
| 2587 | + } |
|
| 2505 | 2588 | foreach ($arr_map_langages as $language_key => $language_txt) {
|
| 2506 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 2507 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 2508 | - else |
|
| 2509 | - $geodir_default_language_selected = ''; |
|
| 2589 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) { |
|
| 2590 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 2591 | + } else { |
|
| 2592 | + $geodir_default_language_selected = ''; |
|
| 2593 | + } |
|
| 2510 | 2594 | |
| 2511 | 2595 | ?> |
| 2512 | 2596 | <option |
@@ -2526,14 +2610,16 @@ discard block |
||
| 2526 | 2610 | <?php |
| 2527 | 2611 | $post_types = geodir_get_posttypes('array');
|
| 2528 | 2612 | $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
| 2529 | - if (empty($geodir_default_map_search_pt)) |
|
| 2530 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 2613 | + if (empty($geodir_default_map_search_pt)) { |
|
| 2614 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 2615 | + } |
|
| 2531 | 2616 | if (is_array($post_types)) {
|
| 2532 | 2617 | foreach ($post_types as $key => $post_types_obj) {
|
| 2533 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 2534 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 2535 | - else |
|
| 2536 | - $geodir_search_pt_selected = ''; |
|
| 2618 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) { |
|
| 2619 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 2620 | + } else { |
|
| 2621 | + $geodir_search_pt_selected = ''; |
|
| 2622 | + } |
|
| 2537 | 2623 | |
| 2538 | 2624 | ?> |
| 2539 | 2625 | <option |
@@ -2653,7 +2739,7 @@ discard block |
||
| 2653 | 2739 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 2654 | 2740 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 2655 | 2741 | echo 'checked="checked"'; |
| 2656 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 2742 | + } elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 2657 | 2743 | <?php echo $value['desc']; ?></label><br> |
| 2658 | 2744 | </fieldset> |
| 2659 | 2745 | <?php |
@@ -2673,10 +2759,18 @@ discard block |
||
| 2673 | 2759 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 2674 | 2760 | <td class="forminp"> |
| 2675 | 2761 | <textarea |
| 2676 | - <?php if (isset($value['args'])) echo $value['args'] . ' '; ?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 2762 | + <?php if (isset($value['args'])) { |
|
| 2763 | + echo $value['args'] . ' '; |
|
| 2764 | +} |
|
| 2765 | +?>name="<?php echo esc_attr($value['id']); ?>" |
|
| 2677 | 2766 | id="<?php echo esc_attr($value['id']); ?>" |
| 2678 | 2767 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2679 | - style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) echo esc_textarea(stripslashes(get_option($value['id']))); else echo esc_textarea($value['std']); ?></textarea><span |
|
| 2768 | + style="<?php echo esc_attr($value['css']); ?>"><?php if (get_option($value['id'])) { |
|
| 2769 | + echo esc_textarea(stripslashes(get_option($value['id']))); |
|
| 2770 | +} else { |
|
| 2771 | + echo esc_textarea($value['std']); |
|
| 2772 | +} |
|
| 2773 | +?></textarea><span |
|
| 2680 | 2774 | class="description"><?php echo $value['desc'] ?></span> |
| 2681 | 2775 | |
| 2682 | 2776 | </td> |
@@ -2690,10 +2784,11 @@ discard block |
||
| 2690 | 2784 | <td class="forminp"><?php |
| 2691 | 2785 | |
| 2692 | 2786 | $content = ''; |
| 2693 | - if (get_option($value['id'])) |
|
| 2694 | - $content = stripslashes(get_option($value['id'])); |
|
| 2695 | - else |
|
| 2696 | - $content = $value['std']; |
|
| 2787 | + if (get_option($value['id'])) { |
|
| 2788 | + $content = stripslashes(get_option($value['id'])); |
|
| 2789 | + } else { |
|
| 2790 | + $content = $value['std']; |
|
| 2791 | + } |
|
| 2697 | 2792 | |
| 2698 | 2793 | $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
| 2699 | 2794 | |
@@ -2733,7 +2828,9 @@ discard block |
||
| 2733 | 2828 | 'echo' => false, |
| 2734 | 2829 | 'selected' => $page_setting); |
| 2735 | 2830 | |
| 2736 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 2831 | + if (isset($value['args'])) { |
|
| 2832 | + $args = wp_parse_args($value['args'], $args); |
|
| 2833 | + } |
|
| 2737 | 2834 | |
| 2738 | 2835 | ?> |
| 2739 | 2836 | <tr valign="top" class="single_select_page"> |
@@ -2753,8 +2850,10 @@ discard block |
||
| 2753 | 2850 | if (strstr($country_setting, ':')) : |
| 2754 | 2851 | $country = current(explode(':', $country_setting));
|
| 2755 | 2852 | $state = end(explode(':', $country_setting));
|
| 2756 | - else : |
|
| 2757 | - $country = $country_setting; |
|
| 2853 | + else { |
|
| 2854 | + : |
|
| 2855 | + $country = $country_setting; |
|
| 2856 | + } |
|
| 2758 | 2857 | $state = '*'; |
| 2759 | 2858 | endif; |
| 2760 | 2859 | ?> |
@@ -2781,8 +2880,10 @@ discard block |
||
| 2781 | 2880 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 2782 | 2881 | title="Country" class="chosen_select"> |
| 2783 | 2882 | <?php |
| 2784 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 2785 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 2883 | + if ($countries) { |
|
| 2884 | + foreach ($countries as $key => $val) : |
|
| 2885 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 2886 | + } |
|
| 2786 | 2887 | endforeach; |
| 2787 | 2888 | ?> |
| 2788 | 2889 | </select> |
@@ -3046,8 +3147,9 @@ discard block |
||
| 3046 | 3147 | endforeach; |
| 3047 | 3148 | endif; |
| 3048 | 3149 | |
| 3049 | - if (!empty($place_img_array)) |
|
| 3050 | - $curImages = implode(',', $place_img_array);
|
|
| 3150 | + if (!empty($place_img_array)) { |
|
| 3151 | + $curImages = implode(',', $place_img_array); |
|
| 3152 | + } |
|
| 3051 | 3153 | |
| 3052 | 3154 | |
| 3053 | 3155 | // adjust values here |
@@ -3394,16 +3496,17 @@ discard block |
||
| 3394 | 3496 | |
| 3395 | 3497 | $post_type = NULL; |
| 3396 | 3498 | |
| 3397 | - if ($post && isset($post->post_type)) |
|
| 3398 | - $post_type = $post->post_type; |
|
| 3399 | - elseif ($typenow) |
|
| 3400 | - $post_type = $typenow; |
|
| 3401 | - elseif ($current_screen && isset($current_screen->post_type)) |
|
| 3402 | - $post_type = $current_screen->post_type; |
|
| 3403 | - elseif (isset($_REQUEST['post_type'])) |
|
| 3404 | - $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3405 | - elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 3406 | - $post_type = get_post_type($_REQUEST['post']); |
|
| 3499 | + if ($post && isset($post->post_type)) { |
|
| 3500 | + $post_type = $post->post_type; |
|
| 3501 | + } elseif ($typenow) { |
|
| 3502 | + $post_type = $typenow; |
|
| 3503 | + } elseif ($current_screen && isset($current_screen->post_type)) { |
|
| 3504 | + $post_type = $current_screen->post_type; |
|
| 3505 | + } elseif (isset($_REQUEST['post_type'])) { |
|
| 3506 | + $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3507 | + } elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) { |
|
| 3508 | + $post_type = get_post_type($_REQUEST['post']); |
|
| 3509 | + } |
|
| 3407 | 3510 | |
| 3408 | 3511 | return $post_type; |
| 3409 | 3512 | } |
@@ -3462,9 +3565,10 @@ discard block |
||
| 3462 | 3565 | function geodir_hide_admin_preview_button() {
|
| 3463 | 3566 | global $post_type; |
| 3464 | 3567 | $post_types = geodir_get_posttypes(); |
| 3465 | - if(in_array($post_type, $post_types)) |
|
| 3466 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 3467 | -} |
|
| 3568 | + if(in_array($post_type, $post_types)) { |
|
| 3569 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>'; |
|
| 3570 | + } |
|
| 3571 | + } |
|
| 3468 | 3572 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 3469 | 3573 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
| 3470 | 3574 | |
@@ -6258,8 +6362,9 @@ discard block |
||
| 6258 | 6362 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 6259 | 6363 | global $wpdb, $plugin_prefix; |
| 6260 | 6364 | |
| 6261 | - if ( ! post_type_exists( $post_type ) ) |
|
| 6262 | - return new stdClass; |
|
| 6365 | + if ( ! post_type_exists( $post_type ) ) { |
|
| 6366 | + return new stdClass; |
|
| 6367 | + } |
|
| 6263 | 6368 | |
| 6264 | 6369 | $table = $plugin_prefix . $post_type . '_detail'; |
| 6265 | 6370 | |
@@ -7039,7 +7144,9 @@ discard block |
||
| 7039 | 7144 | |
| 7040 | 7145 | if ($page_found) : |
| 7041 | 7146 | // Page exists |
| 7042 | - if (!$option_value) update_option($option, $page_found); |
|
| 7147 | + if (!$option_value) { |
|
| 7148 | + update_option($option, $page_found); |
|
| 7149 | + } |
|
| 7043 | 7150 | return; |
| 7044 | 7151 | endif; |
| 7045 | 7152 | |
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Admin functions. |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Admin functions. |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Updates option value when GeoDirectory get deactivated. |
@@ -132,14 +132,14 @@ discard block |
||
| 132 | 132 | wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
| 133 | 133 | wp_enqueue_script('geodirectory-goMap-script');
|
| 134 | 134 | |
| 135 | - // font awesome rating script |
|
| 136 | - if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
|
| 137 | - wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 138 | - wp_enqueue_script('geodir-barrating-js');
|
|
| 139 | - } else { // default rating script
|
|
| 140 | - wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | - wp_enqueue_script('geodir-jRating-js');
|
|
| 142 | - } |
|
| 135 | + // font awesome rating script |
|
| 136 | + if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
|
| 137 | + wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 138 | + wp_enqueue_script('geodir-barrating-js');
|
|
| 139 | + } else { // default rating script
|
|
| 140 | + wp_register_script('geodir-jRating-js', geodir_plugin_url() . '/geodirectory-assets/js/jRating.jquery.js', array(), GEODIRECTORY_VERSION);
|
|
| 141 | + wp_enqueue_script('geodir-jRating-js');
|
|
| 142 | + } |
|
| 143 | 143 | |
| 144 | 144 | wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.js', array(), GEODIRECTORY_VERSION);
|
| 145 | 145 | wp_enqueue_script('geodir-on-document-load');
|
@@ -337,13 +337,13 @@ discard block |
||
| 337 | 337 | flush_rewrite_rules(false); |
| 338 | 338 | |
| 339 | 339 | break; |
| 340 | - case 'fail': |
|
| 341 | - $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
|
| 340 | + case 'fail': |
|
| 341 | + $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
|
| 342 | 342 | |
| 343 | - if ($gderr == 21) |
|
| 344 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | - else |
|
| 346 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 343 | + if ($gderr == 21) |
|
| 344 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 345 | + else |
|
| 346 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
|
| 347 | 347 | break; |
| 348 | 348 | } |
| 349 | 349 | } |
@@ -383,15 +383,15 @@ discard block |
||
| 383 | 383 | if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
| 384 | 384 | if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
| 385 | 385 | |
| 386 | - /** |
|
| 387 | - * Fires before updating geodirectory admin settings. |
|
| 388 | - * |
|
| 389 | - * @since 1.4.2 |
|
| 390 | - * |
|
| 391 | - * @param string $current_tab Current tab in geodirectory settings. |
|
| 392 | - * @param array $geodir_settings Array of geodirectory settings. |
|
| 393 | - */ |
|
| 394 | - do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
|
| 386 | + /** |
|
| 387 | + * Fires before updating geodirectory admin settings. |
|
| 388 | + * |
|
| 389 | + * @since 1.4.2 |
|
| 390 | + * |
|
| 391 | + * @param string $current_tab Current tab in geodirectory settings. |
|
| 392 | + * @param array $geodir_settings Array of geodirectory settings. |
|
| 393 | + */ |
|
| 394 | + do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
|
| 395 | 395 | |
| 396 | 396 | if (!empty($geodir_settings[$current_tab])) |
| 397 | 397 | geodir_update_options($geodir_settings[$current_tab]); |
@@ -480,11 +480,11 @@ discard block |
||
| 480 | 480 | <?php |
| 481 | 481 | |
| 482 | 482 | $default_location = geodir_get_default_location(); |
| 483 | - $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 484 | - $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 485 | - $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 486 | - $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 487 | - $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 483 | + $city = isset($default_location->city) ? $default_location->city : ''; |
|
| 484 | + $region =isset($default_location->region) ? $default_location->region : ''; |
|
| 485 | + $country =isset($default_location->country) ? $default_location->country : ''; |
|
| 486 | + $city_latitude =isset($default_location->city_latitude) ? $default_location->city_latitude : ''; |
|
| 487 | + $city_longitude =isset($default_location->city_longitude) ? $default_location->city_longitude : ''; |
|
| 488 | 488 | |
| 489 | 489 | ?> |
| 490 | 490 | var geocoder = new google.maps.Geocoder(); |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | */ |
| 758 | 758 | function geodir_update_options($options, $dummy = false) |
| 759 | 759 | {
|
| 760 | - // print_r($_POST); print_r($options); exit; |
|
| 760 | + // print_r($_POST); print_r($options); exit; |
|
| 761 | 761 | |
| 762 | 762 | if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
| 763 | 763 | |
@@ -2281,10 +2281,10 @@ discard block |
||
| 2281 | 2281 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2282 | 2282 | style=" <?php echo esc_attr($value['css']); ?>" |
| 2283 | 2283 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2284 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2285 | - } else {
|
|
| 2286 | - echo esc_attr($value['std']); |
|
| 2287 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2284 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2285 | + } else {
|
|
| 2286 | + echo esc_attr($value['std']); |
|
| 2287 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2288 | 2288 | </tr><?php |
| 2289 | 2289 | break; |
| 2290 | 2290 | |
@@ -2298,10 +2298,10 @@ discard block |
||
| 2298 | 2298 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 2299 | 2299 | style="<?php echo esc_attr($value['css']); ?>" |
| 2300 | 2300 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2301 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2302 | - } else {
|
|
| 2303 | - echo esc_attr($value['std']); |
|
| 2304 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2301 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2302 | + } else {
|
|
| 2303 | + echo esc_attr($value['std']); |
|
| 2304 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 2305 | 2305 | </tr><?php |
| 2306 | 2306 | break; |
| 2307 | 2307 | |
@@ -2321,10 +2321,10 @@ discard block |
||
| 2321 | 2321 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 2322 | 2322 | style="<?php echo esc_attr($value['css']); ?>" |
| 2323 | 2323 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 2324 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2325 | - } else {
|
|
| 2326 | - echo esc_attr($value['std']); |
|
| 2327 | - } ?>" class="colorpick"/> <span |
|
| 2324 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 2325 | + } else {
|
|
| 2326 | + echo esc_attr($value['std']); |
|
| 2327 | + } ?>" class="colorpick"/> <span |
|
| 2328 | 2328 | class="description"><?php echo $value['desc']; ?></span> |
| 2329 | 2329 | |
| 2330 | 2330 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
@@ -2713,22 +2713,22 @@ discard block |
||
| 2713 | 2713 | |
| 2714 | 2714 | case 'single_select_page' : |
| 2715 | 2715 | // WPML |
| 2716 | - $switch_lang = false; |
|
| 2717 | - $disabled = ''; |
|
| 2718 | - if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
|
| 2719 | - global $sitepress; |
|
| 2716 | + $switch_lang = false; |
|
| 2717 | + $disabled = ''; |
|
| 2718 | + if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
|
| 2719 | + global $sitepress; |
|
| 2720 | 2720 | |
| 2721 | - $default_lang = $sitepress->get_default_language(); |
|
| 2722 | - $current_lang = $sitepress->get_current_language(); |
|
| 2721 | + $default_lang = $sitepress->get_default_language(); |
|
| 2722 | + $current_lang = $sitepress->get_current_language(); |
|
| 2723 | 2723 | |
| 2724 | - if ($current_lang != 'all' && $current_lang != $default_lang) {
|
|
| 2725 | - $disabled = "disabled='disabled'"; |
|
| 2726 | - $switch_lang = $current_lang; |
|
| 2727 | - $sitepress->switch_lang('all', true);
|
|
| 2728 | - } |
|
| 2729 | - } |
|
| 2730 | - // |
|
| 2731 | - $page_setting = (int)get_option($value['id']); |
|
| 2724 | + if ($current_lang != 'all' && $current_lang != $default_lang) {
|
|
| 2725 | + $disabled = "disabled='disabled'"; |
|
| 2726 | + $switch_lang = $current_lang; |
|
| 2727 | + $sitepress->switch_lang('all', true);
|
|
| 2728 | + } |
|
| 2729 | + } |
|
| 2730 | + // |
|
| 2731 | + $page_setting = (int)get_option($value['id']); |
|
| 2732 | 2732 | |
| 2733 | 2733 | $args = array('name' => $value['id'],
|
| 2734 | 2734 | 'id' => $value['id'], |
@@ -2749,9 +2749,9 @@ discard block |
||
| 2749 | 2749 | <span class="description"><?php echo $value['desc'] ?></span> |
| 2750 | 2750 | </td> |
| 2751 | 2751 | </tr><?php |
| 2752 | - if ($switch_lang) {
|
|
| 2753 | - $sitepress->switch_lang($switch_lang, true); |
|
| 2754 | - } |
|
| 2752 | + if ($switch_lang) {
|
|
| 2753 | + $sitepress->switch_lang($switch_lang, true); |
|
| 2754 | + } |
|
| 2755 | 2755 | break; |
| 2756 | 2756 | case 'single_select_country' : |
| 2757 | 2757 | $countries = $geodirectory->countries->countries; |
@@ -3396,22 +3396,22 @@ discard block |
||
| 3396 | 3396 | * @return string Post type ex: gd_place |
| 3397 | 3397 | */ |
| 3398 | 3398 | function geodir_admin_current_post_type() {
|
| 3399 | - global $post, $typenow, $current_screen; |
|
| 3399 | + global $post, $typenow, $current_screen; |
|
| 3400 | 3400 | |
| 3401 | - $post_type = NULL; |
|
| 3401 | + $post_type = NULL; |
|
| 3402 | 3402 | |
| 3403 | - if ($post && isset($post->post_type)) |
|
| 3404 | - $post_type = $post->post_type; |
|
| 3405 | - elseif ($typenow) |
|
| 3406 | - $post_type = $typenow; |
|
| 3407 | - elseif ($current_screen && isset($current_screen->post_type)) |
|
| 3408 | - $post_type = $current_screen->post_type; |
|
| 3409 | - elseif (isset($_REQUEST['post_type'])) |
|
| 3410 | - $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3411 | - elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 3412 | - $post_type = get_post_type($_REQUEST['post']); |
|
| 3413 | - |
|
| 3414 | - return $post_type; |
|
| 3403 | + if ($post && isset($post->post_type)) |
|
| 3404 | + $post_type = $post->post_type; |
|
| 3405 | + elseif ($typenow) |
|
| 3406 | + $post_type = $typenow; |
|
| 3407 | + elseif ($current_screen && isset($current_screen->post_type)) |
|
| 3408 | + $post_type = $current_screen->post_type; |
|
| 3409 | + elseif (isset($_REQUEST['post_type'])) |
|
| 3410 | + $post_type = sanitize_key($_REQUEST['post_type']); |
|
| 3411 | + elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 3412 | + $post_type = get_post_type($_REQUEST['post']); |
|
| 3413 | + |
|
| 3414 | + return $post_type; |
|
| 3415 | 3415 | } |
| 3416 | 3416 | |
| 3417 | 3417 | /** |
@@ -3426,33 +3426,33 @@ discard block |
||
| 3426 | 3426 | * @param array $geodir_settings Array of geodirectory settings. |
| 3427 | 3427 | */ |
| 3428 | 3428 | function geodir_before_update_options($current_tab, $geodir_settings) {
|
| 3429 | - $active_tab = isset($_REQUEST['active_tab']) ? trim($_REQUEST['active_tab']) : ''; |
|
| 3429 | + $active_tab = isset($_REQUEST['active_tab']) ? trim($_REQUEST['active_tab']) : ''; |
|
| 3430 | 3430 | |
| 3431 | - // Permalink settings |
|
| 3432 | - if ($current_tab == 'permalink_settings') {
|
|
| 3433 | - $listing_prefix = isset($_POST['geodir_listing_prefix']) ? trim($_POST['geodir_listing_prefix']) : ''; |
|
| 3434 | - $location_prefix = isset($_POST['geodir_location_prefix']) ? trim($_POST['geodir_location_prefix']) : ''; |
|
| 3431 | + // Permalink settings |
|
| 3432 | + if ($current_tab == 'permalink_settings') {
|
|
| 3433 | + $listing_prefix = isset($_POST['geodir_listing_prefix']) ? trim($_POST['geodir_listing_prefix']) : ''; |
|
| 3434 | + $location_prefix = isset($_POST['geodir_location_prefix']) ? trim($_POST['geodir_location_prefix']) : ''; |
|
| 3435 | 3435 | |
| 3436 | - // Don't allow same slug url for listing and location |
|
| 3437 | - if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
|
| 3438 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
|
| 3439 | - wp_redirect($redirect_url); |
|
| 3440 | - exit; |
|
| 3441 | - } |
|
| 3436 | + // Don't allow same slug url for listing and location |
|
| 3437 | + if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
|
| 3438 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
|
| 3439 | + wp_redirect($redirect_url); |
|
| 3440 | + exit; |
|
| 3441 | + } |
|
| 3442 | 3442 | |
| 3443 | - // Don't allow to update page settings on different language. |
|
| 3444 | - if (geodir_is_wpml()) {
|
|
| 3445 | - global $sitepress; |
|
| 3446 | - $current_language = $sitepress->get_current_language(); |
|
| 3447 | - $default_language = $sitepress->get_default_language(); |
|
| 3443 | + // Don't allow to update page settings on different language. |
|
| 3444 | + if (geodir_is_wpml()) {
|
|
| 3445 | + global $sitepress; |
|
| 3446 | + $current_language = $sitepress->get_current_language(); |
|
| 3447 | + $default_language = $sitepress->get_default_language(); |
|
| 3448 | 3448 | |
| 3449 | - if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 3450 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
|
|
| 3451 | - wp_redirect($redirect_url); |
|
| 3452 | - exit; |
|
| 3453 | - } |
|
| 3454 | - } |
|
| 3455 | - } |
|
| 3449 | + if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 3450 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab);
|
|
| 3451 | + wp_redirect($redirect_url); |
|
| 3452 | + exit; |
|
| 3453 | + } |
|
| 3454 | + } |
|
| 3455 | + } |
|
| 3456 | 3456 | } |
| 3457 | 3457 | |
| 3458 | 3458 | |
@@ -3483,7 +3483,7 @@ discard block |
||
| 3483 | 3483 | * @return array Array of tab data. |
| 3484 | 3484 | */ |
| 3485 | 3485 | function geodir_import_export_tab( $tabs ) {
|
| 3486 | - $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
|
| 3486 | + $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
|
| 3487 | 3487 | return $tabs; |
| 3488 | 3488 | } |
| 3489 | 3489 | |
@@ -3497,8 +3497,8 @@ discard block |
||
| 3497 | 3497 | * @return string Html content. |
| 3498 | 3498 | */ |
| 3499 | 3499 | function geodir_import_export_page() {
|
| 3500 | - $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
|
| 3501 | - $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
|
| 3500 | + $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
|
| 3501 | + $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
|
| 3502 | 3502 | /** |
| 3503 | 3503 | * Filter sample category data csv file url. |
| 3504 | 3504 | * |
@@ -3507,9 +3507,9 @@ discard block |
||
| 3507 | 3507 | * |
| 3508 | 3508 | * @param string $gd_cats_sample_csv Sample category data csv file url. |
| 3509 | 3509 | */ |
| 3510 | - $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
|
| 3510 | + $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
|
| 3511 | 3511 | |
| 3512 | - $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
|
| 3512 | + $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
|
| 3513 | 3513 | /** |
| 3514 | 3514 | * Filter sample post data csv file url. |
| 3515 | 3515 | * |
@@ -3520,42 +3520,42 @@ discard block |
||
| 3520 | 3520 | */ |
| 3521 | 3521 | $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
| 3522 | 3522 | |
| 3523 | - $gd_posttypes = geodir_get_posttypes( 'array' ); |
|
| 3523 | + $gd_posttypes = geodir_get_posttypes( 'array' ); |
|
| 3524 | 3524 | |
| 3525 | - $gd_posttypes_option = ''; |
|
| 3526 | - foreach ( $gd_posttypes as $gd_posttype => $row ) {
|
|
| 3527 | - $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>'; |
|
| 3528 | - } |
|
| 3529 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 3525 | + $gd_posttypes_option = ''; |
|
| 3526 | + foreach ( $gd_posttypes as $gd_posttype => $row ) {
|
|
| 3527 | + $gd_posttypes_option .= '<option value="' . $gd_posttype . '" data-cats="' . (int)geodir_get_terms_count( $gd_posttype ) . '" data-posts="' . (int)geodir_get_posts_count( $gd_posttype ) . '">' . __( $row['labels']['name'], 'geodirectory' ) . '</option>'; |
|
| 3528 | + } |
|
| 3529 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 3530 | 3530 | |
| 3531 | - $gd_chunksize_options = array(); |
|
| 3532 | - $gd_chunksize_options[100] = 100; |
|
| 3533 | - $gd_chunksize_options[200] = 200; |
|
| 3534 | - $gd_chunksize_options[500] = 500; |
|
| 3535 | - $gd_chunksize_options[1000] = 1000; |
|
| 3536 | - $gd_chunksize_options[2000] = 2000; |
|
| 3537 | - $gd_chunksize_options[5000] = 5000; |
|
| 3538 | - $gd_chunksize_options[10000] = 10000; |
|
| 3539 | - $gd_chunksize_options[20000] = 20000; |
|
| 3540 | - $gd_chunksize_options[50000] = 50000; |
|
| 3541 | - $gd_chunksize_options[100000] = 100000; |
|
| 3531 | + $gd_chunksize_options = array(); |
|
| 3532 | + $gd_chunksize_options[100] = 100; |
|
| 3533 | + $gd_chunksize_options[200] = 200; |
|
| 3534 | + $gd_chunksize_options[500] = 500; |
|
| 3535 | + $gd_chunksize_options[1000] = 1000; |
|
| 3536 | + $gd_chunksize_options[2000] = 2000; |
|
| 3537 | + $gd_chunksize_options[5000] = 5000; |
|
| 3538 | + $gd_chunksize_options[10000] = 10000; |
|
| 3539 | + $gd_chunksize_options[20000] = 20000; |
|
| 3540 | + $gd_chunksize_options[50000] = 50000; |
|
| 3541 | + $gd_chunksize_options[100000] = 100000; |
|
| 3542 | 3542 | |
| 3543 | - /** |
|
| 3544 | - * Filter max entries per export csv file. |
|
| 3545 | - * |
|
| 3546 | - * @since 1.5.6 |
|
| 3547 | - * @package GeoDirectory |
|
| 3548 | - * |
|
| 3549 | - * @param string $gd_chunksize_options Entries options. |
|
| 3550 | - */ |
|
| 3543 | + /** |
|
| 3544 | + * Filter max entries per export csv file. |
|
| 3545 | + * |
|
| 3546 | + * @since 1.5.6 |
|
| 3547 | + * @package GeoDirectory |
|
| 3548 | + * |
|
| 3549 | + * @param string $gd_chunksize_options Entries options. |
|
| 3550 | + */ |
|
| 3551 | 3551 | $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
| 3552 | 3552 | |
| 3553 | - $gd_chunksize_option = ''; |
|
| 3554 | - foreach ($gd_chunksize_options as $value => $title) {
|
|
| 3555 | - $gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>'; |
|
| 3556 | - } |
|
| 3553 | + $gd_chunksize_option = ''; |
|
| 3554 | + foreach ($gd_chunksize_options as $value => $title) {
|
|
| 3555 | + $gd_chunksize_option .= '<option value="' . $value . '" ' . selected($value, 5000, false) . '>' . $title . '</option>'; |
|
| 3556 | + } |
|
| 3557 | 3557 | |
| 3558 | - $uploads = wp_upload_dir(); |
|
| 3558 | + $uploads = wp_upload_dir(); |
|
| 3559 | 3559 | ?> |
| 3560 | 3560 | </form> |
| 3561 | 3561 | <div class="inner_content_tab_main gd-import-export"> |
@@ -3617,13 +3617,13 @@ discard block |
||
| 3617 | 3617 | <input id="gd_im_postplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-pupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imposts_sample" id="gd_ie_imposts_sample"> |
| 3618 | 3618 | <input type="hidden" id="gd_ie_imposts_csv" value="<?php echo $gd_posts_sample_csv;?>" /> |
| 3619 | 3619 | <?php |
| 3620 | - /** |
|
| 3621 | - * Called just after the sample CSV download link. |
|
| 3622 | - * |
|
| 3623 | - * @since 1.0.0 |
|
| 3624 | - */ |
|
| 3625 | - do_action('geodir_sample_csv_download_link');
|
|
| 3626 | - ?> |
|
| 3620 | + /** |
|
| 3621 | + * Called just after the sample CSV download link. |
|
| 3622 | + * |
|
| 3623 | + * @since 1.0.0 |
|
| 3624 | + */ |
|
| 3625 | + do_action('geodir_sample_csv_download_link');
|
|
| 3626 | + ?> |
|
| 3627 | 3627 | <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_postpluploadan' ); ?>"></span> |
| 3628 | 3628 | <div class="filelist"></div> |
| 3629 | 3629 | </div> |
@@ -3731,14 +3731,14 @@ discard block |
||
| 3731 | 3731 | <input id="gd_im_catplupload-browse-button" type="button" value="<?php echo SELECT_UPLOAD_CSV; ?>" class="gd-imex-cupload button-primary" /><input type="button" value="<?php echo esc_attr( __( 'Download Sample CSV', 'geodirectory' ) );?>" class="button-secondary" name="gd_ie_imcats_sample" id="gd_ie_imcats_sample"> |
| 3732 | 3732 | <input type="hidden" id="gd_ie_imcats_csv" value="<?php echo $gd_cats_sample_csv;?>" /> |
| 3733 | 3733 | <?php |
| 3734 | - /** |
|
| 3735 | - * Called just after the sample CSV download link. |
|
| 3736 | - * |
|
| 3737 | - * @since 1.0.0 |
|
| 3734 | + /** |
|
| 3735 | + * Called just after the sample CSV download link. |
|
| 3736 | + * |
|
| 3737 | + * @since 1.0.0 |
|
| 3738 | 3738 | * @package GeoDirectory |
| 3739 | - */ |
|
| 3740 | - do_action('geodir_sample_cats_csv_download_link');
|
|
| 3741 | - ?> |
|
| 3739 | + */ |
|
| 3740 | + do_action('geodir_sample_cats_csv_download_link');
|
|
| 3741 | + ?> |
|
| 3742 | 3742 | <span class="ajaxnonceplu" id="ajaxnonceplu<?php echo wp_create_nonce( 'gd_im_catpluploadan' ); ?>"></span> |
| 3743 | 3743 | <div class="filelist"></div> |
| 3744 | 3744 | </div> |
@@ -3814,19 +3814,19 @@ discard block |
||
| 3814 | 3814 | </div> |
| 3815 | 3815 | </div> |
| 3816 | 3816 | <?php |
| 3817 | - /** |
|
| 3818 | - * Allows you to add more setting to the GD > Import & Export page. |
|
| 3819 | - * |
|
| 3820 | - * Called after the last setting on the GD > Import & Export page. |
|
| 3821 | - * @since 1.4.6 |
|
| 3817 | + /** |
|
| 3818 | + * Allows you to add more setting to the GD > Import & Export page. |
|
| 3819 | + * |
|
| 3820 | + * Called after the last setting on the GD > Import & Export page. |
|
| 3821 | + * @since 1.4.6 |
|
| 3822 | 3822 | * @package GeoDirectory |
| 3823 | - * |
|
| 3824 | - * @param array $gd_posttypes GD post types. |
|
| 3823 | + * |
|
| 3824 | + * @param array $gd_posttypes GD post types. |
|
| 3825 | 3825 | * @param array $gd_chunksize_options File chunk size options. |
| 3826 | 3826 | * @param string $nonce Wordpress security token for GD import & export. |
| 3827 | - */ |
|
| 3828 | - do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
|
| 3829 | - ?> |
|
| 3827 | + */ |
|
| 3828 | + do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
|
| 3829 | + ?> |
|
| 3830 | 3830 | </div> |
| 3831 | 3831 | </div> |
| 3832 | 3832 | <script type="text/javascript"> |
@@ -4547,7 +4547,7 @@ discard block |
||
| 4547 | 4547 | * @return string Json data. |
| 4548 | 4548 | */ |
| 4549 | 4549 | function geodir_ajax_import_export() {
|
| 4550 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 4550 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 4551 | 4551 | |
| 4552 | 4552 | // try to set higher limits for import |
| 4553 | 4553 | $max_input_time = ini_get('max_input_time');
|
@@ -4568,26 +4568,26 @@ discard block |
||
| 4568 | 4568 | } |
| 4569 | 4569 | } |
| 4570 | 4570 | |
| 4571 | - error_reporting(0); |
|
| 4571 | + error_reporting(0); |
|
| 4572 | 4572 | |
| 4573 | - $json = array(); |
|
| 4573 | + $json = array(); |
|
| 4574 | 4574 | |
| 4575 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 4576 | - wp_send_json( $json ); |
|
| 4577 | - } |
|
| 4575 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 4576 | + wp_send_json( $json ); |
|
| 4577 | + } |
|
| 4578 | 4578 | |
| 4579 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 4580 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 4581 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 4579 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 4580 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 4581 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 4582 | 4582 | |
| 4583 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 4584 | - wp_send_json( $json ); |
|
| 4585 | - } |
|
| 4583 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 4584 | + wp_send_json( $json ); |
|
| 4585 | + } |
|
| 4586 | 4586 | |
| 4587 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 4588 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 4589 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 4590 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 4587 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 4588 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 4589 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 4590 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 4591 | 4591 | |
| 4592 | 4592 | $wp_filesystem = geodir_init_filesystem(); |
| 4593 | 4593 | if (!$wp_filesystem) {
|
@@ -4595,551 +4595,551 @@ discard block |
||
| 4595 | 4595 | wp_send_json( $json ); |
| 4596 | 4596 | } |
| 4597 | 4597 | |
| 4598 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 4599 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 4598 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 4599 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 4600 | 4600 | wp_send_json( $json ); |
| 4601 | - } |
|
| 4601 | + } |
|
| 4602 | 4602 | |
| 4603 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 4604 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 4605 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 4606 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4607 | - wp_send_json( $json ); |
|
| 4608 | - } |
|
| 4609 | - } |
|
| 4603 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 4604 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 4605 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 4606 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4607 | + wp_send_json( $json ); |
|
| 4608 | + } |
|
| 4609 | + } |
|
| 4610 | 4610 | |
| 4611 | - switch ( $task ) {
|
|
| 4612 | - case 'export_posts': {
|
|
| 4613 | - // WPML |
|
| 4614 | - $is_wpml = geodir_is_wpml(); |
|
| 4615 | - if ($is_wpml) {
|
|
| 4616 | - global $sitepress; |
|
| 4617 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4611 | + switch ( $task ) {
|
|
| 4612 | + case 'export_posts': {
|
|
| 4613 | + // WPML |
|
| 4614 | + $is_wpml = geodir_is_wpml(); |
|
| 4615 | + if ($is_wpml) {
|
|
| 4616 | + global $sitepress; |
|
| 4617 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4618 | 4618 | |
| 4619 | - $sitepress->switch_lang('all', true);
|
|
| 4620 | - } |
|
| 4621 | - // WPML |
|
| 4622 | - if ( $post_type == 'gd_event' ) {
|
|
| 4623 | - //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 ); |
|
| 4624 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 4625 | - } |
|
| 4626 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 4627 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 4628 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4629 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4630 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4631 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 4619 | + $sitepress->switch_lang('all', true);
|
|
| 4620 | + } |
|
| 4621 | + // WPML |
|
| 4622 | + if ( $post_type == 'gd_event' ) {
|
|
| 4623 | + //add_filter( 'geodir_imex_count_posts', 'geodir_imex_count_events', 10, 2 ); |
|
| 4624 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 4625 | + } |
|
| 4626 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 4627 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 4628 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4629 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4630 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4631 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 4632 | 4632 | |
| 4633 | - $chunk_file_paths = array(); |
|
| 4633 | + $chunk_file_paths = array(); |
|
| 4634 | 4634 | |
| 4635 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4636 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4637 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 4638 | - $percentage = min( $percentage, 100 ); |
|
| 4635 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4636 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4637 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 4638 | + $percentage = min( $percentage, 100 ); |
|
| 4639 | 4639 | |
| 4640 | - $json['percentage'] = $percentage; |
|
| 4641 | - // WPML |
|
| 4642 | - if ($is_wpml) {
|
|
| 4643 | - $sitepress->switch_lang($active_lang, true); |
|
| 4644 | - } |
|
| 4645 | - // WPML |
|
| 4646 | - wp_send_json( $json ); |
|
| 4647 | - exit; |
|
| 4648 | - } else {
|
|
| 4649 | - if ( !$posts_count > 0 ) {
|
|
| 4650 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4651 | - } else {
|
|
| 4652 | - $total_posts = $posts_count; |
|
| 4653 | - if ($chunk_per_page > $total_posts) {
|
|
| 4654 | - $chunk_per_page = $total_posts; |
|
| 4655 | - } |
|
| 4656 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 4640 | + $json['percentage'] = $percentage; |
|
| 4641 | + // WPML |
|
| 4642 | + if ($is_wpml) {
|
|
| 4643 | + $sitepress->switch_lang($active_lang, true); |
|
| 4644 | + } |
|
| 4645 | + // WPML |
|
| 4646 | + wp_send_json( $json ); |
|
| 4647 | + exit; |
|
| 4648 | + } else {
|
|
| 4649 | + if ( !$posts_count > 0 ) {
|
|
| 4650 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4651 | + } else {
|
|
| 4652 | + $total_posts = $posts_count; |
|
| 4653 | + if ($chunk_per_page > $total_posts) {
|
|
| 4654 | + $chunk_per_page = $total_posts; |
|
| 4655 | + } |
|
| 4656 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 4657 | 4657 | |
| 4658 | - $j = $chunk_page_no; |
|
| 4659 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 4658 | + $j = $chunk_page_no; |
|
| 4659 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 4660 | 4660 | |
| 4661 | - $per_page = 500; |
|
| 4662 | - if ($per_page > $chunk_per_page) {
|
|
| 4663 | - $per_page = $chunk_per_page; |
|
| 4664 | - } |
|
| 4665 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4661 | + $per_page = 500; |
|
| 4662 | + if ($per_page > $chunk_per_page) {
|
|
| 4663 | + $per_page = $chunk_per_page; |
|
| 4664 | + } |
|
| 4665 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4666 | 4666 | |
| 4667 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4668 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 4667 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4668 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 4669 | 4669 | |
| 4670 | - $clear = $i == 0 ? true : false; |
|
| 4671 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 4672 | - } |
|
| 4670 | + $clear = $i == 0 ? true : false; |
|
| 4671 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 4672 | + } |
|
| 4673 | 4673 | |
| 4674 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4675 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4676 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4677 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4678 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4674 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4675 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4676 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4677 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4678 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4679 | 4679 | |
| 4680 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4681 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4682 | - } |
|
| 4680 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4681 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4682 | + } |
|
| 4683 | 4683 | |
| 4684 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4685 | - $json['total'] = $posts_count; |
|
| 4686 | - $json['files'] = $chunk_file_paths; |
|
| 4687 | - } else {
|
|
| 4688 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4689 | - } |
|
| 4690 | - } |
|
| 4691 | - // WPML |
|
| 4692 | - if ($is_wpml) {
|
|
| 4693 | - $sitepress->switch_lang($active_lang, true); |
|
| 4694 | - } |
|
| 4695 | - // WPML |
|
| 4696 | - wp_send_json( $json ); |
|
| 4697 | - } |
|
| 4698 | - } |
|
| 4699 | - break; |
|
| 4700 | - case 'export_cats': {
|
|
| 4701 | - // WPML |
|
| 4702 | - $is_wpml = geodir_is_wpml(); |
|
| 4703 | - if ($is_wpml) {
|
|
| 4704 | - global $sitepress; |
|
| 4705 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4684 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4685 | + $json['total'] = $posts_count; |
|
| 4686 | + $json['files'] = $chunk_file_paths; |
|
| 4687 | + } else {
|
|
| 4688 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4689 | + } |
|
| 4690 | + } |
|
| 4691 | + // WPML |
|
| 4692 | + if ($is_wpml) {
|
|
| 4693 | + $sitepress->switch_lang($active_lang, true); |
|
| 4694 | + } |
|
| 4695 | + // WPML |
|
| 4696 | + wp_send_json( $json ); |
|
| 4697 | + } |
|
| 4698 | + } |
|
| 4699 | + break; |
|
| 4700 | + case 'export_cats': {
|
|
| 4701 | + // WPML |
|
| 4702 | + $is_wpml = geodir_is_wpml(); |
|
| 4703 | + if ($is_wpml) {
|
|
| 4704 | + global $sitepress; |
|
| 4705 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4706 | 4706 | |
| 4707 | - $sitepress->switch_lang('all', true);
|
|
| 4708 | - } |
|
| 4709 | - // WPML |
|
| 4710 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 4707 | + $sitepress->switch_lang('all', true);
|
|
| 4708 | + } |
|
| 4709 | + // WPML |
|
| 4710 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 4711 | 4711 | |
| 4712 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 4713 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4714 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4715 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4716 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 4712 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 4713 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4714 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4715 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4716 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 4717 | 4717 | |
| 4718 | - $chunk_file_paths = array(); |
|
| 4718 | + $chunk_file_paths = array(); |
|
| 4719 | 4719 | |
| 4720 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4721 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4722 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 4723 | - $percentage = min( $percentage, 100 ); |
|
| 4720 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4721 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4722 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 4723 | + $percentage = min( $percentage, 100 ); |
|
| 4724 | 4724 | |
| 4725 | - $json['percentage'] = $percentage; |
|
| 4726 | - // WPML |
|
| 4727 | - if ($is_wpml) {
|
|
| 4728 | - $sitepress->switch_lang($active_lang, true); |
|
| 4729 | - } |
|
| 4730 | - // WPML |
|
| 4731 | - wp_send_json( $json ); |
|
| 4732 | - } else {
|
|
| 4733 | - if ( !$terms_count > 0 ) {
|
|
| 4734 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4735 | - } else {
|
|
| 4736 | - $total_terms = $terms_count; |
|
| 4737 | - if ($chunk_per_page > $terms_count) {
|
|
| 4738 | - $chunk_per_page = $terms_count; |
|
| 4739 | - } |
|
| 4740 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 4725 | + $json['percentage'] = $percentage; |
|
| 4726 | + // WPML |
|
| 4727 | + if ($is_wpml) {
|
|
| 4728 | + $sitepress->switch_lang($active_lang, true); |
|
| 4729 | + } |
|
| 4730 | + // WPML |
|
| 4731 | + wp_send_json( $json ); |
|
| 4732 | + } else {
|
|
| 4733 | + if ( !$terms_count > 0 ) {
|
|
| 4734 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4735 | + } else {
|
|
| 4736 | + $total_terms = $terms_count; |
|
| 4737 | + if ($chunk_per_page > $terms_count) {
|
|
| 4738 | + $chunk_per_page = $terms_count; |
|
| 4739 | + } |
|
| 4740 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 4741 | 4741 | |
| 4742 | - $j = $chunk_page_no; |
|
| 4743 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 4742 | + $j = $chunk_page_no; |
|
| 4743 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 4744 | 4744 | |
| 4745 | - $per_page = 500; |
|
| 4746 | - if ($per_page > $chunk_per_page) {
|
|
| 4747 | - $per_page = $chunk_per_page; |
|
| 4748 | - } |
|
| 4749 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4745 | + $per_page = 500; |
|
| 4746 | + if ($per_page > $chunk_per_page) {
|
|
| 4747 | + $per_page = $chunk_per_page; |
|
| 4748 | + } |
|
| 4749 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4750 | 4750 | |
| 4751 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4752 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 4751 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4752 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 4753 | 4753 | |
| 4754 | - $clear = $i == 0 ? true : false; |
|
| 4755 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 4756 | - } |
|
| 4754 | + $clear = $i == 0 ? true : false; |
|
| 4755 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 4756 | + } |
|
| 4757 | 4757 | |
| 4758 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4759 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4760 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4761 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4762 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4758 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4759 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4760 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4761 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4762 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4763 | 4763 | |
| 4764 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4765 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4766 | - } |
|
| 4764 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4765 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4766 | + } |
|
| 4767 | 4767 | |
| 4768 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4769 | - $json['total'] = $terms_count; |
|
| 4770 | - $json['files'] = $chunk_file_paths; |
|
| 4771 | - } else {
|
|
| 4772 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4773 | - } |
|
| 4774 | - } |
|
| 4775 | - // WPML |
|
| 4776 | - if ($is_wpml) {
|
|
| 4777 | - $sitepress->switch_lang($active_lang, true); |
|
| 4778 | - } |
|
| 4779 | - // WPML |
|
| 4780 | - wp_send_json( $json ); |
|
| 4781 | - } |
|
| 4782 | - } |
|
| 4783 | - break; |
|
| 4784 | - case 'export_locations': {
|
|
| 4785 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 4786 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 4787 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4788 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4789 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 4768 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4769 | + $json['total'] = $terms_count; |
|
| 4770 | + $json['files'] = $chunk_file_paths; |
|
| 4771 | + } else {
|
|
| 4772 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 4773 | + } |
|
| 4774 | + } |
|
| 4775 | + // WPML |
|
| 4776 | + if ($is_wpml) {
|
|
| 4777 | + $sitepress->switch_lang($active_lang, true); |
|
| 4778 | + } |
|
| 4779 | + // WPML |
|
| 4780 | + wp_send_json( $json ); |
|
| 4781 | + } |
|
| 4782 | + } |
|
| 4783 | + break; |
|
| 4784 | + case 'export_locations': {
|
|
| 4785 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 4786 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 4787 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 4788 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 4789 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 4790 | 4790 | |
| 4791 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 4791 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 4792 | 4792 | |
| 4793 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4794 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4795 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 4796 | - $percentage = min( $percentage, 100 ); |
|
| 4793 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 4794 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 4795 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 4796 | + $percentage = min( $percentage, 100 ); |
|
| 4797 | 4797 | |
| 4798 | - $json['percentage'] = $percentage; |
|
| 4799 | - wp_send_json( $json ); |
|
| 4800 | - } else {
|
|
| 4801 | - $chunk_file_paths = array(); |
|
| 4798 | + $json['percentage'] = $percentage; |
|
| 4799 | + wp_send_json( $json ); |
|
| 4800 | + } else {
|
|
| 4801 | + $chunk_file_paths = array(); |
|
| 4802 | 4802 | |
| 4803 | - if ( !$items_count > 0 ) {
|
|
| 4804 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4805 | - } else {
|
|
| 4806 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 4807 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 4803 | + if ( !$items_count > 0 ) {
|
|
| 4804 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 4805 | + } else {
|
|
| 4806 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 4807 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 4808 | 4808 | |
| 4809 | - $j = $chunk_page_no; |
|
| 4810 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 4809 | + $j = $chunk_page_no; |
|
| 4810 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 4811 | 4811 | |
| 4812 | - $per_page = 500; |
|
| 4813 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 4814 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4812 | + $per_page = 500; |
|
| 4813 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 4814 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 4815 | 4815 | |
| 4816 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4817 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 4816 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 4817 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 4818 | 4818 | |
| 4819 | - $clear = $i == 0 ? true : false; |
|
| 4820 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 4821 | - } |
|
| 4819 | + $clear = $i == 0 ? true : false; |
|
| 4820 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 4821 | + } |
|
| 4822 | 4822 | |
| 4823 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4824 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4825 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4826 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4827 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4823 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 4824 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 4825 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 4826 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 4827 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 4828 | 4828 | |
| 4829 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 4830 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4831 | - } |
|
| 4829 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 4830 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 4831 | + } |
|
| 4832 | 4832 | |
| 4833 | - if ( !empty($chunk_file_paths) ) {
|
|
| 4834 | - $json['total'] = $items_count; |
|
| 4835 | - $json['files'] = $chunk_file_paths; |
|
| 4836 | - } else {
|
|
| 4837 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 4838 | - } |
|
| 4839 | - } |
|
| 4840 | - wp_send_json( $json ); |
|
| 4841 | - } |
|
| 4842 | - } |
|
| 4843 | - break; |
|
| 4844 | - case 'prepare_import': |
|
| 4845 | - case 'import_cat': |
|
| 4846 | - case 'import_post': |
|
| 4847 | - case 'import_loc': {
|
|
| 4848 | - // WPML |
|
| 4849 | - $is_wpml = geodir_is_wpml(); |
|
| 4850 | - if ($is_wpml) {
|
|
| 4851 | - global $sitepress; |
|
| 4852 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 4853 | - } |
|
| 4854 | - // WPML |
|
| 4833 | + if ( !empty($chunk_file_paths) ) {
|
|
| 4834 | + $json['total'] = $items_count; |
|
| 4835 | + $json['files'] = $chunk_file_paths; |
|
| 4836 | + } else {
|
|
| 4837 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 4838 | + } |
|
| 4839 | + } |
|
| 4840 | + wp_send_json( $json ); |
|
| 4841 | + } |
|
| 4842 | + } |
|
| 4843 | + break; |
|
| 4844 | + case 'prepare_import': |
|
| 4845 | + case 'import_cat': |
|
| 4846 | + case 'import_post': |
|
| 4847 | + case 'import_loc': {
|
|
| 4848 | + // WPML |
|
| 4849 | + $is_wpml = geodir_is_wpml(); |
|
| 4850 | + if ($is_wpml) {
|
|
| 4851 | + global $sitepress; |
|
| 4852 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 4853 | + } |
|
| 4854 | + // WPML |
|
| 4855 | 4855 | |
| 4856 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 4856 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 4857 | 4857 | |
| 4858 | - $uploads = wp_upload_dir(); |
|
| 4859 | - $uploads_dir = $uploads['path']; |
|
| 4860 | - $uploads_subdir = $uploads['subdir']; |
|
| 4858 | + $uploads = wp_upload_dir(); |
|
| 4859 | + $uploads_dir = $uploads['path']; |
|
| 4860 | + $uploads_subdir = $uploads['subdir']; |
|
| 4861 | 4861 | |
| 4862 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 4863 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4862 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 4863 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 4864 | 4864 | |
| 4865 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 4866 | - $csv_filename = end( $csv_file_arr ); |
|
| 4867 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 4865 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 4866 | + $csv_filename = end( $csv_file_arr ); |
|
| 4867 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 4868 | 4868 | |
| 4869 | - $json['file'] = $csv_file; |
|
| 4870 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4869 | + $json['file'] = $csv_file; |
|
| 4870 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 4871 | 4871 | |
| 4872 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4873 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4872 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 4873 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 4874 | 4874 | |
| 4875 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4876 | - $json['error'] = NULL; |
|
| 4877 | - $json['rows'] = 0; |
|
| 4875 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 4876 | + $json['error'] = NULL; |
|
| 4877 | + $json['rows'] = 0; |
|
| 4878 | 4878 | |
| 4879 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4880 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4881 | - if ( !empty( $data ) ) {
|
|
| 4882 | - $file[] = $data; |
|
| 4883 | - } |
|
| 4884 | - } |
|
| 4885 | - fclose($handle); |
|
| 4886 | - } |
|
| 4879 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 4880 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 4881 | + if ( !empty( $data ) ) {
|
|
| 4882 | + $file[] = $data; |
|
| 4883 | + } |
|
| 4884 | + } |
|
| 4885 | + fclose($handle); |
|
| 4886 | + } |
|
| 4887 | 4887 | |
| 4888 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4888 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 4889 | 4889 | |
| 4890 | - if (!$json['rows'] > 0) {
|
|
| 4891 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4892 | - } |
|
| 4893 | - } else {
|
|
| 4894 | - wp_send_json( $json ); |
|
| 4895 | - } |
|
| 4896 | - } else {
|
|
| 4897 | - wp_send_json( $json ); |
|
| 4898 | - } |
|
| 4890 | + if (!$json['rows'] > 0) {
|
|
| 4891 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 4892 | + } |
|
| 4893 | + } else {
|
|
| 4894 | + wp_send_json( $json ); |
|
| 4895 | + } |
|
| 4896 | + } else {
|
|
| 4897 | + wp_send_json( $json ); |
|
| 4898 | + } |
|
| 4899 | 4899 | |
| 4900 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4901 | - wp_send_json( $json ); |
|
| 4902 | - } |
|
| 4900 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 4901 | + wp_send_json( $json ); |
|
| 4902 | + } |
|
| 4903 | 4903 | |
| 4904 | - $total = $json['rows']; |
|
| 4905 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4906 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4904 | + $total = $json['rows']; |
|
| 4905 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 4906 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 4907 | 4907 | |
| 4908 | - $count = $limit; |
|
| 4909 | - $requested_limit = $limit; |
|
| 4908 | + $count = $limit; |
|
| 4909 | + $requested_limit = $limit; |
|
| 4910 | 4910 | |
| 4911 | - if ($count < $total) {
|
|
| 4912 | - $count = $processed + $count; |
|
| 4913 | - if ($count > $total) {
|
|
| 4914 | - $count = $total; |
|
| 4915 | - } |
|
| 4916 | - } else {
|
|
| 4917 | - $count = $total; |
|
| 4918 | - } |
|
| 4911 | + if ($count < $total) {
|
|
| 4912 | + $count = $processed + $count; |
|
| 4913 | + if ($count > $total) {
|
|
| 4914 | + $count = $total; |
|
| 4915 | + } |
|
| 4916 | + } else {
|
|
| 4917 | + $count = $total; |
|
| 4918 | + } |
|
| 4919 | 4919 | |
| 4920 | - $created = 0; |
|
| 4921 | - $updated = 0; |
|
| 4922 | - $skipped = 0; |
|
| 4923 | - $invalid = 0; |
|
| 4924 | - $invalid_addr = 0; |
|
| 4925 | - $images = 0; |
|
| 4920 | + $created = 0; |
|
| 4921 | + $updated = 0; |
|
| 4922 | + $skipped = 0; |
|
| 4923 | + $invalid = 0; |
|
| 4924 | + $invalid_addr = 0; |
|
| 4925 | + $images = 0; |
|
| 4926 | 4926 | |
| 4927 | - $invalid_title = 0; |
|
| 4928 | - $customKeyarray = array(); |
|
| 4929 | - $gd_post_info = array(); |
|
| 4930 | - $post_location = array(); |
|
| 4931 | - $countpost = 0; |
|
| 4927 | + $invalid_title = 0; |
|
| 4928 | + $customKeyarray = array(); |
|
| 4929 | + $gd_post_info = array(); |
|
| 4930 | + $post_location = array(); |
|
| 4931 | + $countpost = 0; |
|
| 4932 | 4932 | |
| 4933 | - $post_types = geodir_get_posttypes(); |
|
| 4933 | + $post_types = geodir_get_posttypes(); |
|
| 4934 | 4934 | |
| 4935 | - if ( $task == 'import_cat' ) {
|
|
| 4936 | - if (!empty($file)) {
|
|
| 4937 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4935 | + if ( $task == 'import_cat' ) {
|
|
| 4936 | + if (!empty($file)) {
|
|
| 4937 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4938 | 4938 | |
| 4939 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4940 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4941 | - wp_send_json( $json ); |
|
| 4942 | - exit; |
|
| 4943 | - } |
|
| 4939 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4940 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4941 | + wp_send_json( $json ); |
|
| 4942 | + exit; |
|
| 4943 | + } |
|
| 4944 | 4944 | |
| 4945 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4946 | - $index = $processed + $i; |
|
| 4945 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4946 | + $index = $processed + $i; |
|
| 4947 | 4947 | |
| 4948 | - if (isset($file[$index])) {
|
|
| 4949 | - $row = $file[$index]; |
|
| 4950 | - $row = array_map( 'trim', $row ); |
|
| 4951 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4948 | + if (isset($file[$index])) {
|
|
| 4949 | + $row = $file[$index]; |
|
| 4950 | + $row = array_map( 'trim', $row ); |
|
| 4951 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4952 | 4952 | |
| 4953 | - $cat_id = ''; |
|
| 4954 | - $cat_name = ''; |
|
| 4955 | - $cat_slug = ''; |
|
| 4956 | - $cat_posttype = ''; |
|
| 4957 | - $cat_parent = ''; |
|
| 4958 | - $cat_description = ''; |
|
| 4959 | - $cat_schema = ''; |
|
| 4960 | - $cat_top_description = ''; |
|
| 4961 | - $cat_image = ''; |
|
| 4962 | - $cat_icon = ''; |
|
| 4963 | - $cat_language = ''; |
|
| 4953 | + $cat_id = ''; |
|
| 4954 | + $cat_name = ''; |
|
| 4955 | + $cat_slug = ''; |
|
| 4956 | + $cat_posttype = ''; |
|
| 4957 | + $cat_parent = ''; |
|
| 4958 | + $cat_description = ''; |
|
| 4959 | + $cat_schema = ''; |
|
| 4960 | + $cat_top_description = ''; |
|
| 4961 | + $cat_image = ''; |
|
| 4962 | + $cat_icon = ''; |
|
| 4963 | + $cat_language = ''; |
|
| 4964 | 4964 | |
| 4965 | - $c = 0; |
|
| 4966 | - foreach ($columns as $column ) {
|
|
| 4967 | - if ( $column == 'cat_id' ) {
|
|
| 4968 | - $cat_id = (int)$row[$c]; |
|
| 4969 | - } else if ( $column == 'cat_name' ) {
|
|
| 4970 | - $cat_name = $row[$c]; |
|
| 4971 | - } else if ( $column == 'cat_slug' ) {
|
|
| 4972 | - $cat_slug = $row[$c]; |
|
| 4973 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 4974 | - $cat_posttype = $row[$c]; |
|
| 4975 | - } else if ( $column == 'cat_parent' ) {
|
|
| 4976 | - $cat_parent = trim($row[$c]); |
|
| 4977 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4978 | - $cat_schema = $row[$c]; |
|
| 4979 | - } else if ( $column == 'cat_description' ) {
|
|
| 4980 | - $cat_description = $row[$c]; |
|
| 4981 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 4982 | - $cat_top_description = $row[$c]; |
|
| 4983 | - } else if ( $column == 'cat_image' ) {
|
|
| 4984 | - $cat_image = $row[$c]; |
|
| 4985 | - } else if ( $column == 'cat_icon' ) {
|
|
| 4986 | - $cat_icon = $row[$c]; |
|
| 4987 | - } |
|
| 4988 | - // WPML |
|
| 4989 | - if ($is_wpml && $column == 'cat_language') {
|
|
| 4990 | - $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4991 | - } |
|
| 4992 | - // WPML |
|
| 4993 | - $c++; |
|
| 4994 | - } |
|
| 4965 | + $c = 0; |
|
| 4966 | + foreach ($columns as $column ) {
|
|
| 4967 | + if ( $column == 'cat_id' ) {
|
|
| 4968 | + $cat_id = (int)$row[$c]; |
|
| 4969 | + } else if ( $column == 'cat_name' ) {
|
|
| 4970 | + $cat_name = $row[$c]; |
|
| 4971 | + } else if ( $column == 'cat_slug' ) {
|
|
| 4972 | + $cat_slug = $row[$c]; |
|
| 4973 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 4974 | + $cat_posttype = $row[$c]; |
|
| 4975 | + } else if ( $column == 'cat_parent' ) {
|
|
| 4976 | + $cat_parent = trim($row[$c]); |
|
| 4977 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 4978 | + $cat_schema = $row[$c]; |
|
| 4979 | + } else if ( $column == 'cat_description' ) {
|
|
| 4980 | + $cat_description = $row[$c]; |
|
| 4981 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 4982 | + $cat_top_description = $row[$c]; |
|
| 4983 | + } else if ( $column == 'cat_image' ) {
|
|
| 4984 | + $cat_image = $row[$c]; |
|
| 4985 | + } else if ( $column == 'cat_icon' ) {
|
|
| 4986 | + $cat_icon = $row[$c]; |
|
| 4987 | + } |
|
| 4988 | + // WPML |
|
| 4989 | + if ($is_wpml && $column == 'cat_language') {
|
|
| 4990 | + $cat_language = geodir_strtolower(trim($row[$c])); |
|
| 4991 | + } |
|
| 4992 | + // WPML |
|
| 4993 | + $c++; |
|
| 4994 | + } |
|
| 4995 | 4995 | |
| 4996 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4997 | - $invalid++; |
|
| 4998 | - continue; |
|
| 4999 | - } |
|
| 4996 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 4997 | + $invalid++; |
|
| 4998 | + continue; |
|
| 4999 | + } |
|
| 5000 | 5000 | |
| 5001 | - // WPML |
|
| 5002 | - if ($is_wpml && $cat_language != '') {
|
|
| 5003 | - $sitepress->switch_lang($cat_language, true); |
|
| 5004 | - } |
|
| 5005 | - // WPML |
|
| 5001 | + // WPML |
|
| 5002 | + if ($is_wpml && $cat_language != '') {
|
|
| 5003 | + $sitepress->switch_lang($cat_language, true); |
|
| 5004 | + } |
|
| 5005 | + // WPML |
|
| 5006 | 5006 | |
| 5007 | - $term_data = array(); |
|
| 5008 | - $term_data['name'] = $cat_name; |
|
| 5009 | - $term_data['slug'] = $cat_slug; |
|
| 5010 | - $term_data['description'] = $cat_description; |
|
| 5011 | - $term_data['cat_schema'] = $cat_schema; |
|
| 5012 | - $term_data['top_description'] = $cat_top_description; |
|
| 5013 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 5014 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 5007 | + $term_data = array(); |
|
| 5008 | + $term_data['name'] = $cat_name; |
|
| 5009 | + $term_data['slug'] = $cat_slug; |
|
| 5010 | + $term_data['description'] = $cat_description; |
|
| 5011 | + $term_data['cat_schema'] = $cat_schema; |
|
| 5012 | + $term_data['top_description'] = $cat_top_description; |
|
| 5013 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 5014 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 5015 | 5015 | |
| 5016 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5016 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5017 | 5017 | |
| 5018 | - $taxonomy = $cat_posttype . 'category'; |
|
| 5018 | + $taxonomy = $cat_posttype . 'category'; |
|
| 5019 | 5019 | |
| 5020 | - $term_data['taxonomy'] = $taxonomy; |
|
| 5020 | + $term_data['taxonomy'] = $taxonomy; |
|
| 5021 | 5021 | |
| 5022 | - $term_parent_id = 0; |
|
| 5023 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 5024 | - $term_parent = ''; |
|
| 5022 | + $term_parent_id = 0; |
|
| 5023 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 5024 | + $term_parent = ''; |
|
| 5025 | 5025 | |
| 5026 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 5027 | - $term_parent = $term_parent; |
|
| 5028 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 5029 | - $term_parent = $term_parent; |
|
| 5030 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 5031 | - $term_parent = $term_parent; |
|
| 5032 | - } else {
|
|
| 5033 | - $term_parent_data = array(); |
|
| 5034 | - $term_parent_data['name'] = $cat_parent; |
|
| 5035 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 5036 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 5026 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 5027 | + $term_parent = $term_parent; |
|
| 5028 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 5029 | + $term_parent = $term_parent; |
|
| 5030 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 5031 | + $term_parent = $term_parent; |
|
| 5032 | + } else {
|
|
| 5033 | + $term_parent_data = array(); |
|
| 5034 | + $term_parent_data['name'] = $cat_parent; |
|
| 5035 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 5036 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 5037 | 5037 | |
| 5038 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 5039 | - } |
|
| 5038 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 5039 | + } |
|
| 5040 | 5040 | |
| 5041 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 5042 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 5043 | - } |
|
| 5044 | - } |
|
| 5045 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 5041 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 5042 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 5043 | + } |
|
| 5044 | + } |
|
| 5045 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 5046 | 5046 | |
| 5047 | - $term_id = NULL; |
|
| 5048 | - if ( $import_choice == 'update' ) {
|
|
| 5049 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5050 | - $term_data['term_id'] = $term['term_id']; |
|
| 5047 | + $term_id = NULL; |
|
| 5048 | + if ( $import_choice == 'update' ) {
|
|
| 5049 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5050 | + $term_data['term_id'] = $term['term_id']; |
|
| 5051 | 5051 | |
| 5052 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5053 | - $updated++; |
|
| 5054 | - } else {
|
|
| 5055 | - $invalid++; |
|
| 5056 | - } |
|
| 5057 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5058 | - $term_data['term_id'] = $term['term_id']; |
|
| 5052 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5053 | + $updated++; |
|
| 5054 | + } else {
|
|
| 5055 | + $invalid++; |
|
| 5056 | + } |
|
| 5057 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5058 | + $term_data['term_id'] = $term['term_id']; |
|
| 5059 | 5059 | |
| 5060 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5061 | - $updated++; |
|
| 5062 | - } else {
|
|
| 5063 | - $invalid++; |
|
| 5064 | - } |
|
| 5065 | - } else {
|
|
| 5066 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5067 | - $created++; |
|
| 5068 | - } else {
|
|
| 5069 | - $invalid++; |
|
| 5070 | - } |
|
| 5071 | - } |
|
| 5072 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5073 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5074 | - $skipped++; |
|
| 5075 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5076 | - $skipped++; |
|
| 5077 | - } else {
|
|
| 5078 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5079 | - $created++; |
|
| 5080 | - } else {
|
|
| 5081 | - $invalid++; |
|
| 5082 | - } |
|
| 5083 | - } |
|
| 5084 | - } else {
|
|
| 5085 | - $invalid++; |
|
| 5086 | - } |
|
| 5060 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 5061 | + $updated++; |
|
| 5062 | + } else {
|
|
| 5063 | + $invalid++; |
|
| 5064 | + } |
|
| 5065 | + } else {
|
|
| 5066 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5067 | + $created++; |
|
| 5068 | + } else {
|
|
| 5069 | + $invalid++; |
|
| 5070 | + } |
|
| 5071 | + } |
|
| 5072 | + } else if ( $import_choice == 'skip' ) {
|
|
| 5073 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 5074 | + $skipped++; |
|
| 5075 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5076 | + $skipped++; |
|
| 5077 | + } else {
|
|
| 5078 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 5079 | + $created++; |
|
| 5080 | + } else {
|
|
| 5081 | + $invalid++; |
|
| 5082 | + } |
|
| 5083 | + } |
|
| 5084 | + } else {
|
|
| 5085 | + $invalid++; |
|
| 5086 | + } |
|
| 5087 | 5087 | |
| 5088 | - if ( $term_id ) {
|
|
| 5089 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 5090 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 5091 | - } |
|
| 5088 | + if ( $term_id ) {
|
|
| 5089 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 5090 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 5091 | + } |
|
| 5092 | 5092 | |
| 5093 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 5094 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 5095 | - } |
|
| 5093 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 5094 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 5095 | + } |
|
| 5096 | 5096 | |
| 5097 | - $attachment = false; |
|
| 5098 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 5099 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 5100 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5097 | + $attachment = false; |
|
| 5098 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 5099 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 5100 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 5101 | 5101 | |
| 5102 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 5103 | - $attachment = true; |
|
| 5104 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 5105 | - } |
|
| 5106 | - } |
|
| 5102 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 5103 | + $attachment = true; |
|
| 5104 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 5105 | + } |
|
| 5106 | + } |
|
| 5107 | 5107 | |
| 5108 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 5109 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 5110 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5108 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 5109 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 5110 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 5111 | 5111 | |
| 5112 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 5113 | - $attachment = true; |
|
| 5114 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 5115 | - } |
|
| 5116 | - } |
|
| 5112 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 5113 | + $attachment = true; |
|
| 5114 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 5115 | + } |
|
| 5116 | + } |
|
| 5117 | 5117 | |
| 5118 | - if ( $attachment ) {
|
|
| 5119 | - $images++; |
|
| 5120 | - } |
|
| 5121 | - } |
|
| 5118 | + if ( $attachment ) {
|
|
| 5119 | + $images++; |
|
| 5120 | + } |
|
| 5121 | + } |
|
| 5122 | 5122 | |
| 5123 | - // WPML |
|
| 5124 | - if ($is_wpml && $cat_language != '') {
|
|
| 5125 | - $sitepress->switch_lang($active_lang, true); |
|
| 5126 | - } |
|
| 5127 | - // WPML |
|
| 5128 | - } |
|
| 5129 | - } |
|
| 5130 | - } |
|
| 5123 | + // WPML |
|
| 5124 | + if ($is_wpml && $cat_language != '') {
|
|
| 5125 | + $sitepress->switch_lang($active_lang, true); |
|
| 5126 | + } |
|
| 5127 | + // WPML |
|
| 5128 | + } |
|
| 5129 | + } |
|
| 5130 | + } |
|
| 5131 | 5131 | |
| 5132 | - $json = array(); |
|
| 5133 | - $json['processed'] = $limit; |
|
| 5134 | - $json['created'] = $created; |
|
| 5135 | - $json['updated'] = $updated; |
|
| 5136 | - $json['skipped'] = $skipped; |
|
| 5137 | - $json['invalid'] = $invalid; |
|
| 5138 | - $json['images'] = $images; |
|
| 5132 | + $json = array(); |
|
| 5133 | + $json['processed'] = $limit; |
|
| 5134 | + $json['created'] = $created; |
|
| 5135 | + $json['updated'] = $updated; |
|
| 5136 | + $json['skipped'] = $skipped; |
|
| 5137 | + $json['invalid'] = $invalid; |
|
| 5138 | + $json['images'] = $images; |
|
| 5139 | 5139 | |
| 5140 | - wp_send_json( $json ); |
|
| 5141 | - exit; |
|
| 5142 | - } else if ( $task == 'import_post' ) {
|
|
| 5140 | + wp_send_json( $json ); |
|
| 5141 | + exit; |
|
| 5142 | + } else if ( $task == 'import_post' ) {
|
|
| 5143 | 5143 | |
| 5144 | 5144 | //run some stuff to make the import quicker |
| 5145 | 5145 | wp_defer_term_counting( true ); |
@@ -5151,503 +5151,503 @@ discard block |
||
| 5151 | 5151 | //remove_all_actions('publish_future_post');
|
| 5152 | 5152 | |
| 5153 | 5153 | |
| 5154 | - if (!empty($file)) {
|
|
| 5155 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 5156 | - $default_status = 'publish'; |
|
| 5157 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 5154 | + if (!empty($file)) {
|
|
| 5155 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 5156 | + $default_status = 'publish'; |
|
| 5157 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 5158 | 5158 | |
| 5159 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5159 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5160 | 5160 | |
| 5161 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5162 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 5163 | - wp_send_json( $json ); |
|
| 5164 | - exit; |
|
| 5165 | - } |
|
| 5161 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5162 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 5163 | + wp_send_json( $json ); |
|
| 5164 | + exit; |
|
| 5165 | + } |
|
| 5166 | 5166 | |
| 5167 | 5167 | $processed_actual=0; |
| 5168 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 5169 | - $index = $processed + $i; |
|
| 5170 | - $gd_post = array(); |
|
| 5168 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 5169 | + $index = $processed + $i; |
|
| 5170 | + $gd_post = array(); |
|
| 5171 | 5171 | |
| 5172 | - if (isset($file[$index])) {$processed_actual++;
|
|
| 5173 | - $row = $file[$index]; |
|
| 5174 | - $row = array_map( 'trim', $row ); |
|
| 5175 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 5176 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 5172 | + if (isset($file[$index])) {$processed_actual++;
|
|
| 5173 | + $row = $file[$index]; |
|
| 5174 | + $row = array_map( 'trim', $row ); |
|
| 5175 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 5176 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 5177 | 5177 | |
| 5178 | - $post_id = ''; |
|
| 5179 | - $post_title = ''; |
|
| 5180 | - $post_author = ''; |
|
| 5181 | - $post_content = ''; |
|
| 5182 | - $post_category_arr = array(); |
|
| 5183 | - $default_category = ''; |
|
| 5184 | - $post_tags = array(); |
|
| 5185 | - $post_type = ''; |
|
| 5186 | - $post_status = ''; |
|
| 5187 | - $geodir_video = ''; |
|
| 5188 | - $post_address = ''; |
|
| 5189 | - $post_city = ''; |
|
| 5190 | - $post_region = ''; |
|
| 5191 | - $post_country = ''; |
|
| 5192 | - $post_zip = ''; |
|
| 5193 | - $post_latitude = ''; |
|
| 5194 | - $post_longitude = ''; |
|
| 5195 | - $geodir_timing = ''; |
|
| 5196 | - $geodir_contact = ''; |
|
| 5197 | - $geodir_email = ''; |
|
| 5198 | - $geodir_website = ''; |
|
| 5199 | - $geodir_twitter = ''; |
|
| 5200 | - $geodir_facebook = ''; |
|
| 5201 | - $geodir_twitter = ''; |
|
| 5202 | - $post_images = array(); |
|
| 5178 | + $post_id = ''; |
|
| 5179 | + $post_title = ''; |
|
| 5180 | + $post_author = ''; |
|
| 5181 | + $post_content = ''; |
|
| 5182 | + $post_category_arr = array(); |
|
| 5183 | + $default_category = ''; |
|
| 5184 | + $post_tags = array(); |
|
| 5185 | + $post_type = ''; |
|
| 5186 | + $post_status = ''; |
|
| 5187 | + $geodir_video = ''; |
|
| 5188 | + $post_address = ''; |
|
| 5189 | + $post_city = ''; |
|
| 5190 | + $post_region = ''; |
|
| 5191 | + $post_country = ''; |
|
| 5192 | + $post_zip = ''; |
|
| 5193 | + $post_latitude = ''; |
|
| 5194 | + $post_longitude = ''; |
|
| 5195 | + $geodir_timing = ''; |
|
| 5196 | + $geodir_contact = ''; |
|
| 5197 | + $geodir_email = ''; |
|
| 5198 | + $geodir_website = ''; |
|
| 5199 | + $geodir_twitter = ''; |
|
| 5200 | + $geodir_facebook = ''; |
|
| 5201 | + $geodir_twitter = ''; |
|
| 5202 | + $post_images = array(); |
|
| 5203 | 5203 | |
| 5204 | - $expire_date = 'Never'; |
|
| 5204 | + $expire_date = 'Never'; |
|
| 5205 | 5205 | |
| 5206 | - $language = ''; |
|
| 5207 | - $original_post_id = ''; |
|
| 5206 | + $language = ''; |
|
| 5207 | + $original_post_id = ''; |
|
| 5208 | 5208 | |
| 5209 | - $c = 0; |
|
| 5210 | - foreach ($columns as $column ) {
|
|
| 5211 | - $gd_post[$column] = $row[$c]; |
|
| 5209 | + $c = 0; |
|
| 5210 | + foreach ($columns as $column ) {
|
|
| 5211 | + $gd_post[$column] = $row[$c]; |
|
| 5212 | 5212 | |
| 5213 | - if ( $column == 'post_id' ) {
|
|
| 5214 | - $post_id = $row[$c]; |
|
| 5215 | - } else if ( $column == 'post_title' ) {
|
|
| 5216 | - $post_title = $row[$c]; |
|
| 5217 | - } else if ( $column == 'post_author' ) {
|
|
| 5218 | - $post_author = $row[$c]; |
|
| 5219 | - } else if ( $column == 'post_content' ) {
|
|
| 5220 | - $post_content = $row[$c]; |
|
| 5221 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 5222 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 5223 | - } else if ( $column == 'default_category' ) {
|
|
| 5224 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 5225 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 5226 | - $post_tags = explode( ',', $row[$c] ); |
|
| 5227 | - } else if ( $column == 'post_type' ) {
|
|
| 5228 | - $post_type = $row[$c]; |
|
| 5229 | - } else if ( $column == 'post_status' ) {
|
|
| 5230 | - $post_status = sanitize_key( $row[$c] ); |
|
| 5231 | - } else if ( $column == 'is_featured' ) {
|
|
| 5232 | - $is_featured = (int)$row[$c]; |
|
| 5233 | - } else if ( $column == 'geodir_video' ) {
|
|
| 5234 | - $geodir_video = $row[$c]; |
|
| 5235 | - } else if ( $column == 'post_address' ) {
|
|
| 5236 | - $post_address = $row[$c]; |
|
| 5237 | - } else if ( $column == 'post_city' ) {
|
|
| 5238 | - $post_city = $row[$c]; |
|
| 5239 | - } else if ( $column == 'post_region' ) {
|
|
| 5240 | - $post_region = $row[$c]; |
|
| 5241 | - } else if ( $column == 'post_country' ) {
|
|
| 5242 | - $post_country = $row[$c]; |
|
| 5243 | - } else if ( $column == 'post_zip' ) {
|
|
| 5244 | - $post_zip = $row[$c]; |
|
| 5245 | - } else if ( $column == 'post_latitude' ) {
|
|
| 5246 | - $post_latitude = $row[$c]; |
|
| 5247 | - } else if ( $column == 'post_longitude' ) {
|
|
| 5248 | - $post_longitude = $row[$c]; |
|
| 5249 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 5250 | - $geodir_timing = $row[$c]; |
|
| 5251 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 5252 | - $geodir_contact = $row[$c]; |
|
| 5253 | - } else if ( $column == 'geodir_email' ) {
|
|
| 5254 | - $geodir_email = $row[$c]; |
|
| 5255 | - } else if ( $column == 'geodir_website' ) {
|
|
| 5256 | - $geodir_website = $row[$c]; |
|
| 5257 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5258 | - $geodir_twitter = $row[$c]; |
|
| 5259 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 5260 | - $geodir_facebook = $row[$c]; |
|
| 5261 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 5262 | - $geodir_twitter = $row[$c]; |
|
| 5263 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 5264 | - $post_images[] = $row[$c]; |
|
| 5265 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 5266 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 5267 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 5268 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 5269 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 5270 | - } |
|
| 5271 | - // WPML |
|
| 5272 | - if ($is_wpml) {
|
|
| 5273 | - if ($column == 'language') {
|
|
| 5274 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 5275 | - } else if ($column == 'original_post_id') {
|
|
| 5276 | - $original_post_id = (int)$row[$c]; |
|
| 5277 | - } |
|
| 5278 | - } |
|
| 5279 | - // WPML |
|
| 5280 | - $c++; |
|
| 5281 | - } |
|
| 5213 | + if ( $column == 'post_id' ) {
|
|
| 5214 | + $post_id = $row[$c]; |
|
| 5215 | + } else if ( $column == 'post_title' ) {
|
|
| 5216 | + $post_title = $row[$c]; |
|
| 5217 | + } else if ( $column == 'post_author' ) {
|
|
| 5218 | + $post_author = $row[$c]; |
|
| 5219 | + } else if ( $column == 'post_content' ) {
|
|
| 5220 | + $post_content = $row[$c]; |
|
| 5221 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 5222 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 5223 | + } else if ( $column == 'default_category' ) {
|
|
| 5224 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 5225 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 5226 | + $post_tags = explode( ',', $row[$c] ); |
|
| 5227 | + } else if ( $column == 'post_type' ) {
|
|
| 5228 | + $post_type = $row[$c]; |
|
| 5229 | + } else if ( $column == 'post_status' ) {
|
|
| 5230 | + $post_status = sanitize_key( $row[$c] ); |
|
| 5231 | + } else if ( $column == 'is_featured' ) {
|
|
| 5232 | + $is_featured = (int)$row[$c]; |
|
| 5233 | + } else if ( $column == 'geodir_video' ) {
|
|
| 5234 | + $geodir_video = $row[$c]; |
|
| 5235 | + } else if ( $column == 'post_address' ) {
|
|
| 5236 | + $post_address = $row[$c]; |
|
| 5237 | + } else if ( $column == 'post_city' ) {
|
|
| 5238 | + $post_city = $row[$c]; |
|
| 5239 | + } else if ( $column == 'post_region' ) {
|
|
| 5240 | + $post_region = $row[$c]; |
|
| 5241 | + } else if ( $column == 'post_country' ) {
|
|
| 5242 | + $post_country = $row[$c]; |
|
| 5243 | + } else if ( $column == 'post_zip' ) {
|
|
| 5244 | + $post_zip = $row[$c]; |
|
| 5245 | + } else if ( $column == 'post_latitude' ) {
|
|
| 5246 | + $post_latitude = $row[$c]; |
|
| 5247 | + } else if ( $column == 'post_longitude' ) {
|
|
| 5248 | + $post_longitude = $row[$c]; |
|
| 5249 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 5250 | + $geodir_timing = $row[$c]; |
|
| 5251 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 5252 | + $geodir_contact = $row[$c]; |
|
| 5253 | + } else if ( $column == 'geodir_email' ) {
|
|
| 5254 | + $geodir_email = $row[$c]; |
|
| 5255 | + } else if ( $column == 'geodir_website' ) {
|
|
| 5256 | + $geodir_website = $row[$c]; |
|
| 5257 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 5258 | + $geodir_twitter = $row[$c]; |
|
| 5259 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 5260 | + $geodir_facebook = $row[$c]; |
|
| 5261 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 5262 | + $geodir_twitter = $row[$c]; |
|
| 5263 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 5264 | + $post_images[] = $row[$c]; |
|
| 5265 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 5266 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 5267 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 5268 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 5269 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 5270 | + } |
|
| 5271 | + // WPML |
|
| 5272 | + if ($is_wpml) {
|
|
| 5273 | + if ($column == 'language') {
|
|
| 5274 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 5275 | + } else if ($column == 'original_post_id') {
|
|
| 5276 | + $original_post_id = (int)$row[$c]; |
|
| 5277 | + } |
|
| 5278 | + } |
|
| 5279 | + // WPML |
|
| 5280 | + $c++; |
|
| 5281 | + } |
|
| 5282 | 5282 | |
| 5283 | - // WPML |
|
| 5284 | - if ($is_wpml && $language != '') {
|
|
| 5285 | - $sitepress->switch_lang($language, true); |
|
| 5286 | - } |
|
| 5287 | - // WPML |
|
| 5283 | + // WPML |
|
| 5284 | + if ($is_wpml && $language != '') {
|
|
| 5285 | + $sitepress->switch_lang($language, true); |
|
| 5286 | + } |
|
| 5287 | + // WPML |
|
| 5288 | 5288 | |
| 5289 | - $gd_post['IMAGE'] = $post_images; |
|
| 5289 | + $gd_post['IMAGE'] = $post_images; |
|
| 5290 | 5290 | |
| 5291 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 5292 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 5291 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 5292 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 5293 | 5293 | |
| 5294 | - $valid = true; |
|
| 5294 | + $valid = true; |
|
| 5295 | 5295 | |
| 5296 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 5297 | - $invalid++; |
|
| 5298 | - $valid = false; |
|
| 5299 | - } |
|
| 5296 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 5297 | + $invalid++; |
|
| 5298 | + $valid = false; |
|
| 5299 | + } |
|
| 5300 | 5300 | |
| 5301 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5302 | - if ( $location_allowed ) {
|
|
| 5303 | - $location_result = geodir_get_default_location(); |
|
| 5304 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 5305 | - $invalid_addr++; |
|
| 5306 | - $valid = false; |
|
| 5307 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 5308 | - if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
|
|
| 5309 | - $invalid_addr++; |
|
| 5310 | - $valid = false; |
|
| 5311 | - } else {
|
|
| 5312 | - if (!function_exists('geodir_location_plugin_activated')) {
|
|
| 5313 | - $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated. |
|
| 5314 | - } |
|
| 5315 | - } |
|
| 5316 | - } |
|
| 5317 | - } |
|
| 5301 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5302 | + if ( $location_allowed ) {
|
|
| 5303 | + $location_result = geodir_get_default_location(); |
|
| 5304 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 5305 | + $invalid_addr++; |
|
| 5306 | + $valid = false; |
|
| 5307 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 5308 | + if ( ( geodir_strtolower( $post_city ) != geodir_strtolower( $location_result->city ) ) || ( geodir_strtolower( $post_region ) != geodir_strtolower( $location_result->region ) ) || (geodir_strtolower( $post_country ) != geodir_strtolower( $location_result->country ) ) ) {
|
|
| 5309 | + $invalid_addr++; |
|
| 5310 | + $valid = false; |
|
| 5311 | + } else {
|
|
| 5312 | + if (!function_exists('geodir_location_plugin_activated')) {
|
|
| 5313 | + $gd_post['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // Set the default location when location manager not activated. |
|
| 5314 | + } |
|
| 5315 | + } |
|
| 5316 | + } |
|
| 5317 | + } |
|
| 5318 | 5318 | |
| 5319 | - if ( !$valid ) {
|
|
| 5320 | - continue; |
|
| 5321 | - } |
|
| 5319 | + if ( !$valid ) {
|
|
| 5320 | + continue; |
|
| 5321 | + } |
|
| 5322 | 5322 | |
| 5323 | - $cat_taxonomy = $post_type . 'category'; |
|
| 5324 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 5323 | + $cat_taxonomy = $post_type . 'category'; |
|
| 5324 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 5325 | 5325 | |
| 5326 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 5327 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 5328 | - } |
|
| 5326 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 5327 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 5328 | + } |
|
| 5329 | 5329 | |
| 5330 | - $post_category = array(); |
|
| 5331 | - $default_category_id = NULL; |
|
| 5332 | - if ( !empty( $post_category_arr ) ) {
|
|
| 5333 | - foreach ( $post_category_arr as $value ) {
|
|
| 5334 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 5330 | + $post_category = array(); |
|
| 5331 | + $default_category_id = NULL; |
|
| 5332 | + if ( !empty( $post_category_arr ) ) {
|
|
| 5333 | + foreach ( $post_category_arr as $value ) {
|
|
| 5334 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 5335 | 5335 | |
| 5336 | - if ( $category_name != '' ) {
|
|
| 5337 | - $term_category = array(); |
|
| 5336 | + if ( $category_name != '' ) {
|
|
| 5337 | + $term_category = array(); |
|
| 5338 | 5338 | |
| 5339 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 5340 | - $term_category = $term; |
|
| 5341 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 5342 | - $term_category = $term; |
|
| 5343 | - } else {
|
|
| 5344 | - $term_data = array(); |
|
| 5345 | - $term_data['name'] = $category_name; |
|
| 5346 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5347 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 5339 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 5340 | + $term_category = $term; |
|
| 5341 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 5342 | + $term_category = $term; |
|
| 5343 | + } else {
|
|
| 5344 | + $term_data = array(); |
|
| 5345 | + $term_data['name'] = $category_name; |
|
| 5346 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 5347 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 5348 | 5348 | |
| 5349 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 5350 | - if ( $term_id ) {
|
|
| 5351 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 5352 | - } |
|
| 5353 | - } |
|
| 5349 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 5350 | + if ( $term_id ) {
|
|
| 5351 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 5352 | + } |
|
| 5353 | + } |
|
| 5354 | 5354 | |
| 5355 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 5356 | - //$post_category[] = $term_category->slug; |
|
| 5357 | - $post_category[] = intval($term_category->term_id); |
|
| 5355 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 5356 | + //$post_category[] = $term_category->slug; |
|
| 5357 | + $post_category[] = intval($term_category->term_id); |
|
| 5358 | 5358 | |
| 5359 | - if ($category_name == $default_category) {
|
|
| 5360 | - $default_category_id = intval($term_category->term_id); |
|
| 5361 | - } |
|
| 5362 | - } |
|
| 5363 | - } |
|
| 5364 | - } |
|
| 5365 | - } |
|
| 5359 | + if ($category_name == $default_category) {
|
|
| 5360 | + $default_category_id = intval($term_category->term_id); |
|
| 5361 | + } |
|
| 5362 | + } |
|
| 5363 | + } |
|
| 5364 | + } |
|
| 5365 | + } |
|
| 5366 | 5366 | |
| 5367 | - $save_post = array(); |
|
| 5368 | - $save_post['post_title'] = $post_title; |
|
| 5369 | - $save_post['post_content'] = $post_content; |
|
| 5370 | - $save_post['post_type'] = $post_type; |
|
| 5371 | - $save_post['post_author'] = $post_author; |
|
| 5372 | - $save_post['post_status'] = $post_status; |
|
| 5373 | - $save_post['post_category'] = $post_category; |
|
| 5374 | - $save_post['post_tags'] = $post_tags; |
|
| 5375 | - |
|
| 5376 | - $saved_post_id = NULL; |
|
| 5377 | - if ( $import_choice == 'update' ) {
|
|
| 5378 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5379 | - $save_post['ID'] = $post_id; |
|
| 5367 | + $save_post = array(); |
|
| 5368 | + $save_post['post_title'] = $post_title; |
|
| 5369 | + $save_post['post_content'] = $post_content; |
|
| 5370 | + $save_post['post_type'] = $post_type; |
|
| 5371 | + $save_post['post_author'] = $post_author; |
|
| 5372 | + $save_post['post_status'] = $post_status; |
|
| 5373 | + $save_post['post_category'] = $post_category; |
|
| 5374 | + $save_post['post_tags'] = $post_tags; |
|
| 5375 | + |
|
| 5376 | + $saved_post_id = NULL; |
|
| 5377 | + if ( $import_choice == 'update' ) {
|
|
| 5378 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5379 | + $save_post['ID'] = $post_id; |
|
| 5380 | 5380 | |
| 5381 | - if ( wp_update_post( $save_post ) ) {
|
|
| 5382 | - $saved_post_id = $post_id; |
|
| 5383 | - $updated++; |
|
| 5384 | - } |
|
| 5385 | - } else {
|
|
| 5386 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5387 | - $created++; |
|
| 5388 | - } |
|
| 5389 | - } |
|
| 5381 | + if ( wp_update_post( $save_post ) ) {
|
|
| 5382 | + $saved_post_id = $post_id; |
|
| 5383 | + $updated++; |
|
| 5384 | + } |
|
| 5385 | + } else {
|
|
| 5386 | + if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5387 | + $created++; |
|
| 5388 | + } |
|
| 5389 | + } |
|
| 5390 | 5390 | |
| 5391 | - if ( !$saved_post_id > 0 ) {
|
|
| 5392 | - $invalid++; |
|
| 5393 | - } |
|
| 5394 | - } else if ( $import_choice == 'skip' ) {
|
|
| 5395 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5396 | - $skipped++; |
|
| 5397 | - } else {
|
|
| 5398 | - if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5399 | - $created++; |
|
| 5400 | - } else {
|
|
| 5401 | - $invalid++; |
|
| 5402 | - } |
|
| 5403 | - } |
|
| 5404 | - } else {
|
|
| 5405 | - $invalid++; |
|
| 5406 | - } |
|
| 5391 | + if ( !$saved_post_id > 0 ) {
|
|
| 5392 | + $invalid++; |
|
| 5393 | + } |
|
| 5394 | + } else if ( $import_choice == 'skip' ) {
|
|
| 5395 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 5396 | + $skipped++; |
|
| 5397 | + } else {
|
|
| 5398 | + if ( $saved_post_id = wp_insert_post( $save_post ) ) {
|
|
| 5399 | + $created++; |
|
| 5400 | + } else {
|
|
| 5401 | + $invalid++; |
|
| 5402 | + } |
|
| 5403 | + } |
|
| 5404 | + } else {
|
|
| 5405 | + $invalid++; |
|
| 5406 | + } |
|
| 5407 | 5407 | |
| 5408 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 5409 | - // WPML |
|
| 5410 | - if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 5411 | - $wpml_post_type = 'post_' . $post_type; |
|
| 5412 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 5413 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 5408 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 5409 | + // WPML |
|
| 5410 | + if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 5411 | + $wpml_post_type = 'post_' . $post_type; |
|
| 5412 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 5413 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 5414 | 5414 | |
| 5415 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 5415 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 5416 | 5416 | |
| 5417 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 5418 | - } |
|
| 5419 | - // WPML |
|
| 5420 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 5417 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 5418 | + } |
|
| 5419 | + // WPML |
|
| 5420 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 5421 | 5421 | |
| 5422 | - $gd_post['post_id'] = $saved_post_id; |
|
| 5423 | - $gd_post['ID'] = $saved_post_id; |
|
| 5424 | - $gd_post['post_tags'] = $post_tags; |
|
| 5425 | - $gd_post['post_title'] = $post_title; |
|
| 5426 | - $gd_post['post_status'] = $post_status; |
|
| 5427 | - $gd_post['submit_time'] = time(); |
|
| 5428 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 5422 | + $gd_post['post_id'] = $saved_post_id; |
|
| 5423 | + $gd_post['ID'] = $saved_post_id; |
|
| 5424 | + $gd_post['post_tags'] = $post_tags; |
|
| 5425 | + $gd_post['post_title'] = $post_title; |
|
| 5426 | + $gd_post['post_status'] = $post_status; |
|
| 5427 | + $gd_post['submit_time'] = time(); |
|
| 5428 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 5429 | 5429 | |
| 5430 | - // post location |
|
| 5431 | - $post_location_id = 0; |
|
| 5432 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 5433 | - $post_location_info = array( |
|
| 5434 | - 'city' => $post_city, |
|
| 5435 | - 'region' => $post_region, |
|
| 5436 | - 'country' => $post_country, |
|
| 5437 | - 'geo_lat' => $post_latitude, |
|
| 5438 | - 'geo_lng' => $post_longitude |
|
| 5439 | - ); |
|
| 5440 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 5441 | - $post_location_id = $location_id; |
|
| 5442 | - } |
|
| 5443 | - } |
|
| 5444 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 5430 | + // post location |
|
| 5431 | + $post_location_id = 0; |
|
| 5432 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 5433 | + $post_location_info = array( |
|
| 5434 | + 'city' => $post_city, |
|
| 5435 | + 'region' => $post_region, |
|
| 5436 | + 'country' => $post_country, |
|
| 5437 | + 'geo_lat' => $post_latitude, |
|
| 5438 | + 'geo_lng' => $post_longitude |
|
| 5439 | + ); |
|
| 5440 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 5441 | + $post_location_id = $location_id; |
|
| 5442 | + } |
|
| 5443 | + } |
|
| 5444 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 5445 | 5445 | |
| 5446 | - // post package info |
|
| 5447 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 5448 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 5449 | - $package_id = $gd_post_info->package_id; |
|
| 5450 | - } |
|
| 5446 | + // post package info |
|
| 5447 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 5448 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 5449 | + $package_id = $gd_post_info->package_id; |
|
| 5450 | + } |
|
| 5451 | 5451 | |
| 5452 | - $package_info = array(); |
|
| 5453 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 5454 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 5452 | + $package_info = array(); |
|
| 5453 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 5454 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 5455 | 5455 | |
| 5456 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 5457 | - $package_info = array(); |
|
| 5458 | - } |
|
| 5459 | - } |
|
| 5456 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 5457 | + $package_info = array(); |
|
| 5458 | + } |
|
| 5459 | + } |
|
| 5460 | 5460 | |
| 5461 | - if (empty($package_info)) {
|
|
| 5462 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 5463 | - } |
|
| 5461 | + if (empty($package_info)) {
|
|
| 5462 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 5463 | + } |
|
| 5464 | 5464 | |
| 5465 | - if (!empty($package_info)) {
|
|
| 5466 | - $package_id = $package_info['pid']; |
|
| 5465 | + if (!empty($package_info)) {
|
|
| 5466 | + $package_id = $package_info['pid']; |
|
| 5467 | 5467 | |
| 5468 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 5469 | - $gd_post['expire_date'] = $expire_date; |
|
| 5470 | - } else {
|
|
| 5471 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 5472 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 5473 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 5474 | - } else {
|
|
| 5475 | - $gd_post['expire_date'] = 'Never'; |
|
| 5476 | - } |
|
| 5477 | - } |
|
| 5468 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 5469 | + $gd_post['expire_date'] = $expire_date; |
|
| 5470 | + } else {
|
|
| 5471 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 5472 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 5473 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 5474 | + } else {
|
|
| 5475 | + $gd_post['expire_date'] = 'Never'; |
|
| 5476 | + } |
|
| 5477 | + } |
|
| 5478 | 5478 | |
| 5479 | - $gd_post['package_id'] = $package_id; |
|
| 5480 | - } |
|
| 5479 | + $gd_post['package_id'] = $package_id; |
|
| 5480 | + } |
|
| 5481 | 5481 | |
| 5482 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5482 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5483 | 5483 | |
| 5484 | - if ($post_type == 'gd_event') {
|
|
| 5485 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 5486 | - } |
|
| 5484 | + if ($post_type == 'gd_event') {
|
|
| 5485 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 5486 | + } |
|
| 5487 | 5487 | |
| 5488 | - if (isset($gd_post['post_id'])) {
|
|
| 5489 | - unset($gd_post['post_id']); |
|
| 5490 | - } |
|
| 5491 | - |
|
| 5492 | - // Export franchise fields |
|
| 5493 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5494 | - if ($is_franchise_active) {
|
|
| 5495 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 5496 | - $gd_franchise_lock = array(); |
|
| 5488 | + if (isset($gd_post['post_id'])) {
|
|
| 5489 | + unset($gd_post['post_id']); |
|
| 5490 | + } |
|
| 5491 | + |
|
| 5492 | + // Export franchise fields |
|
| 5493 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 5494 | + if ($is_franchise_active) {
|
|
| 5495 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 5496 | + $gd_franchise_lock = array(); |
|
| 5497 | 5497 | |
| 5498 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 5499 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 5500 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 5501 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 5502 | - } |
|
| 5498 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 5499 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 5500 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 5501 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 5502 | + } |
|
| 5503 | 5503 | |
| 5504 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 5505 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 5506 | - } else {
|
|
| 5507 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 5508 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 5509 | - } |
|
| 5510 | - } |
|
| 5511 | - } |
|
| 5504 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 5505 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 5506 | + } else {
|
|
| 5507 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 5508 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 5509 | + } |
|
| 5510 | + } |
|
| 5511 | + } |
|
| 5512 | 5512 | |
| 5513 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 5514 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 5515 | - if ($default_category_id) {
|
|
| 5516 | - $save_post['post_default_category'] = $default_category_id; |
|
| 5517 | - $gd_post['default_category'] = $default_category_id; |
|
| 5518 | - } |
|
| 5519 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 5520 | - } |
|
| 5513 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 5514 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 5515 | + if ($default_category_id) {
|
|
| 5516 | + $save_post['post_default_category'] = $default_category_id; |
|
| 5517 | + $gd_post['default_category'] = $default_category_id; |
|
| 5518 | + } |
|
| 5519 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 5520 | + } |
|
| 5521 | 5521 | |
| 5522 | - // Save post info |
|
| 5523 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 5524 | - // post taxonomies |
|
| 5525 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 5526 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 5522 | + // Save post info |
|
| 5523 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 5524 | + // post taxonomies |
|
| 5525 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 5526 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 5527 | 5527 | |
| 5528 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 5529 | - if ($default_category_id) {
|
|
| 5530 | - $post_default_category = $default_category_id; |
|
| 5531 | - } |
|
| 5532 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 5533 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 5534 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 5528 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 5529 | + if ($default_category_id) {
|
|
| 5530 | + $post_default_category = $default_category_id; |
|
| 5531 | + } |
|
| 5532 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 5533 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 5534 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 5535 | 5535 | |
| 5536 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 5537 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 5538 | - } |
|
| 5536 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 5537 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 5538 | + } |
|
| 5539 | 5539 | |
| 5540 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 5540 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 5541 | 5541 | |
| 5542 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 5543 | - } |
|
| 5542 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 5543 | + } |
|
| 5544 | 5544 | |
| 5545 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 5546 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 5547 | - } |
|
| 5545 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 5546 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 5547 | + } |
|
| 5548 | 5548 | |
| 5549 | - // Post images |
|
| 5550 | - if ( !empty( $post_images ) ) {
|
|
| 5551 | - $post_images = array_unique($post_images); |
|
| 5549 | + // Post images |
|
| 5550 | + if ( !empty( $post_images ) ) {
|
|
| 5551 | + $post_images = array_unique($post_images); |
|
| 5552 | 5552 | |
| 5553 | - $old_post_images_arr = array(); |
|
| 5554 | - $saved_post_images_arr = array(); |
|
| 5553 | + $old_post_images_arr = array(); |
|
| 5554 | + $saved_post_images_arr = array(); |
|
| 5555 | 5555 | |
| 5556 | - $order = 1; |
|
| 5556 | + $order = 1; |
|
| 5557 | 5557 | |
| 5558 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 5559 | - if (!empty($old_post_images)) {
|
|
| 5560 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 5561 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 5562 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 5563 | - } |
|
| 5564 | - } |
|
| 5565 | - } |
|
| 5558 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 5559 | + if (!empty($old_post_images)) {
|
|
| 5560 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 5561 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 5562 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 5563 | + } |
|
| 5564 | + } |
|
| 5565 | + } |
|
| 5566 | 5566 | |
| 5567 | - foreach ( $post_images as $post_image ) {
|
|
| 5568 | - $image_name = basename( $post_image ); |
|
| 5569 | - $saved_post_images_arr[] = $image_name; |
|
| 5567 | + foreach ( $post_images as $post_image ) {
|
|
| 5568 | + $image_name = basename( $post_image ); |
|
| 5569 | + $saved_post_images_arr[] = $image_name; |
|
| 5570 | 5570 | |
| 5571 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 5572 | - continue; // Skip if image already exists. |
|
| 5573 | - } |
|
| 5571 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 5572 | + continue; // Skip if image already exists. |
|
| 5573 | + } |
|
| 5574 | 5574 | |
| 5575 | - $image_name_parts = explode( '.', $image_name ); |
|
| 5576 | - array_pop( $image_name_parts ); |
|
| 5577 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 5575 | + $image_name_parts = explode( '.', $image_name ); |
|
| 5576 | + array_pop( $image_name_parts ); |
|
| 5577 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 5578 | 5578 | |
| 5579 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 5579 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 5580 | 5580 | |
| 5581 | - if ( !empty( $arr_file_type ) ) {
|
|
| 5582 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 5581 | + if ( !empty( $arr_file_type ) ) {
|
|
| 5582 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 5583 | 5583 | |
| 5584 | - $attachment = array(); |
|
| 5585 | - $attachment['post_id'] = $saved_post_id; |
|
| 5586 | - $attachment['title'] = $proper_image_name; |
|
| 5587 | - $attachment['content'] = ''; |
|
| 5588 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 5589 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 5590 | - $attachment['menu_order'] = $order; |
|
| 5591 | - $attachment['is_featured'] = 0; |
|
| 5592 | - |
|
| 5593 | - $attachment_set = ''; |
|
| 5594 | - foreach ( $attachment as $key => $val ) {
|
|
| 5595 | - if ( $val != '' ) {
|
|
| 5596 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 5597 | - } |
|
| 5598 | - } |
|
| 5599 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 5584 | + $attachment = array(); |
|
| 5585 | + $attachment['post_id'] = $saved_post_id; |
|
| 5586 | + $attachment['title'] = $proper_image_name; |
|
| 5587 | + $attachment['content'] = ''; |
|
| 5588 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 5589 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 5590 | + $attachment['menu_order'] = $order; |
|
| 5591 | + $attachment['is_featured'] = 0; |
|
| 5592 | + |
|
| 5593 | + $attachment_set = ''; |
|
| 5594 | + foreach ( $attachment as $key => $val ) {
|
|
| 5595 | + if ( $val != '' ) {
|
|
| 5596 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 5597 | + } |
|
| 5598 | + } |
|
| 5599 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 5600 | 5600 | |
| 5601 | - // Add new attachment |
|
| 5602 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 5601 | + // Add new attachment |
|
| 5602 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 5603 | 5603 | |
| 5604 | - $order++; |
|
| 5605 | - } |
|
| 5606 | - } |
|
| 5604 | + $order++; |
|
| 5605 | + } |
|
| 5606 | + } |
|
| 5607 | 5607 | |
| 5608 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5609 | - // Remove previous attachment |
|
| 5610 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 5608 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 5609 | + // Remove previous attachment |
|
| 5610 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 5611 | 5611 | |
| 5612 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 5613 | - $menu_order = 1; |
|
| 5612 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 5613 | + $menu_order = 1; |
|
| 5614 | 5614 | |
| 5615 | - foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 5616 | - $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 5615 | + foreach ( $saved_post_images_arr as $img_name ) {
|
|
| 5616 | + $wpdb->query( $wpdb->prepare( "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d WHERE post_id =%d AND file LIKE %s", array( $menu_order, $saved_post_id, '%/' . $img_name ) ) ); |
|
| 5617 | 5617 | |
| 5618 | - if( $menu_order == 1 ) {
|
|
| 5619 | - if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 5620 | - $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 5621 | - } |
|
| 5622 | - } |
|
| 5623 | - $menu_order++; |
|
| 5624 | - } |
|
| 5625 | - } |
|
| 5618 | + if( $menu_order == 1 ) {
|
|
| 5619 | + if ( $featured_image = $wpdb->get_var( $wpdb->prepare( "SELECT file FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id =%d AND file LIKE %s", array( $saved_post_id, '%/' . $img_name ) ) ) ) {
|
|
| 5620 | + $wpdb->query( $wpdb->prepare( "UPDATE " . $table . " SET featured_image = %s WHERE post_id =%d", array( $featured_image, $saved_post_id ) ) ); |
|
| 5621 | + } |
|
| 5622 | + } |
|
| 5623 | + $menu_order++; |
|
| 5624 | + } |
|
| 5625 | + } |
|
| 5626 | 5626 | |
| 5627 | - if ( $order > 1 ) {
|
|
| 5628 | - $images++; |
|
| 5629 | - } |
|
| 5630 | - } |
|
| 5627 | + if ( $order > 1 ) {
|
|
| 5628 | + $images++; |
|
| 5629 | + } |
|
| 5630 | + } |
|
| 5631 | 5631 | |
| 5632 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 5633 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 5632 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 5633 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 5634 | 5634 | |
| 5635 | - if (isset($is_featured)) {
|
|
| 5636 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 5637 | - } |
|
| 5638 | - if (isset($gd_post['expire_date'])) {
|
|
| 5639 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 5640 | - } |
|
| 5641 | - } |
|
| 5635 | + if (isset($is_featured)) {
|
|
| 5636 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 5637 | + } |
|
| 5638 | + if (isset($gd_post['expire_date'])) {
|
|
| 5639 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 5640 | + } |
|
| 5641 | + } |
|
| 5642 | 5642 | |
| 5643 | - // WPML |
|
| 5644 | - if ($is_wpml && $language != '') {
|
|
| 5645 | - $sitepress->switch_lang($active_lang, true); |
|
| 5646 | - } |
|
| 5647 | - // WPML |
|
| 5648 | - } |
|
| 5649 | - } |
|
| 5650 | - } |
|
| 5643 | + // WPML |
|
| 5644 | + if ($is_wpml && $language != '') {
|
|
| 5645 | + $sitepress->switch_lang($active_lang, true); |
|
| 5646 | + } |
|
| 5647 | + // WPML |
|
| 5648 | + } |
|
| 5649 | + } |
|
| 5650 | + } |
|
| 5651 | 5651 | |
| 5652 | 5652 | //undo some stuff to make the import quicker |
| 5653 | 5653 | wp_defer_term_counting( false ); |
@@ -5655,111 +5655,111 @@ discard block |
||
| 5655 | 5655 | $wpdb->query( 'COMMIT;' ); |
| 5656 | 5656 | $wpdb->query( 'SET autocommit = 1;' ); |
| 5657 | 5657 | |
| 5658 | - $json = array(); |
|
| 5659 | - $json['processed'] = $processed_actual; |
|
| 5660 | - $json['created'] = $created; |
|
| 5661 | - $json['updated'] = $updated; |
|
| 5662 | - $json['skipped'] = $skipped; |
|
| 5663 | - $json['invalid'] = $invalid; |
|
| 5664 | - $json['invalid_addr'] = $invalid_addr; |
|
| 5665 | - $json['images'] = $images; |
|
| 5658 | + $json = array(); |
|
| 5659 | + $json['processed'] = $processed_actual; |
|
| 5660 | + $json['created'] = $created; |
|
| 5661 | + $json['updated'] = $updated; |
|
| 5662 | + $json['skipped'] = $skipped; |
|
| 5663 | + $json['invalid'] = $invalid; |
|
| 5664 | + $json['invalid_addr'] = $invalid_addr; |
|
| 5665 | + $json['images'] = $images; |
|
| 5666 | 5666 | |
| 5667 | - wp_send_json( $json ); |
|
| 5668 | - exit; |
|
| 5669 | - } else if ( $task == 'import_loc' ) {
|
|
| 5670 | - global $gd_post_types; |
|
| 5671 | - $gd_post_types = $post_types; |
|
| 5667 | + wp_send_json( $json ); |
|
| 5668 | + exit; |
|
| 5669 | + } else if ( $task == 'import_loc' ) {
|
|
| 5670 | + global $gd_post_types; |
|
| 5671 | + $gd_post_types = $post_types; |
|
| 5672 | 5672 | |
| 5673 | - if (!empty($file)) {
|
|
| 5674 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5673 | + if (!empty($file)) {
|
|
| 5674 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 5675 | 5675 | |
| 5676 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5677 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 5678 | - wp_send_json( $json ); |
|
| 5679 | - } |
|
| 5676 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 5677 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 5678 | + wp_send_json( $json ); |
|
| 5679 | + } |
|
| 5680 | 5680 | |
| 5681 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 5682 | - $index = $processed + $i; |
|
| 5681 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 5682 | + $index = $processed + $i; |
|
| 5683 | 5683 | |
| 5684 | - if (isset($file[$index])) {
|
|
| 5685 | - $row = $file[$index]; |
|
| 5686 | - $row = array_map( 'trim', $row ); |
|
| 5687 | - $data = array(); |
|
| 5684 | + if (isset($file[$index])) {
|
|
| 5685 | + $row = $file[$index]; |
|
| 5686 | + $row = array_map( 'trim', $row ); |
|
| 5687 | + $data = array(); |
|
| 5688 | 5688 | |
| 5689 | - foreach ($columns as $c => $column ) {
|
|
| 5690 | - if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
|
| 5691 | - $data[$column] = $row[$c]; |
|
| 5692 | - } |
|
| 5693 | - } |
|
| 5689 | + foreach ($columns as $c => $column ) {
|
|
| 5690 | + if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta', 'city_desc', 'region_meta', 'region_desc', 'country_meta', 'country_desc'))) {
|
|
| 5691 | + $data[$column] = $row[$c]; |
|
| 5692 | + } |
|
| 5693 | + } |
|
| 5694 | 5694 | |
| 5695 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 5696 | - $invalid++; |
|
| 5697 | - continue; |
|
| 5698 | - } |
|
| 5695 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 5696 | + $invalid++; |
|
| 5697 | + continue; |
|
| 5698 | + } |
|
| 5699 | 5699 | |
| 5700 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 5700 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 5701 | 5701 | |
| 5702 | - if ( $import_choice == 'update' ) {
|
|
| 5703 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5704 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5705 | - $updated++; |
|
| 5706 | - } else {
|
|
| 5707 | - $invalid++; |
|
| 5708 | - } |
|
| 5709 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5710 | - $data['location_id'] = (int)$location->location_id; |
|
| 5702 | + if ( $import_choice == 'update' ) {
|
|
| 5703 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5704 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5705 | + $updated++; |
|
| 5706 | + } else {
|
|
| 5707 | + $invalid++; |
|
| 5708 | + } |
|
| 5709 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5710 | + $data['location_id'] = (int)$location->location_id; |
|
| 5711 | 5711 | |
| 5712 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 5713 | - $data['location_id'] = (int)$location->location_id; |
|
| 5714 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 5715 | - $data['location_id'] = (int)$location->location_id; |
|
| 5716 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 5717 | - $data['location_id'] = (int)$location->location_id; |
|
| 5718 | - } |
|
| 5712 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 5713 | + $data['location_id'] = (int)$location->location_id; |
|
| 5714 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 5715 | + $data['location_id'] = (int)$location->location_id; |
|
| 5716 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 5717 | + $data['location_id'] = (int)$location->location_id; |
|
| 5718 | + } |
|
| 5719 | 5719 | |
| 5720 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5721 | - $updated++; |
|
| 5722 | - } else {
|
|
| 5723 | - $invalid++; |
|
| 5724 | - } |
|
| 5725 | - } else {
|
|
| 5726 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5727 | - $created++; |
|
| 5728 | - } else {
|
|
| 5729 | - $invalid++; |
|
| 5730 | - } |
|
| 5731 | - } |
|
| 5732 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 5733 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5734 | - $skipped++; |
|
| 5735 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5736 | - $skipped++; |
|
| 5737 | - } else {
|
|
| 5738 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5739 | - $created++; |
|
| 5740 | - } else {
|
|
| 5741 | - $invalid++; |
|
| 5742 | - } |
|
| 5743 | - } |
|
| 5744 | - } else {
|
|
| 5745 | - $invalid++; |
|
| 5746 | - } |
|
| 5747 | - } |
|
| 5748 | - } |
|
| 5749 | - } |
|
| 5720 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 5721 | + $updated++; |
|
| 5722 | + } else {
|
|
| 5723 | + $invalid++; |
|
| 5724 | + } |
|
| 5725 | + } else {
|
|
| 5726 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5727 | + $created++; |
|
| 5728 | + } else {
|
|
| 5729 | + $invalid++; |
|
| 5730 | + } |
|
| 5731 | + } |
|
| 5732 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 5733 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 5734 | + $skipped++; |
|
| 5735 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 5736 | + $skipped++; |
|
| 5737 | + } else {
|
|
| 5738 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 5739 | + $created++; |
|
| 5740 | + } else {
|
|
| 5741 | + $invalid++; |
|
| 5742 | + } |
|
| 5743 | + } |
|
| 5744 | + } else {
|
|
| 5745 | + $invalid++; |
|
| 5746 | + } |
|
| 5747 | + } |
|
| 5748 | + } |
|
| 5749 | + } |
|
| 5750 | 5750 | |
| 5751 | - $json = array(); |
|
| 5752 | - $json['processed'] = $limit; |
|
| 5753 | - $json['created'] = $created; |
|
| 5754 | - $json['updated'] = $updated; |
|
| 5755 | - $json['skipped'] = $skipped; |
|
| 5756 | - $json['invalid'] = $invalid; |
|
| 5757 | - $json['images'] = $images; |
|
| 5751 | + $json = array(); |
|
| 5752 | + $json['processed'] = $limit; |
|
| 5753 | + $json['created'] = $created; |
|
| 5754 | + $json['updated'] = $updated; |
|
| 5755 | + $json['skipped'] = $skipped; |
|
| 5756 | + $json['invalid'] = $invalid; |
|
| 5757 | + $json['images'] = $images; |
|
| 5758 | 5758 | |
| 5759 | - wp_send_json( $json ); |
|
| 5760 | - } |
|
| 5761 | - } |
|
| 5762 | - break; |
|
| 5759 | + wp_send_json( $json ); |
|
| 5760 | + } |
|
| 5761 | + } |
|
| 5762 | + break; |
|
| 5763 | 5763 | case 'import_finish':{
|
| 5764 | 5764 | /** |
| 5765 | 5765 | * Run an action when an import finishes. |
@@ -5773,9 +5773,9 @@ discard block |
||
| 5773 | 5773 | } |
| 5774 | 5774 | break; |
| 5775 | 5775 | |
| 5776 | - } |
|
| 5777 | - echo '0'; |
|
| 5778 | - wp_die(); |
|
| 5776 | + } |
|
| 5777 | + echo '0'; |
|
| 5778 | + wp_die(); |
|
| 5779 | 5779 | } |
| 5780 | 5780 | |
| 5781 | 5781 | /** |
@@ -5801,32 +5801,32 @@ discard block |
||
| 5801 | 5801 | * @return int|bool Term id when success, false when fail. |
| 5802 | 5802 | */ |
| 5803 | 5803 | function geodir_imex_insert_term( $taxonomy, $term_data ) {
|
| 5804 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5805 | - return false; |
|
| 5806 | - } |
|
| 5804 | + if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5805 | + return false; |
|
| 5806 | + } |
|
| 5807 | 5807 | |
| 5808 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5809 | - $args = array(); |
|
| 5810 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5811 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5812 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5808 | + $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5809 | + $args = array(); |
|
| 5810 | + $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5811 | + $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5812 | + $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5813 | 5813 | |
| 5814 | - if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
|
|
| 5815 | - $term_args = array_merge( $term_data, $args ); |
|
| 5816 | - $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 5817 | - $term_args = wp_parse_args( $term_args, $defaults ); |
|
| 5818 | - $term_args = sanitize_term( $term_args, $taxonomy, 'db' ); |
|
| 5819 | - $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
|
| 5820 | - } |
|
| 5814 | + if ( ( !empty( $args['slug'] ) && term_exists( $args['slug'], $taxonomy ) ) || empty( $args['slug'] ) ) {
|
|
| 5815 | + $term_args = array_merge( $term_data, $args ); |
|
| 5816 | + $defaults = array( 'alias_of' => '', 'description' => '', 'parent' => 0, 'slug' => ''); |
|
| 5817 | + $term_args = wp_parse_args( $term_args, $defaults ); |
|
| 5818 | + $term_args = sanitize_term( $term_args, $taxonomy, 'db' ); |
|
| 5819 | + $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
|
| 5820 | + } |
|
| 5821 | 5821 | |
| 5822 | 5822 | if( !empty( $term ) ) {
|
| 5823 | - $result = wp_insert_term( $term, $taxonomy, $args ); |
|
| 5823 | + $result = wp_insert_term( $term, $taxonomy, $args ); |
|
| 5824 | 5824 | if( !is_wp_error( $result ) ) {
|
| 5825 | 5825 | return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
| 5826 | 5826 | } |
| 5827 | 5827 | } |
| 5828 | 5828 | |
| 5829 | - return false; |
|
| 5829 | + return false; |
|
| 5830 | 5830 | } |
| 5831 | 5831 | |
| 5832 | 5832 | /** |
@@ -5853,39 +5853,39 @@ discard block |
||
| 5853 | 5853 | * @return int|bool Term id when success, false when fail. |
| 5854 | 5854 | */ |
| 5855 | 5855 | function geodir_imex_update_term( $taxonomy, $term_data ) {
|
| 5856 | - if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5857 | - return false; |
|
| 5858 | - } |
|
| 5856 | + if ( empty( $taxonomy ) || empty( $term_data ) ) {
|
|
| 5857 | + return false; |
|
| 5858 | + } |
|
| 5859 | 5859 | |
| 5860 | - $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5861 | - $term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0; |
|
| 5860 | + $term = isset( $term_data['name'] ) && !empty( $term_data['name'] ) ? $term_data['name'] : ''; |
|
| 5861 | + $term_id = isset( $term_data['term_id'] ) && !empty( $term_data['term_id'] ) ? $term_data['term_id'] : 0; |
|
| 5862 | 5862 | |
| 5863 | - $args = array(); |
|
| 5864 | - $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5865 | - $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5866 | - $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5863 | + $args = array(); |
|
| 5864 | + $args['description'] = isset( $term_data['description'] ) ? $term_data['description'] : ''; |
|
| 5865 | + $args['slug'] = isset( $term_data['slug'] ) ? $term_data['slug'] : ''; |
|
| 5866 | + $args['parent'] = isset( $term_data['parent'] ) ? (int)$term_data['parent'] : ''; |
|
| 5867 | 5867 | |
| 5868 | - if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
|
|
| 5869 | - $term_data['term_id'] = $term_info['term_id']; |
|
| 5868 | + if ( $term_id > 0 && $term_info = (array)get_term( $term_id, $taxonomy ) ) {
|
|
| 5869 | + $term_data['term_id'] = $term_info['term_id']; |
|
| 5870 | 5870 | |
| 5871 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5871 | + $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5872 | 5872 | |
| 5873 | - if( !is_wp_error( $result ) ) {
|
|
| 5873 | + if( !is_wp_error( $result ) ) {
|
|
| 5874 | 5874 | return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
| 5875 | 5875 | } |
| 5876 | - } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5877 | - $term_data['term_id'] = $term_info['term_id']; |
|
| 5876 | + } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 5877 | + $term_data['term_id'] = $term_info['term_id']; |
|
| 5878 | 5878 | |
| 5879 | - $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5879 | + $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
|
| 5880 | 5880 | |
| 5881 | - if( !is_wp_error( $result ) ) {
|
|
| 5881 | + if( !is_wp_error( $result ) ) {
|
|
| 5882 | 5882 | return $term_id = isset( $result['term_id'] ) ? $result['term_id'] : 0; |
| 5883 | 5883 | } |
| 5884 | - } else {
|
|
| 5885 | - return geodir_imex_insert_term( $taxonomy, $term_data ); |
|
| 5886 | - } |
|
| 5884 | + } else {
|
|
| 5885 | + return geodir_imex_insert_term( $taxonomy, $term_data ); |
|
| 5886 | + } |
|
| 5887 | 5887 | |
| 5888 | - return false; |
|
| 5888 | + return false; |
|
| 5889 | 5889 | } |
| 5890 | 5890 | |
| 5891 | 5891 | /** |
@@ -5898,21 +5898,21 @@ discard block |
||
| 5898 | 5898 | * @return int Posts count. |
| 5899 | 5899 | */ |
| 5900 | 5900 | function geodir_get_posts_count( $post_type ) {
|
| 5901 | - $posts_count = wp_count_posts( $post_type ); |
|
| 5902 | - $posts_count = array_sum( (array)$posts_count ); |
|
| 5901 | + $posts_count = wp_count_posts( $post_type ); |
|
| 5902 | + $posts_count = array_sum( (array)$posts_count ); |
|
| 5903 | 5903 | |
| 5904 | - /** |
|
| 5905 | - * Modify returned post counts for the current post type. |
|
| 5906 | - * |
|
| 5907 | - * @since 1.4.6 |
|
| 5904 | + /** |
|
| 5905 | + * Modify returned post counts for the current post type. |
|
| 5906 | + * |
|
| 5907 | + * @since 1.4.6 |
|
| 5908 | 5908 | * @package GeoDirectory |
| 5909 | - * |
|
| 5910 | - * @param int $posts_count Post counts. |
|
| 5911 | - * @param string $post_type Post type. |
|
| 5912 | - */ |
|
| 5913 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5909 | + * |
|
| 5910 | + * @param int $posts_count Post counts. |
|
| 5911 | + * @param string $post_type Post type. |
|
| 5912 | + */ |
|
| 5913 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5914 | 5914 | |
| 5915 | - return $posts_count; |
|
| 5915 | + return $posts_count; |
|
| 5916 | 5916 | } |
| 5917 | 5917 | |
| 5918 | 5918 | /** |
@@ -5929,18 +5929,18 @@ discard block |
||
| 5929 | 5929 | * @return int Posts count. |
| 5930 | 5930 | */ |
| 5931 | 5931 | function geodir_imex_count_events( $posts_count, $post_type ) {
|
| 5932 | - if ( $post_type == 'gd_event' ) {
|
|
| 5933 | - global $wpdb, $plugin_prefix; |
|
| 5932 | + if ( $post_type == 'gd_event' ) {
|
|
| 5933 | + global $wpdb, $plugin_prefix; |
|
| 5934 | 5934 | |
| 5935 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5936 | - $schedule_table = EVENT_SCHEDULE; |
|
| 5935 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5936 | + $schedule_table = EVENT_SCHEDULE; |
|
| 5937 | 5937 | |
| 5938 | - $query = "SELECT COUNT({$wpdb->posts}.ID) AS total FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s";
|
|
| 5938 | + $query = "SELECT COUNT({$wpdb->posts}.ID) AS total FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s";
|
|
| 5939 | 5939 | |
| 5940 | - $posts_count = (int)$wpdb->get_var( $wpdb->prepare( $query, $post_type ) ); |
|
| 5941 | - } |
|
| 5940 | + $posts_count = (int)$wpdb->get_var( $wpdb->prepare( $query, $post_type ) ); |
|
| 5941 | + } |
|
| 5942 | 5942 | |
| 5943 | - return $posts_count; |
|
| 5943 | + return $posts_count; |
|
| 5944 | 5944 | } |
| 5945 | 5945 | |
| 5946 | 5946 | /** |
@@ -5960,290 +5960,290 @@ discard block |
||
| 5960 | 5960 | * @return array Array of posts data. |
| 5961 | 5961 | */ |
| 5962 | 5962 | function geodir_imex_get_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 5963 | - global $wp_filesystem; |
|
| 5963 | + global $wp_filesystem; |
|
| 5964 | 5964 | |
| 5965 | - $posts = geodir_get_export_posts( $post_type, $per_page, $page_no ); |
|
| 5965 | + $posts = geodir_get_export_posts( $post_type, $per_page, $page_no ); |
|
| 5966 | 5966 | |
| 5967 | - $csv_rows = array(); |
|
| 5967 | + $csv_rows = array(); |
|
| 5968 | 5968 | |
| 5969 | - if ( !empty( $posts ) ) {
|
|
| 5970 | - $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
|
| 5969 | + if ( !empty( $posts ) ) {
|
|
| 5970 | + $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
|
| 5971 | 5971 | |
| 5972 | - $csv_row = array(); |
|
| 5973 | - $csv_row[] = 'post_id'; |
|
| 5974 | - $csv_row[] = 'post_title'; |
|
| 5975 | - $csv_row[] = 'post_author'; |
|
| 5976 | - $csv_row[] = 'post_content'; |
|
| 5977 | - $csv_row[] = 'post_category'; |
|
| 5978 | - $csv_row[] = 'default_category'; |
|
| 5979 | - $csv_row[] = 'post_tags'; |
|
| 5980 | - $csv_row[] = 'post_type'; |
|
| 5981 | - if ( $post_type == 'gd_event' ) {
|
|
| 5982 | - $csv_row[] = 'event_date'; |
|
| 5983 | - $csv_row[] = 'event_enddate'; |
|
| 5984 | - $csv_row[] = 'starttime'; |
|
| 5985 | - $csv_row[] = 'endtime'; |
|
| 5972 | + $csv_row = array(); |
|
| 5973 | + $csv_row[] = 'post_id'; |
|
| 5974 | + $csv_row[] = 'post_title'; |
|
| 5975 | + $csv_row[] = 'post_author'; |
|
| 5976 | + $csv_row[] = 'post_content'; |
|
| 5977 | + $csv_row[] = 'post_category'; |
|
| 5978 | + $csv_row[] = 'default_category'; |
|
| 5979 | + $csv_row[] = 'post_tags'; |
|
| 5980 | + $csv_row[] = 'post_type'; |
|
| 5981 | + if ( $post_type == 'gd_event' ) {
|
|
| 5982 | + $csv_row[] = 'event_date'; |
|
| 5983 | + $csv_row[] = 'event_enddate'; |
|
| 5984 | + $csv_row[] = 'starttime'; |
|
| 5985 | + $csv_row[] = 'endtime'; |
|
| 5986 | 5986 | |
| 5987 | - $csv_row[] = 'is_recurring_event'; |
|
| 5988 | - $csv_row[] = 'event_duration_days'; |
|
| 5989 | - $csv_row[] = 'recurring_dates'; |
|
| 5990 | - $csv_row[] = 'is_whole_day_event'; |
|
| 5991 | - $csv_row[] = 'event_starttimes'; |
|
| 5992 | - $csv_row[] = 'event_endtimes'; |
|
| 5993 | - $csv_row[] = 'recurring_type'; |
|
| 5994 | - $csv_row[] = 'recurring_interval'; |
|
| 5995 | - $csv_row[] = 'recurring_week_days'; |
|
| 5996 | - $csv_row[] = 'recurring_week_nos'; |
|
| 5997 | - $csv_row[] = 'max_recurring_count'; |
|
| 5998 | - $csv_row[] = 'recurring_end_date'; |
|
| 5999 | - } |
|
| 6000 | - $csv_row[] = 'post_status'; |
|
| 6001 | - $csv_row[] = 'is_featured'; |
|
| 6002 | - if ($is_payment_plugin) {
|
|
| 6003 | - $csv_row[] = 'package_id'; |
|
| 6004 | - $csv_row[] = 'expire_date'; |
|
| 6005 | - } |
|
| 6006 | - $csv_row[] = 'geodir_video'; |
|
| 6007 | - $csv_row[] = 'post_address'; |
|
| 6008 | - $csv_row[] = 'post_city'; |
|
| 6009 | - $csv_row[] = 'post_region'; |
|
| 6010 | - $csv_row[] = 'post_country'; |
|
| 6011 | - $csv_row[] = 'post_zip'; |
|
| 6012 | - $csv_row[] = 'post_latitude'; |
|
| 6013 | - $csv_row[] = 'post_longitude'; |
|
| 6014 | - $csv_row[] = 'geodir_timing'; |
|
| 6015 | - $csv_row[] = 'geodir_contact'; |
|
| 6016 | - $csv_row[] = 'geodir_email'; |
|
| 6017 | - $csv_row[] = 'geodir_website'; |
|
| 6018 | - $csv_row[] = 'geodir_twitter'; |
|
| 6019 | - $csv_row[] = 'geodir_facebook'; |
|
| 6020 | - $csv_row[] = 'geodir_video'; |
|
| 6021 | - $csv_row[] = 'geodir_special_offers'; |
|
| 6022 | - // WPML |
|
| 6023 | - $is_wpml = geodir_is_wpml(); |
|
| 6024 | - if ($is_wpml) {
|
|
| 6025 | - $csv_row[] = 'language'; |
|
| 6026 | - $csv_row[] = 'original_post_id'; |
|
| 6027 | - } |
|
| 6028 | - // WPML |
|
| 5987 | + $csv_row[] = 'is_recurring_event'; |
|
| 5988 | + $csv_row[] = 'event_duration_days'; |
|
| 5989 | + $csv_row[] = 'recurring_dates'; |
|
| 5990 | + $csv_row[] = 'is_whole_day_event'; |
|
| 5991 | + $csv_row[] = 'event_starttimes'; |
|
| 5992 | + $csv_row[] = 'event_endtimes'; |
|
| 5993 | + $csv_row[] = 'recurring_type'; |
|
| 5994 | + $csv_row[] = 'recurring_interval'; |
|
| 5995 | + $csv_row[] = 'recurring_week_days'; |
|
| 5996 | + $csv_row[] = 'recurring_week_nos'; |
|
| 5997 | + $csv_row[] = 'max_recurring_count'; |
|
| 5998 | + $csv_row[] = 'recurring_end_date'; |
|
| 5999 | + } |
|
| 6000 | + $csv_row[] = 'post_status'; |
|
| 6001 | + $csv_row[] = 'is_featured'; |
|
| 6002 | + if ($is_payment_plugin) {
|
|
| 6003 | + $csv_row[] = 'package_id'; |
|
| 6004 | + $csv_row[] = 'expire_date'; |
|
| 6005 | + } |
|
| 6006 | + $csv_row[] = 'geodir_video'; |
|
| 6007 | + $csv_row[] = 'post_address'; |
|
| 6008 | + $csv_row[] = 'post_city'; |
|
| 6009 | + $csv_row[] = 'post_region'; |
|
| 6010 | + $csv_row[] = 'post_country'; |
|
| 6011 | + $csv_row[] = 'post_zip'; |
|
| 6012 | + $csv_row[] = 'post_latitude'; |
|
| 6013 | + $csv_row[] = 'post_longitude'; |
|
| 6014 | + $csv_row[] = 'geodir_timing'; |
|
| 6015 | + $csv_row[] = 'geodir_contact'; |
|
| 6016 | + $csv_row[] = 'geodir_email'; |
|
| 6017 | + $csv_row[] = 'geodir_website'; |
|
| 6018 | + $csv_row[] = 'geodir_twitter'; |
|
| 6019 | + $csv_row[] = 'geodir_facebook'; |
|
| 6020 | + $csv_row[] = 'geodir_video'; |
|
| 6021 | + $csv_row[] = 'geodir_special_offers'; |
|
| 6022 | + // WPML |
|
| 6023 | + $is_wpml = geodir_is_wpml(); |
|
| 6024 | + if ($is_wpml) {
|
|
| 6025 | + $csv_row[] = 'language'; |
|
| 6026 | + $csv_row[] = 'original_post_id'; |
|
| 6027 | + } |
|
| 6028 | + // WPML |
|
| 6029 | 6029 | |
| 6030 | - $custom_fields = geodir_imex_get_custom_fields( $post_type ); |
|
| 6031 | - if ( !empty( $custom_fields ) ) {
|
|
| 6032 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 6033 | - $csv_row[] = $custom_field->htmlvar_name; |
|
| 6034 | - } |
|
| 6035 | - } |
|
| 6030 | + $custom_fields = geodir_imex_get_custom_fields( $post_type ); |
|
| 6031 | + if ( !empty( $custom_fields ) ) {
|
|
| 6032 | + foreach ( $custom_fields as $custom_field ) {
|
|
| 6033 | + $csv_row[] = $custom_field->htmlvar_name; |
|
| 6034 | + } |
|
| 6035 | + } |
|
| 6036 | 6036 | |
| 6037 | - // Export franchise fields |
|
| 6038 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 6039 | - if ($is_franchise_active) {
|
|
| 6040 | - $csv_row[] = 'gd_is_franchise'; |
|
| 6041 | - $csv_row[] = 'gd_franchise_lock'; |
|
| 6042 | - $csv_row[] = 'franchise'; |
|
| 6043 | - } |
|
| 6037 | + // Export franchise fields |
|
| 6038 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 6039 | + if ($is_franchise_active) {
|
|
| 6040 | + $csv_row[] = 'gd_is_franchise'; |
|
| 6041 | + $csv_row[] = 'gd_franchise_lock'; |
|
| 6042 | + $csv_row[] = 'franchise'; |
|
| 6043 | + } |
|
| 6044 | 6044 | |
| 6045 | - $csv_rows[] = $csv_row; |
|
| 6045 | + $csv_rows[] = $csv_row; |
|
| 6046 | 6046 | |
| 6047 | - $images_count = 5; |
|
| 6047 | + $images_count = 5; |
|
| 6048 | 6048 | $xx=0; |
| 6049 | - foreach ( $posts as $post ) {$xx++;
|
|
| 6050 | - $post_id = $post['ID']; |
|
| 6049 | + foreach ( $posts as $post ) {$xx++;
|
|
| 6050 | + $post_id = $post['ID']; |
|
| 6051 | 6051 | |
| 6052 | - $gd_post_info = geodir_get_post_info( $post_id ); |
|
| 6053 | - $post_info = (array)$gd_post_info; |
|
| 6052 | + $gd_post_info = geodir_get_post_info( $post_id ); |
|
| 6053 | + $post_info = (array)$gd_post_info; |
|
| 6054 | 6054 | |
| 6055 | - $taxonomy_category = $post_type . 'category'; |
|
| 6056 | - $taxonomy_tags = $post_type . '_tags'; |
|
| 6055 | + $taxonomy_category = $post_type . 'category'; |
|
| 6056 | + $taxonomy_tags = $post_type . '_tags'; |
|
| 6057 | 6057 | |
| 6058 | - $post_category = ''; |
|
| 6059 | - $default_category_id = $gd_post_info->default_category; |
|
| 6060 | - $default_category = ''; |
|
| 6061 | - $post_tags = ''; |
|
| 6062 | - $terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6058 | + $post_category = ''; |
|
| 6059 | + $default_category_id = $gd_post_info->default_category; |
|
| 6060 | + $default_category = ''; |
|
| 6061 | + $post_tags = ''; |
|
| 6062 | + $terms = wp_get_post_terms( $post_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6063 | 6063 | |
| 6064 | - if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
|
|
| 6065 | - $post_category = array(); |
|
| 6066 | - $post_tags = array(); |
|
| 6064 | + if ( !empty( $terms ) && !is_wp_error( $terms ) ) {
|
|
| 6065 | + $post_category = array(); |
|
| 6066 | + $post_tags = array(); |
|
| 6067 | 6067 | |
| 6068 | - foreach ( $terms as $term ) {
|
|
| 6069 | - if ( $term->taxonomy == $taxonomy_category ) {
|
|
| 6070 | - $post_category[] = $term->name; |
|
| 6068 | + foreach ( $terms as $term ) {
|
|
| 6069 | + if ( $term->taxonomy == $taxonomy_category ) {
|
|
| 6070 | + $post_category[] = $term->name; |
|
| 6071 | 6071 | |
| 6072 | - if ($default_category_id == $term->term_id) {
|
|
| 6073 | - $default_category = $term->name; // Default category. |
|
| 6074 | - } |
|
| 6075 | - } |
|
| 6072 | + if ($default_category_id == $term->term_id) {
|
|
| 6073 | + $default_category = $term->name; // Default category. |
|
| 6074 | + } |
|
| 6075 | + } |
|
| 6076 | 6076 | |
| 6077 | - if ( $term->taxonomy == $taxonomy_tags ) {
|
|
| 6078 | - $post_tags[] = $term->name; |
|
| 6079 | - } |
|
| 6080 | - } |
|
| 6077 | + if ( $term->taxonomy == $taxonomy_tags ) {
|
|
| 6078 | + $post_tags[] = $term->name; |
|
| 6079 | + } |
|
| 6080 | + } |
|
| 6081 | 6081 | |
| 6082 | - if (empty($default_category) && !empty($post_category)) {
|
|
| 6083 | - $default_category = $post_category[0]; // Set first one as default category. |
|
| 6084 | - } |
|
| 6085 | - $post_category = !empty( $post_category ) ? implode( ',', $post_category ) : ''; |
|
| 6086 | - $post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : ''; |
|
| 6087 | - } |
|
| 6082 | + if (empty($default_category) && !empty($post_category)) {
|
|
| 6083 | + $default_category = $post_category[0]; // Set first one as default category. |
|
| 6084 | + } |
|
| 6085 | + $post_category = !empty( $post_category ) ? implode( ',', $post_category ) : ''; |
|
| 6086 | + $post_tags = !empty( $post_tags ) ? implode( ',', $post_tags ) : ''; |
|
| 6087 | + } |
|
| 6088 | 6088 | |
| 6089 | - // Franchise data |
|
| 6090 | - $franchise_id = NULL; |
|
| 6091 | - $franchise_info = array(); |
|
| 6092 | - $locked_fields = array(); |
|
| 6089 | + // Franchise data |
|
| 6090 | + $franchise_id = NULL; |
|
| 6091 | + $franchise_info = array(); |
|
| 6092 | + $locked_fields = array(); |
|
| 6093 | 6093 | |
| 6094 | - if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
|
|
| 6095 | - $franchise_id = $post_info['franchise']; |
|
| 6096 | - $gd_franchise_info = geodir_get_post_info($franchise_id); |
|
| 6094 | + if ($is_franchise_active && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 && geodir_franchise_check((int)$post_info['franchise'])) {
|
|
| 6095 | + $franchise_id = $post_info['franchise']; |
|
| 6096 | + $gd_franchise_info = geodir_get_post_info($franchise_id); |
|
| 6097 | 6097 | |
| 6098 | - if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
|
|
| 6099 | - $franchise_info = (array)$gd_franchise_info; |
|
| 6100 | - $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true); |
|
| 6098 | + if (geodir_franchise_pkg_is_active($gd_franchise_info)) {
|
|
| 6099 | + $franchise_info = (array)$gd_franchise_info; |
|
| 6100 | + $locked_fields = geodir_franchise_get_locked_fields($franchise_id, true); |
|
| 6101 | 6101 | |
| 6102 | - if (!empty($locked_fields)) {
|
|
| 6103 | - foreach( $locked_fields as $locked_field) {
|
|
| 6104 | - if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
|
|
| 6105 | - $post_info[$locked_field] = $franchise_info[$locked_field]; |
|
| 6106 | - } |
|
| 6102 | + if (!empty($locked_fields)) {
|
|
| 6103 | + foreach( $locked_fields as $locked_field) {
|
|
| 6104 | + if (isset($post_info[$locked_field]) && isset($franchise_info[$locked_field])) {
|
|
| 6105 | + $post_info[$locked_field] = $franchise_info[$locked_field]; |
|
| 6106 | + } |
|
| 6107 | 6107 | |
| 6108 | - if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
|
|
| 6109 | - $franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6108 | + if (in_array($taxonomy_category, $locked_fields) || in_array('post_tags', $locked_fields)) {
|
|
| 6109 | + $franchise_terms = wp_get_post_terms( $franchise_id, array( $taxonomy_category, $taxonomy_tags ) ); |
|
| 6110 | 6110 | |
| 6111 | - if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
|
|
| 6112 | - $franchise_post_category = array(); |
|
| 6113 | - $franchise_post_tags = array(); |
|
| 6111 | + if ( !empty( $franchise_terms ) && !is_wp_error( $franchise_terms ) ) {
|
|
| 6112 | + $franchise_post_category = array(); |
|
| 6113 | + $franchise_post_tags = array(); |
|
| 6114 | 6114 | |
| 6115 | - foreach ( $franchise_terms as $franchise_term ) {
|
|
| 6116 | - if ( $franchise_term->taxonomy == $taxonomy_category ) {
|
|
| 6117 | - $franchise_post_category[] = $franchise_term->name; |
|
| 6118 | - } |
|
| 6115 | + foreach ( $franchise_terms as $franchise_term ) {
|
|
| 6116 | + if ( $franchise_term->taxonomy == $taxonomy_category ) {
|
|
| 6117 | + $franchise_post_category[] = $franchise_term->name; |
|
| 6118 | + } |
|
| 6119 | 6119 | |
| 6120 | - if ( $franchise_term->taxonomy == $taxonomy_tags ) {
|
|
| 6121 | - $franchise_post_tags[] = $franchise_term->name; |
|
| 6122 | - } |
|
| 6123 | - } |
|
| 6120 | + if ( $franchise_term->taxonomy == $taxonomy_tags ) {
|
|
| 6121 | + $franchise_post_tags[] = $franchise_term->name; |
|
| 6122 | + } |
|
| 6123 | + } |
|
| 6124 | 6124 | |
| 6125 | - if (in_array($taxonomy_category, $locked_fields)) {
|
|
| 6126 | - $post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : ''; |
|
| 6127 | - } |
|
| 6128 | - if (in_array('post_tags', $locked_fields)) {
|
|
| 6129 | - $post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : ''; |
|
| 6130 | - } |
|
| 6131 | - } |
|
| 6132 | - } |
|
| 6133 | - } |
|
| 6134 | - } |
|
| 6135 | - } |
|
| 6136 | - } |
|
| 6125 | + if (in_array($taxonomy_category, $locked_fields)) {
|
|
| 6126 | + $post_category = !empty( $franchise_post_category ) ? implode( ',', $franchise_post_category ) : ''; |
|
| 6127 | + } |
|
| 6128 | + if (in_array('post_tags', $locked_fields)) {
|
|
| 6129 | + $post_tags = !empty( $franchise_post_tags ) ? implode( ',', $franchise_post_tags ) : ''; |
|
| 6130 | + } |
|
| 6131 | + } |
|
| 6132 | + } |
|
| 6133 | + } |
|
| 6134 | + } |
|
| 6135 | + } |
|
| 6136 | + } |
|
| 6137 | 6137 | |
| 6138 | - $post_images = geodir_get_images( $post_id ); |
|
| 6139 | - $current_images = array(); |
|
| 6140 | - if ( !empty( $post_images ) ) {
|
|
| 6141 | - foreach ( $post_images as $post_image ) {
|
|
| 6142 | - $post_image = (array)$post_image; |
|
| 6143 | - $image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : ''; |
|
| 6144 | - if ( $image ) {
|
|
| 6145 | - $current_images[] = $image; |
|
| 6146 | - } |
|
| 6147 | - } |
|
| 6138 | + $post_images = geodir_get_images( $post_id ); |
|
| 6139 | + $current_images = array(); |
|
| 6140 | + if ( !empty( $post_images ) ) {
|
|
| 6141 | + foreach ( $post_images as $post_image ) {
|
|
| 6142 | + $post_image = (array)$post_image; |
|
| 6143 | + $image = !empty( $post_image ) && isset( $post_image['path'] ) && $wp_filesystem->is_file( $post_image['path'] ) && $wp_filesystem->exists( $post_image['path'] ) ? $post_image['src'] : ''; |
|
| 6144 | + if ( $image ) {
|
|
| 6145 | + $current_images[] = $image; |
|
| 6146 | + } |
|
| 6147 | + } |
|
| 6148 | 6148 | |
| 6149 | - $images_count = max( $images_count, count( $current_images ) ); |
|
| 6150 | - } |
|
| 6149 | + $images_count = max( $images_count, count( $current_images ) ); |
|
| 6150 | + } |
|
| 6151 | 6151 | |
| 6152 | - $csv_row = array(); |
|
| 6153 | - $csv_row[] = $post_id; // post_id |
|
| 6154 | - $csv_row[] = $post_info['post_title']; // post_title |
|
| 6155 | - $csv_row[] = $post_info['post_author']; // post_author |
|
| 6156 | - $csv_row[] = $post_info['post_content']; // post_content |
|
| 6157 | - $csv_row[] = $post_category; // post_category |
|
| 6158 | - $csv_row[] = $default_category; // default_category |
|
| 6159 | - $csv_row[] = $post_tags; // post_tags |
|
| 6160 | - $csv_row[] = $post_type; // post_type |
|
| 6161 | - if ( $post_type == 'gd_event' ) {
|
|
| 6162 | - $event_data = geodir_imex_get_event_data($post, $gd_post_info); |
|
| 6163 | - $csv_row[] = $event_data['event_date']; // event_date |
|
| 6164 | - $csv_row[] = $event_data['event_enddate']; // enddate |
|
| 6165 | - $csv_row[] = $event_data['starttime']; // starttime |
|
| 6166 | - $csv_row[] = $event_data['endtime']; // endtime |
|
| 6152 | + $csv_row = array(); |
|
| 6153 | + $csv_row[] = $post_id; // post_id |
|
| 6154 | + $csv_row[] = $post_info['post_title']; // post_title |
|
| 6155 | + $csv_row[] = $post_info['post_author']; // post_author |
|
| 6156 | + $csv_row[] = $post_info['post_content']; // post_content |
|
| 6157 | + $csv_row[] = $post_category; // post_category |
|
| 6158 | + $csv_row[] = $default_category; // default_category |
|
| 6159 | + $csv_row[] = $post_tags; // post_tags |
|
| 6160 | + $csv_row[] = $post_type; // post_type |
|
| 6161 | + if ( $post_type == 'gd_event' ) {
|
|
| 6162 | + $event_data = geodir_imex_get_event_data($post, $gd_post_info); |
|
| 6163 | + $csv_row[] = $event_data['event_date']; // event_date |
|
| 6164 | + $csv_row[] = $event_data['event_enddate']; // enddate |
|
| 6165 | + $csv_row[] = $event_data['starttime']; // starttime |
|
| 6166 | + $csv_row[] = $event_data['endtime']; // endtime |
|
| 6167 | 6167 | |
| 6168 | - $csv_row[] = $event_data['is_recurring_event']; // is_recurring |
|
| 6169 | - $csv_row[] = $event_data['event_duration_days']; // duration_x |
|
| 6170 | - $csv_row[] = $event_data['recurring_dates']; // recurring_dates |
|
| 6171 | - $csv_row[] = $event_data['is_whole_day_event']; // all_day |
|
| 6172 | - $csv_row[] = $event_data['event_starttimes']; // starttimes |
|
| 6173 | - $csv_row[] = $event_data['event_endtimes']; // endtimes |
|
| 6174 | - $csv_row[] = $event_data['recurring_type']; // repeat_type |
|
| 6175 | - $csv_row[] = $event_data['recurring_interval']; // repeat_x |
|
| 6176 | - $csv_row[] = $event_data['recurring_week_days']; // repeat_days |
|
| 6177 | - $csv_row[] = $event_data['recurring_week_nos']; // repeat_weeks |
|
| 6178 | - $csv_row[] = $event_data['max_recurring_count']; // max_repeat |
|
| 6179 | - $csv_row[] = $event_data['recurring_end_date']; // repeat_end |
|
| 6180 | - } |
|
| 6181 | - $csv_row[] = $post_info['post_status']; // post_status |
|
| 6182 | - $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 6183 | - if ($is_payment_plugin) {
|
|
| 6184 | - $csv_row[] = (int)$post_info['package_id']; // package_id |
|
| 6185 | - $csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
|
|
| 6186 | - } |
|
| 6187 | - $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6188 | - $csv_row[] = $post_info['post_address']; // post_address |
|
| 6189 | - $csv_row[] = $post_info['post_city']; // post_city |
|
| 6190 | - $csv_row[] = $post_info['post_region']; // post_region |
|
| 6191 | - $csv_row[] = $post_info['post_country']; // post_country |
|
| 6192 | - $csv_row[] = $post_info['post_zip']; // post_zip |
|
| 6193 | - $csv_row[] = $post_info['post_latitude']; // post_latitude |
|
| 6194 | - $csv_row[] = $post_info['post_longitude']; // post_longitude |
|
| 6195 | - $csv_row[] = $post_info['geodir_timing']; // geodir_timing |
|
| 6196 | - $csv_row[] = $post_info['geodir_contact']; // geodir_contact |
|
| 6197 | - $csv_row[] = $post_info['geodir_email']; // geodir_email |
|
| 6198 | - $csv_row[] = $post_info['geodir_website']; // geodir_website |
|
| 6199 | - $csv_row[] = $post_info['geodir_twitter']; // geodir_twitter |
|
| 6200 | - $csv_row[] = $post_info['geodir_facebook']; // geodir_facebook |
|
| 6201 | - $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6202 | - $csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers |
|
| 6203 | - // WPML |
|
| 6204 | - if ($is_wpml) {
|
|
| 6205 | - $csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type ); |
|
| 6206 | - $csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type ); |
|
| 6207 | - } |
|
| 6208 | - // WPML |
|
| 6168 | + $csv_row[] = $event_data['is_recurring_event']; // is_recurring |
|
| 6169 | + $csv_row[] = $event_data['event_duration_days']; // duration_x |
|
| 6170 | + $csv_row[] = $event_data['recurring_dates']; // recurring_dates |
|
| 6171 | + $csv_row[] = $event_data['is_whole_day_event']; // all_day |
|
| 6172 | + $csv_row[] = $event_data['event_starttimes']; // starttimes |
|
| 6173 | + $csv_row[] = $event_data['event_endtimes']; // endtimes |
|
| 6174 | + $csv_row[] = $event_data['recurring_type']; // repeat_type |
|
| 6175 | + $csv_row[] = $event_data['recurring_interval']; // repeat_x |
|
| 6176 | + $csv_row[] = $event_data['recurring_week_days']; // repeat_days |
|
| 6177 | + $csv_row[] = $event_data['recurring_week_nos']; // repeat_weeks |
|
| 6178 | + $csv_row[] = $event_data['max_recurring_count']; // max_repeat |
|
| 6179 | + $csv_row[] = $event_data['recurring_end_date']; // repeat_end |
|
| 6180 | + } |
|
| 6181 | + $csv_row[] = $post_info['post_status']; // post_status |
|
| 6182 | + $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
|
| 6183 | + if ($is_payment_plugin) {
|
|
| 6184 | + $csv_row[] = (int)$post_info['package_id']; // package_id |
|
| 6185 | + $csv_row[] = $post_info['expire_date'] != '' && geodir_strtolower($post_info['expire_date']) != 'never' ? date_i18n('Y-m-d', strtotime($post_info['expire_date'])) : 'Never'; // expire_date
|
|
| 6186 | + } |
|
| 6187 | + $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6188 | + $csv_row[] = $post_info['post_address']; // post_address |
|
| 6189 | + $csv_row[] = $post_info['post_city']; // post_city |
|
| 6190 | + $csv_row[] = $post_info['post_region']; // post_region |
|
| 6191 | + $csv_row[] = $post_info['post_country']; // post_country |
|
| 6192 | + $csv_row[] = $post_info['post_zip']; // post_zip |
|
| 6193 | + $csv_row[] = $post_info['post_latitude']; // post_latitude |
|
| 6194 | + $csv_row[] = $post_info['post_longitude']; // post_longitude |
|
| 6195 | + $csv_row[] = $post_info['geodir_timing']; // geodir_timing |
|
| 6196 | + $csv_row[] = $post_info['geodir_contact']; // geodir_contact |
|
| 6197 | + $csv_row[] = $post_info['geodir_email']; // geodir_email |
|
| 6198 | + $csv_row[] = $post_info['geodir_website']; // geodir_website |
|
| 6199 | + $csv_row[] = $post_info['geodir_twitter']; // geodir_twitter |
|
| 6200 | + $csv_row[] = $post_info['geodir_facebook']; // geodir_facebook |
|
| 6201 | + $csv_row[] = $post_info['geodir_video']; // geodir_video |
|
| 6202 | + $csv_row[] = $post_info['geodir_special_offers']; // geodir_special_offers |
|
| 6203 | + // WPML |
|
| 6204 | + if ($is_wpml) {
|
|
| 6205 | + $csv_row[] = geodir_get_language_for_element( $post_id, 'post_' . $post_type ); |
|
| 6206 | + $csv_row[] = geodir_imex_original_post_id( $post_id, 'post_' . $post_type ); |
|
| 6207 | + } |
|
| 6208 | + // WPML |
|
| 6209 | 6209 | |
| 6210 | - if ( !empty( $custom_fields ) ) {
|
|
| 6211 | - foreach ( $custom_fields as $custom_field ) {
|
|
| 6212 | - $csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 6213 | - } |
|
| 6214 | - } |
|
| 6210 | + if ( !empty( $custom_fields ) ) {
|
|
| 6211 | + foreach ( $custom_fields as $custom_field ) {
|
|
| 6212 | + $csv_row[] = isset( $post_info[$custom_field->htmlvar_name] ) ? $post_info[$custom_field->htmlvar_name] : ''; |
|
| 6213 | + } |
|
| 6214 | + } |
|
| 6215 | 6215 | |
| 6216 | - // Franchise data |
|
| 6217 | - if ($is_franchise_active) {
|
|
| 6218 | - $gd_is_franchise = ''; |
|
| 6219 | - $locaked_fields = ''; |
|
| 6220 | - $franchise = ''; |
|
| 6216 | + // Franchise data |
|
| 6217 | + if ($is_franchise_active) {
|
|
| 6218 | + $gd_is_franchise = ''; |
|
| 6219 | + $locaked_fields = ''; |
|
| 6220 | + $franchise = ''; |
|
| 6221 | 6221 | |
| 6222 | - if (geodir_franchise_pkg_is_active($gd_post_info)) {
|
|
| 6223 | - $gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true ); |
|
| 6224 | - $locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : ''; |
|
| 6225 | - $locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
|
|
| 6226 | - $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id |
|
| 6227 | - } |
|
| 6222 | + if (geodir_franchise_pkg_is_active($gd_post_info)) {
|
|
| 6223 | + $gd_is_franchise = (int)get_post_meta( $post_id, 'gd_is_franchise', true ); |
|
| 6224 | + $locaked_fields = $gd_is_franchise ? get_post_meta( $post_id, 'gd_franchise_lock', true ) : ''; |
|
| 6225 | + $locaked_fields = (is_array($locaked_fields) && !empty($locaked_fields) ? implode(",", $locaked_fields) : '');
|
|
| 6226 | + $franchise = !$gd_is_franchise && isset($post_info['franchise']) && (int)$post_info['franchise'] > 0 ? (int)$post_info['franchise'] : 0; // franchise id |
|
| 6227 | + } |
|
| 6228 | 6228 | |
| 6229 | - $csv_row[] = (int)$gd_is_franchise; // gd_is_franchise |
|
| 6230 | - $csv_row[] = $locaked_fields; // gd_franchise_lock fields |
|
| 6231 | - $csv_row[] = (int)$franchise; // franchise id |
|
| 6232 | - } |
|
| 6229 | + $csv_row[] = (int)$gd_is_franchise; // gd_is_franchise |
|
| 6230 | + $csv_row[] = $locaked_fields; // gd_franchise_lock fields |
|
| 6231 | + $csv_row[] = (int)$franchise; // franchise id |
|
| 6232 | + } |
|
| 6233 | 6233 | |
| 6234 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6235 | - $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
|
| 6236 | - } |
|
| 6234 | + for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6235 | + $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
|
| 6236 | + } |
|
| 6237 | 6237 | |
| 6238 | - $csv_rows[] = $csv_row; |
|
| 6238 | + $csv_rows[] = $csv_row; |
|
| 6239 | 6239 | |
| 6240 | - } |
|
| 6240 | + } |
|
| 6241 | 6241 | |
| 6242 | - for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6243 | - $csv_rows[0][] = 'IMAGE'; |
|
| 6244 | - } |
|
| 6245 | - } |
|
| 6246 | - return $csv_rows; |
|
| 6242 | + for ( $c = 0; $c < $images_count; $c++ ) {
|
|
| 6243 | + $csv_rows[0][] = 'IMAGE'; |
|
| 6244 | + } |
|
| 6245 | + } |
|
| 6246 | + return $csv_rows; |
|
| 6247 | 6247 | } |
| 6248 | 6248 | |
| 6249 | 6249 | /** |
@@ -6262,48 +6262,48 @@ discard block |
||
| 6262 | 6262 | * @return array Array of posts data. |
| 6263 | 6263 | */ |
| 6264 | 6264 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 6265 | - global $wpdb, $plugin_prefix; |
|
| 6265 | + global $wpdb, $plugin_prefix; |
|
| 6266 | 6266 | |
| 6267 | - if ( ! post_type_exists( $post_type ) ) |
|
| 6268 | - return new stdClass; |
|
| 6267 | + if ( ! post_type_exists( $post_type ) ) |
|
| 6268 | + return new stdClass; |
|
| 6269 | 6269 | |
| 6270 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6270 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6271 | 6271 | |
| 6272 | - $limit = ''; |
|
| 6273 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6274 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 6272 | + $limit = ''; |
|
| 6273 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6274 | + $offset = ( $page_no - 1 ) * $per_page; |
|
| 6275 | 6275 | |
| 6276 | - if ( $offset > 0 ) {
|
|
| 6277 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 6278 | - } else {
|
|
| 6279 | - $limit = " LIMIT " . $per_page; |
|
| 6280 | - } |
|
| 6281 | - } |
|
| 6276 | + if ( $offset > 0 ) {
|
|
| 6277 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 6278 | + } else {
|
|
| 6279 | + $limit = " LIMIT " . $per_page; |
|
| 6280 | + } |
|
| 6281 | + } |
|
| 6282 | 6282 | |
| 6283 | - $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.ID ASC" . $limit;
|
|
| 6284 | - /** |
|
| 6285 | - * Modify returned posts SQL query for the current post type. |
|
| 6286 | - * |
|
| 6287 | - * @since 1.4.6 |
|
| 6283 | + $query = "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s ORDER BY {$wpdb->posts}.ID ASC" . $limit;
|
|
| 6284 | + /** |
|
| 6285 | + * Modify returned posts SQL query for the current post type. |
|
| 6286 | + * |
|
| 6287 | + * @since 1.4.6 |
|
| 6288 | 6288 | * @package GeoDirectory |
| 6289 | - * |
|
| 6290 | - * @param int $query The SQL query. |
|
| 6291 | - * @param string $post_type Post type. |
|
| 6292 | - */ |
|
| 6293 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 6294 | - |
|
| 6295 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 6296 | - |
|
| 6297 | - /** |
|
| 6298 | - * Modify returned post results for the current post type. |
|
| 6299 | - * |
|
| 6300 | - * @since 1.4.6 |
|
| 6289 | + * |
|
| 6290 | + * @param int $query The SQL query. |
|
| 6291 | + * @param string $post_type Post type. |
|
| 6292 | + */ |
|
| 6293 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 6294 | + |
|
| 6295 | + $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 6296 | + |
|
| 6297 | + /** |
|
| 6298 | + * Modify returned post results for the current post type. |
|
| 6299 | + * |
|
| 6300 | + * @since 1.4.6 |
|
| 6301 | 6301 | * @package GeoDirectory |
| 6302 | - * |
|
| 6303 | - * @param object $results An object containing all post ids. |
|
| 6304 | - * @param string $post_type Post type. |
|
| 6305 | - */ |
|
| 6306 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 6302 | + * |
|
| 6303 | + * @param object $results An object containing all post ids. |
|
| 6304 | + * @param string $post_type Post type. |
|
| 6305 | + */ |
|
| 6306 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 6307 | 6307 | } |
| 6308 | 6308 | |
| 6309 | 6309 | /** |
@@ -6321,16 +6321,16 @@ discard block |
||
| 6321 | 6321 | * @return string The SQL query. |
| 6322 | 6322 | */ |
| 6323 | 6323 | function geodir_imex_get_events_query( $query, $post_type ) {
|
| 6324 | - if ( $post_type == 'gd_event' ) {
|
|
| 6325 | - global $wpdb, $plugin_prefix; |
|
| 6324 | + if ( $post_type == 'gd_event' ) {
|
|
| 6325 | + global $wpdb, $plugin_prefix; |
|
| 6326 | 6326 | |
| 6327 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6328 | - $schedule_table = EVENT_SCHEDULE; |
|
| 6327 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 6328 | + $schedule_table = EVENT_SCHEDULE; |
|
| 6329 | 6329 | |
| 6330 | - $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 6331 | - } |
|
| 6330 | + $query = "SELECT {$wpdb->posts}.ID, {$schedule_table}.event_date, {$schedule_table}.event_enddate AS enddate, {$schedule_table}.event_starttime AS starttime, {$schedule_table}.event_endtime AS endtime FROM {$wpdb->posts} INNER JOIN {$table} ON ({$table}.post_id = {$wpdb->posts}.ID) INNER JOIN {$schedule_table} ON ({$schedule_table}.event_id = {$wpdb->posts}.ID) WHERE {$wpdb->posts}.post_type = %s GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC";
|
|
| 6331 | + } |
|
| 6332 | 6332 | |
| 6333 | - return $query; |
|
| 6333 | + return $query; |
|
| 6334 | 6334 | } |
| 6335 | 6335 | |
| 6336 | 6336 | /** |
@@ -6343,16 +6343,16 @@ discard block |
||
| 6343 | 6343 | * @return int Total terms count. |
| 6344 | 6344 | */ |
| 6345 | 6345 | function geodir_get_terms_count( $post_type ) {
|
| 6346 | - $args = array( 'hide_empty' => 0 ); |
|
| 6346 | + $args = array( 'hide_empty' => 0 ); |
|
| 6347 | 6347 | |
| 6348 | - remove_all_filters( 'get_terms' ); |
|
| 6348 | + remove_all_filters( 'get_terms' ); |
|
| 6349 | 6349 | |
| 6350 | - $taxonomy = $post_type . 'category'; |
|
| 6350 | + $taxonomy = $post_type . 'category'; |
|
| 6351 | 6351 | |
| 6352 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 6353 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 6352 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 6353 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 6354 | 6354 | |
| 6355 | - return $count_terms; |
|
| 6355 | + return $count_terms; |
|
| 6356 | 6356 | } |
| 6357 | 6357 | |
| 6358 | 6358 | /** |
@@ -6368,76 +6368,76 @@ discard block |
||
| 6368 | 6368 | * @return array Array of terms data. |
| 6369 | 6369 | */ |
| 6370 | 6370 | function geodir_imex_get_terms( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 6371 | - $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); |
|
| 6371 | + $args = array( 'hide_empty' => 0, 'orderby' => 'id' ); |
|
| 6372 | 6372 | |
| 6373 | - remove_all_filters( 'get_terms' ); |
|
| 6373 | + remove_all_filters( 'get_terms' ); |
|
| 6374 | 6374 | |
| 6375 | - $taxonomy = $post_type . 'category'; |
|
| 6375 | + $taxonomy = $post_type . 'category'; |
|
| 6376 | 6376 | |
| 6377 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6378 | - $args['offset'] = ( $page_no - 1 ) * $per_page; |
|
| 6379 | - $args['number'] = $per_page; |
|
| 6380 | - } |
|
| 6377 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 6378 | + $args['offset'] = ( $page_no - 1 ) * $per_page; |
|
| 6379 | + $args['number'] = $per_page; |
|
| 6380 | + } |
|
| 6381 | 6381 | |
| 6382 | - $terms = get_terms( $taxonomy, $args ); |
|
| 6382 | + $terms = get_terms( $taxonomy, $args ); |
|
| 6383 | 6383 | |
| 6384 | - $csv_rows = array(); |
|
| 6384 | + $csv_rows = array(); |
|
| 6385 | 6385 | |
| 6386 | - if ( !empty( $terms ) ) {
|
|
| 6387 | - $csv_row = array(); |
|
| 6388 | - $csv_row[] = 'cat_id'; |
|
| 6389 | - $csv_row[] = 'cat_name'; |
|
| 6390 | - $csv_row[] = 'cat_slug'; |
|
| 6391 | - $csv_row[] = 'cat_posttype'; |
|
| 6392 | - $csv_row[] = 'cat_parent'; |
|
| 6393 | - $csv_row[] = 'cat_schema'; |
|
| 6394 | - $csv_row[] = 'cat_description'; |
|
| 6395 | - $csv_row[] = 'cat_top_description'; |
|
| 6396 | - $csv_row[] = 'cat_image'; |
|
| 6397 | - $csv_row[] = 'cat_icon'; |
|
| 6398 | - // WPML |
|
| 6399 | - $is_wpml = geodir_is_wpml(); |
|
| 6400 | - if ($is_wpml) {
|
|
| 6401 | - $csv_row[] = 'cat_language'; |
|
| 6402 | - } |
|
| 6403 | - // WPML |
|
| 6386 | + if ( !empty( $terms ) ) {
|
|
| 6387 | + $csv_row = array(); |
|
| 6388 | + $csv_row[] = 'cat_id'; |
|
| 6389 | + $csv_row[] = 'cat_name'; |
|
| 6390 | + $csv_row[] = 'cat_slug'; |
|
| 6391 | + $csv_row[] = 'cat_posttype'; |
|
| 6392 | + $csv_row[] = 'cat_parent'; |
|
| 6393 | + $csv_row[] = 'cat_schema'; |
|
| 6394 | + $csv_row[] = 'cat_description'; |
|
| 6395 | + $csv_row[] = 'cat_top_description'; |
|
| 6396 | + $csv_row[] = 'cat_image'; |
|
| 6397 | + $csv_row[] = 'cat_icon'; |
|
| 6398 | + // WPML |
|
| 6399 | + $is_wpml = geodir_is_wpml(); |
|
| 6400 | + if ($is_wpml) {
|
|
| 6401 | + $csv_row[] = 'cat_language'; |
|
| 6402 | + } |
|
| 6403 | + // WPML |
|
| 6404 | 6404 | |
| 6405 | - $csv_rows[] = $csv_row; |
|
| 6405 | + $csv_rows[] = $csv_row; |
|
| 6406 | 6406 | |
| 6407 | - foreach ( $terms as $term ) {
|
|
| 6408 | - $cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); |
|
| 6409 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 6407 | + foreach ( $terms as $term ) {
|
|
| 6408 | + $cat_icon = get_tax_meta( $term->term_id, 'ct_cat_icon', false, $post_type ); |
|
| 6409 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 6410 | 6410 | |
| 6411 | - $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); |
|
| 6412 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 6411 | + $cat_image = geodir_get_default_catimage( $term->term_id, $post_type ); |
|
| 6412 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 6413 | 6413 | |
| 6414 | - $cat_parent = ''; |
|
| 6415 | - if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
|
|
| 6416 | - $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); |
|
| 6417 | - $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; |
|
| 6418 | - } |
|
| 6414 | + $cat_parent = ''; |
|
| 6415 | + if (isset($term->parent) && (int)$term->parent > 0 && term_exists((int)$term->parent, $taxonomy)) {
|
|
| 6416 | + $parent_term = (array)get_term_by( 'id', (int)$term->parent, $taxonomy ); |
|
| 6417 | + $cat_parent = !empty($parent_term) && isset($parent_term['name']) ? $parent_term['name'] : ''; |
|
| 6418 | + } |
|
| 6419 | 6419 | |
| 6420 | - $csv_row = array(); |
|
| 6421 | - $csv_row[] = $term->term_id; |
|
| 6422 | - $csv_row[] = $term->name; |
|
| 6423 | - $csv_row[] = $term->slug; |
|
| 6424 | - $csv_row[] = $post_type; |
|
| 6425 | - $csv_row[] = $cat_parent; |
|
| 6426 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
|
| 6427 | - $csv_row[] = $term->description; |
|
| 6428 | - $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); |
|
| 6429 | - $csv_row[] = $cat_image; |
|
| 6430 | - $csv_row[] = $cat_icon; |
|
| 6431 | - // WPML |
|
| 6432 | - if ($is_wpml) {
|
|
| 6433 | - $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
|
| 6434 | - } |
|
| 6435 | - // WPML |
|
| 6420 | + $csv_row = array(); |
|
| 6421 | + $csv_row[] = $term->term_id; |
|
| 6422 | + $csv_row[] = $term->name; |
|
| 6423 | + $csv_row[] = $term->slug; |
|
| 6424 | + $csv_row[] = $post_type; |
|
| 6425 | + $csv_row[] = $cat_parent; |
|
| 6426 | + $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
|
| 6427 | + $csv_row[] = $term->description; |
|
| 6428 | + $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_top_desc', false, $post_type ); |
|
| 6429 | + $csv_row[] = $cat_image; |
|
| 6430 | + $csv_row[] = $cat_icon; |
|
| 6431 | + // WPML |
|
| 6432 | + if ($is_wpml) {
|
|
| 6433 | + $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
|
| 6434 | + } |
|
| 6435 | + // WPML |
|
| 6436 | 6436 | |
| 6437 | - $csv_rows[] = $csv_row; |
|
| 6438 | - } |
|
| 6439 | - } |
|
| 6440 | - return $csv_rows; |
|
| 6437 | + $csv_rows[] = $csv_row; |
|
| 6438 | + } |
|
| 6439 | + } |
|
| 6440 | + return $csv_rows; |
|
| 6441 | 6441 | } |
| 6442 | 6442 | |
| 6443 | 6443 | /** |
@@ -6450,9 +6450,9 @@ discard block |
||
| 6450 | 6450 | * @return string Path to the cache directory. |
| 6451 | 6451 | */ |
| 6452 | 6452 | function geodir_path_import_export( $relative = true ) {
|
| 6453 | - $upload_dir = wp_upload_dir(); |
|
| 6453 | + $upload_dir = wp_upload_dir(); |
|
| 6454 | 6454 | |
| 6455 | - return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache'; |
|
| 6455 | + return $relative ? $upload_dir['baseurl'] . '/cache' : $upload_dir['basedir'] . '/cache'; |
|
| 6456 | 6456 | } |
| 6457 | 6457 | |
| 6458 | 6458 | /** |
@@ -6469,29 +6469,29 @@ discard block |
||
| 6469 | 6469 | * @return bool true if success otherwise false. |
| 6470 | 6470 | */ |
| 6471 | 6471 | function geodir_save_csv_data( $file_path, $csv_data = array(), $clear = true ) {
|
| 6472 | - if ( empty( $csv_data ) ) {
|
|
| 6473 | - return false; |
|
| 6474 | - } |
|
| 6472 | + if ( empty( $csv_data ) ) {
|
|
| 6473 | + return false; |
|
| 6474 | + } |
|
| 6475 | 6475 | |
| 6476 | - global $wp_filesystem; |
|
| 6476 | + global $wp_filesystem; |
|
| 6477 | 6477 | |
| 6478 | - $mode = $clear ? 'w+' : 'a+'; |
|
| 6478 | + $mode = $clear ? 'w+' : 'a+'; |
|
| 6479 | 6479 | |
| 6480 | - if ( function_exists( 'fputcsv' ) ) {
|
|
| 6481 | - $file = fopen( $file_path, $mode ); |
|
| 6482 | - foreach( $csv_data as $csv_row ) {
|
|
| 6483 | - //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6484 | - $write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' ); |
|
| 6485 | - } |
|
| 6486 | - fclose( $file ); |
|
| 6487 | - } else {
|
|
| 6488 | - foreach( $csv_data as $csv_row ) {
|
|
| 6489 | - //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6490 | - $wp_filesystem->put_contents( $file_path, $csv_row ); |
|
| 6491 | - } |
|
| 6492 | - } |
|
| 6480 | + if ( function_exists( 'fputcsv' ) ) {
|
|
| 6481 | + $file = fopen( $file_path, $mode ); |
|
| 6482 | + foreach( $csv_data as $csv_row ) {
|
|
| 6483 | + //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6484 | + $write_successful = fputcsv( $file, $csv_row, ",", $enclosure = '"' ); |
|
| 6485 | + } |
|
| 6486 | + fclose( $file ); |
|
| 6487 | + } else {
|
|
| 6488 | + foreach( $csv_data as $csv_row ) {
|
|
| 6489 | + //$csv_row = array_map( 'utf8_decode', $csv_row ); |
|
| 6490 | + $wp_filesystem->put_contents( $file_path, $csv_row ); |
|
| 6491 | + } |
|
| 6492 | + } |
|
| 6493 | 6493 | |
| 6494 | - return true; |
|
| 6494 | + return true; |
|
| 6495 | 6495 | } |
| 6496 | 6496 | |
| 6497 | 6497 | /** |
@@ -6506,17 +6506,17 @@ discard block |
||
| 6506 | 6506 | * @return int No of file rows. |
| 6507 | 6507 | */ |
| 6508 | 6508 | function geodir_import_export_line_count( $file ) {
|
| 6509 | - global $wp_filesystem; |
|
| 6509 | + global $wp_filesystem; |
|
| 6510 | 6510 | |
| 6511 | - if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
|
|
| 6512 | - $contents = $wp_filesystem->get_contents_array( $file ); |
|
| 6511 | + if ( $wp_filesystem->is_file( $file ) && $wp_filesystem->exists( $file ) ) {
|
|
| 6512 | + $contents = $wp_filesystem->get_contents_array( $file ); |
|
| 6513 | 6513 | |
| 6514 | - if ( !empty( $contents ) && is_array( $contents ) ) {
|
|
| 6515 | - return count( $contents ) - 1; |
|
| 6516 | - } |
|
| 6517 | - } |
|
| 6514 | + if ( !empty( $contents ) && is_array( $contents ) ) {
|
|
| 6515 | + return count( $contents ) - 1; |
|
| 6516 | + } |
|
| 6517 | + } |
|
| 6518 | 6518 | |
| 6519 | - return NULL; |
|
| 6519 | + return NULL; |
|
| 6520 | 6520 | } |
| 6521 | 6521 | |
| 6522 | 6522 | /** |
@@ -6530,12 +6530,12 @@ discard block |
||
| 6530 | 6530 | * @return object Queried object. |
| 6531 | 6531 | */ |
| 6532 | 6532 | function geodir_imex_get_custom_fields( $post_type ) {
|
| 6533 | - global $wpdb; |
|
| 6533 | + global $wpdb; |
|
| 6534 | 6534 | |
| 6535 | - $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
|
|
| 6536 | - $rows = $wpdb->get_results( $sql ); |
|
| 6535 | + $sql = $wpdb->prepare("SELECT htmlvar_name FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1' AND is_admin!='1' AND field_type != 'fieldset' AND htmlvar_name != '' ORDER BY id ASC", array( $post_type ) );
|
|
| 6536 | + $rows = $wpdb->get_results( $sql ); |
|
| 6537 | 6537 | |
| 6538 | - return $rows; |
|
| 6538 | + return $rows; |
|
| 6539 | 6539 | } |
| 6540 | 6540 | |
| 6541 | 6541 | /** |
@@ -6546,11 +6546,11 @@ discard block |
||
| 6546 | 6546 | * @return True if WPML is active else False. |
| 6547 | 6547 | */ |
| 6548 | 6548 | function geodir_is_wpml() {
|
| 6549 | - if (function_exists('icl_object_id')) {
|
|
| 6550 | - return true; |
|
| 6551 | - } |
|
| 6549 | + if (function_exists('icl_object_id')) {
|
|
| 6550 | + return true; |
|
| 6551 | + } |
|
| 6552 | 6552 | |
| 6553 | - return false; |
|
| 6553 | + return false; |
|
| 6554 | 6554 | } |
| 6555 | 6555 | |
| 6556 | 6556 | /** |
@@ -6565,9 +6565,9 @@ discard block |
||
| 6565 | 6565 | * @return Language code. |
| 6566 | 6566 | */ |
| 6567 | 6567 | function geodir_get_language_for_element($element_id, $element_type) {
|
| 6568 | - global $sitepress; |
|
| 6568 | + global $sitepress; |
|
| 6569 | 6569 | |
| 6570 | - return $sitepress->get_language_for_element($element_id, $element_type); |
|
| 6570 | + return $sitepress->get_language_for_element($element_id, $element_type); |
|
| 6571 | 6571 | } |
| 6572 | 6572 | |
| 6573 | 6573 | /** |
@@ -6581,18 +6581,18 @@ discard block |
||
| 6581 | 6581 | * @param int $tr_post_id Translation Post ID. |
| 6582 | 6582 | */ |
| 6583 | 6583 | function geodir_icl_make_duplicate($master_post_id, $lang, $postarr, $tr_post_id) {
|
| 6584 | - $post_type = get_post_type($master_post_id); |
|
| 6584 | + $post_type = get_post_type($master_post_id); |
|
| 6585 | 6585 | |
| 6586 | - if (in_array($post_type, geodir_get_posttypes())) {
|
|
| 6587 | - // Duplicate post details |
|
| 6588 | - geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang); |
|
| 6586 | + if (in_array($post_type, geodir_get_posttypes())) {
|
|
| 6587 | + // Duplicate post details |
|
| 6588 | + geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang); |
|
| 6589 | 6589 | |
| 6590 | - // Duplicate taxonomies |
|
| 6591 | - geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang); |
|
| 6590 | + // Duplicate taxonomies |
|
| 6591 | + geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang); |
|
| 6592 | 6592 | |
| 6593 | - // Duplicate post images |
|
| 6594 | - geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang); |
|
| 6595 | - } |
|
| 6593 | + // Duplicate post images |
|
| 6594 | + geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang); |
|
| 6595 | + } |
|
| 6596 | 6596 | } |
| 6597 | 6597 | |
| 6598 | 6598 | /** |
@@ -6609,23 +6609,23 @@ discard block |
||
| 6609 | 6609 | * @return bool True for success, False for fail. |
| 6610 | 6610 | */ |
| 6611 | 6611 | function geodir_icl_duplicate_post_details($master_post_id, $tr_post_id, $lang) {
|
| 6612 | - global $wpdb, $plugin_prefix; |
|
| 6612 | + global $wpdb, $plugin_prefix; |
|
| 6613 | 6613 | |
| 6614 | - $post_type = get_post_type($master_post_id); |
|
| 6615 | - $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 6614 | + $post_type = get_post_type($master_post_id); |
|
| 6615 | + $post_table = $plugin_prefix . $post_type . '_detail'; |
|
| 6616 | 6616 | |
| 6617 | - $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 6618 | - $data = (array)$wpdb->get_row($query); |
|
| 6617 | + $query = $wpdb->prepare("SELECT * FROM " . $post_table . " WHERE post_id = %d", array($master_post_id));
|
|
| 6618 | + $data = (array)$wpdb->get_row($query); |
|
| 6619 | 6619 | |
| 6620 | - if ( !empty( $data ) ) {
|
|
| 6621 | - $data['post_id'] = $tr_post_id; |
|
| 6622 | - unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6620 | + if ( !empty( $data ) ) {
|
|
| 6621 | + $data['post_id'] = $tr_post_id; |
|
| 6622 | + unset($data['default_category'], $data['marker_json'], $data['featured_image'], $data[$post_type . 'category'], $data['overall_rating'], $data['rating_count'], $data['ratings']); |
|
| 6623 | 6623 | |
| 6624 | - $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
|
| 6625 | - return true; |
|
| 6626 | - } |
|
| 6624 | + $wpdb->update($post_table, $data, array('post_id' => $tr_post_id));
|
|
| 6625 | + return true; |
|
| 6626 | + } |
|
| 6627 | 6627 | |
| 6628 | - return false; |
|
| 6628 | + return false; |
|
| 6629 | 6629 | } |
| 6630 | 6630 | |
| 6631 | 6631 | /** |
@@ -6642,40 +6642,40 @@ discard block |
||
| 6642 | 6642 | * @return bool True for success, False for fail. |
| 6643 | 6643 | */ |
| 6644 | 6644 | function geodir_icl_duplicate_taxonomies($master_post_id, $tr_post_id, $lang) {
|
| 6645 | - global $sitepress, $wpdb; |
|
| 6646 | - $post_type = get_post_type($master_post_id); |
|
| 6645 | + global $sitepress, $wpdb; |
|
| 6646 | + $post_type = get_post_type($master_post_id); |
|
| 6647 | 6647 | |
| 6648 | - remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6648 | + remove_filter('get_term', array($sitepress,'get_term_adjust_id')); // AVOID filtering to current language
|
|
| 6649 | 6649 | |
| 6650 | - $taxonomies = get_object_taxonomies($post_type); |
|
| 6651 | - foreach ($taxonomies as $taxonomy) {
|
|
| 6652 | - $terms = get_the_terms($master_post_id, $taxonomy); |
|
| 6653 | - $terms_array = array(); |
|
| 6650 | + $taxonomies = get_object_taxonomies($post_type); |
|
| 6651 | + foreach ($taxonomies as $taxonomy) {
|
|
| 6652 | + $terms = get_the_terms($master_post_id, $taxonomy); |
|
| 6653 | + $terms_array = array(); |
|
| 6654 | 6654 | |
| 6655 | - if ($terms) {
|
|
| 6656 | - foreach ($terms as $term) {
|
|
| 6657 | - $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 6655 | + if ($terms) {
|
|
| 6656 | + foreach ($terms as $term) {
|
|
| 6657 | + $tr_id = apply_filters( 'translate_object_id',$term->term_id, $taxonomy, false, $lang); |
|
| 6658 | 6658 | |
| 6659 | - if (!is_null($tr_id)){
|
|
| 6660 | - // not using get_term - unfiltered get_term |
|
| 6661 | - $translated_term = $wpdb->get_row($wpdb->prepare("
|
|
| 6659 | + if (!is_null($tr_id)){
|
|
| 6660 | + // not using get_term - unfiltered get_term |
|
| 6661 | + $translated_term = $wpdb->get_row($wpdb->prepare("
|
|
| 6662 | 6662 | SELECT * FROM {$wpdb->terms} t JOIN {$wpdb->term_taxonomy} x ON x.term_id = t.term_id WHERE t.term_id = %d AND x.taxonomy = %s", $tr_id, $taxonomy));
|
| 6663 | 6663 | |
| 6664 | - $terms_array[] = $translated_term->term_id; |
|
| 6665 | - } |
|
| 6666 | - } |
|
| 6664 | + $terms_array[] = $translated_term->term_id; |
|
| 6665 | + } |
|
| 6666 | + } |
|
| 6667 | 6667 | |
| 6668 | - if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 6669 | - $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 6670 | - } |
|
| 6668 | + if (!is_taxonomy_hierarchical($taxonomy)){
|
|
| 6669 | + $terms_array = array_unique( array_map( 'intval', $terms_array ) ); |
|
| 6670 | + } |
|
| 6671 | 6671 | |
| 6672 | - wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
|
| 6672 | + wp_set_post_terms($tr_post_id, $terms_array, $taxonomy); |
|
| 6673 | 6673 | |
| 6674 | - if ($taxonomy == $post_type . 'category') {
|
|
| 6675 | - geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 6676 | - } |
|
| 6677 | - } |
|
| 6678 | - } |
|
| 6674 | + if ($taxonomy == $post_type . 'category') {
|
|
| 6675 | + geodir_set_postcat_structure($tr_post_id, $post_type . 'category'); |
|
| 6676 | + } |
|
| 6677 | + } |
|
| 6678 | + } |
|
| 6679 | 6679 | } |
| 6680 | 6680 | |
| 6681 | 6681 | /** |
@@ -6691,29 +6691,29 @@ discard block |
||
| 6691 | 6691 | * @return bool True for success, False for fail. |
| 6692 | 6692 | */ |
| 6693 | 6693 | function geodir_icl_duplicate_post_images($master_post_id, $tr_post_id, $lang) {
|
| 6694 | - global $wpdb; |
|
| 6694 | + global $wpdb; |
|
| 6695 | 6695 | |
| 6696 | - $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6697 | - $wpdb->query($query); |
|
| 6696 | + $query = $wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d", array('%image%', $tr_post_id));
|
|
| 6697 | + $wpdb->query($query); |
|
| 6698 | 6698 | |
| 6699 | - $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 6700 | - $post_images = $wpdb->get_results($query); |
|
| 6699 | + $query = $wpdb->prepare("SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC", array('%image%', $master_post_id));
|
|
| 6700 | + $post_images = $wpdb->get_results($query); |
|
| 6701 | 6701 | |
| 6702 | - if ( !empty( $post_images ) ) {
|
|
| 6703 | - foreach ( $post_images as $post_image) {
|
|
| 6704 | - $image_data = (array)$post_image; |
|
| 6705 | - unset($image_data['ID']); |
|
| 6706 | - $image_data['post_id'] = $tr_post_id; |
|
| 6702 | + if ( !empty( $post_images ) ) {
|
|
| 6703 | + foreach ( $post_images as $post_image) {
|
|
| 6704 | + $image_data = (array)$post_image; |
|
| 6705 | + unset($image_data['ID']); |
|
| 6706 | + $image_data['post_id'] = $tr_post_id; |
|
| 6707 | 6707 | |
| 6708 | - $wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data); |
|
| 6708 | + $wpdb->insert(GEODIR_ATTACHMENT_TABLE, $image_data); |
|
| 6709 | 6709 | |
| 6710 | - geodir_set_wp_featured_image($tr_post_id); |
|
| 6711 | - } |
|
| 6710 | + geodir_set_wp_featured_image($tr_post_id); |
|
| 6711 | + } |
|
| 6712 | 6712 | |
| 6713 | - return true; |
|
| 6714 | - } |
|
| 6713 | + return true; |
|
| 6714 | + } |
|
| 6715 | 6715 | |
| 6716 | - return false; |
|
| 6716 | + return false; |
|
| 6717 | 6717 | } |
| 6718 | 6718 | |
| 6719 | 6719 | /** |
@@ -6727,141 +6727,141 @@ discard block |
||
| 6727 | 6727 | * @return array Event data array. |
| 6728 | 6728 | */ |
| 6729 | 6729 | function geodir_imex_get_event_data($post, $gd_post_info) {
|
| 6730 | - $event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : ''; |
|
| 6731 | - $event_enddate = $event_date; |
|
| 6732 | - $starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : ''; |
|
| 6733 | - $endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : ''; |
|
| 6730 | + $event_date = isset( $post['event_date'] ) && $post['event_date'] != '' && $post['event_date'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $post['event_date'] ) ) : ''; |
|
| 6731 | + $event_enddate = $event_date; |
|
| 6732 | + $starttime = isset( $post['starttime'] ) && $post['starttime'] != '' && $post['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['starttime'] ) ) : ''; |
|
| 6733 | + $endtime = isset( $post['endtime'] ) && $post['endtime'] != '' && $post['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $post['endtime'] ) ) : ''; |
|
| 6734 | 6734 | |
| 6735 | - $is_recurring_event = ''; |
|
| 6736 | - $event_duration_days = ''; |
|
| 6737 | - $is_whole_day_event = ''; |
|
| 6738 | - $recurring_dates = ''; |
|
| 6739 | - $event_starttimes = ''; |
|
| 6740 | - $event_endtimes = ''; |
|
| 6741 | - $recurring_type = ''; |
|
| 6742 | - $recurring_interval = ''; |
|
| 6743 | - $recurring_week_days = ''; |
|
| 6744 | - $recurring_week_nos = ''; |
|
| 6745 | - $max_recurring_count = ''; |
|
| 6746 | - $recurring_end_date = ''; |
|
| 6747 | - $recurring_dates = ''; |
|
| 6735 | + $is_recurring_event = ''; |
|
| 6736 | + $event_duration_days = ''; |
|
| 6737 | + $is_whole_day_event = ''; |
|
| 6738 | + $recurring_dates = ''; |
|
| 6739 | + $event_starttimes = ''; |
|
| 6740 | + $event_endtimes = ''; |
|
| 6741 | + $recurring_type = ''; |
|
| 6742 | + $recurring_interval = ''; |
|
| 6743 | + $recurring_week_days = ''; |
|
| 6744 | + $recurring_week_nos = ''; |
|
| 6745 | + $max_recurring_count = ''; |
|
| 6746 | + $recurring_end_date = ''; |
|
| 6747 | + $recurring_dates = ''; |
|
| 6748 | 6748 | |
| 6749 | - $recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array(); |
|
| 6750 | - if (!empty($recurring_data)) {
|
|
| 6751 | - $event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date; |
|
| 6752 | - $event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date; |
|
| 6753 | - $starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime; |
|
| 6754 | - $endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime; |
|
| 6755 | - $is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : ''; |
|
| 6756 | - $different_times = !empty($recurring_data['different_times']) ? true : false; |
|
| 6749 | + $recurring_data = isset($gd_post_info->recurring_dates) ? maybe_unserialize($gd_post_info->recurring_dates) : array(); |
|
| 6750 | + if (!empty($recurring_data)) {
|
|
| 6751 | + $event_date = isset( $recurring_data['event_start'] ) && $recurring_data['event_start'] != '' && $recurring_data['event_start'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_start'] ) ) : $event_date; |
|
| 6752 | + $event_enddate = isset( $recurring_data['event_end'] ) && $recurring_data['event_end'] != '' && $recurring_data['event_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['event_end'] ) ) : $event_date; |
|
| 6753 | + $starttime = isset( $recurring_data['starttime'] ) && $recurring_data['starttime'] != '' && $recurring_data['starttime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['starttime'] ) ) : $starttime; |
|
| 6754 | + $endtime = isset( $recurring_data['endtime'] ) && $recurring_data['endtime'] != '' && $recurring_data['endtime'] != '00:00:00' ? date_i18n( 'H:i', strtotime( $recurring_data['endtime'] ) ) : $endtime; |
|
| 6755 | + $is_whole_day_event = !empty($recurring_data['all_day']) ? 1 : ''; |
|
| 6756 | + $different_times = !empty($recurring_data['different_times']) ? true : false; |
|
| 6757 | 6757 | |
| 6758 | - $recurring_pkg = geodir_event_recurring_pkg( $gd_post_info ); |
|
| 6759 | - $is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true; |
|
| 6758 | + $recurring_pkg = geodir_event_recurring_pkg( $gd_post_info ); |
|
| 6759 | + $is_recurring = isset( $gd_post_info->is_recurring ) && (int)$gd_post_info->is_recurring == 0 ? false : true; |
|
| 6760 | 6760 | |
| 6761 | - if ($recurring_pkg && $is_recurring) {
|
|
| 6762 | - $recurring_dates = $event_date; |
|
| 6763 | - $event_enddate = ''; |
|
| 6764 | - $is_recurring_event = 1; |
|
| 6761 | + if ($recurring_pkg && $is_recurring) {
|
|
| 6762 | + $recurring_dates = $event_date; |
|
| 6763 | + $event_enddate = ''; |
|
| 6764 | + $is_recurring_event = 1; |
|
| 6765 | 6765 | |
| 6766 | - $recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
|
|
| 6766 | + $recurring_type = !empty($recurring_data['repeat_type']) && in_array($recurring_data['repeat_type'], array('day', 'week', 'month', 'year', 'custom')) ? $recurring_data['repeat_type'] : 'custom';
|
|
| 6767 | 6767 | |
| 6768 | - if (!empty($recurring_data['event_recurring_dates'])) {
|
|
| 6769 | - $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 6768 | + if (!empty($recurring_data['event_recurring_dates'])) {
|
|
| 6769 | + $event_recurring_dates = explode( ',', $recurring_data['event_recurring_dates'] ); |
|
| 6770 | 6770 | |
| 6771 | - if (!empty($event_recurring_dates)) {
|
|
| 6772 | - $recurring_dates = array(); |
|
| 6771 | + if (!empty($event_recurring_dates)) {
|
|
| 6772 | + $recurring_dates = array(); |
|
| 6773 | 6773 | |
| 6774 | - foreach ($event_recurring_dates as $date) {
|
|
| 6775 | - $recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) ); |
|
| 6776 | - } |
|
| 6774 | + foreach ($event_recurring_dates as $date) {
|
|
| 6775 | + $recurring_dates[] = date_i18n( 'd/m/Y', strtotime( $date ) ); |
|
| 6776 | + } |
|
| 6777 | 6777 | |
| 6778 | - $recurring_dates = implode(",", $recurring_dates);
|
|
| 6779 | - } |
|
| 6780 | - } |
|
| 6778 | + $recurring_dates = implode(",", $recurring_dates);
|
|
| 6779 | + } |
|
| 6780 | + } |
|
| 6781 | 6781 | |
| 6782 | - if ($recurring_type == 'custom') {
|
|
| 6783 | - if (!$is_whole_day_event) {
|
|
| 6784 | - $event_starttimes = $starttime; |
|
| 6785 | - $event_endtimes = $endtime; |
|
| 6782 | + if ($recurring_type == 'custom') {
|
|
| 6783 | + if (!$is_whole_day_event) {
|
|
| 6784 | + $event_starttimes = $starttime; |
|
| 6785 | + $event_endtimes = $endtime; |
|
| 6786 | 6786 | |
| 6787 | - if (!empty($recurring_data['starttimes'])) {
|
|
| 6788 | - $times = array(); |
|
| 6787 | + if (!empty($recurring_data['starttimes'])) {
|
|
| 6788 | + $times = array(); |
|
| 6789 | 6789 | |
| 6790 | - foreach ($recurring_data['starttimes'] as $time) {
|
|
| 6791 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6792 | - } |
|
| 6790 | + foreach ($recurring_data['starttimes'] as $time) {
|
|
| 6791 | + $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6792 | + } |
|
| 6793 | 6793 | |
| 6794 | - $event_starttimes = implode(",", $times);
|
|
| 6795 | - } |
|
| 6794 | + $event_starttimes = implode(",", $times);
|
|
| 6795 | + } |
|
| 6796 | 6796 | |
| 6797 | - if (!empty($recurring_data['endtimes'])) {
|
|
| 6798 | - $times = array(); |
|
| 6797 | + if (!empty($recurring_data['endtimes'])) {
|
|
| 6798 | + $times = array(); |
|
| 6799 | 6799 | |
| 6800 | - foreach ($recurring_data['endtimes'] as $time) {
|
|
| 6801 | - $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6802 | - } |
|
| 6800 | + foreach ($recurring_data['endtimes'] as $time) {
|
|
| 6801 | + $times[] = $time != '00:00:00' ? date_i18n( 'H:i', strtotime( $time ) ) : '00:00'; |
|
| 6802 | + } |
|
| 6803 | 6803 | |
| 6804 | - $event_endtimes = implode(",", $times);
|
|
| 6805 | - } |
|
| 6804 | + $event_endtimes = implode(",", $times);
|
|
| 6805 | + } |
|
| 6806 | 6806 | |
| 6807 | - if (!$different_times) {
|
|
| 6808 | - $event_starttimes = ''; |
|
| 6809 | - $event_endtimes = ''; |
|
| 6810 | - } |
|
| 6811 | - } |
|
| 6812 | - } else {
|
|
| 6813 | - $event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1; |
|
| 6814 | - $recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6807 | + if (!$different_times) {
|
|
| 6808 | + $event_starttimes = ''; |
|
| 6809 | + $event_endtimes = ''; |
|
| 6810 | + } |
|
| 6811 | + } |
|
| 6812 | + } else {
|
|
| 6813 | + $event_duration_days = isset($recurring_data['duration_x']) ? (int)$recurring_data['duration_x'] : 1; |
|
| 6814 | + $recurring_interval = !empty($recurring_data['repeat_x']) && (int)$recurring_data['repeat_x'] > 0 ? $recurring_data['repeat_x'] : 1; |
|
| 6815 | 6815 | |
| 6816 | - if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
|
|
| 6817 | - $week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
|
| 6816 | + if (($recurring_type == 'week' || $recurring_type == 'month') && !empty($recurring_data['repeat_days'])) {
|
|
| 6817 | + $week_days = array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat');
|
|
| 6818 | 6818 | |
| 6819 | - $days = array(); |
|
| 6820 | - foreach ($recurring_data['repeat_days'] as $day) {
|
|
| 6821 | - if (isset($week_days[$day])) {
|
|
| 6822 | - $days[] = $week_days[$day]; |
|
| 6823 | - } |
|
| 6824 | - } |
|
| 6819 | + $days = array(); |
|
| 6820 | + foreach ($recurring_data['repeat_days'] as $day) {
|
|
| 6821 | + if (isset($week_days[$day])) {
|
|
| 6822 | + $days[] = $week_days[$day]; |
|
| 6823 | + } |
|
| 6824 | + } |
|
| 6825 | 6825 | |
| 6826 | - $recurring_week_days = implode(",", array_unique($days));
|
|
| 6827 | - } |
|
| 6826 | + $recurring_week_days = implode(",", array_unique($days));
|
|
| 6827 | + } |
|
| 6828 | 6828 | |
| 6829 | - $recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
|
|
| 6830 | - if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
|
|
| 6831 | - $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : ''; |
|
| 6832 | - $max_recurring_count = empty($recurring_end_date) ? 1 : ''; |
|
| 6833 | - } else {
|
|
| 6834 | - $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1); |
|
| 6835 | - } |
|
| 6836 | - } |
|
| 6837 | - } |
|
| 6838 | - } |
|
| 6839 | - if ($is_whole_day_event) {
|
|
| 6840 | - $starttime = ''; |
|
| 6841 | - $endtime = ''; |
|
| 6842 | - $event_starttimes = ''; |
|
| 6843 | - $event_endtimes = ''; |
|
| 6844 | - } |
|
| 6829 | + $recurring_week_nos = $recurring_type == 'month' && !empty($recurring_data['repeat_weeks']) ? implode(",", $recurring_data['repeat_weeks']) : $recurring_week_nos;
|
|
| 6830 | + if (!empty($recurring_data['repeat_end_type']) && (int)$recurring_data['repeat_end_type'] == 1) {
|
|
| 6831 | + $recurring_end_date = isset($recurring_data['repeat_end']) && $recurring_data['repeat_end'] != '' && $recurring_data['repeat_end'] != '0000-00-00 00:00:00' ? date_i18n( 'd/m/Y', strtotime( $recurring_data['repeat_end'] ) ) : ''; |
|
| 6832 | + $max_recurring_count = empty($recurring_end_date) ? 1 : ''; |
|
| 6833 | + } else {
|
|
| 6834 | + $max_recurring_count = (!empty($recurring_data['max_repeat']) && (int)$recurring_data['max_repeat'] > 0 ? (int)$recurring_data['max_repeat'] : 1); |
|
| 6835 | + } |
|
| 6836 | + } |
|
| 6837 | + } |
|
| 6838 | + } |
|
| 6839 | + if ($is_whole_day_event) {
|
|
| 6840 | + $starttime = ''; |
|
| 6841 | + $endtime = ''; |
|
| 6842 | + $event_starttimes = ''; |
|
| 6843 | + $event_endtimes = ''; |
|
| 6844 | + } |
|
| 6845 | 6845 | |
| 6846 | - $data = array(); |
|
| 6847 | - $data['event_date'] = $event_date; |
|
| 6848 | - $data['event_enddate'] = $event_enddate; |
|
| 6849 | - $data['starttime'] = $starttime; |
|
| 6850 | - $data['endtime'] = $endtime; |
|
| 6851 | - $data['is_recurring_event'] = $is_recurring_event; |
|
| 6852 | - $data['recurring_dates'] = $recurring_dates; |
|
| 6853 | - $data['event_duration_days'] = $event_duration_days; |
|
| 6854 | - $data['is_whole_day_event'] = $is_whole_day_event; |
|
| 6855 | - $data['event_starttimes'] = $event_starttimes; |
|
| 6856 | - $data['event_endtimes'] = $event_endtimes; |
|
| 6857 | - $data['recurring_type'] = $recurring_type; |
|
| 6858 | - $data['recurring_interval'] = $recurring_interval; |
|
| 6859 | - $data['recurring_week_days'] = $recurring_week_days; |
|
| 6860 | - $data['recurring_week_nos'] = $recurring_week_nos; |
|
| 6861 | - $data['max_recurring_count'] = $max_recurring_count; |
|
| 6862 | - $data['recurring_end_date'] = $recurring_end_date; |
|
| 6846 | + $data = array(); |
|
| 6847 | + $data['event_date'] = $event_date; |
|
| 6848 | + $data['event_enddate'] = $event_enddate; |
|
| 6849 | + $data['starttime'] = $starttime; |
|
| 6850 | + $data['endtime'] = $endtime; |
|
| 6851 | + $data['is_recurring_event'] = $is_recurring_event; |
|
| 6852 | + $data['recurring_dates'] = $recurring_dates; |
|
| 6853 | + $data['event_duration_days'] = $event_duration_days; |
|
| 6854 | + $data['is_whole_day_event'] = $is_whole_day_event; |
|
| 6855 | + $data['event_starttimes'] = $event_starttimes; |
|
| 6856 | + $data['event_endtimes'] = $event_endtimes; |
|
| 6857 | + $data['recurring_type'] = $recurring_type; |
|
| 6858 | + $data['recurring_interval'] = $recurring_interval; |
|
| 6859 | + $data['recurring_week_days'] = $recurring_week_days; |
|
| 6860 | + $data['recurring_week_nos'] = $recurring_week_nos; |
|
| 6861 | + $data['max_recurring_count'] = $max_recurring_count; |
|
| 6862 | + $data['recurring_end_date'] = $recurring_end_date; |
|
| 6863 | 6863 | |
| 6864 | - return $data; |
|
| 6864 | + return $data; |
|
| 6865 | 6865 | } |
| 6866 | 6866 | |
| 6867 | 6867 | /** |
@@ -6877,12 +6877,12 @@ discard block |
||
| 6877 | 6877 | * @return doesn't Date. |
| 6878 | 6878 | */ |
| 6879 | 6879 | function geodir_imex_get_date_ymd($date) {
|
| 6880 | - if (strpos($date, '/') !== false) {
|
|
| 6881 | - $date = str_replace('/', '-', $date); // PHP doesn't work well with dd/mm/yyyy format.
|
|
| 6882 | - } |
|
| 6880 | + if (strpos($date, '/') !== false) {
|
|
| 6881 | + $date = str_replace('/', '-', $date); // PHP doesn't work well with dd/mm/yyyy format.
|
|
| 6882 | + } |
|
| 6883 | 6883 | |
| 6884 | - $date = date_i18n('Y-m-d', strtotime($date));
|
|
| 6885 | - return $date; |
|
| 6884 | + $date = date_i18n('Y-m-d', strtotime($date));
|
|
| 6885 | + return $date; |
|
| 6886 | 6886 | } |
| 6887 | 6887 | |
| 6888 | 6888 | /** |
@@ -6895,117 +6895,117 @@ discard block |
||
| 6895 | 6895 | * @return array Event data array. |
| 6896 | 6896 | */ |
| 6897 | 6897 | function geodir_imex_process_event_data($gd_post) {
|
| 6898 | - $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); |
|
| 6899 | - |
|
| 6900 | - $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6901 | - $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : ''; |
|
| 6902 | - $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date; |
|
| 6903 | - $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; |
|
| 6904 | - $starttime = isset($gd_post['starttime']) && !$all_day ? $gd_post['starttime'] : ''; |
|
| 6905 | - $endtime = isset($gd_post['endtime']) && !$all_day ? $gd_post['endtime'] : ''; |
|
| 6898 | + $recurring_pkg = geodir_event_recurring_pkg( (object)$gd_post ); |
|
| 6899 | + |
|
| 6900 | + $is_recurring = isset( $gd_post['is_recurring_event'] ) && (int)$gd_post['is_recurring_event'] == 0 ? false : true; |
|
| 6901 | + $event_date = isset($gd_post['event_date']) && $gd_post['event_date'] != '' ? geodir_imex_get_date_ymd($gd_post['event_date']) : ''; |
|
| 6902 | + $event_enddate = isset($gd_post['event_enddate']) && $gd_post['event_enddate'] != '' ? geodir_imex_get_date_ymd($gd_post['event_enddate']) : $event_date; |
|
| 6903 | + $all_day = isset($gd_post['is_whole_day_event']) && !empty($gd_post['is_whole_day_event']) ? true : false; |
|
| 6904 | + $starttime = isset($gd_post['starttime']) && !$all_day ? $gd_post['starttime'] : ''; |
|
| 6905 | + $endtime = isset($gd_post['endtime']) && !$all_day ? $gd_post['endtime'] : ''; |
|
| 6906 | 6906 | |
| 6907 | - $repeat_type = ''; |
|
| 6908 | - $different_times = ''; |
|
| 6909 | - $starttimes = ''; |
|
| 6910 | - $endtimes = ''; |
|
| 6911 | - $repeat_days = ''; |
|
| 6912 | - $repeat_weeks = ''; |
|
| 6913 | - $event_recurring_dates = ''; |
|
| 6914 | - $repeat_x = ''; |
|
| 6915 | - $duration_x = ''; |
|
| 6916 | - $repeat_end_type = ''; |
|
| 6917 | - $max_repeat = ''; |
|
| 6918 | - $repeat_end = ''; |
|
| 6907 | + $repeat_type = ''; |
|
| 6908 | + $different_times = ''; |
|
| 6909 | + $starttimes = ''; |
|
| 6910 | + $endtimes = ''; |
|
| 6911 | + $repeat_days = ''; |
|
| 6912 | + $repeat_weeks = ''; |
|
| 6913 | + $event_recurring_dates = ''; |
|
| 6914 | + $repeat_x = ''; |
|
| 6915 | + $duration_x = ''; |
|
| 6916 | + $repeat_end_type = ''; |
|
| 6917 | + $max_repeat = ''; |
|
| 6918 | + $repeat_end = ''; |
|
| 6919 | 6919 | |
| 6920 | - if ($recurring_pkg && $is_recurring) {
|
|
| 6921 | - $repeat_type = $gd_post['recurring_type']; |
|
| 6920 | + if ($recurring_pkg && $is_recurring) {
|
|
| 6921 | + $repeat_type = $gd_post['recurring_type']; |
|
| 6922 | 6922 | |
| 6923 | - if ($repeat_type == 'custom') {
|
|
| 6924 | - $starttimes = !$all_day && !empty($gd_post['event_starttimes']) ? explode(",", $gd_post['event_starttimes']) : array();
|
|
| 6925 | - $endtimes = !$all_day && !empty($gd_post['event_endtimes']) ? explode(",", $gd_post['event_endtimes']) : array();
|
|
| 6923 | + if ($repeat_type == 'custom') {
|
|
| 6924 | + $starttimes = !$all_day && !empty($gd_post['event_starttimes']) ? explode(",", $gd_post['event_starttimes']) : array();
|
|
| 6925 | + $endtimes = !$all_day && !empty($gd_post['event_endtimes']) ? explode(",", $gd_post['event_endtimes']) : array();
|
|
| 6926 | 6926 | |
| 6927 | - if (!empty($starttimes) || !empty($endtimes)) {
|
|
| 6928 | - $different_times = true; |
|
| 6929 | - } |
|
| 6927 | + if (!empty($starttimes) || !empty($endtimes)) {
|
|
| 6928 | + $different_times = true; |
|
| 6929 | + } |
|
| 6930 | 6930 | |
| 6931 | - $recurring_dates = isset($gd_post['recurring_dates']) && $gd_post['recurring_dates'] != '' ? explode(",", $gd_post['recurring_dates']) : array();
|
|
| 6932 | - if (!empty($recurring_dates)) {
|
|
| 6933 | - $event_recurring_dates = array(); |
|
| 6931 | + $recurring_dates = isset($gd_post['recurring_dates']) && $gd_post['recurring_dates'] != '' ? explode(",", $gd_post['recurring_dates']) : array();
|
|
| 6932 | + if (!empty($recurring_dates)) {
|
|
| 6933 | + $event_recurring_dates = array(); |
|
| 6934 | 6934 | |
| 6935 | - foreach ($recurring_dates as $recurring_date) {
|
|
| 6936 | - $recurring_date = trim($recurring_date); |
|
| 6935 | + foreach ($recurring_dates as $recurring_date) {
|
|
| 6936 | + $recurring_date = trim($recurring_date); |
|
| 6937 | 6937 | |
| 6938 | - if ($recurring_date != '') {
|
|
| 6939 | - $event_recurring_dates[] = geodir_imex_get_date_ymd($recurring_date); |
|
| 6940 | - } |
|
| 6941 | - } |
|
| 6938 | + if ($recurring_date != '') {
|
|
| 6939 | + $event_recurring_dates[] = geodir_imex_get_date_ymd($recurring_date); |
|
| 6940 | + } |
|
| 6941 | + } |
|
| 6942 | 6942 | |
| 6943 | - $event_recurring_dates = array_unique($event_recurring_dates); |
|
| 6944 | - $event_recurring_dates = implode(",", $event_recurring_dates);
|
|
| 6945 | - } |
|
| 6946 | - } else {
|
|
| 6947 | - $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; |
|
| 6948 | - $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; |
|
| 6949 | - $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; |
|
| 6950 | - $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6943 | + $event_recurring_dates = array_unique($event_recurring_dates); |
|
| 6944 | + $event_recurring_dates = implode(",", $event_recurring_dates);
|
|
| 6945 | + } |
|
| 6946 | + } else {
|
|
| 6947 | + $duration_x = !empty( $gd_post['event_duration_days'] ) ? (int)$gd_post['event_duration_days'] : 1; |
|
| 6948 | + $repeat_x = !empty( $gd_post['recurring_interval'] ) ? (int)$gd_post['recurring_interval'] : 1; |
|
| 6949 | + $max_repeat = !empty( $gd_post['max_recurring_count'] ) ? (int)$gd_post['max_recurring_count'] : 1; |
|
| 6950 | + $repeat_end = !empty( $gd_post['recurring_end_date'] ) ? geodir_imex_get_date_ymd($gd_post['recurring_end_date']) : ''; |
|
| 6951 | 6951 | |
| 6952 | - $repeat_end_type = $repeat_end != '' ? 1 : 0; |
|
| 6953 | - $max_repeat = $repeat_end != '' ? '' : $max_repeat; |
|
| 6952 | + $repeat_end_type = $repeat_end != '' ? 1 : 0; |
|
| 6953 | + $max_repeat = $repeat_end != '' ? '' : $max_repeat; |
|
| 6954 | 6954 | |
| 6955 | - $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
|
|
| 6955 | + $week_days = array_flip(array('sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'));
|
|
| 6956 | 6956 | |
| 6957 | - $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6958 | - $repeat_days = array(); |
|
| 6959 | - if (!empty($a_repeat_days)) {
|
|
| 6960 | - foreach ($a_repeat_days as $repeat_day) {
|
|
| 6961 | - $repeat_day = geodir_strtolower(trim($repeat_day)); |
|
| 6957 | + $a_repeat_days = isset($gd_post['recurring_week_days']) && trim($gd_post['recurring_week_days'])!='' ? explode(',', trim($gd_post['recurring_week_days'])) : array();
|
|
| 6958 | + $repeat_days = array(); |
|
| 6959 | + if (!empty($a_repeat_days)) {
|
|
| 6960 | + foreach ($a_repeat_days as $repeat_day) {
|
|
| 6961 | + $repeat_day = geodir_strtolower(trim($repeat_day)); |
|
| 6962 | 6962 | |
| 6963 | - if ($repeat_day != '' && isset($week_days[$repeat_day])) {
|
|
| 6964 | - $repeat_days[] = $week_days[$repeat_day]; |
|
| 6965 | - } |
|
| 6966 | - } |
|
| 6963 | + if ($repeat_day != '' && isset($week_days[$repeat_day])) {
|
|
| 6964 | + $repeat_days[] = $week_days[$repeat_day]; |
|
| 6965 | + } |
|
| 6966 | + } |
|
| 6967 | 6967 | |
| 6968 | - $repeat_days = array_unique($repeat_days); |
|
| 6969 | - } |
|
| 6968 | + $repeat_days = array_unique($repeat_days); |
|
| 6969 | + } |
|
| 6970 | 6970 | |
| 6971 | - $a_repeat_weeks = isset($gd_post['recurring_week_nos']) && trim($gd_post['recurring_week_nos']) != '' ? explode(",", trim($gd_post['recurring_week_nos'])) : array();
|
|
| 6972 | - $repeat_weeks = array(); |
|
| 6973 | - if (!empty($a_repeat_weeks)) {
|
|
| 6974 | - foreach ($a_repeat_weeks as $repeat_week) {
|
|
| 6975 | - $repeat_weeks[] = (int)$repeat_week; |
|
| 6976 | - } |
|
| 6971 | + $a_repeat_weeks = isset($gd_post['recurring_week_nos']) && trim($gd_post['recurring_week_nos']) != '' ? explode(",", trim($gd_post['recurring_week_nos'])) : array();
|
|
| 6972 | + $repeat_weeks = array(); |
|
| 6973 | + if (!empty($a_repeat_weeks)) {
|
|
| 6974 | + foreach ($a_repeat_weeks as $repeat_week) {
|
|
| 6975 | + $repeat_weeks[] = (int)$repeat_week; |
|
| 6976 | + } |
|
| 6977 | 6977 | |
| 6978 | - $repeat_weeks = array_unique($repeat_weeks); |
|
| 6979 | - } |
|
| 6980 | - } |
|
| 6981 | - } |
|
| 6978 | + $repeat_weeks = array_unique($repeat_weeks); |
|
| 6979 | + } |
|
| 6980 | + } |
|
| 6981 | + } |
|
| 6982 | 6982 | |
| 6983 | - if (isset($gd_post['recurring_dates'])) {
|
|
| 6984 | - unset($gd_post['recurring_dates']); |
|
| 6985 | - } |
|
| 6983 | + if (isset($gd_post['recurring_dates'])) {
|
|
| 6984 | + unset($gd_post['recurring_dates']); |
|
| 6985 | + } |
|
| 6986 | 6986 | |
| 6987 | - $gd_post['is_recurring'] = $is_recurring; |
|
| 6988 | - $gd_post['event_date'] = $event_date; |
|
| 6989 | - $gd_post['event_start'] = $event_date; |
|
| 6990 | - $gd_post['event_end'] = $event_enddate; |
|
| 6991 | - $gd_post['all_day'] = $all_day; |
|
| 6992 | - $gd_post['starttime'] = $starttime; |
|
| 6993 | - $gd_post['endtime'] = $endtime; |
|
| 6987 | + $gd_post['is_recurring'] = $is_recurring; |
|
| 6988 | + $gd_post['event_date'] = $event_date; |
|
| 6989 | + $gd_post['event_start'] = $event_date; |
|
| 6990 | + $gd_post['event_end'] = $event_enddate; |
|
| 6991 | + $gd_post['all_day'] = $all_day; |
|
| 6992 | + $gd_post['starttime'] = $starttime; |
|
| 6993 | + $gd_post['endtime'] = $endtime; |
|
| 6994 | 6994 | |
| 6995 | - $gd_post['repeat_type'] = $repeat_type; |
|
| 6996 | - $gd_post['different_times'] = $different_times; |
|
| 6997 | - $gd_post['starttimes'] = $starttimes; |
|
| 6998 | - $gd_post['endtimes'] = $endtimes; |
|
| 6999 | - $gd_post['repeat_days'] = $repeat_days; |
|
| 7000 | - $gd_post['repeat_weeks'] = $repeat_weeks; |
|
| 7001 | - $gd_post['event_recurring_dates'] = $event_recurring_dates; |
|
| 7002 | - $gd_post['repeat_x'] = $repeat_x; |
|
| 7003 | - $gd_post['duration_x'] = $duration_x; |
|
| 7004 | - $gd_post['repeat_end_type'] = $repeat_end_type; |
|
| 7005 | - $gd_post['max_repeat'] = $max_repeat; |
|
| 7006 | - $gd_post['repeat_end'] = $repeat_end; |
|
| 7007 | - |
|
| 7008 | - return $gd_post; |
|
| 6995 | + $gd_post['repeat_type'] = $repeat_type; |
|
| 6996 | + $gd_post['different_times'] = $different_times; |
|
| 6997 | + $gd_post['starttimes'] = $starttimes; |
|
| 6998 | + $gd_post['endtimes'] = $endtimes; |
|
| 6999 | + $gd_post['repeat_days'] = $repeat_days; |
|
| 7000 | + $gd_post['repeat_weeks'] = $repeat_weeks; |
|
| 7001 | + $gd_post['event_recurring_dates'] = $event_recurring_dates; |
|
| 7002 | + $gd_post['repeat_x'] = $repeat_x; |
|
| 7003 | + $gd_post['duration_x'] = $duration_x; |
|
| 7004 | + $gd_post['repeat_end_type'] = $repeat_end_type; |
|
| 7005 | + $gd_post['max_repeat'] = $max_repeat; |
|
| 7006 | + $gd_post['repeat_end'] = $repeat_end; |
|
| 7007 | + |
|
| 7008 | + return $gd_post; |
|
| 7009 | 7009 | } |
| 7010 | 7010 | |
| 7011 | 7011 | /** |
@@ -7077,12 +7077,12 @@ discard block |
||
| 7077 | 7077 | * @return Original element id. |
| 7078 | 7078 | */ |
| 7079 | 7079 | function geodir_imex_original_post_id($element_id, $element_type) {
|
| 7080 | - global $sitepress; |
|
| 7080 | + global $sitepress; |
|
| 7081 | 7081 | |
| 7082 | - $original_element_id = $sitepress->get_original_element_id($element_id, $element_type); |
|
| 7083 | - $element_id = $element_id != $original_element_id ? $original_element_id : ''; |
|
| 7082 | + $original_element_id = $sitepress->get_original_element_id($element_id, $element_type); |
|
| 7083 | + $element_id = $element_id != $original_element_id ? $original_element_id : ''; |
|
| 7084 | 7084 | |
| 7085 | - return $element_id; |
|
| 7085 | + return $element_id; |
|
| 7086 | 7086 | } |
| 7087 | 7087 | |
| 7088 | 7088 | /* |
@@ -7162,15 +7162,15 @@ discard block |
||
| 7162 | 7162 | * @global object $sitepress Sitepress WPML object. |
| 7163 | 7163 | */ |
| 7164 | 7164 | function geodir_wpml_permalink_setting_notice() {
|
| 7165 | - if (geodir_is_wpml()) {
|
|
| 7166 | - global $sitepress; |
|
| 7167 | - $current_language = $sitepress->get_current_language(); |
|
| 7168 | - $default_language = $sitepress->get_default_language(); |
|
| 7169 | - if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 7170 | - ?> |
|
| 7165 | + if (geodir_is_wpml()) {
|
|
| 7166 | + global $sitepress; |
|
| 7167 | + $current_language = $sitepress->get_current_language(); |
|
| 7168 | + $default_language = $sitepress->get_default_language(); |
|
| 7169 | + if ($current_language != 'all' && $current_language != $default_language) {
|
|
| 7170 | + ?> |
|
| 7171 | 7171 | <div class="updated error notice-success" id="message"><p style="color:red"><strong><?php _e('Saving GeoDirectory pages settings on a different language breaks pages settings. Try to save after switching to default language.', 'geodirectory');?></strong></p></div>
|
| 7172 | 7172 | <?php |
| 7173 | - } |
|
| 7174 | - } |
|
| 7173 | + } |
|
| 7174 | + } |
|
| 7175 | 7175 | } |
| 7176 | 7176 | ?> |
| 7177 | 7177 | \ No newline at end of file |
@@ -1639,6 +1639,7 @@ |
||
| 1639 | 1639 | * @since 1.0.0 |
| 1640 | 1640 | * @package GeoDirectory |
| 1641 | 1641 | * @global object $current_user Current user object. |
| 1642 | + * @param string|null $input |
|
| 1642 | 1643 | * @return array Returns parsed data as array. |
| 1643 | 1644 | */ |
| 1644 | 1645 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") |
@@ -1,12 +1,12 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * GeoDirectory Admin. |
|
| 4 | - * |
|
| 5 | - * Main admin file which loads all settings panels and sets up admin menus. |
|
| 6 | - * |
|
| 7 | - * @since 1.0.0 |
|
| 8 | - * @package GeoDirectory |
|
| 9 | - */ |
|
| 3 | + * GeoDirectory Admin. |
|
| 4 | + * |
|
| 5 | + * Main admin file which loads all settings panels and sets up admin menus. |
|
| 6 | + * |
|
| 7 | + * @since 1.0.0 |
|
| 8 | + * @package GeoDirectory |
|
| 9 | + */ |
|
| 10 | 10 | |
| 11 | 11 | add_action('admin_init', 'geodir_admin_init');
|
| 12 | 12 | if (!function_exists('geodir_admin_init')) {
|
@@ -85,11 +85,11 @@ discard block |
||
| 85 | 85 | {
|
| 86 | 86 | global $pagenow; |
| 87 | 87 | |
| 88 | - // Get the current post type |
|
| 89 | - $post_type = geodir_admin_current_post_type(); |
|
| 90 | - $geodir_post_types = geodir_get_posttypes(); |
|
| 88 | + // Get the current post type |
|
| 89 | + $post_type = geodir_admin_current_post_type(); |
|
| 90 | + $geodir_post_types = geodir_get_posttypes(); |
|
| 91 | 91 | |
| 92 | - if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
|
|
| 92 | + if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
|
|
| 93 | 93 | add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
|
| 94 | 94 | add_action('admin_enqueue_scripts', 'geodir_admin_styles');
|
| 95 | 95 | } |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | |
| 427 | 427 | |
| 428 | 428 | foreach ($sort_options as $key => $val) {
|
| 429 | - $val = stripslashes_deep($val); // strip slashes |
|
| 429 | + $val = stripslashes_deep($val); // strip slashes |
|
| 430 | 430 | |
| 431 | 431 | $check_html_variable = $wpdb->get_var( |
| 432 | 432 | $wpdb->prepare( |
@@ -1546,20 +1546,20 @@ discard block |
||
| 1546 | 1546 | function geodir_diagnose_load_db_language() {
|
| 1547 | 1547 | global $wpdb; |
| 1548 | 1548 | |
| 1549 | - $is_error_during_diagnose = geodirectory_load_db_language(); |
|
| 1549 | + $is_error_during_diagnose = geodirectory_load_db_language(); |
|
| 1550 | 1550 | |
| 1551 | 1551 | $output_str = ''; |
| 1552 | 1552 | |
| 1553 | 1553 | if ($is_error_during_diagnose) {
|
| 1554 | 1554 | $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
|
| 1555 | - $info_div_class = "geodir_problem_info"; |
|
| 1555 | + $info_div_class = "geodir_problem_info"; |
|
| 1556 | 1556 | } else {
|
| 1557 | 1557 | $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
|
| 1558 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1558 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1559 | 1559 | $fix_button_txt = ''; |
| 1560 | 1560 | } |
| 1561 | 1561 | |
| 1562 | - echo "<ul class='$info_div_class'>"; |
|
| 1562 | + echo "<ul class='$info_div_class'>"; |
|
| 1563 | 1563 | echo $output_str; |
| 1564 | 1564 | echo $fix_button_txt; |
| 1565 | 1565 | echo "</ul>"; |
@@ -1684,7 +1684,7 @@ discard block |
||
| 1684 | 1684 | $uploads = wp_upload_dir(); |
| 1685 | 1685 | ini_set('auto_detect_line_endings', true);
|
| 1686 | 1686 | |
| 1687 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 1687 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 1688 | 1688 | |
| 1689 | 1689 | $task = isset($_POST['task']) ? $_POST['task'] : ''; |
| 1690 | 1690 | $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
@@ -1884,8 +1884,8 @@ discard block |
||
| 1884 | 1884 | $post_longitude = addslashes($buffer[$c]); |
| 1885 | 1885 | } |
| 1886 | 1886 | |
| 1887 | - // Post status |
|
| 1888 | - if ($customKeyarray[$c] == 'post_status') {
|
|
| 1887 | + // Post status |
|
| 1888 | + if ($customKeyarray[$c] == 'post_status') {
|
|
| 1889 | 1889 | $post_status = sanitize_key( $buffer[$c] ); |
| 1890 | 1890 | } |
| 1891 | 1891 | } |
@@ -1902,10 +1902,10 @@ discard block |
||
| 1902 | 1902 | } |
| 1903 | 1903 | } |
| 1904 | 1904 | |
| 1905 | - // Default post status |
|
| 1906 | - $default_status = 'publish'; |
|
| 1907 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 1908 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 1905 | + // Default post status |
|
| 1906 | + $default_status = 'publish'; |
|
| 1907 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 1908 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 1909 | 1909 | |
| 1910 | 1910 | $my_post['post_title'] = $post_title; |
| 1911 | 1911 | $my_post['post_content'] = $post_desc; |
@@ -2128,5 +2128,5 @@ discard block |
||
| 2128 | 2128 | add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); |
| 2129 | 2129 | |
| 2130 | 2130 | if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
| 2131 | - add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
|
|
| 2131 | + add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
|
|
| 2132 | 2132 | } |
| 2133 | 2133 | \ No newline at end of file |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | function geodir_get_admin_option_form($current_tab) |
| 64 | 64 | {
|
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php |
|
| 65 | + geodir_admin_option_form($current_tab); // defined in admin template tags.php |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
|
| 71 | 71 | add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
|
| 72 | 72 | add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
|
| 73 | -add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
|
|
| 73 | +add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
|
|
| 74 | 74 | |
| 75 | 75 | //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
|
| 76 | 76 | |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | -add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 239 | +add_action('save_post', 'geodir_post_information_save', 10, 2);
|
|
| 240 | 240 | |
| 241 | 241 | |
| 242 | 242 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | |
| 264 | 264 | $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
| 265 | 265 | |
| 266 | - if(!empty($gd_taxonomy)) {
|
|
| 266 | + if (!empty($gd_taxonomy)) {
|
|
| 267 | 267 | foreach ($gd_taxonomy as $tax) {
|
| 268 | 268 | |
| 269 | 269 | remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | global $wpdb; |
| 417 | 417 | $listing_type = ($_REQUEST['listing_type'] != '') ? $_REQUEST['listing_type'] : 'gd_place'; |
| 418 | 418 | ?> |
| 419 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
| 419 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
| 420 | 420 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo $_REQUEST['subtab']; ?>"/> |
| 421 | 421 | <ul> |
| 422 | 422 | |
@@ -441,11 +441,11 @@ discard block |
||
| 441 | 441 | |
| 442 | 442 | |
| 443 | 443 | ?> |
| 444 | - <li <?php echo $display;?>> |
|
| 445 | - <a id="gt-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" |
|
| 446 | - title="<?php echo $val['site_title'];?>" |
|
| 447 | - class="gt-draggable-form-items gt-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" |
|
| 448 | - href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory');?></a> |
|
| 444 | + <li <?php echo $display; ?>> |
|
| 445 | + <a id="gt-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>" |
|
| 446 | + title="<?php echo $val['site_title']; ?>" |
|
| 447 | + class="gt-draggable-form-items gt-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" |
|
| 448 | + href="javascript:void(0);"><b></b><?php _e($val['site_title'], 'geodirectory'); ?></a> |
|
| 449 | 449 | </li><?php |
| 450 | 450 | |
| 451 | 451 | } |
@@ -513,40 +513,40 @@ discard block |
||
| 513 | 513 | |
| 514 | 514 | $listing_type = ($_REQUEST['listing_type'] != '') ? $_REQUEST['listing_type'] : 'gd_place'; |
| 515 | 515 | ?> |
| 516 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
| 516 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
| 517 | 517 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo $_REQUEST['subtab']; ?>"/> |
| 518 | 518 | <ul class="full"> |
| 519 | 519 | <li><a id="gt-fieldset" class="gt-draggable-form-items gt-fieldset" |
| 520 | - href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory');?></a></li>
|
|
| 520 | + href="javascript:void(0);"><?php _e('Fieldset', 'geodirectory'); ?></a></li>
|
|
| 521 | 521 | </ul> |
| 522 | 522 | <ul> |
| 523 | 523 | <li><a id="gt-text" class="gt-draggable-form-items gt-text" |
| 524 | - href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory');?></a></li>
|
|
| 524 | + href="javascript:void(0);"><b></b><?php _e('Text', 'geodirectory'); ?></a></li>
|
|
| 525 | 525 | <li><a id="gt-datepicker" class="gt-draggable-form-items gt-datepicker" |
| 526 | - href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory');?></a></li>
|
|
| 526 | + href="javascript:void(0);"><b></b><?php _e('Date', 'geodirectory'); ?></a></li>
|
|
| 527 | 527 | <li><a id="gt-textarea" class="gt-draggable-form-items gt-textarea" |
| 528 | - href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory');?></a></li>
|
|
| 528 | + href="javascript:void(0);"><b></b><?php _e('Textarea', 'geodirectory'); ?></a></li>
|
|
| 529 | 529 | <li><a id="gt-time" class="gt-draggable-form-items gt-time" |
| 530 | - href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory');?></a></li>
|
|
| 530 | + href="javascript:void(0);"><b></b><?php _e('Time', 'geodirectory'); ?></a></li>
|
|
| 531 | 531 | <li><a id="gt-checkbox" class="gt-draggable-form-items gt-checkbox" |
| 532 | - href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory');?></a></li>
|
|
| 532 | + href="javascript:void(0);"><b></b><?php _e('Checkbox', 'geodirectory'); ?></a></li>
|
|
| 533 | 533 | <li><a id="gt-phone" class="gt-draggable-form-items gt-phone" |
| 534 | - href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory');?></a></li>
|
|
| 534 | + href="javascript:void(0);"><b></b><?php _e('Phone', 'geodirectory'); ?></a></li>
|
|
| 535 | 535 | <li><a id="gt-radio" class="gt-draggable-form-items gt-radio" |
| 536 | - href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory');?></a></li>
|
|
| 536 | + href="javascript:void(0);"><b></b><?php _e('Radio', 'geodirectory'); ?></a></li>
|
|
| 537 | 537 | <li><a id="gt-email" class="gt-draggable-form-items gt-email" |
| 538 | - href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory');?></a></li>
|
|
| 538 | + href="javascript:void(0);"><b></b><?php _e('Email', 'geodirectory'); ?></a></li>
|
|
| 539 | 539 | <li><a id="gt-select" class="gt-draggable-form-items gt-select" |
| 540 | - href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory');?></a></li>
|
|
| 541 | - <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory');?></a></li>-->
|
|
| 540 | + href="javascript:void(0);"><b></b><?php _e('Select', 'geodirectory'); ?></a></li>
|
|
| 541 | + <!--<li><a id="gt-taxonomy" class="gt-draggable-form-items gt-select" href="javascript:void(0);"><b></b><?php _e('Taxonomy', 'geodirectory'); ?></a></li>-->
|
|
| 542 | 542 | <li><a id="gt-multiselect" class="gt-draggable-form-items gt-multiselect" |
| 543 | - href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory');?></a></li>
|
|
| 543 | + href="javascript:void(0);"><b></b><?php _e('Multi Select', 'geodirectory'); ?></a></li>
|
|
| 544 | 544 | <li><a id="gt-url" class="gt-draggable-form-items gt-url" |
| 545 | - href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory');?></a></li>
|
|
| 545 | + href="javascript:void(0);"><b></b><?php _e('URL', 'geodirectory'); ?></a></li>
|
|
| 546 | 546 | <li><a id="gt-html" class="gt-draggable-form-items gt-html" |
| 547 | - href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory');?></a></li>
|
|
| 547 | + href="javascript:void(0);"><b></b><?php _e('HTML', 'geodirectory'); ?></a></li>
|
|
| 548 | 548 | <li><a id="gt-file" class="gt-draggable-form-items gt-file" |
| 549 | - href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory');?></a></li>
|
|
| 549 | + href="javascript:void(0);"><b></b><?php _e('File Upload', 'geodirectory'); ?></a></li>
|
|
| 550 | 550 | |
| 551 | 551 | </ul> |
| 552 | 552 | |
@@ -663,7 +663,7 @@ discard block |
||
| 663 | 663 | |
| 664 | 664 | switch ($sub_tab) {
|
| 665 | 665 | case 'custom_fields': |
| 666 | - $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type));;
|
|
| 666 | + $note = sprintf(__('Click on any box below to add a field of that type on add %s listing form. You must be use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type)); ;
|
|
| 667 | 667 | break; |
| 668 | 668 | |
| 669 | 669 | case 'sorting_options': |
@@ -717,7 +717,7 @@ discard block |
||
| 717 | 717 | |
| 718 | 718 | switch ($sub_tab) {
|
| 719 | 719 | case 'custom_fields': |
| 720 | - $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type));;
|
|
| 720 | + $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type)); ;
|
|
| 721 | 721 | break; |
| 722 | 722 | |
| 723 | 723 | case 'sorting_options': |
@@ -816,13 +816,13 @@ discard block |
||
| 816 | 816 | $filter_arr['is_error_during_diagnose'] = true; |
| 817 | 817 | |
| 818 | 818 | if ($fix) {
|
| 819 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
|
|
| 820 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
|
|
| 819 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak"); // get backup table count
|
|
| 820 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table"); // get new table count
|
|
| 821 | 821 | |
| 822 | 822 | if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
|
| 823 | 823 | //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
|
| 824 | 824 | |
| 825 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
|
|
| 825 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2"); // rename bak table to new table
|
|
| 826 | 826 | |
| 827 | 827 | if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
| 828 | 828 | $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
|
@@ -832,8 +832,8 @@ discard block |
||
| 832 | 832 | |
| 833 | 833 | } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
|
| 834 | 834 | |
| 835 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
|
|
| 836 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
|
|
| 835 | + $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2"); // rename new table to bak2
|
|
| 836 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table"); // rename bak table to new table
|
|
| 837 | 837 | |
| 838 | 838 | if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
| 839 | 839 | $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
|
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | |
| 844 | 844 | } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
|
| 845 | 845 | |
| 846 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
|
|
| 846 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2"); // rename ms_bak table to ms_bak2
|
|
| 847 | 847 | |
| 848 | 848 | if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
| 849 | 849 | $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
|
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
|
| 1028 | 1028 | foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
|
| 1029 | 1029 | if (is_numeric($cat_part)) {
|
| 1030 | - $raw_cats[] = (int)$cat_part; |
|
| 1030 | + $raw_cats[] = (int) $cat_part; |
|
| 1031 | 1031 | } |
| 1032 | 1032 | } |
| 1033 | 1033 | |
@@ -1337,9 +1337,9 @@ discard block |
||
| 1337 | 1337 | ////////////////////////////////// |
| 1338 | 1338 | $option_value = get_option('geodir_home_page');
|
| 1339 | 1339 | $page = get_post($option_value); |
| 1340 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1340 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1341 | 1341 | |
| 1342 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1342 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1343 | 1343 | $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
|
| 1344 | 1344 | else {
|
| 1345 | 1345 | $is_error_during_diagnose = true; |
@@ -1362,9 +1362,9 @@ discard block |
||
| 1362 | 1362 | ////////////////////////////////// |
| 1363 | 1363 | $option_value = get_option('geodir_add_listing_page');
|
| 1364 | 1364 | $page = get_post($option_value); |
| 1365 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1365 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1366 | 1366 | |
| 1367 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1367 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1368 | 1368 | $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
|
| 1369 | 1369 | else {
|
| 1370 | 1370 | $is_error_during_diagnose = true; |
@@ -1388,9 +1388,9 @@ discard block |
||
| 1388 | 1388 | ////////////////////////////////// |
| 1389 | 1389 | $option_value = get_option('geodir_preview_page');
|
| 1390 | 1390 | $page = get_post($option_value); |
| 1391 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1391 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1392 | 1392 | |
| 1393 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1393 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1394 | 1394 | $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
|
| 1395 | 1395 | else {
|
| 1396 | 1396 | $is_error_during_diagnose = true; |
@@ -1413,9 +1413,9 @@ discard block |
||
| 1413 | 1413 | ////////////////////////////////// |
| 1414 | 1414 | $option_value = get_option('geodir_success_page');
|
| 1415 | 1415 | $page = get_post($option_value); |
| 1416 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1416 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1417 | 1417 | |
| 1418 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1418 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1419 | 1419 | $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
|
| 1420 | 1420 | else {
|
| 1421 | 1421 | $is_error_during_diagnose = true; |
@@ -1438,9 +1438,9 @@ discard block |
||
| 1438 | 1438 | ////////////////////////////////// |
| 1439 | 1439 | $option_value = get_option('geodir_info_page');
|
| 1440 | 1440 | $page = get_post($option_value); |
| 1441 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1441 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1442 | 1442 | |
| 1443 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1443 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1444 | 1444 | $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
|
| 1445 | 1445 | else {
|
| 1446 | 1446 | $is_error_during_diagnose = true; |
@@ -1463,9 +1463,9 @@ discard block |
||
| 1463 | 1463 | ////////////////////////////////// |
| 1464 | 1464 | $option_value = get_option('geodir_login_page');
|
| 1465 | 1465 | $page = get_post($option_value); |
| 1466 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1466 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1467 | 1467 | |
| 1468 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1468 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1469 | 1469 | $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
|
| 1470 | 1470 | else {
|
| 1471 | 1471 | $is_error_during_diagnose = true; |
@@ -1488,9 +1488,9 @@ discard block |
||
| 1488 | 1488 | ////////////////////////////////// |
| 1489 | 1489 | $option_value = get_option('geodir_location_page');
|
| 1490 | 1490 | $page = get_post($option_value); |
| 1491 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1491 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1492 | 1492 | |
| 1493 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1493 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1494 | 1494 | $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
|
| 1495 | 1495 | else {
|
| 1496 | 1496 | $is_error_during_diagnose = true; |
@@ -1508,13 +1508,13 @@ discard block |
||
| 1508 | 1508 | /* Diagnose Location Page Ends */ |
| 1509 | 1509 | //////////////////////////////// |
| 1510 | 1510 | |
| 1511 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
|
|
| 1511 | + $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
|
|
| 1512 | 1512 | /** |
| 1513 | 1513 | * This action is called at the end of the GD Tools page check function. |
| 1514 | 1514 | * |
| 1515 | 1515 | * @since 1.5.2 |
| 1516 | 1516 | */ |
| 1517 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
|
|
| 1517 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
|
|
| 1518 | 1518 | |
| 1519 | 1519 | $output_str = $page_chk_arr['output_str']; |
| 1520 | 1520 | $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
@@ -1711,7 +1711,7 @@ discard block |
||
| 1711 | 1711 | |
| 1712 | 1712 | if (($handle = fopen($target_path, "r")) !== FALSE) {
|
| 1713 | 1713 | while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
|
| 1714 | - if(is_array($data) && !empty($data)) {
|
|
| 1714 | + if (is_array($data) && !empty($data)) {
|
|
| 1715 | 1715 | $file[] = '"' . implode('","', $data) . '"';
|
| 1716 | 1716 | } |
| 1717 | 1717 | } |
@@ -1886,7 +1886,7 @@ discard block |
||
| 1886 | 1886 | |
| 1887 | 1887 | // Post status |
| 1888 | 1888 | if ($customKeyarray[$c] == 'post_status') {
|
| 1889 | - $post_status = sanitize_key( $buffer[$c] ); |
|
| 1889 | + $post_status = sanitize_key($buffer[$c]); |
|
| 1890 | 1890 | } |
| 1891 | 1891 | } |
| 1892 | 1892 | |
@@ -1904,8 +1904,8 @@ discard block |
||
| 1904 | 1904 | |
| 1905 | 1905 | // Default post status |
| 1906 | 1906 | $default_status = 'publish'; |
| 1907 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 1908 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 1907 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; |
|
| 1908 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; |
|
| 1909 | 1909 | |
| 1910 | 1910 | $my_post['post_title'] = $post_title; |
| 1911 | 1911 | $my_post['post_content'] = $post_desc; |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | $payment_info = array(); |
| 1950 | 1950 | $package_info = array(); |
| 1951 | 1951 | |
| 1952 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 1952 | + $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 1953 | 1953 | $package_id = ''; |
| 1954 | 1954 | if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
| 1955 | 1955 | $package_id = $gd_post_info['package_id']; |
@@ -2050,11 +2050,11 @@ discard block |
||
| 2050 | 2050 | } |
| 2051 | 2051 | |
| 2052 | 2052 | // Add the tab in left sidebar menu fro import & export page. |
| 2053 | -add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 ); |
|
| 2053 | +add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
|
|
| 2054 | 2054 | |
| 2055 | 2055 | // Handle ajax request for impot/export. |
| 2056 | -add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' ); |
|
| 2057 | -add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' ); |
|
| 2056 | +add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
|
|
| 2057 | +add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
|
|
| 2058 | 2058 | |
| 2059 | 2059 | |
| 2060 | 2060 | /** |
@@ -2065,40 +2065,40 @@ discard block |
||
| 2065 | 2065 | * @param $post_id int $post_id The post ID of the post being saved. |
| 2066 | 2066 | * @param $post object $post The post object of the post being saved. |
| 2067 | 2067 | */ |
| 2068 | -function geodir_update_location_prefix($post_id,$post){
|
|
| 2069 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
|
|
| 2070 | - update_option('geodir_location_prefix',$post->post_name);
|
|
| 2068 | +function geodir_update_location_prefix($post_id, $post) {
|
|
| 2069 | + if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
|
|
| 2070 | + update_option('geodir_location_prefix', $post->post_name);
|
|
| 2071 | 2071 | } |
| 2072 | 2072 | |
| 2073 | 2073 | } |
| 2074 | 2074 | |
| 2075 | -add_action('save_post', 'geodir_update_location_prefix',10,2);
|
|
| 2075 | +add_action('save_post', 'geodir_update_location_prefix', 10, 2);
|
|
| 2076 | 2076 | |
| 2077 | -add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' ); |
|
| 2077 | +add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
|
|
| 2078 | 2078 | |
| 2079 | -function geodir_ga_callback(){
|
|
| 2079 | +function geodir_ga_callback() {
|
|
| 2080 | 2080 | |
| 2081 | -if(isset($_REQUEST['code']) && $_REQUEST['code']) {
|
|
| 2081 | +if (isset($_REQUEST['code']) && $_REQUEST['code']) {
|
|
| 2082 | 2082 | $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
| 2083 | - $code = "code=".$_REQUEST['code']; |
|
| 2083 | + $code = "code=" . $_REQUEST['code']; |
|
| 2084 | 2084 | $grant_type = "&grant_type=authorization_code"; |
| 2085 | 2085 | $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
| 2086 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2087 | - $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
|
|
| 2086 | + $client_id = "&client_id=" . get_option('geodir_ga_client_id');
|
|
| 2087 | + $client_secret = "&client_secret=" . get_option('geodir_ga_client_secret');
|
|
| 2088 | 2088 | |
| 2089 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
| 2089 | + $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id . $client_secret; |
|
| 2090 | 2090 | |
| 2091 | 2091 | $response = wp_remote_post($auth_url, array('timeout' => 15));
|
| 2092 | 2092 | |
| 2093 | 2093 | //print_r($response); |
| 2094 | 2094 | |
| 2095 | - $error_msg = __('Something went wrong','geodirectory');
|
|
| 2096 | - if(!empty($response['response']['code']) && $response['response']['code']==200){
|
|
| 2095 | + $error_msg = __('Something went wrong', 'geodirectory');
|
|
| 2096 | + if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
|
|
| 2097 | 2097 | |
| 2098 | 2098 | $parts = json_decode($response['body']); |
| 2099 | 2099 | //print_r($parts); |
| 2100 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
|
|
| 2101 | - else{
|
|
| 2100 | + if (!isset($parts->access_token)) {echo $error_msg . " - #1"; exit; }
|
|
| 2101 | + else {
|
|
| 2102 | 2102 | |
| 2103 | 2103 | update_option('gd_ga_access_token', $parts->access_token);
|
| 2104 | 2104 | update_option('gd_ga_refresh_token', $parts->refresh_token);
|
@@ -2107,25 +2107,25 @@ discard block |
||
| 2107 | 2107 | |
| 2108 | 2108 | |
| 2109 | 2109 | } |
| 2110 | - elseif(!empty($response['response']['code'])) {
|
|
| 2110 | + elseif (!empty($response['response']['code'])) {
|
|
| 2111 | 2111 | $parts = json_decode($response['body']); |
| 2112 | 2112 | |
| 2113 | - if(isset($parts->error)){
|
|
| 2114 | - echo $parts->error.": ".$parts->error_description;exit; |
|
| 2115 | - }else{
|
|
| 2116 | - echo $error_msg." - #2";exit; |
|
| 2113 | + if (isset($parts->error)) {
|
|
| 2114 | + echo $parts->error . ": " . $parts->error_description; exit; |
|
| 2115 | + } else {
|
|
| 2116 | + echo $error_msg . " - #2"; exit; |
|
| 2117 | 2117 | } |
| 2118 | 2118 | |
| 2119 | - }else{
|
|
| 2119 | + } else {
|
|
| 2120 | 2120 | |
| 2121 | - echo $error_msg." - #3";exit; |
|
| 2121 | + echo $error_msg . " - #3"; exit; |
|
| 2122 | 2122 | |
| 2123 | 2123 | } |
| 2124 | 2124 | } |
| 2125 | 2125 | exit; |
| 2126 | 2126 | } |
| 2127 | 2127 | |
| 2128 | -add_filter( 'icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4 ); |
|
| 2128 | +add_filter('icl_make_duplicate', 'geodir_icl_make_duplicate', 11, 4);
|
|
| 2129 | 2129 | |
| 2130 | 2130 | if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
| 2131 | 2131 | add_action('geodir_before_admin_panel', 'geodir_wpml_permalink_setting_notice');
|
@@ -24,8 +24,11 @@ discard block |
||
| 24 | 24 | global $current_tab; |
| 25 | 25 | geodir_redirect_to_admin_panel_on_installed(); |
| 26 | 26 | $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; |
| 27 | - if (!(isset($_REQUEST['action']))) // this will avoide Ajax requests |
|
| 28 | - geodir_handle_option_form_submit($current_tab); // located in admin function.php |
|
| 27 | + if (!(isset($_REQUEST['action']))) { |
|
| 28 | + // this will avoide Ajax requests |
|
| 29 | + geodir_handle_option_form_submit($current_tab); |
|
| 30 | + } |
|
| 31 | + // located in admin function.php |
|
| 29 | 32 | /** |
| 30 | 33 | * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. |
| 31 | 34 | * |
@@ -313,8 +316,9 @@ discard block |
||
| 313 | 316 | if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
|
| 314 | 317 | |
| 315 | 318 | foreach ($notification as $key => $value) {
|
| 316 | - if ($value['type'] == 'textarea') |
|
| 317 | - $notification[$key]['type'] = 'editor'; |
|
| 319 | + if ($value['type'] == 'textarea') { |
|
| 320 | + $notification[$key]['type'] = 'editor'; |
|
| 321 | + } |
|
| 318 | 322 | } |
| 319 | 323 | |
| 320 | 324 | } |
@@ -339,8 +343,9 @@ discard block |
||
| 339 | 343 | if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
|
| 340 | 344 | |
| 341 | 345 | foreach ($design_setting as $key => $value) {
|
| 342 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
| 343 | - $design_setting[$key]['type'] = 'editor'; |
|
| 346 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') { |
|
| 347 | + $design_setting[$key]['type'] = 'editor'; |
|
| 348 | + } |
|
| 344 | 349 | } |
| 345 | 350 | |
| 346 | 351 | } |
@@ -436,8 +441,9 @@ discard block |
||
| 436 | 441 | ); |
| 437 | 442 | |
| 438 | 443 | $display = ''; |
| 439 | - if ($check_html_variable) |
|
| 440 | - $display = ' style="display:none;"'; |
|
| 444 | + if ($check_html_variable) { |
|
| 445 | + $display = ' style="display:none;"'; |
|
| 446 | + } |
|
| 441 | 447 | |
| 442 | 448 | |
| 443 | 449 | ?> |
@@ -744,8 +750,9 @@ discard block |
||
| 744 | 750 | |
| 745 | 751 | if (!get_option('geodir_remove_unnecessary_fields')) {
|
| 746 | 752 | |
| 747 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
|
|
| 748 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
|
|
| 753 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'")) { |
|
| 754 | + $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`"); |
|
| 755 | + } |
|
| 749 | 756 | |
| 750 | 757 | update_option('geodir_remove_unnecessary_fields', '1');
|
| 751 | 758 | |
@@ -771,15 +778,17 @@ discard block |
||
| 771 | 778 | $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
| 772 | 779 | switch ($geodir_admin_ajax_action) {
|
| 773 | 780 | case 'diagnosis' : |
| 774 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 775 | - $diagnose_this = $_REQUEST['diagnose_this']; |
|
| 781 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
|
| 782 | + $diagnose_this = $_REQUEST['diagnose_this']; |
|
| 783 | + } |
|
| 776 | 784 | call_user_func('geodir_diagnose_' . $diagnose_this);
|
| 777 | 785 | exit(); |
| 778 | 786 | break; |
| 779 | 787 | |
| 780 | 788 | case 'diagnosis-fix' : |
| 781 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 782 | - $diagnose_this = $_REQUEST['diagnose_this']; |
|
| 789 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') { |
|
| 790 | + $diagnose_this = $_REQUEST['diagnose_this']; |
|
| 791 | + } |
|
| 783 | 792 | call_user_func('geodir_diagnose_' . $diagnose_this);
|
| 784 | 793 | exit(); |
| 785 | 794 | break; |
@@ -1337,11 +1346,11 @@ discard block |
||
| 1337 | 1346 | ////////////////////////////////// |
| 1338 | 1347 | $option_value = get_option('geodir_home_page');
|
| 1339 | 1348 | $page = get_post($option_value); |
| 1340 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1349 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
|
|
| 1341 | 1350 | |
| 1342 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1343 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1344 | - else {
|
|
| 1351 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
| 1352 | + $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; |
|
| 1353 | + } else {
|
|
| 1345 | 1354 | $is_error_during_diagnose = true; |
| 1346 | 1355 | $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
|
| 1347 | 1356 | if ($fix) {
|
@@ -1362,11 +1371,11 @@ discard block |
||
| 1362 | 1371 | ////////////////////////////////// |
| 1363 | 1372 | $option_value = get_option('geodir_add_listing_page');
|
| 1364 | 1373 | $page = get_post($option_value); |
| 1365 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1374 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
|
|
| 1366 | 1375 | |
| 1367 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1368 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1369 | - else {
|
|
| 1376 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
| 1377 | + $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; |
|
| 1378 | + } else {
|
|
| 1370 | 1379 | $is_error_during_diagnose = true; |
| 1371 | 1380 | $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
|
| 1372 | 1381 | if ($fix) {
|
@@ -1388,11 +1397,11 @@ discard block |
||
| 1388 | 1397 | ////////////////////////////////// |
| 1389 | 1398 | $option_value = get_option('geodir_preview_page');
|
| 1390 | 1399 | $page = get_post($option_value); |
| 1391 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1400 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
|
|
| 1392 | 1401 | |
| 1393 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1394 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1395 | - else {
|
|
| 1402 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
| 1403 | + $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; |
|
| 1404 | + } else {
|
|
| 1396 | 1405 | $is_error_during_diagnose = true; |
| 1397 | 1406 | $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
|
| 1398 | 1407 | if ($fix) {
|
@@ -1413,11 +1422,11 @@ discard block |
||
| 1413 | 1422 | ////////////////////////////////// |
| 1414 | 1423 | $option_value = get_option('geodir_success_page');
|
| 1415 | 1424 | $page = get_post($option_value); |
| 1416 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1425 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
|
|
| 1417 | 1426 | |
| 1418 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1419 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1420 | - else {
|
|
| 1427 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
| 1428 | + $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; |
|
| 1429 | + } else {
|
|
| 1421 | 1430 | $is_error_during_diagnose = true; |
| 1422 | 1431 | $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
|
| 1423 | 1432 | if ($fix) {
|
@@ -1438,11 +1447,11 @@ discard block |
||
| 1438 | 1447 | ////////////////////////////////// |
| 1439 | 1448 | $option_value = get_option('geodir_info_page');
|
| 1440 | 1449 | $page = get_post($option_value); |
| 1441 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1450 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
|
|
| 1442 | 1451 | |
| 1443 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1444 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1445 | - else {
|
|
| 1452 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
| 1453 | + $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; |
|
| 1454 | + } else {
|
|
| 1446 | 1455 | $is_error_during_diagnose = true; |
| 1447 | 1456 | $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
|
| 1448 | 1457 | if ($fix) {
|
@@ -1463,11 +1472,11 @@ discard block |
||
| 1463 | 1472 | ////////////////////////////////// |
| 1464 | 1473 | $option_value = get_option('geodir_login_page');
|
| 1465 | 1474 | $page = get_post($option_value); |
| 1466 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1475 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
|
|
| 1467 | 1476 | |
| 1468 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1469 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1470 | - else {
|
|
| 1477 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
| 1478 | + $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; |
|
| 1479 | + } else {
|
|
| 1471 | 1480 | $is_error_during_diagnose = true; |
| 1472 | 1481 | $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
|
| 1473 | 1482 | if ($fix) {
|
@@ -1488,11 +1497,11 @@ discard block |
||
| 1488 | 1497 | ////////////////////////////////// |
| 1489 | 1498 | $option_value = get_option('geodir_location_page');
|
| 1490 | 1499 | $page = get_post($option_value); |
| 1491 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1500 | + if(!empty($page)){$page_found = $page->ID;} else{$page_found = '';}
|
|
| 1492 | 1501 | |
| 1493 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1494 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1495 | - else {
|
|
| 1502 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') { |
|
| 1503 | + $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; |
|
| 1504 | + } else {
|
|
| 1496 | 1505 | $is_error_during_diagnose = true; |
| 1497 | 1506 | $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
|
| 1498 | 1507 | if ($fix) {
|
@@ -1936,8 +1945,9 @@ discard block |
||
| 1936 | 1945 | ); |
| 1937 | 1946 | |
| 1938 | 1947 | $post_location_info = $request_info['post_location']; |
| 1939 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 1940 | - $post_location_id = $location_id; |
|
| 1948 | + if ($location_id = geodir_add_new_location($post_location_info)) { |
|
| 1949 | + $post_location_id = $location_id; |
|
| 1950 | + } |
|
| 1941 | 1951 | } else {
|
| 1942 | 1952 | $post_location_id = 0; |
| 1943 | 1953 | } |
@@ -2000,8 +2010,9 @@ discard block |
||
| 2000 | 2010 | $attachment_set = ''; |
| 2001 | 2011 | |
| 2002 | 2012 | foreach ($attachment as $key => $val) {
|
| 2003 | - if ($val != '') |
|
| 2004 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2013 | + if ($val != '') { |
|
| 2014 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2015 | + } |
|
| 2005 | 2016 | } |
| 2006 | 2017 | $attachment_set = trim($attachment_set, ", "); |
| 2007 | 2018 | |
@@ -2097,8 +2108,7 @@ discard block |
||
| 2097 | 2108 | |
| 2098 | 2109 | $parts = json_decode($response['body']); |
| 2099 | 2110 | //print_r($parts); |
| 2100 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
|
|
| 2101 | - else{
|
|
| 2111 | + if(!isset($parts->access_token)){echo $error_msg." - #1";exit;} else{
|
|
| 2102 | 2112 | |
| 2103 | 2113 | update_option('gd_ga_access_token', $parts->access_token);
|
| 2104 | 2114 | update_option('gd_ga_refresh_token', $parts->refresh_token);
|
@@ -2106,17 +2116,16 @@ discard block |
||
| 2106 | 2116 | } |
| 2107 | 2117 | |
| 2108 | 2118 | |
| 2109 | - } |
|
| 2110 | - elseif(!empty($response['response']['code'])) {
|
|
| 2119 | + } elseif(!empty($response['response']['code'])) {
|
|
| 2111 | 2120 | $parts = json_decode($response['body']); |
| 2112 | 2121 | |
| 2113 | 2122 | if(isset($parts->error)){
|
| 2114 | 2123 | echo $parts->error.": ".$parts->error_description;exit; |
| 2115 | - }else{
|
|
| 2124 | + } else{
|
|
| 2116 | 2125 | echo $error_msg." - #2";exit; |
| 2117 | 2126 | } |
| 2118 | 2127 | |
| 2119 | - }else{
|
|
| 2128 | + } else{
|
|
| 2120 | 2129 | |
| 2121 | 2130 | echo $error_msg." - #3";exit; |
| 2122 | 2131 | |
@@ -2054,6 +2054,11 @@ discard block |
||
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | 2056 | //update meta |
| 2057 | + |
|
| 2058 | + /** |
|
| 2059 | + * @param string $term_id |
|
| 2060 | + * @param string $key |
|
| 2061 | + */ |
|
| 2057 | 2062 | public function update_tax_meta($term_id, $key, $value, $post_type = '') |
| 2058 | 2063 | { |
| 2059 | 2064 | |
@@ -2095,6 +2100,12 @@ discard block |
||
| 2095 | 2100 | |
| 2096 | 2101 | //get term meta field |
| 2097 | 2102 | if (!function_exists('get_tax_meta')) { |
| 2103 | + |
|
| 2104 | + /** |
|
| 2105 | + * @param string $key |
|
| 2106 | + * |
|
| 2107 | + * @return string |
|
| 2108 | + */ |
|
| 2098 | 2109 | function get_tax_meta($term_id, $key, $multi = false, $post_type = '') |
| 2099 | 2110 | { |
| 2100 | 2111 | |
@@ -2139,6 +2150,10 @@ discard block |
||
| 2139 | 2150 | |
| 2140 | 2151 | //update meta |
| 2141 | 2152 | if (!function_exists('update_tax_meta')) { |
| 2153 | + |
|
| 2154 | + /** |
|
| 2155 | + * @param string $key |
|
| 2156 | + */ |
|
| 2142 | 2157 | function update_tax_meta($term_id, $key, $value, $post_type = '') |
| 2143 | 2158 | { |
| 2144 | 2159 | |
@@ -803,7 +803,7 @@ discard block |
||
| 803 | 803 | { |
| 804 | 804 | |
| 805 | 805 | if (!is_array($meta)) |
| 806 | - $meta = (array)$meta; |
|
| 806 | + $meta = (array) $meta; |
|
| 807 | 807 | |
| 808 | 808 | $this->show_field_begin($field, $meta); |
| 809 | 809 | echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | { |
| 828 | 828 | |
| 829 | 829 | if (!is_array($meta)) |
| 830 | - $meta = (array)$meta; |
|
| 830 | + $meta = (array) $meta; |
|
| 831 | 831 | |
| 832 | 832 | $this->show_field_begin($field, $meta); |
| 833 | 833 | foreach ($field['options'] as $key => $value) { |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | global $post; |
| 891 | 891 | |
| 892 | 892 | if (!is_array($meta)) |
| 893 | - $meta = (array)$meta; |
|
| 893 | + $meta = (array) $meta; |
|
| 894 | 894 | |
| 895 | 895 | $this->show_field_begin($field, $meta); |
| 896 | 896 | echo "{$field['desc']}<br />"; |
@@ -1013,7 +1013,7 @@ discard block |
||
| 1013 | 1013 | { |
| 1014 | 1014 | |
| 1015 | 1015 | if (!is_array($meta)) |
| 1016 | - $meta = (array)$meta; |
|
| 1016 | + $meta = (array) $meta; |
|
| 1017 | 1017 | |
| 1018 | 1018 | $this->show_field_begin($field, $meta); |
| 1019 | 1019 | |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | { |
| 1074 | 1074 | global $post; |
| 1075 | 1075 | |
| 1076 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1076 | + if (!is_array($meta)) $meta = (array) $meta; |
|
| 1077 | 1077 | $this->show_field_begin($field, $meta); |
| 1078 | 1078 | $options = $field['options']; |
| 1079 | 1079 | $posts = get_posts($options['args']); |
@@ -1111,7 +1111,7 @@ discard block |
||
| 1111 | 1111 | { |
| 1112 | 1112 | global $post; |
| 1113 | 1113 | |
| 1114 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1114 | + if (!is_array($meta)) $meta = (array) $meta; |
|
| 1115 | 1115 | $this->show_field_begin($field, $meta); |
| 1116 | 1116 | $options = $field['options']; |
| 1117 | 1117 | $terms = get_terms($options['taxonomy'], $options['args']); |
@@ -1370,7 +1370,7 @@ discard block |
||
| 1370 | 1370 | if (!is_wp_error($id)) { |
| 1371 | 1371 | |
| 1372 | 1372 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
| 1373 | - add_post_meta($term_id, $name, $id, false); // save file's url in meta fields |
|
| 1373 | + add_post_meta($term_id, $name, $id, false); // save file's url in meta fields |
|
| 1374 | 1374 | |
| 1375 | 1375 | } // End if |
| 1376 | 1376 | |
@@ -1415,7 +1415,7 @@ discard block |
||
| 1415 | 1415 | if (!is_wp_error($id)) { |
| 1416 | 1416 | |
| 1417 | 1417 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
| 1418 | - return $id; // return file's url in meta fields |
|
| 1418 | + return $id; // return file's url in meta fields |
|
| 1419 | 1419 | } // End if |
| 1420 | 1420 | } // End foreach |
| 1421 | 1421 | } |
@@ -1430,9 +1430,9 @@ discard block |
||
| 1430 | 1430 | { |
| 1431 | 1431 | |
| 1432 | 1432 | // Default values for meta box |
| 1433 | - $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array)$this->_meta_box); |
|
| 1433 | + $this->_meta_box = array_merge(array('context' => 'normal', 'priority' => 'high', 'pages' => array('post')), (array) $this->_meta_box); |
|
| 1434 | 1434 | |
| 1435 | - if(is_array($this->_fields)) { |
|
| 1435 | + if (is_array($this->_fields)) { |
|
| 1436 | 1436 | // Default values for fields |
| 1437 | 1437 | foreach ($this->_fields as &$field) { |
| 1438 | 1438 | $multiple = in_array($field['type'], array('checkbox_list', 'file', 'image')); |
@@ -1452,7 +1452,7 @@ discard block |
||
| 1452 | 1452 | */ |
| 1453 | 1453 | public function has_field($type) |
| 1454 | 1454 | { |
| 1455 | - if(is_array($this->_fields)) { |
|
| 1455 | + if (is_array($this->_fields)) { |
|
| 1456 | 1456 | foreach ($this->_fields as $field) { |
| 1457 | 1457 | if ($type == $field['type']) |
| 1458 | 1458 | return true; |
@@ -2020,12 +2020,12 @@ discard block |
||
| 2020 | 2020 | $post_type = $taxObject->object_type[0]; |
| 2021 | 2021 | } |
| 2022 | 2022 | |
| 2023 | - if($post_type=='post'){$post_type='';} |
|
| 2024 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2023 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2024 | + if ($post_type) {$post_type = $post_type . '_'; } |
|
| 2025 | 2025 | |
| 2026 | 2026 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
| 2027 | 2027 | |
| 2028 | - $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2028 | + $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2029 | 2029 | if (isset($m[$key])) { |
| 2030 | 2030 | return $m[$key]; |
| 2031 | 2031 | } else { |
@@ -2042,15 +2042,15 @@ discard block |
||
| 2042 | 2042 | $post_type = $taxObject->object_type[0]; |
| 2043 | 2043 | } |
| 2044 | 2044 | |
| 2045 | - if($post_type=='post'){$post_type='';} |
|
| 2046 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2045 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2046 | + if ($post_type) {$post_type = $post_type . '_'; } |
|
| 2047 | 2047 | |
| 2048 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2048 | + $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2049 | 2049 | |
| 2050 | 2050 | if (isset($m[$key])) { |
| 2051 | 2051 | unset($m[$key]); |
| 2052 | 2052 | } |
| 2053 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2053 | + update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2054 | 2054 | } |
| 2055 | 2055 | |
| 2056 | 2056 | //update meta |
@@ -2062,13 +2062,13 @@ discard block |
||
| 2062 | 2062 | $post_type = $taxObject->object_type[0]; |
| 2063 | 2063 | } |
| 2064 | 2064 | |
| 2065 | - if($post_type=='post'){$post_type='';} |
|
| 2066 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2065 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2066 | + if ($post_type) {$post_type = $post_type . '_'; } |
|
| 2067 | 2067 | |
| 2068 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2068 | + $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2069 | 2069 | |
| 2070 | 2070 | $m[$key] = $value; |
| 2071 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2071 | + update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2072 | 2072 | |
| 2073 | 2073 | /** |
| 2074 | 2074 | * Called after the tax meta is updated. |
@@ -2103,12 +2103,12 @@ discard block |
||
| 2103 | 2103 | $post_type = $taxObject->object_type[0]; |
| 2104 | 2104 | } |
| 2105 | 2105 | |
| 2106 | - if($post_type=='post'){$post_type='';} |
|
| 2107 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2106 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2107 | + if ($post_type) {$post_type = $post_type . '_'; } |
|
| 2108 | 2108 | |
| 2109 | 2109 | $t_id = (is_object($term_id)) ? $term_id->term_id : $term_id; |
| 2110 | 2110 | |
| 2111 | - $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2111 | + $m = get_option('tax_meta_' . $post_type . $t_id); |
|
| 2112 | 2112 | if (isset($m[$key])) { |
| 2113 | 2113 | return $m[$key]; |
| 2114 | 2114 | } else { |
@@ -2125,15 +2125,15 @@ discard block |
||
| 2125 | 2125 | $taxObject = get_taxonomy($_REQUEST['taxonomy']); |
| 2126 | 2126 | $post_type = $taxObject->object_type[0]; |
| 2127 | 2127 | |
| 2128 | - if($post_type=='post'){$post_type='';} |
|
| 2129 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2128 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2129 | + if ($post_type) {$post_type = $post_type . '_'; } |
|
| 2130 | 2130 | |
| 2131 | 2131 | $m = get_option('tax_meta_' . $post_type . $term_id); |
| 2132 | 2132 | |
| 2133 | 2133 | if (isset($m[$key])) { |
| 2134 | 2134 | unset($m[$key]); |
| 2135 | 2135 | } |
| 2136 | - update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2136 | + update_option('tax_meta_' . $post_type . $term_id, $m); |
|
| 2137 | 2137 | } |
| 2138 | 2138 | } |
| 2139 | 2139 | |
@@ -2147,10 +2147,10 @@ discard block |
||
| 2147 | 2147 | $post_type = $taxObject->object_type[0]; |
| 2148 | 2148 | } |
| 2149 | 2149 | |
| 2150 | - if($post_type=='post'){$post_type='';} |
|
| 2151 | - if($post_type){$post_type = $post_type.'_';} |
|
| 2150 | + if ($post_type == 'post') {$post_type = ''; } |
|
| 2151 | + if ($post_type) {$post_type = $post_type . '_'; } |
|
| 2152 | 2152 | |
| 2153 | - $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2153 | + $m = get_option('tax_meta_' . $post_type . $term_id); |
|
| 2154 | 2154 | |
| 2155 | 2155 | $m[$key] = $value; |
| 2156 | 2156 | update_option('tax_meta_' . $post_type . $term_id, $m); |
@@ -102,8 +102,9 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | |
| 104 | 104 | // If we are not in admin area exit. |
| 105 | - if (!is_admin()) |
|
| 106 | - return; |
|
| 105 | + if (!is_admin()) { |
|
| 106 | + return; |
|
| 107 | + } |
|
| 107 | 108 | |
| 108 | 109 | // Assign meta box values to local variables and add it's missed values. |
| 109 | 110 | $this->_meta_box = $meta_box; |
@@ -111,15 +112,15 @@ discard block |
||
| 111 | 112 | $this->_fields = &$this->_meta_box['fields']; |
| 112 | 113 | $this->_Local_images = (isset($meta_box['local_images'])) ? true : false; |
| 113 | 114 | $this->add_missed_values(); |
| 114 | - if (isset($meta_box['use_with_theme'])) |
|
| 115 | - if ($meta_box['use_with_theme'] === true) { |
|
| 115 | + if (isset($meta_box['use_with_theme'])) { |
|
| 116 | + if ($meta_box['use_with_theme'] === true) { |
|
| 116 | 117 | $this->SelfPath = get_stylesheet_directory_uri() . '/library/cat-meta'; |
| 118 | + } |
|
| 117 | 119 | } elseif ($meta_box['use_with_theme'] === false) { |
| 118 | 120 | $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
| 119 | 121 | } else { |
| 120 | 122 | $this->SelfPath = $meta_box['use_with_theme']; |
| 121 | - } |
|
| 122 | - else { |
|
| 123 | + } else { |
|
| 123 | 124 | $this->SelfPath = plugins_url('cat-meta-functions', plugin_basename(dirname(__FILE__))); |
| 124 | 125 | } |
| 125 | 126 | |
@@ -190,8 +191,9 @@ discard block |
||
| 190 | 191 | { |
| 191 | 192 | |
| 192 | 193 | // Check if the field is an image or file. If not, return. |
| 193 | - if (!$this->has_field('image') && !$this->has_field('file')) |
|
| 194 | - return; |
|
| 194 | + if (!$this->has_field('image') && !$this->has_field('file')) { |
|
| 195 | + return; |
|
| 196 | + } |
|
| 195 | 197 | |
| 196 | 198 | |
| 197 | 199 | add_action('wp_enqueue_scripts', array(&$this, 'enqueue_tax_meta_scripts'), 100); |
@@ -235,8 +237,9 @@ discard block |
||
| 235 | 237 | { |
| 236 | 238 | |
| 237 | 239 | // If post variables are empty, return. |
| 238 | - if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) |
|
| 239 | - return; |
|
| 240 | + if (!isset($_POST['at-insert']) || empty($_POST['attachments'])) { |
|
| 241 | + return; |
|
| 242 | + } |
|
| 240 | 243 | |
| 241 | 244 | // Security Check |
| 242 | 245 | check_admin_referer('media-form'); |
@@ -256,8 +259,9 @@ discard block |
||
| 256 | 259 | $attachment = stripslashes_deep($attachment); |
| 257 | 260 | |
| 258 | 261 | // If not selected or url is empty, continue in loop. |
| 259 | - if (empty($attachment['selected']) || empty($attachment['url'])) |
|
| 260 | - continue; |
|
| 262 | + if (empty($attachment['selected']) || empty($attachment['url'])) { |
|
| 263 | + continue; |
|
| 264 | + } |
|
| 261 | 265 | |
| 262 | 266 | $li = "<li id='item_{$attachment_id}'>"; |
| 263 | 267 | $li .= "<img src='{$attachment['url']}' alt='image_{$attachment_id}' />"; |
@@ -308,13 +312,15 @@ discard block |
||
| 308 | 312 | |
| 309 | 313 | |
| 310 | 314 | // If data is not set, die. |
| 311 | - if (!isset($_POST['data'])) |
|
| 312 | - die(); |
|
| 315 | + if (!isset($_POST['data'])) { |
|
| 316 | + die(); |
|
| 317 | + } |
|
| 313 | 318 | |
| 314 | 319 | list($nonce, $term_id, $key, $attach_id) = explode('|', $_POST['data']); |
| 315 | 320 | |
| 316 | - if (!wp_verify_nonce($nonce, 'at_ajax_delete')) |
|
| 317 | - die('1'); |
|
| 321 | + if (!wp_verify_nonce($nonce, 'at_ajax_delete')) { |
|
| 322 | + die('1'); |
|
| 323 | + } |
|
| 318 | 324 | |
| 319 | 325 | $this->delete_tax_meta($term_id, $key, $attach_id); |
| 320 | 326 | |
@@ -336,8 +342,9 @@ discard block |
||
| 336 | 342 | $ok = false; |
| 337 | 343 | if (strpos($field_id, '[') === false) { |
| 338 | 344 | check_admin_referer("at-delete-mupload_" . urldecode($field_id)); |
| 339 | - if ($term_id > 0) |
|
| 340 | - $this->delete_tax_meta($term_id, $field_id); |
|
| 345 | + if ($term_id > 0) { |
|
| 346 | + $this->delete_tax_meta($term_id, $field_id); |
|
| 347 | + } |
|
| 341 | 348 | //$ok = wp_delete_attachment( $attachment_id ); |
| 342 | 349 | $ok = 1; |
| 343 | 350 | } else { |
@@ -349,8 +356,9 @@ discard block |
||
| 349 | 356 | $saved = $this->get_tax_meta($term_id, $f[0], true); |
| 350 | 357 | if (isset($saved[$f[1]][$f[2]])) { |
| 351 | 358 | unset($saved[$f[1]][$f[2]]); |
| 352 | - if ($term_id > 0) |
|
| 353 | - update_post_meta($term_id, $f[0], $saved); |
|
| 359 | + if ($term_id > 0) { |
|
| 360 | + update_post_meta($term_id, $f[0], $saved); |
|
| 361 | + } |
|
| 354 | 362 | //$ok = wp_delete_attachment( $attachment_id ); |
| 355 | 363 | $ok = 1; |
| 356 | 364 | } |
@@ -375,13 +383,15 @@ discard block |
||
| 375 | 383 | public function reorder_images() |
| 376 | 384 | { |
| 377 | 385 | |
| 378 | - if (!isset($_POST['data'])) |
|
| 379 | - die(); |
|
| 386 | + if (!isset($_POST['data'])) { |
|
| 387 | + die(); |
|
| 388 | + } |
|
| 380 | 389 | |
| 381 | 390 | list($order, $term_id, $key, $nonce) = explode('|', $_POST['data']); |
| 382 | 391 | |
| 383 | - if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) |
|
| 384 | - die('1'); |
|
| 392 | + if (!wp_verify_nonce($nonce, 'at_ajax_reorder')) { |
|
| 393 | + die('1'); |
|
| 394 | + } |
|
| 385 | 395 | |
| 386 | 396 | parse_str($order, $items); |
| 387 | 397 | $items = $items['item']; |
@@ -513,8 +523,9 @@ discard block |
||
| 513 | 523 | foreach ($this->_fields as $field) { |
| 514 | 524 | $meta = $this->get_tax_meta($term_id, $field['id'], !$field['multiple']); |
| 515 | 525 | $meta = ($meta !== '') ? $meta : $field['std']; |
| 516 | - if ('image' != $field['type'] && $field['type'] != 'repeater') |
|
| 517 | - $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); |
|
| 526 | + if ('image' != $field['type'] && $field['type'] != 'repeater') { |
|
| 527 | + $meta = is_array($meta) ? array_map('esc_attr', $meta) : esc_attr($meta); |
|
| 528 | + } |
|
| 518 | 529 | |
| 519 | 530 | if ($field['validate_func']) { |
| 520 | 531 | echo '<tr class="form-field form-required ' . $field['style'] . '">'; |
@@ -560,8 +571,9 @@ discard block |
||
| 560 | 571 | $id = $field['id'] . '[' . $c . '][' . $f['id'] . ']'; |
| 561 | 572 | $m = $me[$f['id']]; |
| 562 | 573 | $m = ($m !== '') ? $m : $f['std']; |
| 563 | - if ('image' != $f['type'] && $f['type'] != 'repeater') |
|
| 564 | - $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); |
|
| 574 | + if ('image' != $f['type'] && $f['type'] != 'repeater') { |
|
| 575 | + $m = is_array($m) ? array_map('esc_attr', $m) : esc_attr($m); |
|
| 576 | + } |
|
| 565 | 577 | //set new id for field in array format |
| 566 | 578 | $f['id'] = $id; |
| 567 | 579 | if (!$field['inline']) { |
@@ -802,8 +814,9 @@ discard block |
||
| 802 | 814 | public function show_field_select($field, $meta) |
| 803 | 815 | { |
| 804 | 816 | |
| 805 | - if (!is_array($meta)) |
|
| 806 | - $meta = (array)$meta; |
|
| 817 | + if (!is_array($meta)) { |
|
| 818 | + $meta = (array)$meta; |
|
| 819 | + } |
|
| 807 | 820 | |
| 808 | 821 | $this->show_field_begin($field, $meta); |
| 809 | 822 | echo "<select class='at-select' name='{$field['id']}" . ($field['multiple'] ? "[]' id='{$field['id']}' multiple='multiple'" : "'") . ">"; |
@@ -826,8 +839,9 @@ discard block |
||
| 826 | 839 | public function show_field_radio($field, $meta) |
| 827 | 840 | { |
| 828 | 841 | |
| 829 | - if (!is_array($meta)) |
|
| 830 | - $meta = (array)$meta; |
|
| 842 | + if (!is_array($meta)) { |
|
| 843 | + $meta = (array)$meta; |
|
| 844 | + } |
|
| 831 | 845 | |
| 832 | 846 | $this->show_field_begin($field, $meta); |
| 833 | 847 | foreach ($field['options'] as $key => $value) { |
@@ -889,8 +903,9 @@ discard block |
||
| 889 | 903 | |
| 890 | 904 | global $post; |
| 891 | 905 | |
| 892 | - if (!is_array($meta)) |
|
| 893 | - $meta = (array)$meta; |
|
| 906 | + if (!is_array($meta)) { |
|
| 907 | + $meta = (array)$meta; |
|
| 908 | + } |
|
| 894 | 909 | |
| 895 | 910 | $this->show_field_begin($field, $meta); |
| 896 | 911 | echo "{$field['desc']}<br />"; |
@@ -934,8 +949,9 @@ discard block |
||
| 934 | 949 | $this->show_field_begin($field, $meta); |
| 935 | 950 | $html = wp_nonce_field("at-delete-mupload_{$field['id']}", "nonce-delete-mupload_" . $field['id'], false, false); |
| 936 | 951 | if (is_array($meta)) { |
| 937 | - if (isset($meta[0]) && is_array($meta[0])) |
|
| 938 | - $meta = $meta[0]; |
|
| 952 | + if (isset($meta[0]) && is_array($meta[0])) { |
|
| 953 | + $meta = $meta[0]; |
|
| 954 | + } |
|
| 939 | 955 | } |
| 940 | 956 | |
| 941 | 957 | $uploads = wp_upload_dir(); |
@@ -947,8 +963,9 @@ discard block |
||
| 947 | 963 | //print_r($uploads); |
| 948 | 964 | //print_r($file_info); |
| 949 | 965 | |
| 950 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 951 | - $sub_dir = $file_info['dirname']; |
|
| 966 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') { |
|
| 967 | + $sub_dir = $file_info['dirname']; |
|
| 968 | + } |
|
| 952 | 969 | |
| 953 | 970 | $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
| 954 | 971 | $uploads_baseurl = $uploads['baseurl']; |
@@ -988,8 +1005,9 @@ discard block |
||
| 988 | 1005 | public function show_field_color($field, $meta) |
| 989 | 1006 | { |
| 990 | 1007 | |
| 991 | - if (empty($meta)) |
|
| 992 | - $meta = '#'; |
|
| 1008 | + if (empty($meta)) { |
|
| 1009 | + $meta = '#'; |
|
| 1010 | + } |
|
| 993 | 1011 | |
| 994 | 1012 | $this->show_field_begin($field, $meta); |
| 995 | 1013 | |
@@ -1012,8 +1030,9 @@ discard block |
||
| 1012 | 1030 | public function show_field_checkbox_list($field, $meta) |
| 1013 | 1031 | { |
| 1014 | 1032 | |
| 1015 | - if (!is_array($meta)) |
|
| 1016 | - $meta = (array)$meta; |
|
| 1033 | + if (!is_array($meta)) { |
|
| 1034 | + $meta = (array)$meta; |
|
| 1035 | + } |
|
| 1017 | 1036 | |
| 1018 | 1037 | $this->show_field_begin($field, $meta); |
| 1019 | 1038 | |
@@ -1073,7 +1092,9 @@ discard block |
||
| 1073 | 1092 | { |
| 1074 | 1093 | global $post; |
| 1075 | 1094 | |
| 1076 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1095 | + if (!is_array($meta)) { |
|
| 1096 | + $meta = (array)$meta; |
|
| 1097 | + } |
|
| 1077 | 1098 | $this->show_field_begin($field, $meta); |
| 1078 | 1099 | $options = $field['options']; |
| 1079 | 1100 | $posts = get_posts($options['args']); |
@@ -1111,7 +1132,9 @@ discard block |
||
| 1111 | 1132 | { |
| 1112 | 1133 | global $post; |
| 1113 | 1134 | |
| 1114 | - if (!is_array($meta)) $meta = (array)$meta; |
|
| 1135 | + if (!is_array($meta)) { |
|
| 1136 | + $meta = (array)$meta; |
|
| 1137 | + } |
|
| 1115 | 1138 | $this->show_field_begin($field, $meta); |
| 1116 | 1139 | $options = $field['options']; |
| 1117 | 1140 | $terms = get_terms($options['taxonomy'], $options['args']); |
@@ -1145,17 +1168,20 @@ discard block |
||
| 1145 | 1168 | { |
| 1146 | 1169 | |
| 1147 | 1170 | $taxnow = ''; |
| 1148 | - if (isset($_POST['taxonomy'])) |
|
| 1149 | - $taxnow = $_POST['taxonomy']; |
|
| 1171 | + if (isset($_POST['taxonomy'])) { |
|
| 1172 | + $taxnow = $_POST['taxonomy']; |
|
| 1173 | + } |
|
| 1150 | 1174 | |
| 1151 | 1175 | if (!isset($term_id) // Check Revision |
| 1152 | 1176 | || (!in_array($taxnow, $this->_meta_box['pages'])) // Check if current taxonomy type is supported. |
| 1153 | 1177 | || (!check_admin_referer(basename(__FILE__), 'tax_meta_class_nonce')) // Check nonce - Security |
| 1154 | 1178 | || (!current_user_can('manage_categories')) |
| 1155 | - ) // Check permission |
|
| 1179 | + ) { |
|
| 1180 | + // Check permission |
|
| 1156 | 1181 | { |
| 1157 | 1182 | return $term_id; |
| 1158 | 1183 | } |
| 1184 | + } |
|
| 1159 | 1185 | |
| 1160 | 1186 | |
| 1161 | 1187 | foreach ($this->_fields as $field) { |
@@ -1249,8 +1275,9 @@ discard block |
||
| 1249 | 1275 | { |
| 1250 | 1276 | $name = $field['id']; |
| 1251 | 1277 | $this->delete_tax_meta($term_id, $name); |
| 1252 | - if ($new === '' || $new === array()) |
|
| 1253 | - return; |
|
| 1278 | + if ($new === '' || $new === array()) { |
|
| 1279 | + return; |
|
| 1280 | + } |
|
| 1254 | 1281 | |
| 1255 | 1282 | $this->update_tax_meta($term_id, $name, $new); |
| 1256 | 1283 | } |
@@ -1270,8 +1297,9 @@ discard block |
||
| 1270 | 1297 | $name = $field['id']; |
| 1271 | 1298 | |
| 1272 | 1299 | $this->delete_tax_meta($term_id, $name); |
| 1273 | - if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') |
|
| 1274 | - return; |
|
| 1300 | + if ($new === '' || $new === array() || $new['id'] == '' || $new['src'] == '') { |
|
| 1301 | + return; |
|
| 1302 | + } |
|
| 1275 | 1303 | |
| 1276 | 1304 | $this->update_tax_meta($term_id, $name, $new); |
| 1277 | 1305 | } |
@@ -1318,8 +1346,9 @@ discard block |
||
| 1318 | 1346 | break; |
| 1319 | 1347 | } |
| 1320 | 1348 | } |
| 1321 | - if (!$this->is_array_empty($n)) |
|
| 1322 | - $temp[] = $n; |
|
| 1349 | + if (!$this->is_array_empty($n)) { |
|
| 1350 | + $temp[] = $n; |
|
| 1351 | + } |
|
| 1323 | 1352 | } |
| 1324 | 1353 | if (isset($temp) && count($temp) > 0 && !$this->is_array_empty($temp)) { |
| 1325 | 1354 | $this->update_tax_meta($term_id, $field['id'], $temp); |
@@ -1347,14 +1376,16 @@ discard block |
||
| 1347 | 1376 | { |
| 1348 | 1377 | |
| 1349 | 1378 | $name = $field['id']; |
| 1350 | - if (empty($_FILES[$name])) |
|
| 1351 | - return; |
|
| 1379 | + if (empty($_FILES[$name])) { |
|
| 1380 | + return; |
|
| 1381 | + } |
|
| 1352 | 1382 | $this->fix_file_array($_FILES[$name]); |
| 1353 | 1383 | foreach ($_FILES[$name] as $position => $fileitem) { |
| 1354 | 1384 | |
| 1355 | 1385 | $file = wp_handle_upload($fileitem, array('test_form' => false)); |
| 1356 | - if (empty($file['file'])) |
|
| 1357 | - continue; |
|
| 1386 | + if (empty($file['file'])) { |
|
| 1387 | + continue; |
|
| 1388 | + } |
|
| 1358 | 1389 | $filename = $file['file']; |
| 1359 | 1390 | |
| 1360 | 1391 | $attachment = array( |
@@ -1392,14 +1423,16 @@ discard block |
||
| 1392 | 1423 | { |
| 1393 | 1424 | |
| 1394 | 1425 | $name = $field['id']; |
| 1395 | - if (empty($_FILES[$name])) |
|
| 1396 | - return; |
|
| 1426 | + if (empty($_FILES[$name])) { |
|
| 1427 | + return; |
|
| 1428 | + } |
|
| 1397 | 1429 | $this->fix_file_array($_FILES[$name]); |
| 1398 | 1430 | foreach ($_FILES[$name] as $position => $fileitem) { |
| 1399 | 1431 | |
| 1400 | 1432 | $file = wp_handle_upload($fileitem, array('test_form' => false)); |
| 1401 | - if (empty($file['file'])) |
|
| 1402 | - continue; |
|
| 1433 | + if (empty($file['file'])) { |
|
| 1434 | + continue; |
|
| 1435 | + } |
|
| 1403 | 1436 | $filename = $file['file']; |
| 1404 | 1437 | |
| 1405 | 1438 | $attachment = array( |
@@ -1454,8 +1487,9 @@ discard block |
||
| 1454 | 1487 | { |
| 1455 | 1488 | if(is_array($this->_fields)) { |
| 1456 | 1489 | foreach ($this->_fields as $field) { |
| 1457 | - if ($type == $field['type']) |
|
| 1458 | - return true; |
|
| 1490 | + if ($type == $field['type']) { |
|
| 1491 | + return true; |
|
| 1492 | + } |
|
| 1459 | 1493 | } |
| 1460 | 1494 | } |
| 1461 | 1495 | return false; |
@@ -1993,18 +2027,21 @@ discard block |
||
| 1993 | 2027 | */ |
| 1994 | 2028 | public function is_array_empty($array) |
| 1995 | 2029 | { |
| 1996 | - if (!is_array($array)) |
|
| 1997 | - return true; |
|
| 2030 | + if (!is_array($array)) { |
|
| 2031 | + return true; |
|
| 2032 | + } |
|
| 1998 | 2033 | |
| 1999 | 2034 | foreach ($array as $a) { |
| 2000 | 2035 | if (is_array($a)) { |
| 2001 | 2036 | foreach ($a as $sub_a) { |
| 2002 | - if (!empty($sub_a) && $sub_a != '') |
|
| 2003 | - return false; |
|
| 2037 | + if (!empty($sub_a) && $sub_a != '') { |
|
| 2038 | + return false; |
|
| 2039 | + } |
|
| 2004 | 2040 | } |
| 2005 | 2041 | } else { |
| 2006 | - if (!empty($a) && $a != '') |
|
| 2007 | - return false; |
|
| 2042 | + if (!empty($a) && $a != '') { |
|
| 2043 | + return false; |
|
| 2044 | + } |
|
| 2008 | 2045 | } |
| 2009 | 2046 | } |
| 2010 | 2047 | return true; |
@@ -113,7 +113,7 @@ |
||
| 113 | 113 | * @since 1.0.0 |
| 114 | 114 | * @package GeoDirectory |
| 115 | 115 | * @param array $classes Class array. |
| 116 | - * @return array Modified class array. |
|
| 116 | + * @return string[] Modified class array. |
|
| 117 | 117 | */ |
| 118 | 118 | function geodir_x_body_class($classes) |
| 119 | 119 | { |
@@ -307,7 +307,7 @@ discard block |
||
| 307 | 307 | // 8. Get shop title. |
| 308 | 308 | // |
| 309 | 309 | |
| 310 | - GLOBAL $post,$wp; |
|
| 310 | + GLOBAL $post, $wp; |
|
| 311 | 311 | |
| 312 | 312 | if (geodir_is_page('detail') || geodir_is_page('listing') || (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id())) { |
| 313 | 313 | geodir_breadcrumb(); |
@@ -315,13 +315,13 @@ discard block |
||
| 315 | 315 | |
| 316 | 316 | $stack = x_get_stack(); |
| 317 | 317 | $delimiter = ' <span class="delimiter"><i class="x-icon-angle-right"></i></span> '; // 1 |
| 318 | - $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2 |
|
| 319 | - $home_link = home_url(); // 3 |
|
| 320 | - $current_before = '<span class="current">'; // 4 |
|
| 321 | - $current_after = '</span>'; // 5 |
|
| 322 | - $page_title = get_the_title(); // 6 |
|
| 323 | - $blog_title = get_the_title(get_option('page_for_posts', true)); // 7 |
|
| 324 | - $shop_title = get_theme_mod('x_' . $stack . '_shop_title'); // 8 |
|
| 318 | + $home_text = '<span class="home"><i class="x-icon-home"></i></span>'; // 2 |
|
| 319 | + $home_link = home_url(); // 3 |
|
| 320 | + $current_before = '<span class="current">'; // 4 |
|
| 321 | + $current_after = '</span>'; // 5 |
|
| 322 | + $page_title = get_the_title(); // 6 |
|
| 323 | + $blog_title = get_the_title(get_option('page_for_posts', true)); // 7 |
|
| 324 | + $shop_title = get_theme_mod('x_' . $stack . '_shop_title'); // 8 |
|
| 325 | 325 | |
| 326 | 326 | if (function_exists('woocommerce_get_page_id')) { |
| 327 | 327 | $shop_url = x_get_shop_link(); |
@@ -336,7 +336,9 @@ discard block |
||
| 336 | 336 | echo '<div class="x-breadcrumbs"><a href="' . $home_link . '">' . $home_text . '</a>' . $delimiter; |
| 337 | 337 | if (is_category()) { |
| 338 | 338 | $the_cat = get_category(get_query_var('cat'), false); |
| 339 | - if ($the_cat->parent != 0) echo get_category_parents($the_cat->parent, TRUE, $delimiter); |
|
| 339 | + if ($the_cat->parent != 0) { |
|
| 340 | + echo get_category_parents($the_cat->parent, TRUE, $delimiter); |
|
| 341 | + } |
|
| 340 | 342 | echo $current_before . single_cat_title('', false) . $current_after; |
| 341 | 343 | } elseif (x_is_product_category()) { |
| 342 | 344 | echo $shop_link . $delimiter . $current_before . single_cat_title('', false) . $current_after; |
@@ -371,7 +373,9 @@ discard block |
||
| 371 | 373 | $breadcrumbs = array_reverse($breadcrumbs); |
| 372 | 374 | for ($i = 0; $i < count($breadcrumbs); $i++) { |
| 373 | 375 | echo $breadcrumbs[$i]; |
| 374 | - if ($i != count($breadcrumbs) - 1) echo $delimiter; |
|
| 376 | + if ($i != count($breadcrumbs) - 1) { |
|
| 377 | + echo $delimiter; |
|
| 378 | + } |
|
| 375 | 379 | } |
| 376 | 380 | echo $delimiter . $current_before . $page_title . $current_after; |
| 377 | 381 | } elseif (is_tag()) { |
@@ -3448,7 +3448,7 @@ discard block |
||
| 3448 | 3448 | * @global object $wpdb WordPress Database object. |
| 3449 | 3449 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 3450 | 3450 | * @param int $post_id The post ID. |
| 3451 | - * @return mixed Returns video. |
|
| 3451 | + * @return string Returns video. |
|
| 3452 | 3452 | */ |
| 3453 | 3453 | function geodir_get_video($post_id) |
| 3454 | 3454 | {
|
@@ -3474,7 +3474,7 @@ discard block |
||
| 3474 | 3474 | * @global object $wpdb WordPress Database object. |
| 3475 | 3475 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 3476 | 3476 | * @param int $post_id The post ID. |
| 3477 | - * @return mixed Returns special offers. |
|
| 3477 | + * @return string Returns special offers. |
|
| 3478 | 3478 | */ |
| 3479 | 3479 | function geodir_get_special_offers($post_id) |
| 3480 | 3480 | {
|
@@ -3498,7 +3498,7 @@ discard block |
||
| 3498 | 3498 | * |
| 3499 | 3499 | * @since 1.0.0 |
| 3500 | 3500 | * @package GeoDirectory |
| 3501 | - * @return mixed|void Returns max upload file size. |
|
| 3501 | + * @return string|null Returns max upload file size. |
|
| 3502 | 3502 | */ |
| 3503 | 3503 | function geodir_max_upload_size() |
| 3504 | 3504 | {
|
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL") |
| 50 | 50 | {
|
| 51 | 51 | global $wpdb; |
| 52 | - $result = 0;// no rows affected |
|
| 52 | + $result = 0; // no rows affected |
|
| 53 | 53 | if (!geodir_column_exist($db, $column)) {
|
| 54 | 54 | if (!empty($db) && !empty($column)) |
| 55 | 55 | $result = $wpdb->query("ALTER TABLE `$db` ADD `$column` $column_attr");
|
@@ -431,7 +431,7 @@ discard block |
||
| 431 | 431 | |
| 432 | 432 | $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . GEODIR_CUSTOM_FIELDS_TABLE);
|
| 433 | 433 | |
| 434 | - $sort_order = (int)$last_order + 1; |
|
| 434 | + $sort_order = (int) $last_order + 1; |
|
| 435 | 435 | } |
| 436 | 436 | |
| 437 | 437 | $default_value_add = ''; |
@@ -683,18 +683,18 @@ discard block |
||
| 683 | 683 | $op_size = '500'; |
| 684 | 684 | |
| 685 | 685 | // only make the field as big as it needs to be. |
| 686 | - if(isset($option_values) && $option_values && $field_type=='select'){
|
|
| 687 | - $option_values_arr = explode(',',$option_values);
|
|
| 688 | - if(is_array($option_values_arr)){
|
|
| 686 | + if (isset($option_values) && $option_values && $field_type == 'select') {
|
|
| 687 | + $option_values_arr = explode(',', $option_values);
|
|
| 688 | + if (is_array($option_values_arr)) {
|
|
| 689 | 689 | $op_max = 0; |
| 690 | - foreach($option_values_arr as $op_val){
|
|
| 691 | - if(strlen($op_val) && strlen($op_val)>$op_max){$op_max = strlen($op_val);}
|
|
| 690 | + foreach ($option_values_arr as $op_val) {
|
|
| 691 | + if (strlen($op_val) && strlen($op_val) > $op_max) {$op_max = strlen($op_val); }
|
|
| 692 | 692 | } |
| 693 | - if($op_max){$op_size =$op_max; }
|
|
| 693 | + if ($op_max) {$op_size = $op_max; }
|
|
| 694 | 694 | } |
| 695 | - }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
|
|
| 696 | - if(strlen($option_values)){
|
|
| 697 | - $op_size = strlen($option_values); |
|
| 695 | + }elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
|
|
| 696 | + if (strlen($option_values)) {
|
|
| 697 | + $op_size = strlen($option_values); |
|
| 698 | 698 | } |
| 699 | 699 | } |
| 700 | 700 | |
@@ -705,8 +705,8 @@ discard block |
||
| 705 | 705 | } |
| 706 | 706 | |
| 707 | 707 | $alter_result = $wpdb->query($meta_field_add); |
| 708 | - if($alter_result===false){
|
|
| 709 | - return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 708 | + if ($alter_result === false) {
|
|
| 709 | + return __('Column change failed, you may have too many columns.', 'geodirectory');
|
|
| 710 | 710 | } |
| 711 | 711 | |
| 712 | 712 | if (isset($request_field['cat_display_type'])) |
@@ -722,8 +722,8 @@ discard block |
||
| 722 | 722 | case 'html': |
| 723 | 723 | |
| 724 | 724 | $alter_result = $wpdb->query("ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` TEXT NULL");
|
| 725 | - if($alter_result===false){
|
|
| 726 | - return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 725 | + if ($alter_result === false) {
|
|
| 726 | + return __('Column change failed, you may have too many columns.', 'geodirectory');
|
|
| 727 | 727 | } |
| 728 | 728 | if (isset($request_field['advanced_editor'])) |
| 729 | 729 | $extra_fields = $request_field['advanced_editor']; |
@@ -737,7 +737,7 @@ discard block |
||
| 737 | 737 | default: |
| 738 | 738 | if ($data_type != 'VARCHAR' && $data_type != '') {
|
| 739 | 739 | if ($data_type == 'FLOAT' && $decimal_point > 0) {
|
| 740 | - $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int)$decimal_point . ") NULL"; |
|
| 740 | + $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` DECIMAL(11, " . (int) $decimal_point . ") NULL"; |
|
| 741 | 741 | } else {
|
| 742 | 742 | $default_value_add = "ALTER TABLE " . $detail_table . " CHANGE `" . $old_html_variable . "` `" . $htmlvar_name . "` " . $data_type . " NULL"; |
| 743 | 743 | } |
@@ -753,8 +753,8 @@ discard block |
||
| 753 | 753 | } |
| 754 | 754 | |
| 755 | 755 | $alter_result = $wpdb->query($default_value_add); |
| 756 | - if($alter_result===false){
|
|
| 757 | - return __('Column change failed, you may have too many columns.','geodirectory');
|
|
| 756 | + if ($alter_result === false) {
|
|
| 757 | + return __('Column change failed, you may have too many columns.', 'geodirectory');
|
|
| 758 | 758 | } |
| 759 | 759 | break; |
| 760 | 760 | endswitch; |
@@ -802,7 +802,7 @@ discard block |
||
| 802 | 802 | for_admin_use = %s |
| 803 | 803 | where id = %d", |
| 804 | 804 | |
| 805 | - array($post_type, $admin_title, $site_title, $field_type, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use, $cf) |
|
| 805 | + array($post_type, $admin_title, $site_title, $field_type, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_required, $required_msg, $css_class, $field_icon, $field_icon, $show_on_listing, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point, $validation_pattern, $validation_msg, $for_admin_use, $cf) |
|
| 806 | 806 | ) |
| 807 | 807 | |
| 808 | 808 | ); |
@@ -962,7 +962,7 @@ discard block |
||
| 962 | 962 | $data_type = 'TINYINT'; |
| 963 | 963 | |
| 964 | 964 | $meta_field_add = $data_type . "( 1 ) NOT NULL "; |
| 965 | - if ((int)$default_value === 1) {
|
|
| 965 | + if ((int) $default_value === 1) {
|
|
| 966 | 966 | $meta_field_add .= " DEFAULT '1'"; |
| 967 | 967 | } |
| 968 | 968 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | } |
| 996 | 996 | } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
|
| 997 | 997 | if (strlen($option_values)) {
|
| 998 | - $op_size = strlen($option_values); |
|
| 998 | + $op_size = strlen($option_values); |
|
| 999 | 999 | } |
| 1000 | 1000 | |
| 1001 | 1001 | if (isset($request_field['multi_display_type'])) {
|
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | $meta_field_add = $data_type . " NULL "; |
| 1069 | 1069 | |
| 1070 | 1070 | if ($data_type == 'FLOAT' && $decimal_point > 0) {
|
| 1071 | - $meta_field_add = "DECIMAL(11, " . (int)$decimal_point . ") NULL "; |
|
| 1071 | + $meta_field_add = "DECIMAL(11, " . (int) $decimal_point . ") NULL "; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | if (is_numeric($default_value) && $default_value != '') {
|
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | validation_msg = %s, |
| 1134 | 1134 | for_admin_use = %s ", |
| 1135 | 1135 | |
| 1136 | - array($post_type, $admin_title, $site_title, $field_type, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point,$validation_pattern,$validation_msg, $for_admin_use) |
|
| 1136 | + array($post_type, $admin_title, $site_title, $field_type, $htmlvar_name, $admin_desc, $clabels, $default_value, $sort_order, $is_active, $is_default, $is_admin, $is_required, $required_msg, $css_class, $field_icon, $show_on_listing, $show_on_detail, $show_as_tab, $option_values, $price_pkg, $cat_sort, $cat_filter, $data_type, $extra_field_query, $decimal_point, $validation_pattern, $validation_msg, $for_admin_use) |
|
| 1137 | 1137 | |
| 1138 | 1138 | ) |
| 1139 | 1139 | |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | |
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | - return (int)$lastid; |
|
| 1148 | + return (int) $lastid; |
|
| 1149 | 1149 | |
| 1150 | 1150 | |
| 1151 | 1151 | } else {
|
@@ -1234,7 +1234,7 @@ discard block |
||
| 1234 | 1234 | $value = ''; |
| 1235 | 1235 | |
| 1236 | 1236 | /* field available to site admin only for edit */ |
| 1237 | - $for_admin_use = isset($val['for_admin_use']) && (int)$val['for_admin_use'] == 1 ? true : false; |
|
| 1237 | + $for_admin_use = isset($val['for_admin_use']) && (int) $val['for_admin_use'] == 1 ? true : false; |
|
| 1238 | 1238 | if ($for_admin_use && !is_super_admin()) {
|
| 1239 | 1239 | continue; |
| 1240 | 1240 | } |
@@ -1271,10 +1271,10 @@ discard block |
||
| 1271 | 1271 | do_action('geodir_before_custom_form_field_' . $name, $listing_type, $package_id, $val);
|
| 1272 | 1272 | |
| 1273 | 1273 | if ($type == 'fieldset') {
|
| 1274 | - $fieldset_id = (int)$val['id']; |
|
| 1274 | + $fieldset_id = (int) $val['id']; |
|
| 1275 | 1275 | $fieldset_field_class = 'gd-fieldset-' . $fieldset_id; |
| 1276 | - ?><h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?> |
|
| 1277 | - <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>';?> |
|
| 1276 | + ?><h5 id="geodir_fieldset_<?php echo $fieldset_id; ?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id; ?>"><?php echo $site_title; ?> |
|
| 1277 | + <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>'; ?> |
|
| 1278 | 1278 | </h5><?php |
| 1279 | 1279 | |
| 1280 | 1280 | } elseif ($type == 'address') {
|
@@ -1302,7 +1302,7 @@ discard block |
||
| 1302 | 1302 | $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : ''; |
| 1303 | 1303 | $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : ''; |
| 1304 | 1304 | } else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) {
|
| 1305 | - $post_info = (array)$post_info; |
|
| 1305 | + $post_info = (array) $post_info; |
|
| 1306 | 1306 | |
| 1307 | 1307 | $address = $post_info[$prefix . 'address']; |
| 1308 | 1308 | $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : ''; |
@@ -1346,16 +1346,16 @@ discard block |
||
| 1346 | 1346 | |
| 1347 | 1347 | ?> |
| 1348 | 1348 | |
| 1349 | - <div id="geodir_<?php echo $prefix . 'address';?>_row" |
|
| 1350 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1349 | + <div id="geodir_<?php echo $prefix . 'address'; ?>_row" |
|
| 1350 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1351 | 1351 | <label> |
| 1352 | 1352 | <?php _e($address_title, 'geodirectory'); ?> |
| 1353 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1353 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1354 | 1354 | </label> |
| 1355 | - <input type="text" field_type="<?php echo $type;?>" name="<?php echo $prefix . 'address';?>" |
|
| 1356 | - id="<?php echo $prefix . 'address';?>" class="geodir_textfield" |
|
| 1355 | + <input type="text" field_type="<?php echo $type; ?>" name="<?php echo $prefix . 'address'; ?>" |
|
| 1356 | + id="<?php echo $prefix . 'address'; ?>" class="geodir_textfield" |
|
| 1357 | 1357 | value="<?php echo esc_attr(stripslashes($address)); ?>"/> |
| 1358 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1358 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1359 | 1359 | <?php if ($is_required) { ?>
|
| 1360 | 1360 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1361 | 1361 | <?php } ?> |
@@ -1376,7 +1376,7 @@ discard block |
||
| 1376 | 1376 | if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?>
|
| 1377 | 1377 | |
| 1378 | 1378 | <div id="geodir_<?php echo $prefix . 'zip'; ?>_row" |
| 1379 | - class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1379 | + class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1380 | 1380 | <label> |
| 1381 | 1381 | <?php _e($zip_title, 'geodirectory'); ?> |
| 1382 | 1382 | <?php /*if($is_required) echo '<span>*</span>';*/ ?> |
@@ -1392,7 +1392,7 @@ discard block |
||
| 1392 | 1392 | |
| 1393 | 1393 | <?php if (isset($extra_fields['show_map']) && $extra_fields['show_map']) { ?>
|
| 1394 | 1394 | |
| 1395 | - <div id="geodir_<?php echo $prefix . 'map'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1395 | + <div id="geodir_<?php echo $prefix . 'map'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1396 | 1396 | <?php |
| 1397 | 1397 | /** |
| 1398 | 1398 | * Contains add listing page map functions. |
@@ -1411,7 +1411,7 @@ discard block |
||
| 1411 | 1411 | /* show lat lng */ |
| 1412 | 1412 | $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?> |
| 1413 | 1413 | <div id="geodir_<?php echo $prefix . 'latitude'; ?>_row" |
| 1414 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>> |
|
| 1414 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>" <?php echo $style_latlng; ?>> |
|
| 1415 | 1415 | <label> |
| 1416 | 1416 | <?php echo PLACE_ADDRESS_LAT; ?> |
| 1417 | 1417 | <?php if ($is_required) echo '<span>*</span>'; ?> |
@@ -1426,7 +1426,7 @@ discard block |
||
| 1426 | 1426 | </div> |
| 1427 | 1427 | |
| 1428 | 1428 | <div id="geodir_<?php echo $prefix . 'longitude'; ?>_row" |
| 1429 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>> |
|
| 1429 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>" <?php echo $style_latlng; ?>> |
|
| 1430 | 1430 | <label> |
| 1431 | 1431 | <?php echo PLACE_ADDRESS_LNG; ?> |
| 1432 | 1432 | <?php if ($is_required) echo '<span>*</span>'; ?> |
@@ -1442,7 +1442,7 @@ discard block |
||
| 1442 | 1442 | <?php } ?> |
| 1443 | 1443 | |
| 1444 | 1444 | <?php if (isset($extra_fields['show_mapview']) && $extra_fields['show_mapview']) { ?>
|
| 1445 | - <div id="geodir_<?php echo $prefix . 'mapview'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1445 | + <div id="geodir_<?php echo $prefix . 'mapview'; ?>_row" class="geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1446 | 1446 | <label><?php _e($mapview_title, 'geodirectory'); ?></label> |
| 1447 | 1447 | |
| 1448 | 1448 | |
@@ -1484,30 +1484,30 @@ discard block |
||
| 1484 | 1484 | <?php } elseif ($type == 'text') {
|
| 1485 | 1485 | |
| 1486 | 1486 | //number and float validation $validation_pattern |
| 1487 | - if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
|
|
| 1488 | - elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
|
|
| 1487 | + if (isset($val['data_type']) && $val['data_type'] == 'INT') {$type = 'number'; }
|
|
| 1488 | + elseif (isset($val['data_type']) && $val['data_type'] == 'FLOAT') {$type = 'float'; }
|
|
| 1489 | 1489 | //print_r($val); |
| 1490 | 1490 | //validation |
| 1491 | - if(isset($val['validation_pattern']) && $val['validation_pattern']){
|
|
| 1492 | - $validation = 'pattern="'.$val['validation_pattern'].'"'; |
|
| 1493 | - }else{$validation='';}
|
|
| 1491 | + if (isset($val['validation_pattern']) && $val['validation_pattern']) {
|
|
| 1492 | + $validation = 'pattern="' . $val['validation_pattern'] . '"'; |
|
| 1493 | + } else {$validation = ''; }
|
|
| 1494 | 1494 | |
| 1495 | 1495 | // validation message |
| 1496 | - if(isset($val['validation_msg']) && $val['validation_msg']){
|
|
| 1497 | - $validation_msg = 'title="'.$val['validation_msg'].'"'; |
|
| 1498 | - }else{$validation_msg='';}
|
|
| 1496 | + if (isset($val['validation_msg']) && $val['validation_msg']) {
|
|
| 1497 | + $validation_msg = 'title="' . $val['validation_msg'] . '"'; |
|
| 1498 | + } else {$validation_msg = ''; }
|
|
| 1499 | 1499 | ?> |
| 1500 | 1500 | |
| 1501 | - <div id="<?php echo $name;?>_row" |
|
| 1502 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1501 | + <div id="<?php echo $name; ?>_row" |
|
| 1502 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1503 | 1503 | <label> |
| 1504 | 1504 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1505 | 1505 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1506 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1506 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1507 | 1507 | </label> |
| 1508 | - <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
|
| 1509 | - value="<?php echo esc_attr(stripslashes($value));?>" type="<?php echo $type;?>" class="geodir_textfield" <?php echo $validation;echo $validation_msg;?> /> |
|
| 1510 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1508 | + <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" |
|
| 1509 | + value="<?php echo esc_attr(stripslashes($value)); ?>" type="<?php echo $type; ?>" class="geodir_textfield" <?php echo $validation; echo $validation_msg; ?> /> |
|
| 1510 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1511 | 1511 | <?php if ($is_required) { ?>
|
| 1512 | 1512 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1513 | 1513 | <?php } ?> |
@@ -1518,16 +1518,16 @@ discard block |
||
| 1518 | 1518 | $value = ''; |
| 1519 | 1519 | }?> |
| 1520 | 1520 | |
| 1521 | - <div id="<?php echo $name;?>_row" |
|
| 1522 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1521 | + <div id="<?php echo $name; ?>_row" |
|
| 1522 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1523 | 1523 | <label> |
| 1524 | 1524 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1525 | 1525 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1526 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1526 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1527 | 1527 | </label> |
| 1528 | - <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
|
| 1529 | - value="<?php echo esc_attr(stripslashes($value));?>" type="email" class="geodir_textfield"/> |
|
| 1530 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1528 | + <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" |
|
| 1529 | + value="<?php echo esc_attr(stripslashes($value)); ?>" type="email" class="geodir_textfield"/> |
|
| 1530 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1531 | 1531 | <?php if ($is_required) { ?>
|
| 1532 | 1532 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1533 | 1533 | <?php } ?> |
@@ -1538,16 +1538,16 @@ discard block |
||
| 1538 | 1538 | $value = ''; |
| 1539 | 1539 | } ?> |
| 1540 | 1540 | |
| 1541 | - <div id="<?php echo $name;?>_row" |
|
| 1542 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1541 | + <div id="<?php echo $name; ?>_row" |
|
| 1542 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1543 | 1543 | <label> |
| 1544 | 1544 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1545 | 1545 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1546 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1546 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1547 | 1547 | </label> |
| 1548 | - <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
|
| 1549 | - value="<?php echo esc_attr(stripslashes($value));?>" type="tel" class="geodir_textfield"/> |
|
| 1550 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1548 | + <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" |
|
| 1549 | + value="<?php echo esc_attr(stripslashes($value)); ?>" type="tel" class="geodir_textfield"/> |
|
| 1550 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1551 | 1551 | <?php if ($is_required) { ?>
|
| 1552 | 1552 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1553 | 1553 | <?php } ?> |
@@ -1558,31 +1558,31 @@ discard block |
||
| 1558 | 1558 | $value = ''; |
| 1559 | 1559 | }?> |
| 1560 | 1560 | |
| 1561 | - <div id="<?php echo $name;?>_row" |
|
| 1562 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1561 | + <div id="<?php echo $name; ?>_row" |
|
| 1562 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1563 | 1563 | <label> |
| 1564 | 1564 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1565 | 1565 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1566 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1566 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1567 | 1567 | </label> |
| 1568 | - <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
|
| 1569 | - value="<?php echo esc_attr(stripslashes($value));?>" type="url" class="geodir_textfield" |
|
| 1568 | + <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" |
|
| 1569 | + value="<?php echo esc_attr(stripslashes($value)); ?>" type="url" class="geodir_textfield" |
|
| 1570 | 1570 | oninvalid="setCustomValidity('<?php _e('Please enter a valid URL including http://', 'geodirectory'); ?>')"
|
| 1571 | 1571 | onchange="try{setCustomValidity('')}catch(e){}"
|
| 1572 | 1572 | /> |
| 1573 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1573 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1574 | 1574 | <?php if ($is_required) { ?>
|
| 1575 | 1575 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1576 | 1576 | <?php } ?> |
| 1577 | 1577 | </div> |
| 1578 | 1578 | |
| 1579 | 1579 | <?php } elseif ($type == 'radio') { ?>
|
| 1580 | - <div id="<?php echo $name;?>_row" |
|
| 1581 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1580 | + <div id="<?php echo $name; ?>_row" |
|
| 1581 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1582 | 1582 | <label> |
| 1583 | 1583 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1584 | 1584 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1585 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1585 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1586 | 1586 | </label> |
| 1587 | 1587 | <?php if ($option_values) {
|
| 1588 | 1588 | $option_values = geodir_string_values_to_options($option_values, true); |
@@ -1591,14 +1591,14 @@ discard block |
||
| 1591 | 1591 | foreach ($option_values as $option_value) {
|
| 1592 | 1592 | if (empty($option_value['optgroup'])) {
|
| 1593 | 1593 | ?> |
| 1594 | - <input name="<?php echo $name;?>" id="<?php echo $name;?>" <?php checked($value, $option_value['value']);?> value="<?php echo esc_attr($option_value['value']); ?>" class="gd-checkbox" field_type="<?php echo $type;?>" type="radio" /><?php echo $option_value['label']; ?> |
|
| 1594 | + <input name="<?php echo $name; ?>" id="<?php echo $name; ?>" <?php checked($value, $option_value['value']); ?> value="<?php echo esc_attr($option_value['value']); ?>" class="gd-checkbox" field_type="<?php echo $type; ?>" type="radio" /><?php echo $option_value['label']; ?> |
|
| 1595 | 1595 | <?php |
| 1596 | 1596 | } |
| 1597 | 1597 | } |
| 1598 | 1598 | } |
| 1599 | 1599 | } |
| 1600 | 1600 | ?> |
| 1601 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1601 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1602 | 1602 | <?php if ($is_required) { ?>
|
| 1603 | 1603 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1604 | 1604 | <?php } ?> |
@@ -1606,22 +1606,22 @@ discard block |
||
| 1606 | 1606 | |
| 1607 | 1607 | <?php } elseif ($type == 'checkbox') { ?>
|
| 1608 | 1608 | |
| 1609 | - <div id="<?php echo $name;?>_row" |
|
| 1610 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1609 | + <div id="<?php echo $name; ?>_row" |
|
| 1610 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1611 | 1611 | <label> |
| 1612 | 1612 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1613 | 1613 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1614 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1614 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1615 | 1615 | </label> |
| 1616 | 1616 | <?php if ($value != '1') {
|
| 1617 | 1617 | $value = '0'; |
| 1618 | 1618 | }?> |
| 1619 | - <input type="hidden" name="<?php echo $name;?>" id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>"/> |
|
| 1619 | + <input type="hidden" name="<?php echo $name; ?>" id="<?php echo $name; ?>" value="<?php echo esc_attr($value); ?>"/> |
|
| 1620 | 1620 | <input <?php if ($value == '1') {
|
| 1621 | 1621 | echo 'checked="checked"'; |
| 1622 | - }?> value="1" class="gd-checkbox" field_type="<?php echo $type;?>" type="checkbox" |
|
| 1623 | - onchange="if(this.checked){jQuery('#<?php echo $name;?>').val('1');} else{ jQuery('#<?php echo $name;?>').val('0');}"/>
|
|
| 1624 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1622 | + }?> value="1" class="gd-checkbox" field_type="<?php echo $type; ?>" type="checkbox" |
|
| 1623 | + onchange="if(this.checked){jQuery('#<?php echo $name; ?>').val('1');} else{ jQuery('#<?php echo $name; ?>').val('0');}"/>
|
|
| 1624 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1625 | 1625 | <?php if ($is_required) { ?>
|
| 1626 | 1626 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1627 | 1627 | <?php } ?> |
@@ -1630,44 +1630,44 @@ discard block |
||
| 1630 | 1630 | <?php } elseif ($type == 'textarea') {
|
| 1631 | 1631 | ?> |
| 1632 | 1632 | |
| 1633 | - <div id="<?php echo $name;?>_row" |
|
| 1634 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1633 | + <div id="<?php echo $name; ?>_row" |
|
| 1634 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1635 | 1635 | <label> |
| 1636 | 1636 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1637 | 1637 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1638 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1638 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1639 | 1639 | </label><?php |
| 1640 | 1640 | |
| 1641 | 1641 | |
| 1642 | 1642 | if (is_array($extra_fields) && in_array('1', $extra_fields)) {
|
| 1643 | 1643 | |
| 1644 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?>
|
|
| 1644 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); ?>
|
|
| 1645 | 1645 | |
| 1646 | - <div class="editor" field_id="<?php echo $name;?>" field_type="editor"> |
|
| 1646 | + <div class="editor" field_id="<?php echo $name; ?>" field_type="editor"> |
|
| 1647 | 1647 | <?php wp_editor(stripslashes($value), $name, $editor_settings); ?> |
| 1648 | 1648 | </div><?php |
| 1649 | 1649 | |
| 1650 | 1650 | } else {
|
| 1651 | 1651 | |
| 1652 | - ?><textarea field_type="<?php echo $type;?>" class="geodir_textarea" name="<?php echo $name;?>" |
|
| 1653 | - id="<?php echo $name;?>"><?php echo stripslashes($value);?></textarea><?php |
|
| 1652 | + ?><textarea field_type="<?php echo $type; ?>" class="geodir_textarea" name="<?php echo $name; ?>" |
|
| 1653 | + id="<?php echo $name; ?>"><?php echo stripslashes($value); ?></textarea><?php |
|
| 1654 | 1654 | |
| 1655 | 1655 | }?> |
| 1656 | 1656 | |
| 1657 | 1657 | |
| 1658 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1658 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1659 | 1659 | <?php if ($is_required) { ?>
|
| 1660 | 1660 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1661 | 1661 | <?php } ?> |
| 1662 | 1662 | </div> |
| 1663 | 1663 | |
| 1664 | 1664 | <?php } elseif ($type == 'select') { ?>
|
| 1665 | - <div id="<?php echo $name;?>_row" |
|
| 1666 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1665 | + <div id="<?php echo $name; ?>_row" |
|
| 1666 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1667 | 1667 | <label> |
| 1668 | 1668 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1669 | 1669 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1670 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1670 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1671 | 1671 | </label> |
| 1672 | 1672 | <?php |
| 1673 | 1673 | $option_values_arr = geodir_string_values_to_options($option_values, true); |
@@ -1688,11 +1688,11 @@ discard block |
||
| 1688 | 1688 | } |
| 1689 | 1689 | } |
| 1690 | 1690 | ?> |
| 1691 | - <select field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
|
| 1691 | + <select field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" |
|
| 1692 | 1692 | class="geodir_textfield textfield_x chosen_select" |
| 1693 | - data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '…';?>"
|
|
| 1694 | - option-ajaxchosen="false"><?php echo $select_options;?></select> |
|
| 1695 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1693 | + data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '…'; ?>"
|
|
| 1694 | + option-ajaxchosen="false"><?php echo $select_options; ?></select> |
|
| 1695 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1696 | 1696 | <?php if ($is_required) { ?>
|
| 1697 | 1697 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1698 | 1698 | <?php } ?> |
@@ -1706,7 +1706,7 @@ discard block |
||
| 1706 | 1706 | } |
| 1707 | 1707 | ?> |
| 1708 | 1708 | <div id="<?php echo $name; ?>_row" |
| 1709 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1709 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1710 | 1710 | <label> |
| 1711 | 1711 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1712 | 1712 | echo (trim($site_title)) ? $site_title : ' '; ?> |
@@ -1780,7 +1780,7 @@ discard block |
||
| 1780 | 1780 | ?> |
| 1781 | 1781 | |
| 1782 | 1782 | <div id="<?php echo $name; ?>_row" |
| 1783 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1783 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1784 | 1784 | <label> |
| 1785 | 1785 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1786 | 1786 | echo (trim($site_title)) ? $site_title : ' '; ?> |
@@ -1810,8 +1810,8 @@ discard block |
||
| 1810 | 1810 | |
| 1811 | 1811 | $date_format = str_replace($search, $replace, $extra_fields['date_format']); |
| 1812 | 1812 | |
| 1813 | - if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty
|
|
| 1814 | - if($value && !isset($_REQUEST['backandedit'])) {
|
|
| 1813 | + if ($value == '0000-00-00') {$value = ''; }//if date not set, then mark it empty
|
|
| 1814 | + if ($value && !isset($_REQUEST['backandedit'])) {
|
|
| 1815 | 1815 | $time = strtotime($value); |
| 1816 | 1816 | $value = date($date_format, $time); |
| 1817 | 1817 | } |
@@ -1821,37 +1821,37 @@ discard block |
||
| 1821 | 1821 | |
| 1822 | 1822 | jQuery(function () {
|
| 1823 | 1823 | |
| 1824 | - jQuery("#<?php echo $name;?>").datepicker({changeMonth: true, changeYear: true <?php
|
|
| 1824 | + jQuery("#<?php echo $name; ?>").datepicker({changeMonth: true, changeYear: true <?php
|
|
| 1825 | 1825 | /** |
| 1826 | 1826 | * Used to add extra option to datepicker per custom field. |
| 1827 | 1827 | * |
| 1828 | 1828 | * @since 1.5.7 |
| 1829 | 1829 | * @param string $name The custom field name. |
| 1830 | 1830 | */ |
| 1831 | - echo apply_filters("gd_datepicker_extra_{$name}",'');?>});
|
|
| 1831 | + echo apply_filters("gd_datepicker_extra_{$name}", ''); ?>});
|
|
| 1832 | 1832 | |
| 1833 | - jQuery("#<?php echo $name;?>").datepicker("option", "dateFormat", '<?php echo $extra_fields['date_format'];?>');
|
|
| 1833 | + jQuery("#<?php echo $name; ?>").datepicker("option", "dateFormat", '<?php echo $extra_fields['date_format']; ?>');
|
|
| 1834 | 1834 | |
| 1835 | - <?php if(!empty($value)){?>
|
|
| 1836 | - jQuery("#<?php echo $name;?>").datepicker("setDate", "<?php echo $value;?>");
|
|
| 1835 | + <?php if (!empty($value)) {?>
|
|
| 1836 | + jQuery("#<?php echo $name; ?>").datepicker("setDate", "<?php echo $value; ?>");
|
|
| 1837 | 1837 | <?php } ?> |
| 1838 | 1838 | |
| 1839 | 1839 | }); |
| 1840 | 1840 | |
| 1841 | 1841 | </script> |
| 1842 | - <div id="<?php echo $name;?>_row" |
|
| 1843 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1842 | + <div id="<?php echo $name; ?>_row" |
|
| 1843 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1844 | 1844 | <label> |
| 1845 | 1845 | |
| 1846 | 1846 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1847 | 1847 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1848 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1848 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1849 | 1849 | </label> |
| 1850 | 1850 | |
| 1851 | - <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
|
| 1852 | - value="<?php echo esc_attr($value);?>" type="text" class="geodir_textfield"/> |
|
| 1851 | + <input field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" id="<?php echo $name; ?>" |
|
| 1852 | + value="<?php echo esc_attr($value); ?>" type="text" class="geodir_textfield"/> |
|
| 1853 | 1853 | |
| 1854 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1854 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1855 | 1855 | <?php if ($is_required) { ?>
|
| 1856 | 1856 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1857 | 1857 | <?php } ?> |
@@ -1865,25 +1865,25 @@ discard block |
||
| 1865 | 1865 | <script type="text/javascript"> |
| 1866 | 1866 | jQuery(document).ready(function () {
|
| 1867 | 1867 | |
| 1868 | - jQuery('#<?php echo $name;?>').timepicker({
|
|
| 1868 | + jQuery('#<?php echo $name; ?>').timepicker({
|
|
| 1869 | 1869 | showPeriod: true, |
| 1870 | 1870 | showLeadingZero: true, |
| 1871 | 1871 | showPeriod: true, |
| 1872 | 1872 | }); |
| 1873 | 1873 | }); |
| 1874 | 1874 | </script> |
| 1875 | - <div id="<?php echo $name;?>_row" |
|
| 1876 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1875 | + <div id="<?php echo $name; ?>_row" |
|
| 1876 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1877 | 1877 | <label> |
| 1878 | 1878 | |
| 1879 | 1879 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1880 | 1880 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1881 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1881 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1882 | 1882 | </label> |
| 1883 | - <input readonly="readonly" field_type="<?php echo $type;?>" name="<?php echo $name;?>" |
|
| 1884 | - id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>" type="text" class="geodir_textfield"/> |
|
| 1883 | + <input readonly="readonly" field_type="<?php echo $type; ?>" name="<?php echo $name; ?>" |
|
| 1884 | + id="<?php echo $name; ?>" value="<?php echo esc_attr($value); ?>" type="text" class="geodir_textfield"/> |
|
| 1885 | 1885 | |
| 1886 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1886 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 1887 | 1887 | <?php if ($is_required) { ?>
|
| 1888 | 1888 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 1889 | 1889 | <?php } ?> |
@@ -1893,15 +1893,15 @@ discard block |
||
| 1893 | 1893 | if ($value == $val['default']) {
|
| 1894 | 1894 | $value = ''; |
| 1895 | 1895 | } ?> |
| 1896 | - <div id="<?php echo $name;?>_row" |
|
| 1897 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1896 | + <div id="<?php echo $name; ?>_row" |
|
| 1897 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 1898 | 1898 | <label> |
| 1899 | 1899 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1900 | 1900 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1901 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1901 | + <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1902 | 1902 | </label> |
| 1903 | 1903 | |
| 1904 | - <div id="<?php echo $name;?>" class="geodir_taxonomy_field" style="float:left; width:70%;"> |
|
| 1904 | + <div id="<?php echo $name; ?>" class="geodir_taxonomy_field" style="float:left; width:70%;"> |
|
| 1905 | 1905 | <?php |
| 1906 | 1906 | global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats; |
| 1907 | 1907 | |
@@ -1913,7 +1913,7 @@ discard block |
||
| 1913 | 1913 | |
| 1914 | 1914 | $package_info = array(); |
| 1915 | 1915 | |
| 1916 | - $package_info = (array)geodir_post_package_info($package_info, $post, $post_type); |
|
| 1916 | + $package_info = (array) geodir_post_package_info($package_info, $post, $post_type); |
|
| 1917 | 1917 | |
| 1918 | 1918 | if (!empty($package_info)) {
|
| 1919 | 1919 | |
@@ -1996,7 +1996,7 @@ discard block |
||
| 1996 | 1996 | ?> |
| 1997 | 1997 | </div> |
| 1998 | 1998 | |
| 1999 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
|
| 1999 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?></span> |
|
| 2000 | 2000 | <?php if ($is_required) { ?>
|
| 2001 | 2001 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 2002 | 2002 | <?php } ?> |
@@ -2038,7 +2038,7 @@ discard block |
||
| 2038 | 2038 | $file_totImg = count($curImages); |
| 2039 | 2039 | } |
| 2040 | 2040 | |
| 2041 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
|
|
| 2041 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? implode(",", $extra_fields['gd_file_types']) : '';
|
|
| 2042 | 2042 | $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
|
| 2043 | 2043 | |
| 2044 | 2044 | ?> |
@@ -2049,13 +2049,13 @@ discard block |
||
| 2049 | 2049 | </h5> <?php */ |
| 2050 | 2050 | ?> |
| 2051 | 2051 | |
| 2052 | - <div id="<?php echo $name;?>_row" |
|
| 2053 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 2052 | + <div id="<?php echo $name; ?>_row" |
|
| 2053 | + class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class; ?>"> |
|
| 2054 | 2054 | |
| 2055 | 2055 | <div id="<?php echo $file_id; ?>dropbox" style="text-align:center;"> |
| 2056 | 2056 | <label |
| 2057 | 2057 | style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory'); |
| 2058 | - echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label> |
|
| 2058 | + echo $site_title; ?><?php if ($is_required) echo '<span>*</span>'; ?></label> |
|
| 2059 | 2059 | <input class="geodir-custom-file-upload" field_type="file" type="hidden" |
| 2060 | 2060 | name="<?php echo $file_id; ?>" id="<?php echo $file_id; ?>" |
| 2061 | 2061 | value="<?php echo esc_attr($file_value); ?>"/> |
@@ -2063,7 +2063,7 @@ discard block |
||
| 2063 | 2063 | id="<?php echo $file_id; ?>image_limit" value="<?php echo $file_image_limit; ?>"/> |
| 2064 | 2064 | <?php if ($allowed_file_types != '') { ?>
|
| 2065 | 2065 | <input type="hidden" name="<?php echo $file_id; ?>_allowed_types" |
| 2066 | - id="<?php echo $file_id; ?>_allowed_types" value="<?php echo esc_attr($allowed_file_types); ?>" data-exts="<?php echo esc_attr($display_file_types);?>"/> |
|
| 2066 | + id="<?php echo $file_id; ?>_allowed_types" value="<?php echo esc_attr($allowed_file_types); ?>" data-exts="<?php echo esc_attr($display_file_types); ?>"/> |
|
| 2067 | 2067 | <?php } ?> |
| 2068 | 2068 | <input type="hidden" name="<?php echo $file_id; ?>totImg" id="<?php echo $file_id; ?>totImg" |
| 2069 | 2069 | value="<?php if (isset($file_totImg)) {
|
@@ -2079,7 +2079,7 @@ discard block |
||
| 2079 | 2079 | <?php /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */
|
| 2080 | 2080 | ?> |
| 2081 | 2081 | <input id="<?php echo $file_id; ?>plupload-browse-button" type="button" |
| 2082 | - value="<?php ($file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory') ); ?>"
|
|
| 2082 | + value="<?php ($file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory')); ?>"
|
|
| 2083 | 2083 | class="geodir_button" style="margin-top:10px;"/> |
| 2084 | 2084 | <span class="ajaxnonceplu" |
| 2085 | 2085 | id="ajaxnonceplu<?php echo wp_create_nonce($file_id . 'pluploadan'); ?>"></span> |
@@ -2102,7 +2102,7 @@ discard block |
||
| 2102 | 2102 | |
| 2103 | 2103 | </div> |
| 2104 | 2104 | </div> |
| 2105 | - <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?> <?php echo ( $display_file_types != '' ? __('Allowed file types:', 'geodirectory') . ' ' . $display_file_types : '' );?></span>
|
|
| 2105 | + <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory'); ?> <?php echo ($display_file_types != '' ? __('Allowed file types:', 'geodirectory') . ' ' . $display_file_types : ''); ?></span>
|
|
| 2106 | 2106 | <?php if ($is_required) { ?>
|
| 2107 | 2107 | <span class="geodir_message_error"><?php _e($required_msg, 'geodirectory'); ?></span> |
| 2108 | 2108 | <?php } ?> |
@@ -2208,7 +2208,7 @@ discard block |
||
| 2208 | 2208 | |
| 2209 | 2209 | $variables_array = array(); |
| 2210 | 2210 | |
| 2211 | - if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int)$type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
|
|
| 2211 | + if ($fields_location == 'detail' && isset($type['show_as_tab']) && (int) $type['show_as_tab'] == 1 && in_array($type['type'], array('text', 'datepicker', 'textarea', 'time', 'phone', 'email', 'select', 'multiselect', 'url', 'html', 'fieldset', 'radio', 'checkbox', 'file'))) {
|
|
| 2212 | 2212 | continue; |
| 2213 | 2213 | } |
| 2214 | 2214 | |
@@ -2234,12 +2234,12 @@ discard block |
||
| 2234 | 2234 | |
| 2235 | 2235 | case 'fieldset': |
| 2236 | 2236 | |
| 2237 | - $fieldset_class = 'fieldset-'.sanitize_title_with_dashes($type['site_title']); |
|
| 2237 | + $fieldset_class = 'fieldset-' . sanitize_title_with_dashes($type['site_title']); |
|
| 2238 | 2238 | |
| 2239 | 2239 | if ($field_set_start == 1) {
|
| 2240 | - echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>'; |
|
| 2240 | + echo '</div><div class="geodir-company_info field-group ' . $type['htmlvar_name'] . '"><h2 class="' . $fieldset_class . '">' . __($type['site_title'], 'geodirectory') . '</h2>'; |
|
| 2241 | 2241 | } else {
|
| 2242 | - echo '<h2 class="'.$fieldset_class.'">' . __($type['site_title'], 'geodirectory') . '</h2>'; |
|
| 2242 | + echo '<h2 class="' . $fieldset_class . '">' . __($type['site_title'], 'geodirectory') . '</h2>'; |
|
| 2243 | 2243 | $field_set_start = 1; |
| 2244 | 2244 | } |
| 2245 | 2245 | |
@@ -2411,7 +2411,7 @@ discard block |
||
| 2411 | 2411 | |
| 2412 | 2412 | $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
| 2413 | 2413 | $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; |
| 2414 | - if(!empty($type['default_value'])){$title = $type['default_value'];}
|
|
| 2414 | + if (!empty($type['default_value'])) {$title = $type['default_value']; }
|
|
| 2415 | 2415 | $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
| 2416 | 2416 | |
| 2417 | 2417 | |
@@ -2524,17 +2524,17 @@ discard block |
||
| 2524 | 2524 | $date_format = $date_format['date_format']; |
| 2525 | 2525 | } |
| 2526 | 2526 | |
| 2527 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 2528 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 2527 | + $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format
|
|
| 2528 | + $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format
|
|
| 2529 | 2529 | |
| 2530 | 2530 | $date_format = str_replace($search, $replace, $date_format); |
| 2531 | 2531 | |
| 2532 | 2532 | $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $post->{$type['htmlvar_name']}) : $post->{$type['htmlvar_name']}; // PHP doesn't work well with dd/mm/yyyy format
|
| 2533 | 2533 | |
| 2534 | 2534 | $value = ''; |
| 2535 | - if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
|
|
| 2535 | + if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']} != "0000-00-00") {
|
|
| 2536 | 2536 | $value = date($date_format, strtotime($post_htmlvar_value)); |
| 2537 | - }else{
|
|
| 2537 | + } else {
|
|
| 2538 | 2538 | continue; |
| 2539 | 2539 | } |
| 2540 | 2540 | |
@@ -2677,7 +2677,7 @@ discard block |
||
| 2677 | 2677 | |
| 2678 | 2678 | $html_var = $type['htmlvar_name']; |
| 2679 | 2679 | |
| 2680 | - if ((int)$post->$html_var == 1): |
|
| 2680 | + if ((int) $post->$html_var == 1): |
|
| 2681 | 2681 | |
| 2682 | 2682 | if ($post->{$type['htmlvar_name']} == '1'):
|
| 2683 | 2683 | $html_val = __('Yes', 'geodirectory');
|
@@ -2904,8 +2904,8 @@ discard block |
||
| 2904 | 2904 | $html = '<div class="geodir_more_info ' . $geodir_odd_even . ' ' . $type['css_class'] . ' ' . $type['htmlvar_name'] . '" style="clear:both;"><span class="geodir-i-email" style="' . $field_icon . '">' . $field_icon_af; |
| 2905 | 2905 | $html .= (trim($type['site_title'])) ? __($type['site_title'], 'geodirectory') . ': ' : ''; |
| 2906 | 2906 | $html .= '</span><span class="geodir-email-address-output">'; |
| 2907 | - $email = stripslashes($post->{$type['htmlvar_name']}) ;
|
|
| 2908 | - if($e_split = explode('@',$email)){
|
|
| 2907 | + $email = stripslashes($post->{$type['htmlvar_name']});
|
|
| 2908 | + if ($e_split = explode('@', $email)) {
|
|
| 2909 | 2909 | /** |
| 2910 | 2910 | * Filter email custom field name output. |
| 2911 | 2911 | * |
@@ -2914,10 +2914,10 @@ discard block |
||
| 2914 | 2914 | * @param string $email The email string being output. |
| 2915 | 2915 | * @param array $type Custom field variables array. |
| 2916 | 2916 | */ |
| 2917 | - $email_name = apply_filters('geodir_email_field_name_output',$email,$type);
|
|
| 2918 | - $html .= "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
|
|
| 2919 | - }else{
|
|
| 2920 | - $html .= $email; |
|
| 2917 | + $email_name = apply_filters('geodir_email_field_name_output', $email, $type);
|
|
| 2918 | + $html .= "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
|
|
| 2919 | + } else {
|
|
| 2920 | + $html .= $email; |
|
| 2921 | 2921 | } |
| 2922 | 2922 | $html .= '</span></div>'; |
| 2923 | 2923 | } |
@@ -2937,7 +2937,7 @@ discard block |
||
| 2937 | 2937 | if (!empty($files)): |
| 2938 | 2938 | |
| 2939 | 2939 | $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; |
| 2940 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2940 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : '';
|
|
| 2941 | 2941 | |
| 2942 | 2942 | $file_paths = ''; |
| 2943 | 2943 | foreach ($files as $file) {
|
@@ -2968,7 +2968,7 @@ discard block |
||
| 2968 | 2968 | // If the uploaded file is image |
| 2969 | 2969 | if (in_array($uploaded_file_type, $image_file_types)) {
|
| 2970 | 2970 | $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
| 2971 | - $file_paths .= '<a href="'.$file.'">'; |
|
| 2971 | + $file_paths .= '<a href="' . $file . '">'; |
|
| 2972 | 2972 | $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
| 2973 | 2973 | $file_paths .= '</a>'; |
| 2974 | 2974 | //$file_paths .= '<img src="'.$file.'" />'; |
@@ -3105,7 +3105,7 @@ discard block |
||
| 3105 | 3105 | $terms = $termsOrdered; |
| 3106 | 3106 | } |
| 3107 | 3107 | } |
| 3108 | - $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object)$terms) : '';
|
|
| 3108 | + $html_value = !empty($links) && !empty($terms) ? wp_sprintf('%l', $links, (object) $terms) : '';
|
|
| 3109 | 3109 | |
| 3110 | 3110 | if ($html_value != '') {
|
| 3111 | 3111 | if (strpos($field_icon, 'http') !== false) {
|
@@ -3267,7 +3267,7 @@ discard block |
||
| 3267 | 3267 | $geodir_uploadurl = $uploads['url']; |
| 3268 | 3268 | $sub_dir = $uploads['subdir']; |
| 3269 | 3269 | |
| 3270 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 3270 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types']) ? $extra_fields['gd_file_types'] : '';
|
|
| 3271 | 3271 | |
| 3272 | 3272 | for ($m = 0; $m < count($post_image); $m++) {
|
| 3273 | 3273 | |
@@ -3338,8 +3338,8 @@ discard block |
||
| 3338 | 3338 | if (!empty($postcurr_images)) {
|
| 3339 | 3339 | |
| 3340 | 3340 | if ($file_urls != $postcurr_images) {
|
| 3341 | - $invalid_files[] = (object)array('src' => $postcurr_images);
|
|
| 3342 | - $invalid_files = (object)$invalid_files; |
|
| 3341 | + $invalid_files[] = (object) array('src' => $postcurr_images);
|
|
| 3342 | + $invalid_files = (object) $invalid_files; |
|
| 3343 | 3343 | } |
| 3344 | 3344 | } |
| 3345 | 3345 | |
@@ -3426,7 +3426,7 @@ discard block |
||
| 3426 | 3426 | remove_filter('upload_dir', 'geodir_upload_dir');
|
| 3427 | 3427 | |
| 3428 | 3428 | |
| 3429 | - if(!isset($status['url']) && isset($status['error'])){
|
|
| 3429 | + if (!isset($status['url']) && isset($status['error'])) {
|
|
| 3430 | 3430 | print_r($status); |
| 3431 | 3431 | } |
| 3432 | 3432 | |
@@ -3502,10 +3502,10 @@ discard block |
||
| 3502 | 3502 | */ |
| 3503 | 3503 | function geodir_max_upload_size() |
| 3504 | 3504 | {
|
| 3505 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 3505 | + $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
|
|
| 3506 | 3506 | |
| 3507 | 3507 | if ($max_filesize > 0 && $max_filesize < 1) {
|
| 3508 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 3508 | + $max_filesize = (int) ($max_filesize * 1024) . 'kb'; |
|
| 3509 | 3509 | } else {
|
| 3510 | 3510 | $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
| 3511 | 3511 | } |
@@ -3813,7 +3813,7 @@ discard block |
||
| 3813 | 3813 | } |
| 3814 | 3814 | |
| 3815 | 3815 | |
| 3816 | - return (int)$lastid; |
|
| 3816 | + return (int) $lastid; |
|
| 3817 | 3817 | |
| 3818 | 3818 | } |
| 3819 | 3819 | } |
@@ -3909,38 +3909,38 @@ discard block |
||
| 3909 | 3909 | $nonce = wp_create_nonce('custom_fields_' . $result_str);
|
| 3910 | 3910 | |
| 3911 | 3911 | ?> |
| 3912 | - <li class="text" id="licontainer_<?php echo $result_str;?>"> |
|
| 3913 | - <div class="title title<?php echo $result_str;?> gt-fieldset" |
|
| 3914 | - title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory');?>"
|
|
| 3915 | - ondblclick="show_hide('field_frm<?php echo $result_str;?>')">
|
|
| 3912 | + <li class="text" id="licontainer_<?php echo $result_str; ?>"> |
|
| 3913 | + <div class="title title<?php echo $result_str; ?> gt-fieldset" |
|
| 3914 | + title="<?php _e('Double Click to toggle and drag-drop to sort', 'geodirectory'); ?>"
|
|
| 3915 | + ondblclick="show_hide('field_frm<?php echo $result_str; ?>')">
|
|
| 3916 | 3916 | <?php |
| 3917 | 3917 | |
| 3918 | 3918 | $nonce = wp_create_nonce('custom_fields_' . $result_str);
|
| 3919 | 3919 | ?> |
| 3920 | 3920 | |
| 3921 | - <div title="<?php _e('Click to remove field', 'geodirectory');?>"
|
|
| 3922 | - onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
|
|
| 3921 | + <div title="<?php _e('Click to remove field', 'geodirectory'); ?>"
|
|
| 3922 | + onclick="delete_sort_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>', this)"
|
|
| 3923 | 3923 | class="handlediv close"></div> |
| 3924 | 3924 | |
| 3925 | 3925 | <b style="cursor:pointer;" |
| 3926 | - onclick="show_hide('field_frm<?php echo $result_str;?>')"><?php echo geodir_ucwords(__('Field:', 'geodirectory') . ' (' . $site_title . ')');?></b>
|
|
| 3926 | + onclick="show_hide('field_frm<?php echo $result_str; ?>')"><?php echo geodir_ucwords(__('Field:', 'geodirectory') . ' (' . $site_title . ')'); ?></b>
|
|
| 3927 | 3927 | |
| 3928 | 3928 | </div> |
| 3929 | 3929 | |
| 3930 | - <div id="field_frm<?php echo $result_str;?>" class="field_frm" |
|
| 3930 | + <div id="field_frm<?php echo $result_str; ?>" class="field_frm" |
|
| 3931 | 3931 | style="display:<?php if ($field_ins_upd == 'submit') {
|
| 3932 | 3932 | echo 'block;'; |
| 3933 | 3933 | } else {
|
| 3934 | 3934 | echo 'none;'; |
| 3935 | 3935 | } ?>"> |
| 3936 | 3936 | <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> |
| 3937 | - <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/> |
|
| 3938 | - <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/> |
|
| 3939 | - <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str;?>"/> |
|
| 3937 | + <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type; ?>"/> |
|
| 3938 | + <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type; ?>"/> |
|
| 3939 | + <input type="hidden" name="field_id" id="field_id" value="<?php echo $result_str; ?>"/> |
|
| 3940 | 3940 | <input type="hidden" name="data_type" id="data_type" value="<?php if (isset($field_info->data_type)) {
|
| 3941 | 3941 | echo $field_info->data_type; |
| 3942 | 3942 | }?>"/> |
| 3943 | - <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name;?>"/> |
|
| 3943 | + <input type="hidden" name="htmlvar_name" id="htmlvar_name" value="<?php echo $htmlvar_name; ?>"/> |
|
| 3944 | 3944 | |
| 3945 | 3945 | |
| 3946 | 3946 | <table class="widefat post fixed" border="0" style="width:100%;"> |
@@ -4022,42 +4022,42 @@ discard block |
||
| 4022 | 4022 | <?php } ?> |
| 4023 | 4023 | |
| 4024 | 4024 | <tr> |
| 4025 | - <td><strong><?php _e('Is active :', 'geodirectory');?></strong></td>
|
|
| 4025 | + <td><strong><?php _e('Is active :', 'geodirectory'); ?></strong></td>
|
|
| 4026 | 4026 | <td align="left"> |
| 4027 | 4027 | <select name="is_active" id="is_active"> |
| 4028 | 4028 | <option |
| 4029 | 4029 | value="1" <?php if (isset($field_info->is_active) && $field_info->is_active == '1') {
|
| 4030 | 4030 | echo 'selected="selected"'; |
| 4031 | - }?>><?php _e('Yes', 'geodirectory');?></option>
|
|
| 4031 | + }?>><?php _e('Yes', 'geodirectory'); ?></option>
|
|
| 4032 | 4032 | <option |
| 4033 | 4033 | value="0" <?php if (isset($field_info->is_active) && $field_info->is_active == '0') {
|
| 4034 | 4034 | echo 'selected="selected"'; |
| 4035 | - }?>><?php _e('No', 'geodirectory');?></option>
|
|
| 4035 | + }?>><?php _e('No', 'geodirectory'); ?></option>
|
|
| 4036 | 4036 | </select> |
| 4037 | 4037 | <br/> |
| 4038 | - <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory');?></span>
|
|
| 4038 | + <span><?php _e('Select yes or no. If no is selected then the field will not be displayed anywhere.', 'geodirectory'); ?></span>
|
|
| 4039 | 4039 | </td> |
| 4040 | 4040 | </tr> |
| 4041 | 4041 | |
| 4042 | 4042 | <tr> |
| 4043 | - <td><strong><?php _e('Display order :', 'geodirectory');?></strong></td>
|
|
| 4043 | + <td><strong><?php _e('Display order :', 'geodirectory'); ?></strong></td>
|
|
| 4044 | 4044 | <td align="left"><input type="text" readonly="readonly" name="sort_order" id="sort_order" |
| 4045 | 4045 | value="<?php if (isset($field_info->sort_order)) {
|
| 4046 | 4046 | echo esc_attr($field_info->sort_order); |
| 4047 | 4047 | }?>" size="50"/> |
| 4048 | 4048 | <br/> |
| 4049 | - <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory');?></span>
|
|
| 4049 | + <span><?php _e('Enter the display order of this field in backend. e.g. 5', 'geodirectory'); ?></span>
|
|
| 4050 | 4050 | </td> |
| 4051 | 4051 | </tr> |
| 4052 | 4052 | |
| 4053 | 4053 | <tr> |
| 4054 | 4054 | <td> </td> |
| 4055 | 4055 | <td align="left"> |
| 4056 | - <input type="button" class="button" name="save" id="save" value="<?php esc_attr_e('Save', 'geodirectory');?>"
|
|
| 4057 | - onclick="save_sort_field('<?php echo $result_str;?>')"/>
|
|
| 4056 | + <input type="button" class="button" name="save" id="save" value="<?php esc_attr_e('Save', 'geodirectory'); ?>"
|
|
| 4057 | + onclick="save_sort_field('<?php echo $result_str; ?>')"/>
|
|
| 4058 | 4058 | |
| 4059 | - <a href="javascript:void(0)"><input type="button" name="delete" value="<?php esc_attr_e('Delete', 'geodirectory');?>"
|
|
| 4060 | - onclick="delete_sort_field('<?php echo $result_str;?>', '<?php echo $nonce;?>', this)"
|
|
| 4059 | + <a href="javascript:void(0)"><input type="button" name="delete" value="<?php esc_attr_e('Delete', 'geodirectory'); ?>"
|
|
| 4060 | + onclick="delete_sort_field('<?php echo $result_str; ?>', '<?php echo $nonce; ?>', this)"
|
|
| 4061 | 4061 | class="button_n"/></a> |
| 4062 | 4062 | |
| 4063 | 4063 | </td> |
@@ -4092,7 +4092,7 @@ discard block |
||
| 4092 | 4092 | if (!$package_id || !$field_name || !$post_type) {
|
| 4093 | 4093 | return true; |
| 4094 | 4094 | } |
| 4095 | - $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int)$package_id));
|
|
| 4095 | + $sql = $wpdb->prepare("SELECT id FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE is_active='1' AND htmlvar_name=%s AND post_type=%s AND FIND_IN_SET(%s, packages)", array($field_name, $post_type, (int) $package_id));
|
|
| 4096 | 4096 | |
| 4097 | 4097 | if ($wpdb->get_var($sql)) {
|
| 4098 | 4098 | return true; |
@@ -51,8 +51,9 @@ discard block |
||
| 51 | 51 | global $wpdb; |
| 52 | 52 | $result = 0;// no rows affected |
| 53 | 53 | if (!geodir_column_exist($db, $column)) {
|
| 54 | - if (!empty($db) && !empty($column)) |
|
| 55 | - $result = $wpdb->query("ALTER TABLE `$db` ADD `$column` $column_attr");
|
|
| 54 | + if (!empty($db) && !empty($column)) { |
|
| 55 | + $result = $wpdb->query("ALTER TABLE `$db` ADD `$column` $column_attr"); |
|
| 56 | + } |
|
| 56 | 57 | } |
| 57 | 58 | return $result; |
| 58 | 59 | } |
@@ -82,10 +83,11 @@ discard block |
||
| 82 | 83 | |
| 83 | 84 | $default_query = ''; |
| 84 | 85 | |
| 85 | - if ($default == 'default') |
|
| 86 | - $default_query = " and is_default IN ('1') ";
|
|
| 87 | - elseif ($default == 'custom') |
|
| 88 | - $default_query = " and is_default = '0' "; |
|
| 86 | + if ($default == 'default') { |
|
| 87 | + $default_query = " and is_default IN ('1') "; |
|
| 88 | + } elseif ($default == 'custom') { |
|
| 89 | + $default_query = " and is_default = '0' "; |
|
| 90 | + } |
|
| 89 | 91 | |
| 90 | 92 | if ($fields_location == 'detail') {
|
| 91 | 93 | $default_query = " and show_on_detail='1' "; |
@@ -243,10 +245,12 @@ discard block |
||
| 243 | 245 | |
| 244 | 246 | return $field_id; |
| 245 | 247 | |
| 246 | - } else |
|
| 247 | - return 0; |
|
| 248 | - } else |
|
| 249 | - return 0; |
|
| 248 | + } else { |
|
| 249 | + return 0; |
|
| 250 | + } |
|
| 251 | + } else { |
|
| 252 | + return 0; |
|
| 253 | + } |
|
| 250 | 254 | |
| 251 | 255 | } |
| 252 | 256 | } |
@@ -355,7 +359,9 @@ discard block |
||
| 355 | 359 | }*/ |
| 356 | 360 | |
| 357 | 361 | |
| 358 | - if ($post_type == '') $post_type = 'gd_place'; |
|
| 362 | + if ($post_type == '') { |
|
| 363 | + $post_type = 'gd_place'; |
|
| 364 | + } |
|
| 359 | 365 | |
| 360 | 366 | |
| 361 | 367 | $detail_table = $plugin_prefix . $post_type . '_detail'; |
@@ -388,20 +394,23 @@ discard block |
||
| 388 | 394 | } |
| 389 | 395 | |
| 390 | 396 | $option_values = ''; |
| 391 | - if (isset($request_field['option_values'])) |
|
| 392 | - $option_values = $request_field['option_values']; |
|
| 397 | + if (isset($request_field['option_values'])) { |
|
| 398 | + $option_values = $request_field['option_values']; |
|
| 399 | + } |
|
| 393 | 400 | |
| 394 | 401 | $cat_sort = ''; |
| 395 | - if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort'])) |
|
| 396 | - $cat_sort = implode(",", $request_field['cat_sort']);
|
|
| 402 | + if (isset($request_field['cat_sort']) && !empty($request_field['cat_sort'])) { |
|
| 403 | + $cat_sort = implode(",", $request_field['cat_sort']); |
|
| 404 | + } |
|
| 397 | 405 | |
| 398 | 406 | $cat_filter = ''; |
| 399 | - if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter'])) |
|
| 400 | - $cat_filter = implode(",", $request_field['cat_filter']);
|
|
| 407 | + if (isset($request_field['cat_filter']) && !empty($request_field['cat_filter'])) { |
|
| 408 | + $cat_filter = implode(",", $request_field['cat_filter']); |
|
| 409 | + } |
|
| 401 | 410 | |
| 402 | - if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) |
|
| 403 | - $price_pkg = implode(",", $request_field['show_on_pkg']);
|
|
| 404 | - else {
|
|
| 411 | + if (isset($request_field['show_on_pkg']) && !empty($request_field['show_on_pkg'])) { |
|
| 412 | + $price_pkg = implode(",", $request_field['show_on_pkg']); |
|
| 413 | + } else {
|
|
| 405 | 414 | $package_info = array(); |
| 406 | 415 | |
| 407 | 416 | $package_info = geodir_post_package_info($package_info, '', $post_type); |
@@ -409,22 +418,29 @@ discard block |
||
| 409 | 418 | } |
| 410 | 419 | |
| 411 | 420 | |
| 412 | - if (isset($request_field['extra']) && !empty($request_field['extra'])) |
|
| 413 | - $extra_fields = $request_field['extra']; |
|
| 421 | + if (isset($request_field['extra']) && !empty($request_field['extra'])) { |
|
| 422 | + $extra_fields = $request_field['extra']; |
|
| 423 | + } |
|
| 414 | 424 | |
| 415 | - if (isset($request_field['is_default']) && $request_field['is_default'] != '') |
|
| 416 | - $is_default = $request_field['is_default']; |
|
| 417 | - else |
|
| 418 | - $is_default = '0'; |
|
| 425 | + if (isset($request_field['is_default']) && $request_field['is_default'] != '') { |
|
| 426 | + $is_default = $request_field['is_default']; |
|
| 427 | + } else { |
|
| 428 | + $is_default = '0'; |
|
| 429 | + } |
|
| 419 | 430 | |
| 420 | - if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') |
|
| 421 | - $is_admin = $request_field['is_admin']; |
|
| 422 | - else |
|
| 423 | - $is_admin = '0'; |
|
| 431 | + if (isset($request_field['is_admin']) && $request_field['is_admin'] != '') { |
|
| 432 | + $is_admin = $request_field['is_admin']; |
|
| 433 | + } else { |
|
| 434 | + $is_admin = '0'; |
|
| 435 | + } |
|
| 424 | 436 | |
| 425 | 437 | |
| 426 | - if ($is_active == '') $is_active = 1; |
|
| 427 | - if ($is_required == '') $is_required = 0; |
|
| 438 | + if ($is_active == '') { |
|
| 439 | + $is_active = 1; |
|
| 440 | + } |
|
| 441 | + if ($is_required == '') { |
|
| 442 | + $is_required = 0; |
|
| 443 | + } |
|
| 428 | 444 | |
| 429 | 445 | |
| 430 | 446 | if ($sort_order == '') {
|
@@ -692,7 +708,7 @@ discard block |
||
| 692 | 708 | } |
| 693 | 709 | if($op_max){$op_size =$op_max; }
|
| 694 | 710 | } |
| 695 | - }elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
|
|
| 711 | + } elseif(isset($option_values) && $option_values && $field_type=='multiselect'){
|
|
| 696 | 712 | if(strlen($option_values)){
|
| 697 | 713 | $op_size = strlen($option_values); |
| 698 | 714 | } |
@@ -709,11 +725,13 @@ discard block |
||
| 709 | 725 | return __('Column change failed, you may have too many columns.','geodirectory');
|
| 710 | 726 | } |
| 711 | 727 | |
| 712 | - if (isset($request_field['cat_display_type'])) |
|
| 713 | - $extra_fields = $request_field['cat_display_type']; |
|
| 728 | + if (isset($request_field['cat_display_type'])) { |
|
| 729 | + $extra_fields = $request_field['cat_display_type']; |
|
| 730 | + } |
|
| 714 | 731 | |
| 715 | - if (isset($request_field['multi_display_type'])) |
|
| 716 | - $extra_fields = $request_field['multi_display_type']; |
|
| 732 | + if (isset($request_field['multi_display_type'])) { |
|
| 733 | + $extra_fields = $request_field['multi_display_type']; |
|
| 734 | + } |
|
| 717 | 735 | |
| 718 | 736 | |
| 719 | 737 | break; |
@@ -725,8 +743,9 @@ discard block |
||
| 725 | 743 | if($alter_result===false){
|
| 726 | 744 | return __('Column change failed, you may have too many columns.','geodirectory');
|
| 727 | 745 | } |
| 728 | - if (isset($request_field['advanced_editor'])) |
|
| 729 | - $extra_fields = $request_field['advanced_editor']; |
|
| 746 | + if (isset($request_field['advanced_editor'])) { |
|
| 747 | + $extra_fields = $request_field['advanced_editor']; |
|
| 748 | + } |
|
| 730 | 749 | |
| 731 | 750 | break; |
| 732 | 751 | |
@@ -820,8 +839,9 @@ discard block |
||
| 820 | 839 | ); |
| 821 | 840 | |
| 822 | 841 | |
| 823 | - if ($cat_sort == '') |
|
| 824 | - $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name)));
|
|
| 842 | + if ($cat_sort == '') { |
|
| 843 | + $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type = %s and htmlvar_name = %s", array($post_type, $htmlvar_name))); |
|
| 844 | + } |
|
| 825 | 845 | |
| 826 | 846 | |
| 827 | 847 | /** |
@@ -1188,8 +1208,10 @@ discard block |
||
| 1188 | 1208 | } |
| 1189 | 1209 | |
| 1190 | 1210 | return $post_meta_info; |
| 1191 | - else: |
|
| 1192 | - return false; |
|
| 1211 | + else { |
|
| 1212 | + : |
|
| 1213 | + return false; |
|
| 1214 | + } |
|
| 1193 | 1215 | endif; |
| 1194 | 1216 | } |
| 1195 | 1217 | |
@@ -1242,8 +1264,9 @@ discard block |
||
| 1242 | 1264 | if (is_admin()) {
|
| 1243 | 1265 | global $post; |
| 1244 | 1266 | |
| 1245 | - if (isset($_REQUEST['post'])) |
|
| 1246 | - $_REQUEST['pid'] = $_REQUEST['post']; |
|
| 1267 | + if (isset($_REQUEST['post'])) { |
|
| 1268 | + $_REQUEST['pid'] = $_REQUEST['post']; |
|
| 1269 | + } |
|
| 1247 | 1270 | } |
| 1248 | 1271 | |
| 1249 | 1272 | if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) {
|
@@ -1274,7 +1297,10 @@ discard block |
||
| 1274 | 1297 | $fieldset_id = (int)$val['id']; |
| 1275 | 1298 | $fieldset_field_class = 'gd-fieldset-' . $fieldset_id; |
| 1276 | 1299 | ?><h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?> |
| 1277 | - <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>';?> |
|
| 1300 | + <?php if ($admin_desc != '') { |
|
| 1301 | + echo '<small>( ' . $admin_desc . ' )</small>'; |
|
| 1302 | +} |
|
| 1303 | +?> |
|
| 1278 | 1304 | </h5><?php |
| 1279 | 1305 | |
| 1280 | 1306 | } elseif ($type == 'address') {
|
@@ -1313,17 +1339,27 @@ discard block |
||
| 1313 | 1339 | } |
| 1314 | 1340 | |
| 1315 | 1341 | $location = geodir_get_default_location(); |
| 1316 | - if (empty($city)) $city = isset($location->city) ? $location->city : ''; |
|
| 1317 | - if (empty($region)) $region = isset($location->region) ? $location->region : ''; |
|
| 1318 | - if (empty($country)) $country = isset($location->country) ? $location->country : ''; |
|
| 1342 | + if (empty($city)) { |
|
| 1343 | + $city = isset($location->city) ? $location->city : ''; |
|
| 1344 | + } |
|
| 1345 | + if (empty($region)) { |
|
| 1346 | + $region = isset($location->region) ? $location->region : ''; |
|
| 1347 | + } |
|
| 1348 | + if (empty($country)) { |
|
| 1349 | + $country = isset($location->country) ? $location->country : ''; |
|
| 1350 | + } |
|
| 1319 | 1351 | |
| 1320 | 1352 | $lat_lng_blank = false; |
| 1321 | 1353 | if (empty($lat) && empty($lng)) {
|
| 1322 | 1354 | $lat_lng_blank = true; |
| 1323 | 1355 | } |
| 1324 | 1356 | |
| 1325 | - if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : ''; |
|
| 1326 | - if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : ''; |
|
| 1357 | + if (empty($lat)) { |
|
| 1358 | + $lat = isset($location->city_latitude) ? $location->city_latitude : ''; |
|
| 1359 | + } |
|
| 1360 | + if (empty($lng)) { |
|
| 1361 | + $lng = isset($location->city_longitude) ? $location->city_longitude : ''; |
|
| 1362 | + } |
|
| 1327 | 1363 | |
| 1328 | 1364 | /** |
| 1329 | 1365 | * Filter the default latitude. |
@@ -1347,10 +1383,16 @@ discard block |
||
| 1347 | 1383 | ?> |
| 1348 | 1384 | |
| 1349 | 1385 | <div id="geodir_<?php echo $prefix . 'address';?>_row" |
| 1350 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1386 | + class="<?php if ($is_required) { |
|
| 1387 | + echo 'required_field'; |
|
| 1388 | +} |
|
| 1389 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1351 | 1390 | <label> |
| 1352 | 1391 | <?php _e($address_title, 'geodirectory'); ?> |
| 1353 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1392 | + <?php if ($is_required) { |
|
| 1393 | + echo '<span>*</span>'; |
|
| 1394 | +} |
|
| 1395 | +?> |
|
| 1354 | 1396 | </label> |
| 1355 | 1397 | <input type="text" field_type="<?php echo $type;?>" name="<?php echo $prefix . 'address';?>" |
| 1356 | 1398 | id="<?php echo $prefix . 'address';?>" class="geodir_textfield" |
@@ -1411,10 +1453,16 @@ discard block |
||
| 1411 | 1453 | /* show lat lng */ |
| 1412 | 1454 | $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?> |
| 1413 | 1455 | <div id="geodir_<?php echo $prefix . 'latitude'; ?>_row" |
| 1414 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>> |
|
| 1456 | + class="<?php if ($is_required) { |
|
| 1457 | + echo 'required_field'; |
|
| 1458 | +} |
|
| 1459 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>> |
|
| 1415 | 1460 | <label> |
| 1416 | 1461 | <?php echo PLACE_ADDRESS_LAT; ?> |
| 1417 | - <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1462 | + <?php if ($is_required) { |
|
| 1463 | + echo '<span>*</span>'; |
|
| 1464 | +} |
|
| 1465 | +?> |
|
| 1418 | 1466 | </label> |
| 1419 | 1467 | <input type="text" field_type="<?php echo $type; ?>" name="<?php echo $prefix . 'latitude'; ?>" |
| 1420 | 1468 | id="<?php echo $prefix . 'latitude'; ?>" class="geodir_textfield" |
@@ -1426,10 +1474,16 @@ discard block |
||
| 1426 | 1474 | </div> |
| 1427 | 1475 | |
| 1428 | 1476 | <div id="geodir_<?php echo $prefix . 'longitude'; ?>_row" |
| 1429 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>> |
|
| 1477 | + class="<?php if ($is_required) { |
|
| 1478 | + echo 'required_field'; |
|
| 1479 | +} |
|
| 1480 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>" <?php echo $style_latlng; ?>> |
|
| 1430 | 1481 | <label> |
| 1431 | 1482 | <?php echo PLACE_ADDRESS_LNG; ?> |
| 1432 | - <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1483 | + <?php if ($is_required) { |
|
| 1484 | + echo '<span>*</span>'; |
|
| 1485 | +} |
|
| 1486 | +?> |
|
| 1433 | 1487 | </label> |
| 1434 | 1488 | <input type="text" field_type="<?php echo $type; ?>" name="<?php echo $prefix . 'longitude'; ?>" |
| 1435 | 1489 | id="<?php echo $prefix . 'longitude'; ?>" class="geodir_textfield" |
@@ -1484,26 +1538,31 @@ discard block |
||
| 1484 | 1538 | <?php } elseif ($type == 'text') {
|
| 1485 | 1539 | |
| 1486 | 1540 | //number and float validation $validation_pattern |
| 1487 | - if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';}
|
|
| 1488 | - elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
|
|
| 1541 | + if(isset($val['data_type']) && $val['data_type']=='INT'){$type = 'number';} elseif(isset($val['data_type']) && $val['data_type']=='FLOAT'){$type = 'float';}
|
|
| 1489 | 1542 | //print_r($val); |
| 1490 | 1543 | //validation |
| 1491 | 1544 | if(isset($val['validation_pattern']) && $val['validation_pattern']){
|
| 1492 | 1545 | $validation = 'pattern="'.$val['validation_pattern'].'"'; |
| 1493 | - }else{$validation='';}
|
|
| 1546 | + } else{$validation='';}
|
|
| 1494 | 1547 | |
| 1495 | 1548 | // validation message |
| 1496 | 1549 | if(isset($val['validation_msg']) && $val['validation_msg']){
|
| 1497 | 1550 | $validation_msg = 'title="'.$val['validation_msg'].'"'; |
| 1498 | - }else{$validation_msg='';}
|
|
| 1551 | + } else{$validation_msg='';}
|
|
| 1499 | 1552 | ?> |
| 1500 | 1553 | |
| 1501 | 1554 | <div id="<?php echo $name;?>_row" |
| 1502 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1555 | + class="<?php if ($is_required) { |
|
| 1556 | + echo 'required_field'; |
|
| 1557 | +} |
|
| 1558 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1503 | 1559 | <label> |
| 1504 | 1560 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1505 | 1561 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1506 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1562 | + <?php if ($is_required) { |
|
| 1563 | + echo '<span>*</span>'; |
|
| 1564 | +} |
|
| 1565 | +?> |
|
| 1507 | 1566 | </label> |
| 1508 | 1567 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
| 1509 | 1568 | value="<?php echo esc_attr(stripslashes($value));?>" type="<?php echo $type;?>" class="geodir_textfield" <?php echo $validation;echo $validation_msg;?> /> |
@@ -1519,11 +1578,17 @@ discard block |
||
| 1519 | 1578 | }?> |
| 1520 | 1579 | |
| 1521 | 1580 | <div id="<?php echo $name;?>_row" |
| 1522 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1581 | + class="<?php if ($is_required) { |
|
| 1582 | + echo 'required_field'; |
|
| 1583 | +} |
|
| 1584 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1523 | 1585 | <label> |
| 1524 | 1586 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1525 | 1587 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1526 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1588 | + <?php if ($is_required) { |
|
| 1589 | + echo '<span>*</span>'; |
|
| 1590 | +} |
|
| 1591 | +?> |
|
| 1527 | 1592 | </label> |
| 1528 | 1593 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
| 1529 | 1594 | value="<?php echo esc_attr(stripslashes($value));?>" type="email" class="geodir_textfield"/> |
@@ -1539,11 +1604,17 @@ discard block |
||
| 1539 | 1604 | } ?> |
| 1540 | 1605 | |
| 1541 | 1606 | <div id="<?php echo $name;?>_row" |
| 1542 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1607 | + class="<?php if ($is_required) { |
|
| 1608 | + echo 'required_field'; |
|
| 1609 | +} |
|
| 1610 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1543 | 1611 | <label> |
| 1544 | 1612 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1545 | 1613 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1546 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1614 | + <?php if ($is_required) { |
|
| 1615 | + echo '<span>*</span>'; |
|
| 1616 | +} |
|
| 1617 | +?> |
|
| 1547 | 1618 | </label> |
| 1548 | 1619 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
| 1549 | 1620 | value="<?php echo esc_attr(stripslashes($value));?>" type="tel" class="geodir_textfield"/> |
@@ -1559,11 +1630,17 @@ discard block |
||
| 1559 | 1630 | }?> |
| 1560 | 1631 | |
| 1561 | 1632 | <div id="<?php echo $name;?>_row" |
| 1562 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1633 | + class="<?php if ($is_required) { |
|
| 1634 | + echo 'required_field'; |
|
| 1635 | +} |
|
| 1636 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1563 | 1637 | <label> |
| 1564 | 1638 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1565 | 1639 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1566 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1640 | + <?php if ($is_required) { |
|
| 1641 | + echo '<span>*</span>'; |
|
| 1642 | +} |
|
| 1643 | +?> |
|
| 1567 | 1644 | </label> |
| 1568 | 1645 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
| 1569 | 1646 | value="<?php echo esc_attr(stripslashes($value));?>" type="url" class="geodir_textfield" |
@@ -1578,11 +1655,17 @@ discard block |
||
| 1578 | 1655 | |
| 1579 | 1656 | <?php } elseif ($type == 'radio') { ?>
|
| 1580 | 1657 | <div id="<?php echo $name;?>_row" |
| 1581 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1658 | + class="<?php if ($is_required) { |
|
| 1659 | + echo 'required_field'; |
|
| 1660 | +} |
|
| 1661 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1582 | 1662 | <label> |
| 1583 | 1663 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1584 | 1664 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1585 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1665 | + <?php if ($is_required) { |
|
| 1666 | + echo '<span>*</span>'; |
|
| 1667 | +} |
|
| 1668 | +?> |
|
| 1586 | 1669 | </label> |
| 1587 | 1670 | <?php if ($option_values) {
|
| 1588 | 1671 | $option_values = geodir_string_values_to_options($option_values, true); |
@@ -1607,11 +1690,17 @@ discard block |
||
| 1607 | 1690 | <?php } elseif ($type == 'checkbox') { ?>
|
| 1608 | 1691 | |
| 1609 | 1692 | <div id="<?php echo $name;?>_row" |
| 1610 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1693 | + class="<?php if ($is_required) { |
|
| 1694 | + echo 'required_field'; |
|
| 1695 | +} |
|
| 1696 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1611 | 1697 | <label> |
| 1612 | 1698 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1613 | 1699 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1614 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1700 | + <?php if ($is_required) { |
|
| 1701 | + echo '<span>*</span>'; |
|
| 1702 | +} |
|
| 1703 | +?> |
|
| 1615 | 1704 | </label> |
| 1616 | 1705 | <?php if ($value != '1') {
|
| 1617 | 1706 | $value = '0'; |
@@ -1631,11 +1720,17 @@ discard block |
||
| 1631 | 1720 | ?> |
| 1632 | 1721 | |
| 1633 | 1722 | <div id="<?php echo $name;?>_row" |
| 1634 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1723 | + class="<?php if ($is_required) { |
|
| 1724 | + echo 'required_field'; |
|
| 1725 | +} |
|
| 1726 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1635 | 1727 | <label> |
| 1636 | 1728 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1637 | 1729 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1638 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1730 | + <?php if ($is_required) { |
|
| 1731 | + echo '<span>*</span>'; |
|
| 1732 | +} |
|
| 1733 | +?> |
|
| 1639 | 1734 | </label><?php |
| 1640 | 1735 | |
| 1641 | 1736 | |
@@ -1663,11 +1758,17 @@ discard block |
||
| 1663 | 1758 | |
| 1664 | 1759 | <?php } elseif ($type == 'select') { ?>
|
| 1665 | 1760 | <div id="<?php echo $name;?>_row" |
| 1666 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1761 | + class="<?php if ($is_required) { |
|
| 1762 | + echo 'required_field'; |
|
| 1763 | +} |
|
| 1764 | +?> geodir_form_row geodir_custom_fields clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1667 | 1765 | <label> |
| 1668 | 1766 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1669 | 1767 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1670 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1768 | + <?php if ($is_required) { |
|
| 1769 | + echo '<span>*</span>'; |
|
| 1770 | +} |
|
| 1771 | +?> |
|
| 1671 | 1772 | </label> |
| 1672 | 1773 | <?php |
| 1673 | 1774 | $option_values_arr = geodir_string_values_to_options($option_values, true); |
@@ -1706,11 +1807,17 @@ discard block |
||
| 1706 | 1807 | } |
| 1707 | 1808 | ?> |
| 1708 | 1809 | <div id="<?php echo $name; ?>_row" |
| 1709 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1810 | + class="<?php if ($is_required) { |
|
| 1811 | + echo 'required_field'; |
|
| 1812 | +} |
|
| 1813 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1710 | 1814 | <label> |
| 1711 | 1815 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1712 | 1816 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1713 | - <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1817 | + <?php if ($is_required) { |
|
| 1818 | + echo '<span>*</span>'; |
|
| 1819 | +} |
|
| 1820 | +?> |
|
| 1714 | 1821 | </label> |
| 1715 | 1822 | <input type="hidden" name="gd_field_<?php echo $name; ?>" value="1"/> |
| 1716 | 1823 | <?php if ($multi_display == 'select') { ?>
|
@@ -1780,11 +1887,17 @@ discard block |
||
| 1780 | 1887 | ?> |
| 1781 | 1888 | |
| 1782 | 1889 | <div id="<?php echo $name; ?>_row" |
| 1783 | - class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1890 | + class="<?php if ($is_required) { |
|
| 1891 | + echo 'required_field'; |
|
| 1892 | +} |
|
| 1893 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1784 | 1894 | <label> |
| 1785 | 1895 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1786 | 1896 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1787 | - <?php if ($is_required) echo '<span>*</span>'; ?> |
|
| 1897 | + <?php if ($is_required) { |
|
| 1898 | + echo '<span>*</span>'; |
|
| 1899 | +} |
|
| 1900 | +?> |
|
| 1788 | 1901 | </label> |
| 1789 | 1902 | |
| 1790 | 1903 | <?php $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); ?>
|
@@ -1801,8 +1914,9 @@ discard block |
||
| 1801 | 1914 | </div> |
| 1802 | 1915 | <?php } elseif ($type == 'datepicker') {
|
| 1803 | 1916 | |
| 1804 | - if ($extra_fields['date_format'] == '') |
|
| 1805 | - $extra_fields['date_format'] = 'yy-mm-dd'; |
|
| 1917 | + if ($extra_fields['date_format'] == '') { |
|
| 1918 | + $extra_fields['date_format'] = 'yy-mm-dd'; |
|
| 1919 | + } |
|
| 1806 | 1920 | |
| 1807 | 1921 | |
| 1808 | 1922 | $search = array('dd', 'mm', 'yy');
|
@@ -1840,12 +1954,18 @@ discard block |
||
| 1840 | 1954 | |
| 1841 | 1955 | </script> |
| 1842 | 1956 | <div id="<?php echo $name;?>_row" |
| 1843 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1957 | + class="<?php if ($is_required) { |
|
| 1958 | + echo 'required_field'; |
|
| 1959 | +} |
|
| 1960 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1844 | 1961 | <label> |
| 1845 | 1962 | |
| 1846 | 1963 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1847 | 1964 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1848 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 1965 | + <?php if ($is_required) { |
|
| 1966 | + echo '<span>*</span>'; |
|
| 1967 | +} |
|
| 1968 | +?> |
|
| 1849 | 1969 | </label> |
| 1850 | 1970 | |
| 1851 | 1971 | <input field_type="<?php echo $type;?>" name="<?php echo $name;?>" id="<?php echo $name;?>" |
@@ -1859,8 +1979,9 @@ discard block |
||
| 1859 | 1979 | |
| 1860 | 1980 | <?php } elseif ($type == 'time') {
|
| 1861 | 1981 | |
| 1862 | - if ($value != '') |
|
| 1863 | - $value = date('H:i', strtotime($value));
|
|
| 1982 | + if ($value != '') { |
|
| 1983 | + $value = date('H:i', strtotime($value)); |
|
| 1984 | + } |
|
| 1864 | 1985 | ?> |
| 1865 | 1986 | <script type="text/javascript"> |
| 1866 | 1987 | jQuery(document).ready(function () {
|
@@ -1873,12 +1994,18 @@ discard block |
||
| 1873 | 1994 | }); |
| 1874 | 1995 | </script> |
| 1875 | 1996 | <div id="<?php echo $name;?>_row" |
| 1876 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1997 | + class="<?php if ($is_required) { |
|
| 1998 | + echo 'required_field'; |
|
| 1999 | +} |
|
| 2000 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1877 | 2001 | <label> |
| 1878 | 2002 | |
| 1879 | 2003 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1880 | 2004 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1881 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 2005 | + <?php if ($is_required) { |
|
| 2006 | + echo '<span>*</span>'; |
|
| 2007 | +} |
|
| 2008 | +?> |
|
| 1882 | 2009 | </label> |
| 1883 | 2010 | <input readonly="readonly" field_type="<?php echo $type;?>" name="<?php echo $name;?>" |
| 1884 | 2011 | id="<?php echo $name;?>" value="<?php echo esc_attr($value);?>" type="text" class="geodir_textfield"/> |
@@ -1894,11 +2021,17 @@ discard block |
||
| 1894 | 2021 | $value = ''; |
| 1895 | 2022 | } ?> |
| 1896 | 2023 | <div id="<?php echo $name;?>_row" |
| 1897 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 2024 | + class="<?php if ($is_required) { |
|
| 2025 | + echo 'required_field'; |
|
| 2026 | +} |
|
| 2027 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 1898 | 2028 | <label> |
| 1899 | 2029 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1900 | 2030 | echo (trim($site_title)) ? $site_title : ' '; ?> |
| 1901 | - <?php if ($is_required) echo '<span>*</span>';?> |
|
| 2031 | + <?php if ($is_required) { |
|
| 2032 | + echo '<span>*</span>'; |
|
| 2033 | +} |
|
| 2034 | +?> |
|
| 1902 | 2035 | </label> |
| 1903 | 2036 | |
| 1904 | 2037 | <div id="<?php echo $name;?>" class="geodir_taxonomy_field" style="float:left; width:70%;"> |
@@ -1932,8 +2065,9 @@ discard block |
||
| 1932 | 2065 | $post_cat = implode(",", $post_cat[$name]);
|
| 1933 | 2066 | |
| 1934 | 2067 | } else {
|
| 1935 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 1936 | - $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true); |
|
| 2068 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
| 2069 | + $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true); |
|
| 2070 | + } |
|
| 1937 | 2071 | } |
| 1938 | 2072 | |
| 1939 | 2073 | |
@@ -1971,21 +2105,24 @@ discard block |
||
| 1971 | 2105 | |
| 1972 | 2106 | $cat_display == ''; |
| 1973 | 2107 | $multiple = ''; |
| 1974 | - if ($cat_display == 'multiselect') |
|
| 1975 | - $multiple = 'multiple="multiple"'; |
|
| 2108 | + if ($cat_display == 'multiselect') { |
|
| 2109 | + $multiple = 'multiple="multiple"'; |
|
| 2110 | + } |
|
| 1976 | 2111 | |
| 1977 | 2112 | echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">';
|
| 1978 | 2113 | |
| 1979 | 2114 | |
| 1980 | - if ($cat_display == 'select') |
|
| 1981 | - echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>';
|
|
| 2115 | + if ($cat_display == 'select') { |
|
| 2116 | + echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>'; |
|
| 2117 | + } |
|
| 1982 | 2118 | |
| 1983 | 2119 | } |
| 1984 | 2120 | |
| 1985 | 2121 | echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0); |
| 1986 | 2122 | |
| 1987 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 1988 | - echo '</select>'; |
|
| 2123 | + if ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 2124 | + echo '</select>'; |
|
| 2125 | + } |
|
| 1989 | 2126 | |
| 1990 | 2127 | } else {
|
| 1991 | 2128 | |
@@ -2015,18 +2152,23 @@ discard block |
||
| 2015 | 2152 | |
| 2016 | 2153 | $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls. |
| 2017 | 2154 | |
| 2018 | - } else |
|
| 2019 | - $file_value = ''; |
|
| 2155 | + } else { |
|
| 2156 | + $file_value = ''; |
|
| 2157 | + } |
|
| 2020 | 2158 | |
| 2021 | - if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) |
|
| 2022 | - $file_multiple = true; // allow multiple files upload |
|
| 2023 | - else |
|
| 2024 | - $file_multiple = false; |
|
| 2159 | + if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) { |
|
| 2160 | + $file_multiple = true; |
|
| 2161 | + } |
|
| 2162 | + // allow multiple files upload |
|
| 2163 | + else { |
|
| 2164 | + $file_multiple = false; |
|
| 2165 | + } |
|
| 2025 | 2166 | |
| 2026 | - if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) |
|
| 2027 | - $file_image_limit = $extra_fields['image_limit']; |
|
| 2028 | - else |
|
| 2029 | - $file_image_limit = 1; |
|
| 2167 | + if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) { |
|
| 2168 | + $file_image_limit = $extra_fields['image_limit']; |
|
| 2169 | + } else { |
|
| 2170 | + $file_image_limit = 1; |
|
| 2171 | + } |
|
| 2030 | 2172 | |
| 2031 | 2173 | $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
| 2032 | 2174 | |
@@ -2034,8 +2176,9 @@ discard block |
||
| 2034 | 2176 | |
| 2035 | 2177 | if (!empty($file_value)) {
|
| 2036 | 2178 | $curImages = explode(',', $file_value);
|
| 2037 | - if (!empty($curImages)) |
|
| 2038 | - $file_totImg = count($curImages); |
|
| 2179 | + if (!empty($curImages)) { |
|
| 2180 | + $file_totImg = count($curImages); |
|
| 2181 | + } |
|
| 2039 | 2182 | } |
| 2040 | 2183 | |
| 2041 | 2184 | $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
|
@@ -2050,12 +2193,18 @@ discard block |
||
| 2050 | 2193 | ?> |
| 2051 | 2194 | |
| 2052 | 2195 | <div id="<?php echo $name;?>_row" |
| 2053 | - class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 2196 | + class="<?php if ($is_required) { |
|
| 2197 | + echo 'required_field'; |
|
| 2198 | +} |
|
| 2199 | +?> geodir_form_row clearfix <?php echo $fieldset_field_class;?>"> |
|
| 2054 | 2200 | |
| 2055 | 2201 | <div id="<?php echo $file_id; ?>dropbox" style="text-align:center;"> |
| 2056 | 2202 | <label |
| 2057 | 2203 | style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory'); |
| 2058 | - echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label> |
|
| 2204 | + echo $site_title; ?><?php if ($is_required) { |
|
| 2205 | + echo '<span>*</span>'; |
|
| 2206 | + } |
|
| 2207 | + ?></label> |
|
| 2059 | 2208 | <input class="geodir-custom-file-upload" field_type="file" type="hidden" |
| 2060 | 2209 | name="<?php echo $file_id; ?>" id="<?php echo $file_id; ?>" |
| 2061 | 2210 | value="<?php echo esc_attr($file_value); ?>"/> |
@@ -2196,9 +2345,10 @@ discard block |
||
| 2196 | 2345 | $field_set_start = 0; |
| 2197 | 2346 | |
| 2198 | 2347 | |
| 2199 | - if ($fields_location == 'detail') |
|
| 2200 | - |
|
| 2201 | - $i = 1; |
|
| 2348 | + if ($fields_location == 'detail') { |
|
| 2349 | + |
|
| 2350 | + $i = 1; |
|
| 2351 | + } |
|
| 2202 | 2352 | foreach ($fields_info as $type) {
|
| 2203 | 2353 | $type = stripslashes_deep($type); // strip slashes |
| 2204 | 2354 | $html = ''; |
@@ -2215,8 +2365,9 @@ discard block |
||
| 2215 | 2365 | $variables_array['post_id'] = $post->ID; |
| 2216 | 2366 | $variables_array['label'] = __($type['site_title'], 'geodirectory'); |
| 2217 | 2367 | $variables_array['value'] = ''; |
| 2218 | - if (isset($post->{$type['htmlvar_name']}))
|
|
| 2219 | - $variables_array['value'] = $post->{$type['htmlvar_name']};
|
|
| 2368 | + if (isset($post->{$type['htmlvar_name']})) { |
|
| 2369 | + $variables_array['value'] = $post->{$type['htmlvar_name']}; |
|
| 2370 | + } |
|
| 2220 | 2371 | endif; |
| 2221 | 2372 | |
| 2222 | 2373 | //if($type['field_icon']) |
@@ -2343,8 +2494,9 @@ discard block |
||
| 2343 | 2494 | if ($fields_location == 'detail') {
|
| 2344 | 2495 | |
| 2345 | 2496 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2346 | - if ($i % 2 == 0) |
|
| 2347 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2497 | + if ($i % 2 == 0) { |
|
| 2498 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2499 | + } |
|
| 2348 | 2500 | |
| 2349 | 2501 | $i++; |
| 2350 | 2502 | } |
@@ -2418,8 +2570,9 @@ discard block |
||
| 2418 | 2570 | if ($fields_location == 'detail') {
|
| 2419 | 2571 | |
| 2420 | 2572 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2421 | - if ($i % 2 == 0) |
|
| 2422 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2573 | + if ($i % 2 == 0) { |
|
| 2574 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2575 | + } |
|
| 2423 | 2576 | |
| 2424 | 2577 | $i++; |
| 2425 | 2578 | } |
@@ -2461,8 +2614,9 @@ discard block |
||
| 2461 | 2614 | if ($fields_location == 'detail') {
|
| 2462 | 2615 | |
| 2463 | 2616 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2464 | - if ($i % 2 == 0) |
|
| 2465 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2617 | + if ($i % 2 == 0) { |
|
| 2618 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2619 | + } |
|
| 2466 | 2620 | |
| 2467 | 2621 | $i++; |
| 2468 | 2622 | } |
@@ -2482,9 +2636,10 @@ discard block |
||
| 2482 | 2636 | if ($post->{$type['htmlvar_name']}):
|
| 2483 | 2637 | |
| 2484 | 2638 | $value = ''; |
| 2485 | - if ($post->{$type['htmlvar_name']} != '')
|
|
| 2486 | - //$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
|
|
| 2487 | - $value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']}));
|
|
| 2639 | + if ($post->{$type['htmlvar_name']} != '') { |
|
| 2640 | + //$value = date('h:i',strtotime($post->{$type['htmlvar_name']}));
|
|
| 2641 | + $value = date(get_option('time_format'), strtotime($post->{$type['htmlvar_name']})); |
|
| 2642 | + } |
|
| 2488 | 2643 | |
| 2489 | 2644 | if (strpos($field_icon, 'http') !== false) {
|
| 2490 | 2645 | $field_icon_af = ''; |
@@ -2499,8 +2654,9 @@ discard block |
||
| 2499 | 2654 | if ($fields_location == 'detail') {
|
| 2500 | 2655 | |
| 2501 | 2656 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2502 | - if ($i % 2 == 0) |
|
| 2503 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2657 | + if ($i % 2 == 0) { |
|
| 2658 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2659 | + } |
|
| 2504 | 2660 | |
| 2505 | 2661 | $i++; |
| 2506 | 2662 | } |
@@ -2533,7 +2689,7 @@ discard block |
||
| 2533 | 2689 | $value = ''; |
| 2534 | 2690 | if ($post->{$type['htmlvar_name']} != '' && $post->{$type['htmlvar_name']}!="0000-00-00") {
|
| 2535 | 2691 | $value = date($date_format, strtotime($post_htmlvar_value)); |
| 2536 | - }else{
|
|
| 2692 | + } else{
|
|
| 2537 | 2693 | continue; |
| 2538 | 2694 | } |
| 2539 | 2695 | |
@@ -2550,8 +2706,9 @@ discard block |
||
| 2550 | 2706 | if ($fields_location == 'detail') {
|
| 2551 | 2707 | |
| 2552 | 2708 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2553 | - if ($i % 2 == 0) |
|
| 2554 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2709 | + if ($i % 2 == 0) { |
|
| 2710 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2711 | + } |
|
| 2555 | 2712 | |
| 2556 | 2713 | $i++; |
| 2557 | 2714 | } |
@@ -2583,8 +2740,9 @@ discard block |
||
| 2583 | 2740 | if ($fields_location == 'detail') {
|
| 2584 | 2741 | |
| 2585 | 2742 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2586 | - if ($i % 2 == 0) |
|
| 2587 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2743 | + if ($i % 2 == 0) { |
|
| 2744 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2745 | + } |
|
| 2588 | 2746 | |
| 2589 | 2747 | $i++; |
| 2590 | 2748 | } |
@@ -2608,8 +2766,9 @@ discard block |
||
| 2608 | 2766 | if ($fields_location == 'detail') {
|
| 2609 | 2767 | |
| 2610 | 2768 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2611 | - if ($i % 2 == 0) |
|
| 2612 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2769 | + if ($i % 2 == 0) { |
|
| 2770 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2771 | + } |
|
| 2613 | 2772 | |
| 2614 | 2773 | $i++; |
| 2615 | 2774 | } |
@@ -2659,8 +2818,9 @@ discard block |
||
| 2659 | 2818 | if ($fields_location == 'detail') {
|
| 2660 | 2819 | |
| 2661 | 2820 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2662 | - if ($i % 2 == 0) |
|
| 2663 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2821 | + if ($i % 2 == 0) { |
|
| 2822 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2823 | + } |
|
| 2664 | 2824 | |
| 2665 | 2825 | $i++; |
| 2666 | 2826 | } |
@@ -2680,8 +2840,10 @@ discard block |
||
| 2680 | 2840 | |
| 2681 | 2841 | if ($post->{$type['htmlvar_name']} == '1'):
|
| 2682 | 2842 | $html_val = __('Yes', 'geodirectory');
|
| 2683 | - else: |
|
| 2684 | - $html_val = __('No', 'geodirectory');
|
|
| 2843 | + else { |
|
| 2844 | + : |
|
| 2845 | + $html_val = __('No', 'geodirectory'); |
|
| 2846 | + } |
|
| 2685 | 2847 | endif; |
| 2686 | 2848 | |
| 2687 | 2849 | if (strpos($field_icon, 'http') !== false) {
|
@@ -2697,8 +2859,9 @@ discard block |
||
| 2697 | 2859 | if ($fields_location == 'detail') {
|
| 2698 | 2860 | |
| 2699 | 2861 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2700 | - if ($i % 2 == 0) |
|
| 2701 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2862 | + if ($i % 2 == 0) { |
|
| 2863 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2864 | + } |
|
| 2702 | 2865 | |
| 2703 | 2866 | $i++; |
| 2704 | 2867 | } |
@@ -2742,8 +2905,9 @@ discard block |
||
| 2742 | 2905 | if ($fields_location == 'detail') {
|
| 2743 | 2906 | |
| 2744 | 2907 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2745 | - if ($i % 2 == 0) |
|
| 2746 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2908 | + if ($i % 2 == 0) { |
|
| 2909 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2910 | + } |
|
| 2747 | 2911 | |
| 2748 | 2912 | $i++; |
| 2749 | 2913 | } |
@@ -2794,8 +2958,9 @@ discard block |
||
| 2794 | 2958 | if ($fields_location == 'detail') {
|
| 2795 | 2959 | |
| 2796 | 2960 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2797 | - if ($i % 2 == 0) |
|
| 2798 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2961 | + if ($i % 2 == 0) { |
|
| 2962 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 2963 | + } |
|
| 2799 | 2964 | |
| 2800 | 2965 | $i++; |
| 2801 | 2966 | } |
@@ -2849,8 +3014,9 @@ discard block |
||
| 2849 | 3014 | if ($fields_location == 'detail') {
|
| 2850 | 3015 | |
| 2851 | 3016 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2852 | - if ($i % 2 == 0) |
|
| 2853 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3017 | + if ($i % 2 == 0) { |
|
| 3018 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3019 | + } |
|
| 2854 | 3020 | |
| 2855 | 3021 | $i++; |
| 2856 | 3022 | } |
@@ -2895,8 +3061,9 @@ discard block |
||
| 2895 | 3061 | if ($fields_location == 'detail') {
|
| 2896 | 3062 | |
| 2897 | 3063 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2898 | - if ($i % 2 == 0) |
|
| 2899 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3064 | + if ($i % 2 == 0) { |
|
| 3065 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3066 | + } |
|
| 2900 | 3067 | |
| 2901 | 3068 | $i++; |
| 2902 | 3069 | } |
@@ -2916,7 +3083,7 @@ discard block |
||
| 2916 | 3083 | */ |
| 2917 | 3084 | $email_name = apply_filters('geodir_email_field_name_output',$email,$type);
|
| 2918 | 3085 | $html .= "<script>document.write('<a href=\"mailto:'+'$e_split[0]' + '@' + '$e_split[1]'+'\">$email_name</a>')</script>";
|
| 2919 | - }else{
|
|
| 3086 | + } else{
|
|
| 2920 | 3087 | $html .= $email; |
| 2921 | 3088 | } |
| 2922 | 3089 | $html .= '</span></div>'; |
@@ -2994,8 +3161,9 @@ discard block |
||
| 2994 | 3161 | if ($fields_location == 'detail') {
|
| 2995 | 3162 | |
| 2996 | 3163 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 2997 | - if ($i % 2 == 0) |
|
| 2998 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3164 | + if ($i % 2 == 0) { |
|
| 3165 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3166 | + } |
|
| 2999 | 3167 | |
| 3000 | 3168 | $i++; |
| 3001 | 3169 | } |
@@ -3029,8 +3197,9 @@ discard block |
||
| 3029 | 3197 | if ($fields_location == 'detail') {
|
| 3030 | 3198 | |
| 3031 | 3199 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 3032 | - if ($i % 2 == 0) |
|
| 3033 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3200 | + if ($i % 2 == 0) { |
|
| 3201 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3202 | + } |
|
| 3034 | 3203 | |
| 3035 | 3204 | $i++; |
| 3036 | 3205 | } |
@@ -3058,8 +3227,9 @@ discard block |
||
| 3058 | 3227 | if ($fields_location == 'detail') {
|
| 3059 | 3228 | |
| 3060 | 3229 | $geodir_odd_even = 'geodir_more_info_odd'; |
| 3061 | - if ($i % 2 == 0) |
|
| 3062 | - $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3230 | + if ($i % 2 == 0) { |
|
| 3231 | + $geodir_odd_even = 'geodir_more_info_even'; |
|
| 3232 | + } |
|
| 3063 | 3233 | |
| 3064 | 3234 | $i++; |
| 3065 | 3235 | } |
@@ -3154,7 +3324,9 @@ discard block |
||
| 3154 | 3324 | * @param string $html Custom field unfiltered HTML. |
| 3155 | 3325 | * @param array $variables_array Custom field variables array. |
| 3156 | 3326 | */ |
| 3157 | - if ($html) echo apply_filters("geodir_show_{$html_var}", $html, $variables_array);
|
|
| 3327 | + if ($html) { |
|
| 3328 | + echo apply_filters("geodir_show_{$html_var}", $html, $variables_array); |
|
| 3329 | + } |
|
| 3158 | 3330 | |
| 3159 | 3331 | /** |
| 3160 | 3332 | * Called after a custom fields is output on the frontend. |
@@ -3188,10 +3360,11 @@ discard block |
||
| 3188 | 3360 | */ |
| 3189 | 3361 | function geodir_default_date_format() |
| 3190 | 3362 | {
|
| 3191 | - if ($format = get_option('date_format'))
|
|
| 3192 | - return $format; |
|
| 3193 | - else |
|
| 3194 | - return 'dd-mm-yy'; |
|
| 3363 | + if ($format = get_option('date_format')) { |
|
| 3364 | + return $format; |
|
| 3365 | + } else { |
|
| 3366 | + return 'dd-mm-yy'; |
|
| 3367 | + } |
|
| 3195 | 3368 | } |
| 3196 | 3369 | } |
| 3197 | 3370 | |
@@ -3298,11 +3471,13 @@ discard block |
||
| 3298 | 3471 | // Set an array containing a list of acceptable formats |
| 3299 | 3472 | //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
|
| 3300 | 3473 | |
| 3301 | - if (!function_exists('wp_handle_upload'))
|
|
| 3302 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 3474 | + if (!function_exists('wp_handle_upload')) { |
|
| 3475 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 3476 | + } |
|
| 3303 | 3477 | |
| 3304 | - if (!is_dir($geodir_uploadpath)) |
|
| 3305 | - mkdir($geodir_uploadpath); |
|
| 3478 | + if (!is_dir($geodir_uploadpath)) { |
|
| 3479 | + mkdir($geodir_uploadpath); |
|
| 3480 | + } |
|
| 3306 | 3481 | |
| 3307 | 3482 | $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
| 3308 | 3483 | $explode_sub_dir = explode("/", $sub_dir);
|
@@ -3315,16 +3490,19 @@ discard block |
||
| 3315 | 3490 | } |
| 3316 | 3491 | |
| 3317 | 3492 | $uploaded_file = ''; |
| 3318 | - if (file_exists($img_path)) |
|
| 3319 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 3493 | + if (file_exists($img_path)) { |
|
| 3494 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 3495 | + } |
|
| 3320 | 3496 | |
| 3321 | 3497 | if ($curr_img_dir != $geodir_uploaddir) {
|
| 3322 | - if (file_exists($img_path)) |
|
| 3323 | - unlink($img_path); |
|
| 3498 | + if (file_exists($img_path)) { |
|
| 3499 | + unlink($img_path); |
|
| 3500 | + } |
|
| 3324 | 3501 | } |
| 3325 | 3502 | |
| 3326 | - if (!empty($uploaded_file)) |
|
| 3327 | - $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
| 3503 | + if (!empty($uploaded_file)) { |
|
| 3504 | + $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
| 3505 | + } |
|
| 3328 | 3506 | |
| 3329 | 3507 | } else {
|
| 3330 | 3508 | $file_urls = $post_image[$m]; |
@@ -3345,8 +3523,9 @@ discard block |
||
| 3345 | 3523 | |
| 3346 | 3524 | geodir_save_post_meta($post_id, $field_id, $file_urls); |
| 3347 | 3525 | |
| 3348 | - if (!empty($invalid_files)) |
|
| 3349 | - geodir_remove_attachments($invalid_files); |
|
| 3526 | + if (!empty($invalid_files)) { |
|
| 3527 | + geodir_remove_attachments($invalid_files); |
|
| 3528 | + } |
|
| 3350 | 3529 | |
| 3351 | 3530 | } |
| 3352 | 3531 | } |
@@ -3577,8 +3756,9 @@ discard block |
||
| 3577 | 3756 | |
| 3578 | 3757 | $all_postypes = geodir_get_posttypes(); |
| 3579 | 3758 | |
| 3580 | - if (!in_array($post_type, $all_postypes)) |
|
| 3581 | - return false; |
|
| 3759 | + if (!in_array($post_type, $all_postypes)) { |
|
| 3760 | + return false; |
|
| 3761 | + } |
|
| 3582 | 3762 | |
| 3583 | 3763 | $fields = array(); |
| 3584 | 3764 | |
@@ -3666,8 +3846,10 @@ discard block |
||
| 3666 | 3846 | } |
| 3667 | 3847 | |
| 3668 | 3848 | return $field_ids; |
| 3669 | - else: |
|
| 3670 | - return false; |
|
| 3849 | + else { |
|
| 3850 | + : |
|
| 3851 | + return false; |
|
| 3852 | + } |
|
| 3671 | 3853 | endif; |
| 3672 | 3854 | } |
| 3673 | 3855 | |
@@ -3840,8 +4022,9 @@ discard block |
||
| 3840 | 4022 | |
| 3841 | 4023 | return $field_id; |
| 3842 | 4024 | |
| 3843 | - } else |
|
| 3844 | - return 0; |
|
| 4025 | + } else { |
|
| 4026 | + return 0; |
|
| 4027 | + } |
|
| 3845 | 4028 | |
| 3846 | 4029 | } |
| 3847 | 4030 | } |
@@ -3876,8 +4059,9 @@ discard block |
||
| 3876 | 4059 | |
| 3877 | 4060 | if (!isset($field_info->post_type)) {
|
| 3878 | 4061 | $post_type = $_REQUEST['listing_type']; |
| 3879 | - } else |
|
| 3880 | - $post_type = $field_info->post_type; |
|
| 4062 | + } else { |
|
| 4063 | + $post_type = $field_info->post_type; |
|
| 4064 | + } |
|
| 3881 | 4065 | |
| 3882 | 4066 | |
| 3883 | 4067 | $field_types = explode('-_-', $field_type);
|
@@ -3885,8 +4069,9 @@ discard block |
||
| 3885 | 4069 | $htmlvar_name = isset($field_types[1]) ? $field_types[1] : ''; |
| 3886 | 4070 | |
| 3887 | 4071 | $site_title = ''; |
| 3888 | - if ($site_title == '') |
|
| 3889 | - $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
| 4072 | + if ($site_title == '') { |
|
| 4073 | + $site_title = isset($field_info->site_title) ? $field_info->site_title : ''; |
|
| 4074 | + } |
|
| 3890 | 4075 | |
| 3891 | 4076 | if ($site_title == '') {
|
| 3892 | 4077 | |
@@ -3903,8 +4088,9 @@ discard block |
||
| 3903 | 4088 | |
| 3904 | 4089 | } |
| 3905 | 4090 | |
| 3906 | - if ($htmlvar_name == '') |
|
| 3907 | - $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
| 4091 | + if ($htmlvar_name == '') { |
|
| 4092 | + $htmlvar_name = isset($field_info->htmlvar_name) ? $field_info->htmlvar_name : ''; |
|
| 4093 | + } |
|
| 3908 | 4094 | |
| 3909 | 4095 | $nonce = wp_create_nonce('custom_fields_' . $result_str);
|
| 3910 | 4096 | |
@@ -1,26 +1,26 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Custom fields functions |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - * @global object $wpdb WordPress Database object. |
|
| 8 | - * @global string $table_prefix WordPress Database Table prefix. |
|
| 9 | - */ |
|
| 3 | + * Custom fields functions |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + * @global object $wpdb WordPress Database object. |
|
| 8 | + * @global string $table_prefix WordPress Database Table prefix. |
|
| 9 | + */ |
|
| 10 | 10 | global $wpdb, $table_prefix; |
| 11 | 11 | |
| 12 | 12 | if (!function_exists('geodir_column_exist')) {
|
| 13 | - /** |
|
| 14 | - * Check table column exist or not. |
|
| 15 | - * |
|
| 16 | - * @since 1.0.0 |
|
| 17 | - * @package GeoDirectory |
|
| 13 | + /** |
|
| 14 | + * Check table column exist or not. |
|
| 15 | + * |
|
| 16 | + * @since 1.0.0 |
|
| 17 | + * @package GeoDirectory |
|
| 18 | 18 | * @global object $wpdb WordPress Database object. |
| 19 | - * @param string $db The table name. |
|
| 20 | - * @param string $column The column name. |
|
| 21 | - * @return bool If column exists returns true. Otherwise false. |
|
| 22 | - */ |
|
| 23 | - function geodir_column_exist($db, $column) |
|
| 19 | + * @param string $db The table name. |
|
| 20 | + * @param string $column The column name. |
|
| 21 | + * @return bool If column exists returns true. Otherwise false. |
|
| 22 | + */ |
|
| 23 | + function geodir_column_exist($db, $column) |
|
| 24 | 24 | {
|
| 25 | 25 | global $wpdb; |
| 26 | 26 | $exists = false; |
@@ -36,17 +36,17 @@ discard block |
||
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | if (!function_exists('geodir_add_column_if_not_exist')) {
|
| 39 | - /** |
|
| 40 | - * Add column if table column not exist. |
|
| 41 | - * |
|
| 42 | - * @since 1.0.0 |
|
| 43 | - * @package GeoDirectory |
|
| 39 | + /** |
|
| 40 | + * Add column if table column not exist. |
|
| 41 | + * |
|
| 42 | + * @since 1.0.0 |
|
| 43 | + * @package GeoDirectory |
|
| 44 | 44 | * @global object $wpdb WordPress Database object. |
| 45 | - * @param string $db The table name. |
|
| 46 | - * @param string $column The column name. |
|
| 47 | - * @param string $column_attr The column attributes. |
|
| 48 | - */ |
|
| 49 | - function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL") |
|
| 45 | + * @param string $db The table name. |
|
| 46 | + * @param string $column The column name. |
|
| 47 | + * @param string $column_attr The column attributes. |
|
| 48 | + */ |
|
| 49 | + function geodir_add_column_if_not_exist($db, $column, $column_attr = "VARCHAR( 255 ) NOT NULL") |
|
| 50 | 50 | {
|
| 51 | 51 | global $wpdb; |
| 52 | 52 | $result = 0;// no rows affected |
@@ -152,18 +152,18 @@ discard block |
||
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | if (!function_exists('geodir_custom_field_adminhtml')) {
|
| 155 | - /** |
|
| 156 | - * Adds admin html for custom fields. |
|
| 157 | - * |
|
| 158 | - * @since 1.0.0 |
|
| 159 | - * @package GeoDirectory |
|
| 155 | + /** |
|
| 156 | + * Adds admin html for custom fields. |
|
| 157 | + * |
|
| 158 | + * @since 1.0.0 |
|
| 159 | + * @package GeoDirectory |
|
| 160 | 160 | * @global object $wpdb WordPress Database object. |
| 161 | - * @param string $field_type The form field type. |
|
| 162 | - * @param object|int $result_str The custom field results object or row id. |
|
| 163 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
| 164 | - * @param bool $default when set to true field will be for admin use only. |
|
| 165 | - */ |
|
| 166 | - function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) |
|
| 161 | + * @param string $field_type The form field type. |
|
| 162 | + * @param object|int $result_str The custom field results object or row id. |
|
| 163 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
| 164 | + * @param bool $default when set to true field will be for admin use only. |
|
| 165 | + */ |
|
| 166 | + function geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) |
|
| 167 | 167 | {
|
| 168 | 168 | global $wpdb; |
| 169 | 169 | $cf = $result_str; |
@@ -186,32 +186,32 @@ discard block |
||
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if (!function_exists('geodir_custom_field_delete')) {
|
| 189 | - /** |
|
| 190 | - * Delete custom field using field id. |
|
| 191 | - * |
|
| 192 | - * @since 1.0.0 |
|
| 193 | - * @since 1.5.7 Delete field from sorting fields table when custom field deleted. |
|
| 194 | - * @package GeoDirectory |
|
| 189 | + /** |
|
| 190 | + * Delete custom field using field id. |
|
| 191 | + * |
|
| 192 | + * @since 1.0.0 |
|
| 193 | + * @since 1.5.7 Delete field from sorting fields table when custom field deleted. |
|
| 194 | + * @package GeoDirectory |
|
| 195 | 195 | * @global object $wpdb WordPress Database object. |
| 196 | 196 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 197 | - * @param string $field_id The custom field ID. |
|
| 198 | - * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. |
|
| 199 | - */ |
|
| 200 | - function geodir_custom_field_delete($field_id = '') {
|
|
| 197 | + * @param string $field_id The custom field ID. |
|
| 198 | + * @return int|string If field deleted successfully, returns field id. Otherwise returns 0. |
|
| 199 | + */ |
|
| 200 | + function geodir_custom_field_delete($field_id = '') {
|
|
| 201 | 201 | global $wpdb, $plugin_prefix; |
| 202 | 202 | |
| 203 | - if ($field_id != '') {
|
|
| 203 | + if ($field_id != '') {
|
|
| 204 | 204 | $cf = trim($field_id, '_'); |
| 205 | 205 | |
| 206 | 206 | if ($field = $wpdb->get_row($wpdb->prepare("select htmlvar_name,post_type,field_type from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d", array($cf)))) {
|
| 207 | 207 | $wpdb->query($wpdb->prepare("delete from " . GEODIR_CUSTOM_FIELDS_TABLE . " where id= %d ", array($cf)));
|
| 208 | 208 | |
| 209 | 209 | $post_type = $field->post_type; |
| 210 | - $htmlvar_name = $field->htmlvar_name; |
|
| 210 | + $htmlvar_name = $field->htmlvar_name; |
|
| 211 | 211 | |
| 212 | - if ($post_type != '' && $htmlvar_name != '') {
|
|
| 213 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
|
|
| 214 | - } |
|
| 212 | + if ($post_type != '' && $htmlvar_name != '') {
|
|
| 213 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name=%s AND post_type=%s LIMIT 1", array($htmlvar_name, $post_type)));
|
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | 216 | /** |
| 217 | 217 | * Called after a custom field is deleted. |
@@ -248,15 +248,15 @@ discard block |
||
| 248 | 248 | } |
| 249 | 249 | |
| 250 | 250 | if (!function_exists('geodir_custom_field_save')) {
|
| 251 | - /** |
|
| 252 | - * Save or Update custom fields into the database. |
|
| 253 | - * |
|
| 254 | - * @since 1.0.0 |
|
| 251 | + /** |
|
| 252 | + * Save or Update custom fields into the database. |
|
| 253 | + * |
|
| 254 | + * @since 1.0.0 |
|
| 255 | 255 | * @since 1.5.6 Fix for saving multiselect custom field "Display Type" on first attempt. |
| 256 | - * @package GeoDirectory |
|
| 256 | + * @package GeoDirectory |
|
| 257 | 257 | * @global object $wpdb WordPress Database object. |
| 258 | 258 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 259 | - * @param array $request_field {
|
|
| 259 | + * @param array $request_field {
|
|
| 260 | 260 | * Attributes of the request field array. |
| 261 | 261 | * |
| 262 | 262 | * @type string $action Ajax Action name. Default "geodir_ajax_action". |
@@ -289,10 +289,10 @@ discard block |
||
| 289 | 289 | * @type string $css_class Enter custom css class for field custom style. |
| 290 | 290 | * |
| 291 | 291 | * } |
| 292 | - * @param bool $default Not yet implemented. |
|
| 293 | - * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
| 294 | - */ |
|
| 295 | - function geodir_custom_field_save($request_field = array(), $default = false) |
|
| 292 | + * @param bool $default Not yet implemented. |
|
| 293 | + * @return int|string If field is unique returns inserted row id. Otherwise returns error string. |
|
| 294 | + */ |
|
| 295 | + function geodir_custom_field_save($request_field = array(), $default = false) |
|
| 296 | 296 | {
|
| 297 | 297 | |
| 298 | 298 | global $wpdb, $plugin_prefix; |
@@ -976,27 +976,27 @@ discard block |
||
| 976 | 976 | if (isset($option_values) && $option_values && $field_type == 'select') {
|
| 977 | 977 | $option_values_arr = explode(',', $option_values);
|
| 978 | 978 | |
| 979 | - if (is_array($option_values_arr)) {
|
|
| 979 | + if (is_array($option_values_arr)) {
|
|
| 980 | 980 | $op_max = 0; |
| 981 | 981 | |
| 982 | - foreach ($option_values_arr as $op_val) {
|
|
| 982 | + foreach ($option_values_arr as $op_val) {
|
|
| 983 | 983 | if (strlen($op_val) && strlen($op_val) > $op_max) {
|
| 984 | - $op_max = strlen($op_val); |
|
| 985 | - } |
|
| 984 | + $op_max = strlen($op_val); |
|
| 985 | + } |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | - if ($op_max) {
|
|
| 989 | - $op_size = $op_max; |
|
| 990 | - } |
|
| 988 | + if ($op_max) {
|
|
| 989 | + $op_size = $op_max; |
|
| 990 | + } |
|
| 991 | 991 | } |
| 992 | 992 | } elseif (isset($option_values) && $option_values && $field_type == 'multiselect') {
|
| 993 | 993 | if (strlen($option_values)) {
|
| 994 | 994 | $op_size = strlen($option_values); |
| 995 | 995 | } |
| 996 | 996 | |
| 997 | - if (isset($request_field['multi_display_type'])) {
|
|
| 998 | - $extra_fields = $request_field['multi_display_type']; |
|
| 999 | - } |
|
| 997 | + if (isset($request_field['multi_display_type'])) {
|
|
| 998 | + $extra_fields = $request_field['multi_display_type']; |
|
| 999 | + } |
|
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | 1002 | $meta_field_add = $data_type . "( $op_size ) NULL "; |
@@ -1214,10 +1214,10 @@ discard block |
||
| 1214 | 1214 | $custom_fields = geodir_post_custom_fields($package_id, $default, $post_type); |
| 1215 | 1215 | |
| 1216 | 1216 | $fieldset_id = ''; |
| 1217 | - $fieldset_field_class = 'gd-fieldset-details'; |
|
| 1218 | - foreach ($custom_fields as $key => $val) {
|
|
| 1217 | + $fieldset_field_class = 'gd-fieldset-details'; |
|
| 1218 | + foreach ($custom_fields as $key => $val) {
|
|
| 1219 | 1219 | $val = stripslashes_deep($val); // strip slashes from labels |
| 1220 | - $name = $val['name']; |
|
| 1220 | + $name = $val['name']; |
|
| 1221 | 1221 | $site_title = $val['site_title']; |
| 1222 | 1222 | $type = $val['type']; |
| 1223 | 1223 | $admin_desc = $val['desc']; |
@@ -1268,8 +1268,8 @@ discard block |
||
| 1268 | 1268 | |
| 1269 | 1269 | if ($type == 'fieldset') {
|
| 1270 | 1270 | $fieldset_id = (int)$val['id']; |
| 1271 | - $fieldset_field_class = 'gd-fieldset-' . $fieldset_id; |
|
| 1272 | - ?><h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?> |
|
| 1271 | + $fieldset_field_class = 'gd-fieldset-' . $fieldset_id; |
|
| 1272 | + ?><h5 id="geodir_fieldset_<?php echo $fieldset_id;?>" class="geodir-fieldset-row" gd-fieldset="<?php echo $fieldset_id;?>"><?php echo $site_title;?> |
|
| 1273 | 1273 | <?php if ($admin_desc != '') echo '<small>( ' . $admin_desc . ' )</small>';?> |
| 1274 | 1274 | </h5><?php |
| 1275 | 1275 | |
@@ -1583,15 +1583,15 @@ discard block |
||
| 1583 | 1583 | <?php if ($option_values) {
|
| 1584 | 1584 | $option_values = geodir_string_values_to_options($option_values, true); |
| 1585 | 1585 | |
| 1586 | - if (!empty($option_values)) {
|
|
| 1587 | - foreach ($option_values as $option_value) {
|
|
| 1588 | - if (empty($option_value['optgroup'])) {
|
|
| 1589 | - ?> |
|
| 1586 | + if (!empty($option_values)) {
|
|
| 1587 | + foreach ($option_values as $option_value) {
|
|
| 1588 | + if (empty($option_value['optgroup'])) {
|
|
| 1589 | + ?> |
|
| 1590 | 1590 | <input name="<?php echo $name;?>" id="<?php echo $name;?>" <?php checked($value, $option_value['value']);?> value="<?php echo esc_attr($option_value['value']); ?>" class="gd-checkbox" field_type="<?php echo $type;?>" type="radio" /><?php echo $option_value['label']; ?> |
| 1591 | 1591 | <?php |
| 1592 | - } |
|
| 1593 | - } |
|
| 1594 | - } |
|
| 1592 | + } |
|
| 1593 | + } |
|
| 1594 | + } |
|
| 1595 | 1595 | } |
| 1596 | 1596 | ?> |
| 1597 | 1597 | <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
@@ -2034,8 +2034,8 @@ discard block |
||
| 2034 | 2034 | $file_totImg = count($curImages); |
| 2035 | 2035 | } |
| 2036 | 2036 | |
| 2037 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
|
|
| 2038 | - $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
|
|
| 2037 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : '';
|
|
| 2038 | + $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : '';
|
|
| 2039 | 2039 | |
| 2040 | 2040 | ?> |
| 2041 | 2041 | <?php /*?> <h5 class="geodir-form_title"> <?php echo $site_title; ?> |
@@ -2063,10 +2063,10 @@ discard block |
||
| 2063 | 2063 | <?php } ?> |
| 2064 | 2064 | <input type="hidden" name="<?php echo $file_id; ?>totImg" id="<?php echo $file_id; ?>totImg" |
| 2065 | 2065 | value="<?php if (isset($file_totImg)) {
|
| 2066 | - echo esc_attr($file_totImg); |
|
| 2067 | - } else {
|
|
| 2068 | - echo '0'; |
|
| 2069 | - } ?>"/> |
|
| 2066 | + echo esc_attr($file_totImg); |
|
| 2067 | + } else {
|
|
| 2068 | + echo '0'; |
|
| 2069 | + } ?>"/> |
|
| 2070 | 2070 | |
| 2071 | 2071 | <div style="float:left; width:55%;"> |
| 2072 | 2072 | <div |
@@ -2125,18 +2125,18 @@ discard block |
||
| 2125 | 2125 | |
| 2126 | 2126 | |
| 2127 | 2127 | if (!function_exists('geodir_get_field_infoby')) {
|
| 2128 | - /** |
|
| 2129 | - * Get custom field using key and value. |
|
| 2130 | - * |
|
| 2131 | - * @since 1.0.0 |
|
| 2132 | - * @package GeoDirectory |
|
| 2128 | + /** |
|
| 2129 | + * Get custom field using key and value. |
|
| 2130 | + * |
|
| 2131 | + * @since 1.0.0 |
|
| 2132 | + * @package GeoDirectory |
|
| 2133 | 2133 | * @global object $wpdb WordPress Database object. |
| 2134 | - * @param string $key The key you want to look for. |
|
| 2135 | - * @param string $value The value of the key you want to look for. |
|
| 2136 | - * @param string $geodir_post_type The post type. |
|
| 2137 | - * @return bool|mixed Returns field info when available. otherwise returns false. |
|
| 2138 | - */ |
|
| 2139 | - function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
| 2134 | + * @param string $key The key you want to look for. |
|
| 2135 | + * @param string $value The value of the key you want to look for. |
|
| 2136 | + * @param string $geodir_post_type The post type. |
|
| 2137 | + * @return bool|mixed Returns field info when available. otherwise returns false. |
|
| 2138 | + */ |
|
| 2139 | + function geodir_get_field_infoby($key = '', $value = '', $geodir_post_type = '') |
|
| 2140 | 2140 | {
|
| 2141 | 2141 | |
| 2142 | 2142 | global $wpdb; |
@@ -2159,21 +2159,21 @@ discard block |
||
| 2159 | 2159 | |
| 2160 | 2160 | |
| 2161 | 2161 | if (!function_exists('geodir_show_listing_info')) {
|
| 2162 | - /** |
|
| 2163 | - * Show listing info depending on field location. |
|
| 2164 | - * |
|
| 2165 | - * @since 1.0.0 |
|
| 2166 | - * @since 1.5.7 Custom fields option values added to db translation. |
|
| 2162 | + /** |
|
| 2163 | + * Show listing info depending on field location. |
|
| 2164 | + * |
|
| 2165 | + * @since 1.0.0 |
|
| 2166 | + * @since 1.5.7 Custom fields option values added to db translation. |
|
| 2167 | 2167 | * Changes to display url fields title. |
| 2168 | - * @package GeoDirectory |
|
| 2168 | + * @package GeoDirectory |
|
| 2169 | 2169 | * @global object $wpdb WordPress Database object. |
| 2170 | 2170 | * @global object $post The current post object. |
| 2171 | 2171 | * @global bool $send_to_friend True if send to friend link already rendered. Otherwise false. |
| 2172 | 2172 | * |
| 2173 | - * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
| 2174 | - * @return string Returns listing info html. |
|
| 2175 | - */ |
|
| 2176 | - function geodir_show_listing_info($fields_location = '') {
|
|
| 2173 | + * @param string $fields_location In which page you are going to place this custom fields?. Ex: listing, detail etc. |
|
| 2174 | + * @return string Returns listing info html. |
|
| 2175 | + */ |
|
| 2176 | + function geodir_show_listing_info($fields_location = '') {
|
|
| 2177 | 2177 | global $post, $preview, $wpdb, $send_to_friend; |
| 2178 | 2178 | |
| 2179 | 2179 | $payment_info = array(); |
@@ -2182,7 +2182,7 @@ discard block |
||
| 2182 | 2182 | $package_info = geodir_post_package_info($package_info, $post); |
| 2183 | 2183 | $post_package_id = $package_info->pid; |
| 2184 | 2184 | $p_type = (geodir_get_current_posttype()) ? geodir_get_current_posttype() : $post->post_type; |
| 2185 | - $send_to_friend = false; |
|
| 2185 | + $send_to_friend = false; |
|
| 2186 | 2186 | |
| 2187 | 2187 | ob_start(); |
| 2188 | 2188 | $fields_info = geodir_post_custom_fields($post_package_id, 'default', $p_type, $fields_location); |
@@ -2196,7 +2196,7 @@ discard block |
||
| 2196 | 2196 | |
| 2197 | 2197 | $i = 1; |
| 2198 | 2198 | foreach ($fields_info as $type) {
|
| 2199 | - $type = stripslashes_deep($type); // strip slashes |
|
| 2199 | + $type = stripslashes_deep($type); // strip slashes |
|
| 2200 | 2200 | $html = ''; |
| 2201 | 2201 | $html_var = ''; |
| 2202 | 2202 | $field_icon = ''; |
@@ -2401,13 +2401,13 @@ discard block |
||
| 2401 | 2401 | $field_icon = ''; |
| 2402 | 2402 | } |
| 2403 | 2403 | |
| 2404 | - $a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
|
|
| 2404 | + $a_url = geodir_parse_custom_field_url($post->{$type['htmlvar_name']});
|
|
| 2405 | 2405 | |
| 2406 | 2406 | |
| 2407 | - $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 2408 | - $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; |
|
| 2407 | + $website = !empty($a_url['url']) ? $a_url['url'] : ''; |
|
| 2408 | + $title = !empty($a_url['label']) ? $a_url['label'] : $type['site_title']; |
|
| 2409 | 2409 | if(!empty($type['default_value'])){$title = $type['default_value'];}
|
| 2410 | - $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 2410 | + $title = $title != '' ? __(stripslashes($title), 'geodirectory') : ''; |
|
| 2411 | 2411 | |
| 2412 | 2412 | |
| 2413 | 2413 | $geodir_odd_even = ''; |
@@ -2625,22 +2625,22 @@ discard block |
||
| 2625 | 2625 | if ($post->{$type['htmlvar_name']} != ''):
|
| 2626 | 2626 | |
| 2627 | 2627 | if ($post->{$type['htmlvar_name']} == 'f' || $post->{$type['htmlvar_name']} == '0') {
|
| 2628 | - $html_val = __('No', 'geodirectory');
|
|
| 2629 | - } else if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
|
|
| 2630 | - $html_val = __('Yes', 'geodirectory');
|
|
| 2631 | - } else {
|
|
| 2632 | - if (!empty($type['option_values'])) {
|
|
| 2633 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2628 | + $html_val = __('No', 'geodirectory');
|
|
| 2629 | + } else if ($post->{$type['htmlvar_name']} == 't' || $post->{$type['htmlvar_name']} == '1') {
|
|
| 2630 | + $html_val = __('Yes', 'geodirectory');
|
|
| 2631 | + } else {
|
|
| 2632 | + if (!empty($type['option_values'])) {
|
|
| 2633 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2634 | 2634 | |
| 2635 | - if (!empty($cf_option_values)) {
|
|
| 2636 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2637 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
|
|
| 2638 | - $html_val = $cf_option_value['label']; |
|
| 2639 | - } |
|
| 2640 | - } |
|
| 2641 | - } |
|
| 2642 | - } |
|
| 2643 | - } |
|
| 2635 | + if (!empty($cf_option_values)) {
|
|
| 2636 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2637 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->{$type['htmlvar_name']}) {
|
|
| 2638 | + $html_val = $cf_option_value['label']; |
|
| 2639 | + } |
|
| 2640 | + } |
|
| 2641 | + } |
|
| 2642 | + } |
|
| 2643 | + } |
|
| 2644 | 2644 | |
| 2645 | 2645 | if (strpos($field_icon, 'http') !== false) {
|
| 2646 | 2646 | $field_icon_af = ''; |
@@ -2711,19 +2711,19 @@ discard block |
||
| 2711 | 2711 | $html_var = $type['htmlvar_name']; |
| 2712 | 2712 | |
| 2713 | 2713 | if ($post->{$type['htmlvar_name']}):
|
| 2714 | - $field_value = __($post->$type['htmlvar_name'], 'geodirectory'); |
|
| 2714 | + $field_value = __($post->$type['htmlvar_name'], 'geodirectory'); |
|
| 2715 | 2715 | |
| 2716 | - if (!empty($type['option_values'])) {
|
|
| 2717 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2716 | + if (!empty($type['option_values'])) {
|
|
| 2717 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2718 | 2718 | |
| 2719 | - if (!empty($cf_option_values)) {
|
|
| 2720 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2721 | - if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->$type['htmlvar_name']) {
|
|
| 2722 | - $field_value = $cf_option_value['label']; |
|
| 2723 | - } |
|
| 2724 | - } |
|
| 2725 | - } |
|
| 2726 | - } |
|
| 2719 | + if (!empty($cf_option_values)) {
|
|
| 2720 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2721 | + if (isset($cf_option_value['value']) && $cf_option_value['value'] == $post->$type['htmlvar_name']) {
|
|
| 2722 | + $field_value = $cf_option_value['label']; |
|
| 2723 | + } |
|
| 2724 | + } |
|
| 2725 | + } |
|
| 2726 | + } |
|
| 2727 | 2727 | |
| 2728 | 2728 | if (strpos($field_icon, 'http') !== false) {
|
| 2729 | 2729 | $field_icon_af = ''; |
@@ -2771,19 +2771,19 @@ discard block |
||
| 2771 | 2771 | $field_icon = ''; |
| 2772 | 2772 | } |
| 2773 | 2773 | |
| 2774 | - $field_values = explode(',', trim($post->$type['htmlvar_name'], ","));
|
|
| 2774 | + $field_values = explode(',', trim($post->$type['htmlvar_name'], ","));
|
|
| 2775 | 2775 | |
| 2776 | 2776 | $option_values = array(); |
| 2777 | - if (!empty($type['option_values'])) {
|
|
| 2778 | - $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2777 | + if (!empty($type['option_values'])) {
|
|
| 2778 | + $cf_option_values = geodir_string_values_to_options(stripslashes_deep($type['option_values']), true); |
|
| 2779 | 2779 | |
| 2780 | - if (!empty($cf_option_values)) {
|
|
| 2781 | - foreach ($cf_option_values as $cf_option_value) {
|
|
| 2782 | - if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
|
|
| 2783 | - $option_values[] = $cf_option_value['label']; |
|
| 2784 | - } |
|
| 2785 | - } |
|
| 2786 | - } |
|
| 2780 | + if (!empty($cf_option_values)) {
|
|
| 2781 | + foreach ($cf_option_values as $cf_option_value) {
|
|
| 2782 | + if (isset($cf_option_value['value']) && in_array($cf_option_value['value'], $field_values)) {
|
|
| 2783 | + $option_values[] = $cf_option_value['label']; |
|
| 2784 | + } |
|
| 2785 | + } |
|
| 2786 | + } |
|
| 2787 | 2787 | } |
| 2788 | 2788 | |
| 2789 | 2789 | $geodir_odd_even = ''; |
@@ -2803,11 +2803,11 @@ discard block |
||
| 2803 | 2803 | if (count($option_values) > 1) {
|
| 2804 | 2804 | $html .= '<ul>'; |
| 2805 | 2805 | |
| 2806 | - foreach ($option_values as $val) {
|
|
| 2806 | + foreach ($option_values as $val) {
|
|
| 2807 | 2807 | $html .= '<li>' . $val . '</li>'; |
| 2808 | 2808 | } |
| 2809 | 2809 | |
| 2810 | - $html .= '</ul>'; |
|
| 2810 | + $html .= '</ul>'; |
|
| 2811 | 2811 | } else {
|
| 2812 | 2812 | $html .= $post->$type['htmlvar_name']; |
| 2813 | 2813 | } |
@@ -2816,13 +2816,13 @@ discard block |
||
| 2816 | 2816 | endif; |
| 2817 | 2817 | break; |
| 2818 | 2818 | case 'email': |
| 2819 | - if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
|
|
| 2820 | - continue; // Remove Send Enquiry | Send To Friend from listings page |
|
| 2821 | - } |
|
| 2819 | + if ($type['htmlvar_name'] == 'geodir_email' && !(geodir_is_page('detail') || geodir_is_page('preview'))) {
|
|
| 2820 | + continue; // Remove Send Enquiry | Send To Friend from listings page |
|
| 2821 | + } |
|
| 2822 | 2822 | |
| 2823 | - if ($type['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$type['htmlvar_name']})) {
|
|
| 2824 | - $send_to_friend = true; |
|
| 2825 | - $b_send_inquiry = ''; |
|
| 2823 | + if ($type['htmlvar_name'] == 'geodir_email' && ((isset($package_info->sendtofriend) && $package_info->sendtofriend) || $post->{$type['htmlvar_name']})) {
|
|
| 2824 | + $send_to_friend = true; |
|
| 2825 | + $b_send_inquiry = ''; |
|
| 2826 | 2826 | $b_sendtofriend = ''; |
| 2827 | 2827 | |
| 2828 | 2828 | $html = ''; |
@@ -2860,7 +2860,7 @@ discard block |
||
| 2860 | 2860 | |
| 2861 | 2861 | if (isset($package_info->sendtofriend) && $package_info->sendtofriend) {
|
| 2862 | 2862 | $html .= $seperator . '<a href="javascript:void(0);" class="' . $b_sendtofriend . '">' . SEND_TO_FRIEND . '</a>'; |
| 2863 | - } |
|
| 2863 | + } |
|
| 2864 | 2864 | |
| 2865 | 2865 | $html .= '</span></div>'; |
| 2866 | 2866 | |
@@ -2933,13 +2933,13 @@ discard block |
||
| 2933 | 2933 | if (!empty($files)): |
| 2934 | 2934 | |
| 2935 | 2935 | $extra_fields = !empty($type['extra_fields']) ? maybe_unserialize($type['extra_fields']) : NULL; |
| 2936 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2936 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 2937 | 2937 | |
| 2938 | - $file_paths = ''; |
|
| 2938 | + $file_paths = ''; |
|
| 2939 | 2939 | foreach ($files as $file) {
|
| 2940 | 2940 | if (!empty($file)) {
|
| 2941 | 2941 | |
| 2942 | - // $filetype = wp_check_filetype($file); |
|
| 2942 | + // $filetype = wp_check_filetype($file); |
|
| 2943 | 2943 | |
| 2944 | 2944 | $image_name_arr = explode('/', $file);
|
| 2945 | 2945 | $curr_img_dir = $image_name_arr[count($image_name_arr) - 2]; |
@@ -2948,29 +2948,29 @@ discard block |
||
| 2948 | 2948 | |
| 2949 | 2949 | $arr_file_type = wp_check_filetype($filename); |
| 2950 | 2950 | if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
| 2951 | - continue; |
|
| 2952 | - } |
|
| 2951 | + continue; |
|
| 2952 | + } |
|
| 2953 | 2953 | |
| 2954 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 2955 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
| 2954 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 2955 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
| 2956 | 2956 | |
| 2957 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 2958 | - continue; // Invalid file type. |
|
| 2959 | - } |
|
| 2957 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 2958 | + continue; // Invalid file type. |
|
| 2959 | + } |
|
| 2960 | 2960 | |
| 2961 | 2961 | //$allowed_file_types = array('application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
|
| 2962 | - $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
|
|
| 2962 | + $image_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'image/bmp', 'image/x-icon');
|
|
| 2963 | 2963 | |
| 2964 | 2964 | // If the uploaded file is image |
| 2965 | 2965 | if (in_array($uploaded_file_type, $image_file_types)) {
|
| 2966 | 2966 | $file_paths .= '<div class="geodir-custom-post-gallery" class="clearfix">'; |
| 2967 | 2967 | $file_paths .= '<a href="'.$file.'">'; |
| 2968 | - $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
|
| 2969 | - $file_paths .= '</a>'; |
|
| 2968 | + $file_paths .= geodir_show_image(array('src' => $file), 'thumbnail', false, false);
|
|
| 2969 | + $file_paths .= '</a>'; |
|
| 2970 | 2970 | //$file_paths .= '<img src="'.$file.'" />'; |
| 2971 | 2971 | $file_paths .= '</div>'; |
| 2972 | 2972 | } else {
|
| 2973 | - $ext_path = '_' . $html_var . '_'; |
|
| 2973 | + $ext_path = '_' . $html_var . '_'; |
|
| 2974 | 2974 | $filename = explode($ext_path, $filename); |
| 2975 | 2975 | $file_paths .= '<a href="' . $file . '" target="_blank">' . $filename[count($filename) - 1] . '</a>'; |
| 2976 | 2976 | } |
@@ -3175,14 +3175,14 @@ discard block |
||
| 3175 | 3175 | } |
| 3176 | 3176 | |
| 3177 | 3177 | if (!function_exists('geodir_default_date_format')) {
|
| 3178 | - /** |
|
| 3179 | - * Returns default date format. |
|
| 3180 | - * |
|
| 3181 | - * @since 1.0.0 |
|
| 3182 | - * @package GeoDirectory |
|
| 3183 | - * @return mixed|string|void Returns default date format. |
|
| 3184 | - */ |
|
| 3185 | - function geodir_default_date_format() |
|
| 3178 | + /** |
|
| 3179 | + * Returns default date format. |
|
| 3180 | + * |
|
| 3181 | + * @since 1.0.0 |
|
| 3182 | + * @package GeoDirectory |
|
| 3183 | + * @return mixed|string|void Returns default date format. |
|
| 3184 | + */ |
|
| 3185 | + function geodir_default_date_format() |
|
| 3186 | 3186 | {
|
| 3187 | 3187 | if ($format = get_option('date_format'))
|
| 3188 | 3188 | return $format; |
@@ -3192,30 +3192,30 @@ discard block |
||
| 3192 | 3192 | } |
| 3193 | 3193 | |
| 3194 | 3194 | if (!function_exists('geodir_get_formated_date')) {
|
| 3195 | - /** |
|
| 3196 | - * Returns formatted date. |
|
| 3197 | - * |
|
| 3198 | - * @since 1.0.0 |
|
| 3199 | - * @package GeoDirectory |
|
| 3200 | - * @param string $date Date string to convert. |
|
| 3201 | - * @return bool|int|string Returns formatted date. |
|
| 3202 | - */ |
|
| 3203 | - function geodir_get_formated_date($date) |
|
| 3195 | + /** |
|
| 3196 | + * Returns formatted date. |
|
| 3197 | + * |
|
| 3198 | + * @since 1.0.0 |
|
| 3199 | + * @package GeoDirectory |
|
| 3200 | + * @param string $date Date string to convert. |
|
| 3201 | + * @return bool|int|string Returns formatted date. |
|
| 3202 | + */ |
|
| 3203 | + function geodir_get_formated_date($date) |
|
| 3204 | 3204 | {
|
| 3205 | 3205 | return mysql2date(get_option('date_format'), $date);
|
| 3206 | 3206 | } |
| 3207 | 3207 | } |
| 3208 | 3208 | |
| 3209 | 3209 | if (!function_exists('geodir_get_formated_time')) {
|
| 3210 | - /** |
|
| 3211 | - * Returns formatted time. |
|
| 3212 | - * |
|
| 3213 | - * @since 1.0.0 |
|
| 3214 | - * @package GeoDirectory |
|
| 3215 | - * @param string $time Time string to convert. |
|
| 3216 | - * @return bool|int|string Returns formatted time. |
|
| 3217 | - */ |
|
| 3218 | - function geodir_get_formated_time($time) |
|
| 3210 | + /** |
|
| 3211 | + * Returns formatted time. |
|
| 3212 | + * |
|
| 3213 | + * @since 1.0.0 |
|
| 3214 | + * @package GeoDirectory |
|
| 3215 | + * @param string $time Time string to convert. |
|
| 3216 | + * @return bool|int|string Returns formatted time. |
|
| 3217 | + */ |
|
| 3218 | + function geodir_get_formated_time($time) |
|
| 3219 | 3219 | {
|
| 3220 | 3220 | return mysql2date(get_option('time_format'), $time, $translate = true);
|
| 3221 | 3221 | } |
@@ -3223,21 +3223,21 @@ discard block |
||
| 3223 | 3223 | |
| 3224 | 3224 | |
| 3225 | 3225 | if (!function_exists('geodir_save_post_file_fields')) {
|
| 3226 | - /** |
|
| 3227 | - * Save post file fields |
|
| 3228 | - * |
|
| 3229 | - * @since 1.0.0 |
|
| 3230 | - * @since 1.4.7 Added `$extra_fields` parameter. |
|
| 3231 | - * @package GeoDirectory |
|
| 3226 | + /** |
|
| 3227 | + * Save post file fields |
|
| 3228 | + * |
|
| 3229 | + * @since 1.0.0 |
|
| 3230 | + * @since 1.4.7 Added `$extra_fields` parameter. |
|
| 3231 | + * @package GeoDirectory |
|
| 3232 | 3232 | * @global object $wpdb WordPress Database object. |
| 3233 | 3233 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 3234 | 3234 | * @global object $current_user Current user object. |
| 3235 | - * @param int $post_id |
|
| 3236 | - * @param string $field_id |
|
| 3237 | - * @param array $post_image |
|
| 3238 | - * @param array $extra_fields Array of extra fields. |
|
| 3239 | - */ |
|
| 3240 | - function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
| 3235 | + * @param int $post_id |
|
| 3236 | + * @param string $field_id |
|
| 3237 | + * @param array $post_image |
|
| 3238 | + * @param array $extra_fields Array of extra fields. |
|
| 3239 | + */ |
|
| 3240 | + function geodir_save_post_file_fields($post_id = 0, $field_id = '', $post_image = array(), $extra_fields = array()) |
|
| 3241 | 3241 | {
|
| 3242 | 3242 | |
| 3243 | 3243 | global $wpdb, $plugin_prefix, $current_user; |
@@ -3263,7 +3263,7 @@ discard block |
||
| 3263 | 3263 | $geodir_uploadurl = $uploads['url']; |
| 3264 | 3264 | $sub_dir = $uploads['subdir']; |
| 3265 | 3265 | |
| 3266 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 3266 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? $extra_fields['gd_file_types'] : '';
|
|
| 3267 | 3267 | |
| 3268 | 3268 | for ($m = 0; $m < count($post_image); $m++) {
|
| 3269 | 3269 | |
@@ -3280,47 +3280,47 @@ discard block |
||
| 3280 | 3280 | |
| 3281 | 3281 | $arr_file_type = wp_check_filetype($filename); |
| 3282 | 3282 | |
| 3283 | - if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
|
| 3284 | - continue; |
|
| 3285 | - } |
|
| 3283 | + if (empty($arr_file_type['ext']) || empty($arr_file_type['type'])) {
|
|
| 3284 | + continue; |
|
| 3285 | + } |
|
| 3286 | 3286 | |
| 3287 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 3288 | - $uploaded_file_ext = $arr_file_type['ext']; |
|
| 3287 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 3288 | + $uploaded_file_ext = $arr_file_type['ext']; |
|
| 3289 | 3289 | |
| 3290 | - if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 3291 | - continue; // Invalid file type. |
|
| 3292 | - } |
|
| 3290 | + if (!empty($allowed_file_types) && !in_array($uploaded_file_ext, $allowed_file_types)) {
|
|
| 3291 | + continue; // Invalid file type. |
|
| 3292 | + } |
|
| 3293 | 3293 | |
| 3294 | 3294 | // Set an array containing a list of acceptable formats |
| 3295 | 3295 | //$allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png', 'application/pdf', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/octet-stream', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'text/csv', 'text/plain');
|
| 3296 | 3296 | |
| 3297 | - if (!function_exists('wp_handle_upload'))
|
|
| 3298 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 3297 | + if (!function_exists('wp_handle_upload'))
|
|
| 3298 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 3299 | 3299 | |
| 3300 | - if (!is_dir($geodir_uploadpath)) |
|
| 3301 | - mkdir($geodir_uploadpath); |
|
| 3300 | + if (!is_dir($geodir_uploadpath)) |
|
| 3301 | + mkdir($geodir_uploadpath); |
|
| 3302 | 3302 | |
| 3303 | - $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
| 3304 | - $explode_sub_dir = explode("/", $sub_dir);
|
|
| 3305 | - if ($curr_img_dir == end($explode_sub_dir)) {
|
|
| 3306 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 3307 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 3308 | - } else {
|
|
| 3309 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 3310 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 3311 | - } |
|
| 3303 | + $new_name = $post_id . '_' . $field_id . '_' . $img_name_arr[0] . '.' . $img_name_arr[1]; |
|
| 3304 | + $explode_sub_dir = explode("/", $sub_dir);
|
|
| 3305 | + if ($curr_img_dir == end($explode_sub_dir)) {
|
|
| 3306 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 3307 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 3308 | + } else {
|
|
| 3309 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 3310 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 3311 | + } |
|
| 3312 | 3312 | |
| 3313 | - $uploaded_file = ''; |
|
| 3314 | - if (file_exists($img_path)) |
|
| 3315 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 3313 | + $uploaded_file = ''; |
|
| 3314 | + if (file_exists($img_path)) |
|
| 3315 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 3316 | 3316 | |
| 3317 | - if ($curr_img_dir != $geodir_uploaddir) {
|
|
| 3318 | - if (file_exists($img_path)) |
|
| 3319 | - unlink($img_path); |
|
| 3320 | - } |
|
| 3317 | + if ($curr_img_dir != $geodir_uploaddir) {
|
|
| 3318 | + if (file_exists($img_path)) |
|
| 3319 | + unlink($img_path); |
|
| 3320 | + } |
|
| 3321 | 3321 | |
| 3322 | - if (!empty($uploaded_file)) |
|
| 3323 | - $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
| 3322 | + if (!empty($uploaded_file)) |
|
| 3323 | + $file_urls = $geodir_uploadurl . '/' . $new_name; |
|
| 3324 | 3324 | |
| 3325 | 3325 | } else {
|
| 3326 | 3326 | $file_urls = $post_image[$m]; |
@@ -3375,16 +3375,16 @@ discard block |
||
| 3375 | 3375 | |
| 3376 | 3376 | if (!function_exists('geodir_plupload_action')) {
|
| 3377 | 3377 | |
| 3378 | - /** |
|
| 3379 | - * Get upload directory path details |
|
| 3380 | - * |
|
| 3381 | - * @since 1.0.0 |
|
| 3382 | - * @package GeoDirectory |
|
| 3378 | + /** |
|
| 3379 | + * Get upload directory path details |
|
| 3380 | + * |
|
| 3381 | + * @since 1.0.0 |
|
| 3382 | + * @package GeoDirectory |
|
| 3383 | 3383 | * @global object $current_user Current user object. |
| 3384 | - * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
| 3385 | - * @return mixed Returns upload directory details as an array. |
|
| 3386 | - */ |
|
| 3387 | - function geodir_upload_dir($upload) |
|
| 3384 | + * @param array $upload Array of upload directory data with keys of 'path','url', 'subdir, 'basedir', and 'error'. |
|
| 3385 | + * @return mixed Returns upload directory details as an array. |
|
| 3386 | + */ |
|
| 3387 | + function geodir_upload_dir($upload) |
|
| 3388 | 3388 | {
|
| 3389 | 3389 | global $current_user; |
| 3390 | 3390 | $upload['subdir'] = $upload['subdir'] . '/temp_' . $current_user->data->ID; |
@@ -3393,13 +3393,13 @@ discard block |
||
| 3393 | 3393 | return $upload; |
| 3394 | 3394 | } |
| 3395 | 3395 | |
| 3396 | - /** |
|
| 3397 | - * Handles place file and image upload. |
|
| 3398 | - * |
|
| 3399 | - * @since 1.0.0 |
|
| 3400 | - * @package GeoDirectory |
|
| 3401 | - */ |
|
| 3402 | - function geodir_plupload_action() |
|
| 3396 | + /** |
|
| 3397 | + * Handles place file and image upload. |
|
| 3398 | + * |
|
| 3399 | + * @since 1.0.0 |
|
| 3400 | + * @package GeoDirectory |
|
| 3401 | + */ |
|
| 3402 | + function geodir_plupload_action() |
|
| 3403 | 3403 | {
|
| 3404 | 3404 | |
| 3405 | 3405 | // check ajax noonce |
@@ -3489,14 +3489,14 @@ discard block |
||
| 3489 | 3489 | } |
| 3490 | 3490 | |
| 3491 | 3491 | if (!function_exists('geodir_max_upload_size')) {
|
| 3492 | - /** |
|
| 3493 | - * Get max upload file size |
|
| 3494 | - * |
|
| 3495 | - * @since 1.0.0 |
|
| 3496 | - * @package GeoDirectory |
|
| 3497 | - * @return mixed|void Returns max upload file size. |
|
| 3498 | - */ |
|
| 3499 | - function geodir_max_upload_size() |
|
| 3492 | + /** |
|
| 3493 | + * Get max upload file size |
|
| 3494 | + * |
|
| 3495 | + * @since 1.0.0 |
|
| 3496 | + * @package GeoDirectory |
|
| 3497 | + * @return mixed|void Returns max upload file size. |
|
| 3498 | + */ |
|
| 3499 | + function geodir_max_upload_size() |
|
| 3500 | 3500 | {
|
| 3501 | 3501 | $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
| 3502 | 3502 | |
@@ -3669,14 +3669,14 @@ discard block |
||
| 3669 | 3669 | |
| 3670 | 3670 | |
| 3671 | 3671 | if (!function_exists('geodir_custom_sort_field_save')) {
|
| 3672 | - /** |
|
| 3673 | - * Save or Update custom sort fields into the database. |
|
| 3674 | - * |
|
| 3675 | - * @since 1.0.0 |
|
| 3676 | - * @package GeoDirectory |
|
| 3672 | + /** |
|
| 3673 | + * Save or Update custom sort fields into the database. |
|
| 3674 | + * |
|
| 3675 | + * @since 1.0.0 |
|
| 3676 | + * @package GeoDirectory |
|
| 3677 | 3677 | * @global object $wpdb WordPress Database object. |
| 3678 | 3678 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 3679 | - * @param array $request_field {
|
|
| 3679 | + * @param array $request_field {
|
|
| 3680 | 3680 | * Attributes of the Request field. |
| 3681 | 3681 | * |
| 3682 | 3682 | * @type string $action Ajax action name. |
@@ -3695,10 +3695,10 @@ discard block |
||
| 3695 | 3695 | * @type string $sort_order Sort Order. |
| 3696 | 3696 | * |
| 3697 | 3697 | * } |
| 3698 | - * @param bool $default Not yet implemented. |
|
| 3699 | - * @return int Returns the last affected db table row id. |
|
| 3700 | - */ |
|
| 3701 | - function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
| 3698 | + * @param bool $default Not yet implemented. |
|
| 3699 | + * @return int Returns the last affected db table row id. |
|
| 3700 | + */ |
|
| 3701 | + function geodir_custom_sort_field_save($request_field = array(), $default = false) |
|
| 3702 | 3702 | {
|
| 3703 | 3703 | |
| 3704 | 3704 | global $wpdb, $plugin_prefix; |
@@ -3816,16 +3816,16 @@ discard block |
||
| 3816 | 3816 | |
| 3817 | 3817 | |
| 3818 | 3818 | if (!function_exists('geodir_custom_sort_field_delete')) {
|
| 3819 | - /** |
|
| 3820 | - * Delete a custom sort field using field id. |
|
| 3821 | - * @since 1.0.0 |
|
| 3822 | - * @package GeoDirectory |
|
| 3819 | + /** |
|
| 3820 | + * Delete a custom sort field using field id. |
|
| 3821 | + * @since 1.0.0 |
|
| 3822 | + * @package GeoDirectory |
|
| 3823 | 3823 | * @global object $wpdb WordPress Database object. |
| 3824 | 3824 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 3825 | - * @param string $field_id The field ID. |
|
| 3826 | - * @return int|string Returns field id when successful deletion, else returns 0. |
|
| 3827 | - */ |
|
| 3828 | - function geodir_custom_sort_field_delete($field_id = '') |
|
| 3825 | + * @param string $field_id The field ID. |
|
| 3826 | + * @return int|string Returns field id when successful deletion, else returns 0. |
|
| 3827 | + */ |
|
| 3828 | + function geodir_custom_sort_field_delete($field_id = '') |
|
| 3829 | 3829 | {
|
| 3830 | 3830 | |
| 3831 | 3831 | global $wpdb, $plugin_prefix; |
@@ -3844,18 +3844,18 @@ discard block |
||
| 3844 | 3844 | |
| 3845 | 3845 | |
| 3846 | 3846 | if (!function_exists('geodir_custom_sort_field_adminhtml')) {
|
| 3847 | - /** |
|
| 3848 | - * Custom sort field admin html. |
|
| 3849 | - * |
|
| 3850 | - * @since 1.0.0 |
|
| 3851 | - * @package GeoDirectory |
|
| 3847 | + /** |
|
| 3848 | + * Custom sort field admin html. |
|
| 3849 | + * |
|
| 3850 | + * @since 1.0.0 |
|
| 3851 | + * @package GeoDirectory |
|
| 3852 | 3852 | * @global object $wpdb WordPress Database object. |
| 3853 | - * @param string $field_type The form field type. |
|
| 3854 | - * @param object|int $result_str The custom field results object or row id. |
|
| 3855 | - * @param string $field_ins_upd When set to "submit" displays form. |
|
| 3856 | - * @param bool $default when set to true field will be for admin use only. |
|
| 3857 | - */ |
|
| 3858 | - function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) |
|
| 3853 | + * @param string $field_type The form field type. |
|
| 3854 | + * @param object|int $result_str The custom field results object or row id. |
|
| 3855 | + * @param string $field_ins_upd When set to "submit" displays form. |
|
| 3856 | + * @param bool $default when set to true field will be for admin use only. |
|
| 3857 | + */ |
|
| 3858 | + function geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd = '', $default = false) |
|
| 3859 | 3859 | {
|
| 3860 | 3860 | global $wpdb; |
| 3861 | 3861 | $cf = $result_str; |
@@ -3868,7 +3868,7 @@ discard block |
||
| 3868 | 3868 | $result_str = $cf->id; |
| 3869 | 3869 | } |
| 3870 | 3870 | |
| 3871 | - $field_info = stripslashes_deep($field_info); // strip slashes |
|
| 3871 | + $field_info = stripslashes_deep($field_info); // strip slashes |
|
| 3872 | 3872 | |
| 3873 | 3873 | if (!isset($field_info->post_type)) {
|
| 3874 | 3874 | $post_type = $_REQUEST['listing_type']; |
@@ -3889,9 +3889,9 @@ discard block |
||
| 3889 | 3889 | $fields = geodir_get_custom_sort_options($post_type); |
| 3890 | 3890 | |
| 3891 | 3891 | foreach ($fields as $val) {
|
| 3892 | - $val = stripslashes_deep($val); // strip slashes |
|
| 3892 | + $val = stripslashes_deep($val); // strip slashes |
|
| 3893 | 3893 | |
| 3894 | - if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
|
|
| 3894 | + if ($val['field_type'] == $field_type && $val['htmlvar_name'] == $htmlvar_name) {
|
|
| 3895 | 3895 | $site_title = isset($val['site_title']) ? $val['site_title'] : ''; |
| 3896 | 3896 | } |
| 3897 | 3897 | |
@@ -3925,10 +3925,10 @@ discard block |
||
| 3925 | 3925 | |
| 3926 | 3926 | <div id="field_frm<?php echo $result_str;?>" class="field_frm" |
| 3927 | 3927 | style="display:<?php if ($field_ins_upd == 'submit') {
|
| 3928 | - echo 'block;'; |
|
| 3929 | - } else {
|
|
| 3930 | - echo 'none;'; |
|
| 3931 | - } ?>"> |
|
| 3928 | + echo 'block;'; |
|
| 3929 | + } else {
|
|
| 3930 | + echo 'none;'; |
|
| 3931 | + } ?>"> |
|
| 3932 | 3932 | <input type="hidden" name="_wpnonce" value="<?php echo $nonce; ?>"/> |
| 3933 | 3933 | <input type="hidden" name="listing_type" id="listing_type" value="<?php echo $post_type;?>"/> |
| 3934 | 3934 | <input type="hidden" name="field_type" id="field_type" value="<?php echo $field_type;?>"/> |
@@ -3956,8 +3956,8 @@ discard block |
||
| 3956 | 3956 | <input type="text" name="asc_title" id="asc_title" |
| 3957 | 3957 | placeholder="<?php esc_attr_e('Ascending title', 'geodirectory'); ?>"
|
| 3958 | 3958 | value="<?php if (isset($field_info->asc_title)) {
|
| 3959 | - echo esc_attr($field_info->asc_title); |
|
| 3960 | - } ?>" style="width:45%;"/> |
|
| 3959 | + echo esc_attr($field_info->asc_title); |
|
| 3960 | + } ?>" style="width:45%;"/> |
|
| 3961 | 3961 | |
| 3962 | 3962 | <input type="radio" name="is_default" |
| 3963 | 3963 | value="<?php echo $htmlvar_name; ?>_asc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_asc') {
|
@@ -3980,8 +3980,8 @@ discard block |
||
| 3980 | 3980 | <input type="text" name="desc_title" id="desc_title" |
| 3981 | 3981 | placeholder="<?php esc_attr_e('Descending title', 'geodirectory'); ?>"
|
| 3982 | 3982 | value="<?php if (isset($field_info->desc_title)) {
|
| 3983 | - echo esc_attr($field_info->desc_title); |
|
| 3984 | - } ?>" style="width:45%;"/> |
|
| 3983 | + echo esc_attr($field_info->desc_title); |
|
| 3984 | + } ?>" style="width:45%;"/> |
|
| 3985 | 3985 | <input type="radio" name="is_default" |
| 3986 | 3986 | value="<?php echo $htmlvar_name; ?>_desc" <?php if (isset($field_info->default_order) && $field_info->default_order == $htmlvar_name . '_desc') {
|
| 3987 | 3987 | echo 'checked="checked"'; |
@@ -4067,19 +4067,19 @@ discard block |
||
| 4067 | 4067 | } |
| 4068 | 4068 | |
| 4069 | 4069 | if (!function_exists('check_field_visibility')) {
|
| 4070 | - /** |
|
| 4071 | - * Check field visibility as per price package. |
|
| 4072 | - * |
|
| 4073 | - * @since 1.0.0 |
|
| 4074 | - * @package GeoDirectory |
|
| 4070 | + /** |
|
| 4071 | + * Check field visibility as per price package. |
|
| 4072 | + * |
|
| 4073 | + * @since 1.0.0 |
|
| 4074 | + * @package GeoDirectory |
|
| 4075 | 4075 | * @global object $wpdb WordPress Database object. |
| 4076 | 4076 | * @global array $geodir_addon_list List of active GeoDirectory extensions. |
| 4077 | - * @param int|string $package_id The package ID. |
|
| 4078 | - * @param string $field_name The field name. |
|
| 4079 | - * @param string $post_type Optional. The wordpress post type. |
|
| 4080 | - * @return bool Returns true when field visible, otherwise false. |
|
| 4081 | - */ |
|
| 4082 | - function check_field_visibility($package_id, $field_name, $post_type) |
|
| 4077 | + * @param int|string $package_id The package ID. |
|
| 4078 | + * @param string $field_name The field name. |
|
| 4079 | + * @param string $post_type Optional. The wordpress post type. |
|
| 4080 | + * @return bool Returns true when field visible, otherwise false. |
|
| 4081 | + */ |
|
| 4082 | + function check_field_visibility($package_id, $field_name, $post_type) |
|
| 4083 | 4083 | {
|
| 4084 | 4084 | global $wpdb, $geodir_addon_list; |
| 4085 | 4085 | if (!(isset($geodir_addon_list['geodir_payment_manager']) && $geodir_addon_list['geodir_payment_manager'] == 'yes')) {
|
@@ -4127,15 +4127,15 @@ discard block |
||
| 4127 | 4127 | $input_str = explode("/", $input_str, 2);
|
| 4128 | 4128 | $label = trim($input_str[0]); |
| 4129 | 4129 | if ($translated && $label != '') {
|
| 4130 | - $label = __($label, 'geodirectory'); |
|
| 4131 | - } |
|
| 4132 | - $label = ucfirst($label); |
|
| 4130 | + $label = __($label, 'geodirectory'); |
|
| 4131 | + } |
|
| 4132 | + $label = ucfirst($label); |
|
| 4133 | 4133 | $value = trim($input_str[1]); |
| 4134 | 4134 | } else {
|
| 4135 | 4135 | if ($translated && $input_str != '') {
|
| 4136 | - $input_str = __($input_str, 'geodirectory'); |
|
| 4137 | - } |
|
| 4138 | - $label = ucfirst($input_str); |
|
| 4136 | + $input_str = __($input_str, 'geodirectory'); |
|
| 4137 | + } |
|
| 4138 | + $label = ucfirst($input_str); |
|
| 4139 | 4139 | $value = $input_str; |
| 4140 | 4140 | } |
| 4141 | 4141 | |
@@ -4181,9 +4181,9 @@ discard block |
||
| 4181 | 4181 | if (strpos($optgroup_str, "|") !== false) {
|
| 4182 | 4182 | $optgroup_str_arr = explode("|", $optgroup_str, 2);
|
| 4183 | 4183 | $optgroup_label = trim($optgroup_str_arr[0]); |
| 4184 | - if ($translated && $optgroup_label != '') {
|
|
| 4185 | - $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
| 4186 | - } |
|
| 4184 | + if ($translated && $optgroup_label != '') {
|
|
| 4185 | + $optgroup_label = __($optgroup_label, 'geodirectory'); |
|
| 4186 | + } |
|
| 4187 | 4187 | $optgroup_label = ucfirst($optgroup_label); |
| 4188 | 4188 | $optgroup_str = $optgroup_str_arr[1]; |
| 4189 | 4189 | } |
@@ -153,7 +153,7 @@ |
||
| 153 | 153 | * @param array $package_info Package info array. |
| 154 | 154 | * @param object|string $post The post object. |
| 155 | 155 | * @param string $post_type The post type. |
| 156 | - * @return object Returns filtered package info as an object. |
|
| 156 | + * @return string Returns filtered package info as an object. |
|
| 157 | 157 | */ |
| 158 | 158 | function geodir_post_package_info($package_info, $post = '', $post_type = '') |
| 159 | 159 | {
|
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Custom functions |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Custom functions |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Front end listing view template selection. |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | function geodir_list_view_select() {
|
| 20 | 20 | global $gd_session; |
| 21 | - ?> |
|
| 21 | + ?> |
|
| 22 | 22 | <script type="text/javascript"> |
| 23 | 23 | function geodir_list_view_select(list) {
|
| 24 | 24 | //alert(listval); |
@@ -92,8 +92,8 @@ discard block |
||
| 92 | 92 | } |
| 93 | 93 | $out = ''; |
| 94 | 94 | |
| 95 | - $temp_post = $post; |
|
| 96 | - $excerpt = get_the_excerpt(); |
|
| 95 | + $temp_post = $post; |
|
| 96 | + $excerpt = get_the_excerpt(); |
|
| 97 | 97 | |
| 98 | 98 | $charlength++; |
| 99 | 99 | $excerpt_more = function_exists('geodirf_excerpt_more') ? geodirf_excerpt_more('') : geodir_excerpt_more('');
|
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | $out .= $excerpt; |
| 141 | 141 | } |
| 142 | 142 | } |
| 143 | - $post = $temp_post; |
|
| 143 | + $post = $temp_post; |
|
| 144 | 144 | |
| 145 | 145 | return $out; |
| 146 | 146 | } |
@@ -585,14 +585,14 @@ discard block |
||
| 585 | 585 | {
|
| 586 | 586 | global $wp_query; |
| 587 | 587 | |
| 588 | - /** |
|
| 589 | - * On search pages there should be no sort options, sorting is done by search criteria. |
|
| 590 | - * |
|
| 591 | - * @since 1.4.4 |
|
| 592 | - */ |
|
| 593 | - if ( is_search() ) {
|
|
| 594 | - return; |
|
| 595 | - } |
|
| 588 | + /** |
|
| 589 | + * On search pages there should be no sort options, sorting is done by search criteria. |
|
| 590 | + * |
|
| 591 | + * @since 1.4.4 |
|
| 592 | + */ |
|
| 593 | + if ( is_search() ) {
|
|
| 594 | + return; |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | 597 | $sort_by = ''; |
| 598 | 598 | |
@@ -607,7 +607,7 @@ discard block |
||
| 607 | 607 | |
| 608 | 608 | if (!empty($sort_options)) {
|
| 609 | 609 | foreach ($sort_options as $sort) {
|
| 610 | - $sort = stripslashes_deep($sort); // strip slashes |
|
| 610 | + $sort = stripslashes_deep($sort); // strip slashes |
|
| 611 | 611 | |
| 612 | 612 | $label = __($sort->site_title, 'geodirectory'); |
| 613 | 613 | |
@@ -760,34 +760,34 @@ discard block |
||
| 760 | 760 | |
| 761 | 761 | /* --- return false in invalid request --- */ |
| 762 | 762 | |
| 763 | - $location_url = ''; |
|
| 763 | + $location_url = ''; |
|
| 764 | 764 | if ($add_location_filter != '0') {
|
| 765 | 765 | $location_url = array(); |
| 766 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 766 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 767 | 767 | |
| 768 | - $gd_city = get_query_var('gd_city');
|
|
| 768 | + $gd_city = get_query_var('gd_city');
|
|
| 769 | 769 | |
| 770 | - if ($gd_city) {
|
|
| 771 | - $gd_country = get_query_var('gd_country');
|
|
| 772 | - $gd_region = get_query_var('gd_region');
|
|
| 770 | + if ($gd_city) {
|
|
| 771 | + $gd_country = get_query_var('gd_country');
|
|
| 772 | + $gd_region = get_query_var('gd_region');
|
|
| 773 | 773 | } else {
|
| 774 | 774 | $location = geodir_get_default_location(); |
| 775 | 775 | |
| 776 | - $gd_country = isset($location->country_slug) ? $location->country_slug : ''; |
|
| 777 | - $gd_region = isset($location->region_slug) ? $location->region_slug : ''; |
|
| 778 | - $gd_city = isset($location->city_slug) ? $location->city_slug : ''; |
|
| 776 | + $gd_country = isset($location->country_slug) ? $location->country_slug : ''; |
|
| 777 | + $gd_region = isset($location->region_slug) ? $location->region_slug : ''; |
|
| 778 | + $gd_city = isset($location->city_slug) ? $location->city_slug : ''; |
|
| 779 | 779 | } |
| 780 | 780 | |
| 781 | - if ($geodir_show_location_url == 'all') {
|
|
| 782 | - $location_url[] = $gd_country; |
|
| 783 | - $location_url[] = $gd_region; |
|
| 784 | - } else if ($geodir_show_location_url == 'country_city') {
|
|
| 785 | - $location_url[] = $gd_country; |
|
| 786 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 787 | - $location_url[] = $gd_region; |
|
| 788 | - } |
|
| 781 | + if ($geodir_show_location_url == 'all') {
|
|
| 782 | + $location_url[] = $gd_country; |
|
| 783 | + $location_url[] = $gd_region; |
|
| 784 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 785 | + $location_url[] = $gd_country; |
|
| 786 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 787 | + $location_url[] = $gd_region; |
|
| 788 | + } |
|
| 789 | 789 | |
| 790 | - $location_url[] = $gd_city; |
|
| 790 | + $location_url[] = $gd_city; |
|
| 791 | 791 | |
| 792 | 792 | $location_url = implode('/', $location_url);
|
| 793 | 793 | } |
@@ -946,18 +946,18 @@ discard block |
||
| 946 | 946 | return; |
| 947 | 947 | }// if non GD page, bail |
| 948 | 948 | |
| 949 | - $use_gd_meta = true; |
|
| 950 | - if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
|
|
| 951 | - $use_gd_meta = false; |
|
| 949 | + $use_gd_meta = true; |
|
| 950 | + if (class_exists('WPSEO_Frontend') || class_exists('All_in_One_SEO_Pack')) {
|
|
| 951 | + $use_gd_meta = false; |
|
| 952 | 952 | |
| 953 | - if (geodir_is_page('search')) {
|
|
| 954 | - $use_gd_meta = true; |
|
| 955 | - } |
|
| 956 | - } |
|
| 953 | + if (geodir_is_page('search')) {
|
|
| 954 | + $use_gd_meta = true; |
|
| 955 | + } |
|
| 956 | + } |
|
| 957 | 957 | |
| 958 | - if (!$use_gd_meta) {
|
|
| 959 | - return; |
|
| 960 | - }// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active. |
|
| 958 | + if (!$use_gd_meta) {
|
|
| 959 | + return; |
|
| 960 | + }// bail if Yoast Wordpress SEO or All_in_One_SEO_Pack active. |
|
| 961 | 961 | |
| 962 | 962 | $current_term = $wp_query->get_queried_object(); |
| 963 | 963 | |
@@ -51,20 +51,20 @@ discard block |
||
| 51 | 51 | jQuery(listSel).children('li').switchClass('gridview_onehalf gridview_onethird gridview_onefourth', 'gridview_onefifth', 600);
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - jQuery.post("<?php echo geodir_get_ajax_url();?>&gd_listing_view=" + val, function (data) {
|
|
| 54 | + jQuery.post("<?php echo geodir_get_ajax_url(); ?>&gd_listing_view=" + val, function (data) {
|
|
| 55 | 55 | //alert(data ); |
| 56 | 56 | }); |
| 57 | 57 | } |
| 58 | 58 | </script> |
| 59 | 59 | <div class="geodir-list-view-select"> |
| 60 | 60 | <select name="gd_list_view" id="gd_list_view" onchange="geodir_list_view_select(this);"> |
| 61 | - <?php $listing_view = (int)$gd_session->get('gd_listing_view'); ?>
|
|
| 62 | - <option value=""><?php _e('View:', 'geodirectory');?></option>
|
|
| 63 | - <option value="1" <?php selected(1, $listing_view);?>><?php _e('View: List', 'geodirectory');?></option>
|
|
| 64 | - <option value="2" <?php selected(2, $listing_view);?>><?php _e('View: Grid 2', 'geodirectory');?></option>
|
|
| 65 | - <option value="3" <?php selected(3, $listing_view);?>><?php _e('View: Grid 3', 'geodirectory');?></option>
|
|
| 66 | - <option value="4" <?php selected(4, $listing_view);?>><?php _e('View: Grid 4', 'geodirectory');?></option>
|
|
| 67 | - <option value="5" <?php selected(5, $listing_view);?>><?php _e('View: Grid 5', 'geodirectory');?></option>
|
|
| 61 | + <?php $listing_view = (int) $gd_session->get('gd_listing_view'); ?>
|
|
| 62 | + <option value=""><?php _e('View:', 'geodirectory'); ?></option>
|
|
| 63 | + <option value="1" <?php selected(1, $listing_view); ?>><?php _e('View: List', 'geodirectory'); ?></option>
|
|
| 64 | + <option value="2" <?php selected(2, $listing_view); ?>><?php _e('View: Grid 2', 'geodirectory'); ?></option>
|
|
| 65 | + <option value="3" <?php selected(3, $listing_view); ?>><?php _e('View: Grid 3', 'geodirectory'); ?></option>
|
|
| 66 | + <option value="4" <?php selected(4, $listing_view); ?>><?php _e('View: Grid 4', 'geodirectory'); ?></option>
|
|
| 67 | + <option value="5" <?php selected(5, $listing_view); ?>><?php _e('View: Grid 5', 'geodirectory'); ?></option>
|
|
| 68 | 68 | </select> |
| 69 | 69 | </div> |
| 70 | 70 | <?php |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @param object|string $post The post object. |
| 185 | 185 | * @param string $post_type The post type. |
| 186 | 186 | */ |
| 187 | - return (object)apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
|
|
| 187 | + return (object) apply_filters('geodir_post_package_info', $package_info, $post, $post_type);
|
|
| 188 | 188 | |
| 189 | 189 | } |
| 190 | 190 | |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | // strip slashes message |
| 299 | 299 | $client_message = stripslashes_deep($client_message); |
| 300 | 300 | |
| 301 | - geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']);//To client email |
|
| 301 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email |
|
| 302 | 302 | } |
| 303 | 303 | |
| 304 | 304 | /** |
@@ -403,7 +403,7 @@ discard block |
||
| 403 | 403 | * } |
| 404 | 404 | */ |
| 405 | 405 | do_action('geodir_before_send_to_friend_email', $request);
|
| 406 | - geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']);//To client email |
|
| 406 | + geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email |
|
| 407 | 407 | |
| 408 | 408 | /** |
| 409 | 409 | * Called after the send to friend email is sent. |
@@ -590,7 +590,7 @@ discard block |
||
| 590 | 590 | * |
| 591 | 591 | * @since 1.4.4 |
| 592 | 592 | */ |
| 593 | - if ( is_search() ) {
|
|
| 593 | + if (is_search()) {
|
|
| 594 | 594 | return; |
| 595 | 595 | } |
| 596 | 596 | |
@@ -614,7 +614,7 @@ discard block |
||
| 614 | 614 | if ($sort->field_type == 'random') {
|
| 615 | 615 | $key = $sort->field_type; |
| 616 | 616 | ($sort_by == $key || ($sort->is_default == '1' && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
| 617 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 617 | + $sort_field_options .= '<option ' . $selected . ' value="' . esc_url(add_query_arg('sort_by', $key)) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 618 | 618 | } |
| 619 | 619 | |
| 620 | 620 | if ($sort->htmlvar_name == 'comment_count') {
|
@@ -627,7 +627,7 @@ discard block |
||
| 627 | 627 | if ($sort->asc_title) |
| 628 | 628 | $label = $sort->asc_title; |
| 629 | 629 | ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
| 630 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 630 | + $sort_field_options .= '<option ' . $selected . ' value="' . esc_url(add_query_arg('sort_by', $key)) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | if ($sort->sort_desc) {
|
@@ -636,7 +636,7 @@ discard block |
||
| 636 | 636 | if ($sort->desc_title) |
| 637 | 637 | $label = $sort->desc_title; |
| 638 | 638 | ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
| 639 | - $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 639 | + $sort_field_options .= '<option ' . $selected . ' value="' . esc_url(add_query_arg('sort_by', $key)) . '">' . __($label, 'geodirectory') . '</option>';
|
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | } |
@@ -651,9 +651,9 @@ discard block |
||
| 651 | 651 | <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;"> |
| 652 | 652 | |
| 653 | 653 | <option |
| 654 | - value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
|
|
| 654 | + value="<?php echo esc_url(add_query_arg('sort_by', '')); ?>" <?php if ($sort_by == '') echo 'selected="selected"'; ?>><?php _e('Sort By', 'geodirectory'); ?></option><?php
|
|
| 655 | 655 | |
| 656 | - echo $sort_field_options;?> |
|
| 656 | + echo $sort_field_options; ?> |
|
| 657 | 657 | |
| 658 | 658 | </select> |
| 659 | 659 | |
@@ -722,7 +722,7 @@ discard block |
||
| 722 | 722 | $category = array(); |
| 723 | 723 | |
| 724 | 724 | if (isset($_REQUEST['backandedit'])) {
|
| 725 | - $post = (object)$gd_session->get('listing');
|
|
| 725 | + $post = (object) $gd_session->get('listing');
|
|
| 726 | 726 | $post_type = $post->listing_type; |
| 727 | 727 | if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
| 728 | 728 | $post_id = $_REQUEST['pid']; |
@@ -799,7 +799,7 @@ discard block |
||
| 799 | 799 | if ($add_location_filter != '0') {
|
| 800 | 800 | $geodir_add_location_url = '1'; |
| 801 | 801 | } |
| 802 | - $viewall_url = get_term_link((int)$category[0], $post_type . $category_taxonomy); |
|
| 802 | + $viewall_url = get_term_link((int) $category[0], $post_type . $category_taxonomy); |
|
| 803 | 803 | $geodir_add_location_url = NULL; |
| 804 | 804 | } |
| 805 | 805 | ob_start(); |
@@ -896,7 +896,7 @@ discard block |
||
| 896 | 896 | $geodir_post_category_str = serialize($geodir_post_category_str); |
| 897 | 897 | } |
| 898 | 898 | |
| 899 | - $all_var['post_category_array'] = html_entity_decode((string)$geodir_post_category_str, ENT_QUOTES, 'UTF-8'); |
|
| 899 | + $all_var['post_category_array'] = html_entity_decode((string) $geodir_post_category_str, ENT_QUOTES, 'UTF-8'); |
|
| 900 | 900 | $script = "var post_category_array = " . json_encode($all_var) . ';'; |
| 901 | 901 | echo '<script>'; |
| 902 | 902 | echo $script; |
@@ -1029,7 +1029,7 @@ discard block |
||
| 1029 | 1029 | $location_id = NULL; |
| 1030 | 1030 | if ($geodir_location_manager) {
|
| 1031 | 1031 | $sql = $wpdb->prepare("SELECT location_id FROM " . POST_LOCATION_TABLE . " WHERE city_slug=%s ORDER BY location_id ASC LIMIT 1", array($gd_city));
|
| 1032 | - $location_id = (int)$wpdb->get_var($sql); |
|
| 1032 | + $location_id = (int) $wpdb->get_var($sql); |
|
| 1033 | 1033 | $location_type = geodir_what_is_current_location(); |
| 1034 | 1034 | if ($location_type == 'city') {
|
| 1035 | 1035 | $replace_location = geodir_get_current_location(array('what' => 'city', 'echo' => false));
|
@@ -1090,45 +1090,45 @@ discard block |
||
| 1090 | 1090 | |
| 1091 | 1091 | |
| 1092 | 1092 | $gd_page = ''; |
| 1093 | - if(geodir_is_page('home')){
|
|
| 1093 | + if (geodir_is_page('home')) {
|
|
| 1094 | 1094 | $gd_page = 'home'; |
| 1095 | 1095 | $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
|
| 1096 | 1096 | } |
| 1097 | - elseif(geodir_is_page('detail')){
|
|
| 1097 | + elseif (geodir_is_page('detail')) {
|
|
| 1098 | 1098 | $gd_page = 'detail'; |
| 1099 | 1099 | $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
|
| 1100 | 1100 | } |
| 1101 | - elseif(geodir_is_page('pt')){
|
|
| 1101 | + elseif (geodir_is_page('pt')) {
|
|
| 1102 | 1102 | $gd_page = 'pt'; |
| 1103 | 1103 | $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
|
| 1104 | 1104 | } |
| 1105 | - elseif(geodir_is_page('listing')){
|
|
| 1105 | + elseif (geodir_is_page('listing')) {
|
|
| 1106 | 1106 | $gd_page = 'listing'; |
| 1107 | 1107 | $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
|
| 1108 | 1108 | } |
| 1109 | - elseif(geodir_is_page('location')){
|
|
| 1109 | + elseif (geodir_is_page('location')) {
|
|
| 1110 | 1110 | $gd_page = 'location'; |
| 1111 | 1111 | $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
|
| 1112 | 1112 | $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
|
| 1113 | 1113 | |
| 1114 | 1114 | } |
| 1115 | - elseif(geodir_is_page('search')){
|
|
| 1115 | + elseif (geodir_is_page('search')) {
|
|
| 1116 | 1116 | $gd_page = 'search'; |
| 1117 | 1117 | $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
|
| 1118 | 1118 | } |
| 1119 | - elseif(geodir_is_page('add-listing')){
|
|
| 1119 | + elseif (geodir_is_page('add-listing')) {
|
|
| 1120 | 1120 | $gd_page = 'add-listing'; |
| 1121 | 1121 | $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
|
| 1122 | 1122 | } |
| 1123 | - elseif(geodir_is_page('author')){
|
|
| 1123 | + elseif (geodir_is_page('author')) {
|
|
| 1124 | 1124 | $gd_page = 'author'; |
| 1125 | 1125 | $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
|
| 1126 | 1126 | } |
| 1127 | - elseif(geodir_is_page('login')){
|
|
| 1127 | + elseif (geodir_is_page('login')) {
|
|
| 1128 | 1128 | $gd_page = 'login'; |
| 1129 | 1129 | $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
|
| 1130 | 1130 | } |
| 1131 | - elseif(geodir_is_page('listing-success')){
|
|
| 1131 | + elseif (geodir_is_page('listing-success')) {
|
|
| 1132 | 1132 | $gd_page = 'listing-success'; |
| 1133 | 1133 | $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
|
| 1134 | 1134 | } |
@@ -1156,7 +1156,7 @@ discard block |
||
| 1156 | 1156 | * @param string $title The page description including variables. |
| 1157 | 1157 | * @param string $gd_page The GeoDirectory page type if any. |
| 1158 | 1158 | */ |
| 1159 | - $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'),$gd_page,'');
|
|
| 1159 | + $meta_desc = apply_filters('geodir_seo_meta_description_pre', __($meta_desc, 'geodirectory'), $gd_page, '');
|
|
| 1160 | 1160 | |
| 1161 | 1161 | /** |
| 1162 | 1162 | * Filter SEO meta description. |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | $place_tags = wp_get_post_terms($post->ID, $post->post_type . '_tags', array("fields" => "names"));
|
| 1173 | 1173 | $place_cats = wp_get_post_terms($post->ID, $post->post_type . 'category', array("fields" => "names"));
|
| 1174 | 1174 | |
| 1175 | - $meta_key .= implode(", ", array_merge((array)$place_cats, (array)$place_tags));
|
|
| 1175 | + $meta_key .= implode(", ", array_merge((array) $place_cats, (array) $place_tags));
|
|
| 1176 | 1176 | } else {
|
| 1177 | 1177 | $posttags = get_the_tags(); |
| 1178 | 1178 | if ($posttags) {
|
@@ -1362,8 +1362,8 @@ discard block |
||
| 1362 | 1362 | |
| 1363 | 1363 | global $post, $post_images, $video, $special_offers, $related_listing, $geodir_post_detail_fields; |
| 1364 | 1364 | |
| 1365 | - $post_id = !empty($post) && isset($post->ID) ? (int)$post->ID : 0; |
|
| 1366 | - $request_post_id = !empty($_REQUEST['p']) ? (int)$_REQUEST['p'] : 0; |
|
| 1365 | + $post_id = !empty($post) && isset($post->ID) ? (int) $post->ID : 0; |
|
| 1366 | + $request_post_id = !empty($_REQUEST['p']) ? (int) $_REQUEST['p'] : 0; |
|
| 1367 | 1367 | $is_backend_preview = (is_single() && !empty($_REQUEST['post_type']) && !empty($_REQUEST['preview']) && !empty($_REQUEST['p'])) && is_super_admin() ? true : false; // skip if preview from backend |
| 1368 | 1368 | |
| 1369 | 1369 | if ($is_backend_preview && !$post_id > 0 && $request_post_id > 0) {
|
@@ -1398,7 +1398,7 @@ discard block |
||
| 1398 | 1398 | if (!empty($post_images)) {
|
| 1399 | 1399 | foreach ($post_images as $image) {
|
| 1400 | 1400 | $caption = (!empty($image->caption)) ? $image->caption : ''; |
| 1401 | - $thumb_image .= '<a href="' . $image->src . '" title="'.$caption.'">'; |
|
| 1401 | + $thumb_image .= '<a href="' . $image->src . '" title="' . $caption . '">'; |
|
| 1402 | 1402 | $thumb_image .= geodir_show_image($image, 'thumbnail', true, false); |
| 1403 | 1403 | $thumb_image .= '</a>'; |
| 1404 | 1404 | } |
@@ -1477,12 +1477,12 @@ discard block |
||
| 1477 | 1477 | } |
| 1478 | 1478 | |
| 1479 | 1479 | |
| 1480 | - $arr_detail_page_tabs = geodir_detail_page_tabs_list();// get this sooner so we can get the active tab for the user |
|
| 1480 | + $arr_detail_page_tabs = geodir_detail_page_tabs_list(); // get this sooner so we can get the active tab for the user |
|
| 1481 | 1481 | |
| 1482 | 1482 | $active_tab_name = ''; |
| 1483 | - foreach($arr_detail_page_tabs as $tabs){
|
|
| 1484 | - if(isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && isset($tabs['heading_text']) && $tabs['heading_text']){
|
|
| 1485 | - $active_tab_name = __($tabs['heading_text'],'geodirectory'); |
|
| 1483 | + foreach ($arr_detail_page_tabs as $tabs) {
|
|
| 1484 | + if (isset($tabs['is_active_tab']) && $tabs['is_active_tab'] && isset($tabs['heading_text']) && $tabs['heading_text']) {
|
|
| 1485 | + $active_tab_name = __($tabs['heading_text'], 'geodirectory'); |
|
| 1486 | 1486 | } |
| 1487 | 1487 | } |
| 1488 | 1488 | ?> |
@@ -1491,7 +1491,7 @@ discard block |
||
| 1491 | 1491 | |
| 1492 | 1492 | <div id="geodir-tab-mobile-menu" > |
| 1493 | 1493 | <i class="fa fa-bars"></i> |
| 1494 | - <span class="geodir-mobile-active-tab"><?php echo $active_tab_name;?></span> |
|
| 1494 | + <span class="geodir-mobile-active-tab"><?php echo $active_tab_name; ?></span> |
|
| 1495 | 1495 | <i class="fa fa-sort-desc"></i> |
| 1496 | 1496 | </div> |
| 1497 | 1497 | |
@@ -1511,18 +1511,18 @@ discard block |
||
| 1511 | 1511 | if ($detail_page_tab['is_display']) {
|
| 1512 | 1512 | ?> |
| 1513 | 1513 | <dt></dt> <!-- added to comply with validation --> |
| 1514 | - <dd <?php if ($detail_page_tab['is_active_tab']){ ?>class="geodir-tab-active"<?php }?> >
|
|
| 1515 | - <a data-tab="#<?php echo $tab_index;?>" |
|
| 1516 | - data-status="enable"><?php _e($detail_page_tab['heading_text'],'geodirectory');?></a> |
|
| 1514 | + <dd <?php if ($detail_page_tab['is_active_tab']) { ?>class="geodir-tab-active"<?php }?> >
|
|
| 1515 | + <a data-tab="#<?php echo $tab_index; ?>" |
|
| 1516 | + data-status="enable"><?php _e($detail_page_tab['heading_text'], 'geodirectory'); ?></a> |
|
| 1517 | 1517 | </dd> |
| 1518 | 1518 | |
| 1519 | 1519 | <?php |
| 1520 | 1520 | ob_start() // start tab content buffering |
| 1521 | 1521 | ?> |
| 1522 | - <li id="<?php echo $tab_index;?>Tab" <?php if ($tab_index == 'post_profile') {
|
|
| 1522 | + <li id="<?php echo $tab_index; ?>Tab" <?php if ($tab_index == 'post_profile') {
|
|
| 1523 | 1523 | //echo 'itemprop="description"'; |
| 1524 | 1524 | }?>> |
| 1525 | - <div id="<?php echo $tab_index;?>" class="hash-offset"></div> |
|
| 1525 | + <div id="<?php echo $tab_index; ?>" class="hash-offset"></div> |
|
| 1526 | 1526 | <?php |
| 1527 | 1527 | /** |
| 1528 | 1528 | * Called before the details tab content is output per tab. |
@@ -1572,7 +1572,7 @@ discard block |
||
| 1572 | 1572 | break; |
| 1573 | 1573 | case 'post_video': |
| 1574 | 1574 | /** This action is documented in geodirectory_template_actions.php */ |
| 1575 | - echo apply_filters('the_content', stripslashes($video));// we apply the_content filter so oembed works also;
|
|
| 1575 | + echo apply_filters('the_content', stripslashes($video)); // we apply the_content filter so oembed works also;
|
|
| 1576 | 1576 | break; |
| 1577 | 1577 | case 'special_offers': |
| 1578 | 1578 | echo wpautop(stripslashes($special_offers)); |
@@ -1885,9 +1885,9 @@ discard block |
||
| 1885 | 1885 | $comments_echo .= "</span>\n"; |
| 1886 | 1886 | |
| 1887 | 1887 | $comments_echo .= '<span class="geodir_reviewer_content">'; |
| 1888 | - if($comment->user_id){$comments_echo .= '<a href="'.get_author_posts_url( $comment->user_id ).'">';}
|
|
| 1888 | + if ($comment->user_id) {$comments_echo .= '<a href="' . get_author_posts_url($comment->user_id) . '">'; }
|
|
| 1889 | 1889 | $comments_echo .= '<span class="geodir_reviewer_author">' . $comment->comment_author . '</span> '; |
| 1890 | - if($comment->user_id){$comments_echo .= '</a>';}
|
|
| 1890 | + if ($comment->user_id) {$comments_echo .= '</a>'; }
|
|
| 1891 | 1891 | $comments_echo .= '<span class="geodir_reviewer_reviewed">' . __('reviewed', 'geodirectory') . '</span> ';
|
| 1892 | 1892 | $comments_echo .= '<a href="' . $permalink . '" class="geodir_reviewer_title">' . $post_title . '</a>'; |
| 1893 | 1893 | $comments_echo .= geodir_get_rating_stars($comment->overall_rating, $comment_post_ID); |
@@ -1918,7 +1918,7 @@ discard block |
||
| 1918 | 1918 | if (!empty($post_types)) {
|
| 1919 | 1919 | foreach ($post_types as $key => $post_type) {
|
| 1920 | 1920 | $cpt_name = __($post_type->labels->singular_name, 'geodirectory'); |
| 1921 | - $post_type_name = sprintf(__('%s Categories', 'geodirectory'),$cpt_name);
|
|
| 1921 | + $post_type_name = sprintf(__('%s Categories', 'geodirectory'), $cpt_name);
|
|
| 1922 | 1922 | $taxonomies = geodir_get_taxonomies($key); |
| 1923 | 1923 | $cat_taxonomy = !empty($taxonomies[0]) ? $taxonomies[0] : NULL; |
| 1924 | 1924 | $cat_terms = $cat_taxonomy ? get_terms($cat_taxonomy) : NULL; |
@@ -2025,10 +2025,10 @@ discard block |
||
| 2025 | 2025 | stWidget.addEntry({
|
| 2026 | 2026 | "service": "sharethis", |
| 2027 | 2027 | "element": document.getElementById('st_sharethis'),
|
| 2028 | - "url": "<?php echo geodir_curPageURL();?>", |
|
| 2029 | - "title": "<?php echo $post->post_title;?>", |
|
| 2028 | + "url": "<?php echo geodir_curPageURL(); ?>", |
|
| 2029 | + "title": "<?php echo $post->post_title; ?>", |
|
| 2030 | 2030 | "type": "chicklet", |
| 2031 | - "text": "<?php _e( 'Share', 'geodirectory' );?>" |
|
| 2031 | + "text": "<?php _e('Share', 'geodirectory'); ?>"
|
|
| 2032 | 2032 | });</script> |
| 2033 | 2033 | |
| 2034 | 2034 | </div> |
@@ -526,13 +526,15 @@ discard block |
||
| 526 | 526 | |
| 527 | 527 | $all_postypes = geodir_get_posttypes(); |
| 528 | 528 | |
| 529 | - if (!in_array($post_type, $all_postypes)) |
|
| 530 | - return false; |
|
| 529 | + if (!in_array($post_type, $all_postypes)) { |
|
| 530 | + return false; |
|
| 531 | + } |
|
| 531 | 532 | |
| 532 | 533 | $sort_field_info = $wpdb->get_var($wpdb->prepare("select default_order from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and is_default=%d", array($post_type, 1, 1)));
|
| 533 | 534 | |
| 534 | - if (!empty($sort_field_info)) |
|
| 535 | - return $sort_field_info; |
|
| 535 | + if (!empty($sort_field_info)) { |
|
| 536 | + return $sort_field_info; |
|
| 537 | + } |
|
| 536 | 538 | |
| 537 | 539 | } |
| 538 | 540 | |
@@ -556,8 +558,9 @@ discard block |
||
| 556 | 558 | |
| 557 | 559 | $all_postypes = geodir_get_posttypes(); |
| 558 | 560 | |
| 559 | - if (!in_array($post_type, $all_postypes)) |
|
| 560 | - return false; |
|
| 561 | + if (!in_array($post_type, $all_postypes)) { |
|
| 562 | + return false; |
|
| 563 | + } |
|
| 561 | 564 | |
| 562 | 565 | |
| 563 | 566 | $sort_field_info = $wpdb->get_results($wpdb->prepare("select * from " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " where post_type= %s and is_active=%d and (sort_asc=1 || sort_desc=1 || field_type='random') order by sort_order asc", array($post_type, 1)));
|
@@ -596,7 +599,9 @@ discard block |
||
| 596 | 599 | |
| 597 | 600 | $sort_by = ''; |
| 598 | 601 | |
| 599 | - if (isset($_REQUEST['sort_by'])) $sort_by = $_REQUEST['sort_by']; |
|
| 602 | + if (isset($_REQUEST['sort_by'])) { |
|
| 603 | + $sort_by = $_REQUEST['sort_by']; |
|
| 604 | + } |
|
| 600 | 605 | |
| 601 | 606 | $gd_post_type = geodir_get_current_posttype(); |
| 602 | 607 | |
@@ -624,8 +629,9 @@ discard block |
||
| 624 | 629 | if ($sort->sort_asc) {
|
| 625 | 630 | $key = $sort->htmlvar_name . '_asc'; |
| 626 | 631 | $label = $sort->site_title; |
| 627 | - if ($sort->asc_title) |
|
| 628 | - $label = $sort->asc_title; |
|
| 632 | + if ($sort->asc_title) { |
|
| 633 | + $label = $sort->asc_title; |
|
| 634 | + } |
|
| 629 | 635 | ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
| 630 | 636 | $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
| 631 | 637 | } |
@@ -633,8 +639,9 @@ discard block |
||
| 633 | 639 | if ($sort->sort_desc) {
|
| 634 | 640 | $key = $sort->htmlvar_name . '_desc'; |
| 635 | 641 | $label = $sort->site_title; |
| 636 | - if ($sort->desc_title) |
|
| 637 | - $label = $sort->desc_title; |
|
| 642 | + if ($sort->desc_title) { |
|
| 643 | + $label = $sort->desc_title; |
|
| 644 | + } |
|
| 638 | 645 | ($sort_by == $key || ($sort->is_default == '1' && $sort->default_order == $key && !isset($_REQUEST['sort_by']))) ? $selected = 'selected="selected"' : $selected = ''; |
| 639 | 646 | $sort_field_options .= '<option ' . $selected . ' value="' . esc_url( add_query_arg('sort_by', $key) ) . '">' . __($label, 'geodirectory') . '</option>';
|
| 640 | 647 | } |
@@ -651,7 +658,10 @@ discard block |
||
| 651 | 658 | <select name="sort_by" id="sort_by" onchange="javascript:window.location=this.value;"> |
| 652 | 659 | |
| 653 | 660 | <option |
| 654 | - value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') echo 'selected="selected"';?>><?php _e('Sort By', 'geodirectory');?></option><?php
|
|
| 661 | + value="<?php echo esc_url( add_query_arg('sort_by', '') );?>" <?php if ($sort_by == '') { |
|
| 662 | + echo 'selected="selected"'; |
|
| 663 | +} |
|
| 664 | +?>><?php _e('Sort By', 'geodirectory');?></option><?php
|
|
| 655 | 665 | |
| 656 | 666 | echo $sort_field_options;?> |
| 657 | 667 | |
@@ -724,8 +734,9 @@ discard block |
||
| 724 | 734 | if (isset($_REQUEST['backandedit'])) {
|
| 725 | 735 | $post = (object)$gd_session->get('listing');
|
| 726 | 736 | $post_type = $post->listing_type; |
| 727 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 728 | - $post_id = $_REQUEST['pid']; |
|
| 737 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') { |
|
| 738 | + $post_id = $_REQUEST['pid']; |
|
| 739 | + } |
|
| 729 | 740 | } elseif (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
| 730 | 741 | $post = geodir_get_post_info($_REQUEST['pid']); |
| 731 | 742 | $post_type = $post->post_type; |
@@ -738,25 +749,29 @@ discard block |
||
| 738 | 749 | if ($relate_to == 'category') {
|
| 739 | 750 | |
| 740 | 751 | $category_taxonomy = $post_type . $relate_to; |
| 741 | - if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '') |
|
| 742 | - $category = explode(',', trim($post->$category_taxonomy, ','));
|
|
| 752 | + if (isset($post->$category_taxonomy) && $post->$category_taxonomy != '') { |
|
| 753 | + $category = explode(',', trim($post->$category_taxonomy, ',')); |
|
| 754 | + } |
|
| 743 | 755 | |
| 744 | 756 | } elseif ($relate_to == 'tags') {
|
| 745 | 757 | |
| 746 | 758 | $category_taxonomy = $post_type . '_' . $relate_to; |
| 747 | - if ($post->post_tags != '') |
|
| 748 | - $category = explode(',', trim($post->post_tags, ','));
|
|
| 759 | + if ($post->post_tags != '') { |
|
| 760 | + $category = explode(',', trim($post->post_tags, ',')); |
|
| 761 | + } |
|
| 749 | 762 | $tax_field = 'name'; |
| 750 | 763 | } |
| 751 | 764 | |
| 752 | 765 | /* --- return false in invalid request --- */ |
| 753 | - if (empty($category)) |
|
| 754 | - return false; |
|
| 766 | + if (empty($category)) { |
|
| 767 | + return false; |
|
| 768 | + } |
|
| 755 | 769 | |
| 756 | 770 | $all_postypes = geodir_get_posttypes(); |
| 757 | 771 | |
| 758 | - if (!in_array($post_type, $all_postypes)) |
|
| 759 | - return false; |
|
| 772 | + if (!in_array($post_type, $all_postypes)) { |
|
| 773 | + return false; |
|
| 774 | + } |
|
| 760 | 775 | |
| 761 | 776 | /* --- return false in invalid request --- */ |
| 762 | 777 | |
@@ -914,8 +929,9 @@ discard block |
||
| 914 | 929 | function geodir_get_map_default_language() |
| 915 | 930 | {
|
| 916 | 931 | $geodir_default_map_language = get_option('geodir_default_map_language');
|
| 917 | - if (empty($geodir_default_map_language)) |
|
| 918 | - $geodir_default_map_language = 'en'; |
|
| 932 | + if (empty($geodir_default_map_language)) { |
|
| 933 | + $geodir_default_map_language = 'en'; |
|
| 934 | + } |
|
| 919 | 935 | /** |
| 920 | 936 | * Filter default map language. |
| 921 | 937 | * |
@@ -1093,42 +1109,33 @@ discard block |
||
| 1093 | 1109 | if(geodir_is_page('home')){
|
| 1094 | 1110 | $gd_page = 'home'; |
| 1095 | 1111 | $meta_desc = (get_option('geodir_meta_desc_homepage')) ? get_option('geodir_meta_desc_homepage') : $meta_desc;
|
| 1096 | - } |
|
| 1097 | - elseif(geodir_is_page('detail')){
|
|
| 1112 | + } elseif(geodir_is_page('detail')){
|
|
| 1098 | 1113 | $gd_page = 'detail'; |
| 1099 | 1114 | $meta_desc = (get_option('geodir_meta_desc_detail')) ? get_option('geodir_meta_desc_detail') : $meta_desc;
|
| 1100 | - } |
|
| 1101 | - elseif(geodir_is_page('pt')){
|
|
| 1115 | + } elseif(geodir_is_page('pt')){
|
|
| 1102 | 1116 | $gd_page = 'pt'; |
| 1103 | 1117 | $meta_desc = (get_option('geodir_meta_desc_pt')) ? get_option('geodir_meta_desc_pt') : $meta_desc;
|
| 1104 | - } |
|
| 1105 | - elseif(geodir_is_page('listing')){
|
|
| 1118 | + } elseif(geodir_is_page('listing')){
|
|
| 1106 | 1119 | $gd_page = 'listing'; |
| 1107 | 1120 | $meta_desc = (get_option('geodir_meta_desc_listing')) ? get_option('geodir_meta_desc_listing') : $meta_desc;
|
| 1108 | - } |
|
| 1109 | - elseif(geodir_is_page('location')){
|
|
| 1121 | + } elseif(geodir_is_page('location')){
|
|
| 1110 | 1122 | $gd_page = 'location'; |
| 1111 | 1123 | $meta_desc = (get_option('geodir_meta_desc_location')) ? get_option('geodir_meta_desc_location') : $meta_desc;
|
| 1112 | 1124 | $meta_desc = apply_filters('geodir_seo_meta_location_description', $meta_desc);
|
| 1113 | 1125 | |
| 1114 | - } |
|
| 1115 | - elseif(geodir_is_page('search')){
|
|
| 1126 | + } elseif(geodir_is_page('search')){
|
|
| 1116 | 1127 | $gd_page = 'search'; |
| 1117 | 1128 | $meta_desc = (get_option('geodir_meta_desc_search')) ? get_option('geodir_meta_desc_search') : $meta_desc;
|
| 1118 | - } |
|
| 1119 | - elseif(geodir_is_page('add-listing')){
|
|
| 1129 | + } elseif(geodir_is_page('add-listing')){
|
|
| 1120 | 1130 | $gd_page = 'add-listing'; |
| 1121 | 1131 | $meta_desc = (get_option('geodir_meta_desc_add-listing')) ? get_option('geodir_meta_desc_add-listing') : $meta_desc;
|
| 1122 | - } |
|
| 1123 | - elseif(geodir_is_page('author')){
|
|
| 1132 | + } elseif(geodir_is_page('author')){
|
|
| 1124 | 1133 | $gd_page = 'author'; |
| 1125 | 1134 | $meta_desc = (get_option('geodir_meta_desc_author')) ? get_option('geodir_meta_desc_author') : $meta_desc;
|
| 1126 | - } |
|
| 1127 | - elseif(geodir_is_page('login')){
|
|
| 1135 | + } elseif(geodir_is_page('login')){
|
|
| 1128 | 1136 | $gd_page = 'login'; |
| 1129 | 1137 | $meta_desc = (get_option('geodir_meta_desc_login')) ? get_option('geodir_meta_desc_login') : $meta_desc;
|
| 1130 | - } |
|
| 1131 | - elseif(geodir_is_page('listing-success')){
|
|
| 1138 | + } elseif(geodir_is_page('listing-success')){
|
|
| 1132 | 1139 | $gd_page = 'listing-success'; |
| 1133 | 1140 | $meta_desc = (get_option('geodir_meta_desc_listing-success')) ? get_option('geodir_meta_desc_listing-success') : $meta_desc;
|
| 1134 | 1141 | } |
@@ -1336,8 +1343,9 @@ discard block |
||
| 1336 | 1343 | $tabs_array = geodir_detail_page_tabs_array(); |
| 1337 | 1344 | if (!empty($tabs_excluded)) {
|
| 1338 | 1345 | foreach ($tabs_excluded as $tab) {
|
| 1339 | - if (array_key_exists($tab, $tabs_array)) |
|
| 1340 | - unset($tabs_array[$tab]); |
|
| 1346 | + if (array_key_exists($tab, $tabs_array)) { |
|
| 1347 | + unset($tabs_array[$tab]); |
|
| 1348 | + } |
|
| 1341 | 1349 | } |
| 1342 | 1350 | } |
| 1343 | 1351 | return $tabs_array; |
@@ -1378,8 +1386,9 @@ discard block |
||
| 1378 | 1386 | $video = geodir_get_video($post->ID); |
| 1379 | 1387 | $special_offers = geodir_get_special_offers($post->ID); |
| 1380 | 1388 | $related_listing_array = array(); |
| 1381 | - if (get_option('geodir_add_related_listing_posttypes'))
|
|
| 1382 | - $related_listing_array = get_option('geodir_add_related_listing_posttypes');
|
|
| 1389 | + if (get_option('geodir_add_related_listing_posttypes')) { |
|
| 1390 | + $related_listing_array = get_option('geodir_add_related_listing_posttypes'); |
|
| 1391 | + } |
|
| 1383 | 1392 | |
| 1384 | 1393 | $related_listing = ''; |
| 1385 | 1394 | if (in_array($post->post_type, $related_listing_array)) {
|
@@ -1428,11 +1437,13 @@ discard block |
||
| 1428 | 1437 | $video = isset($post->geodir_video) ? $post->geodir_video : ''; |
| 1429 | 1438 | $special_offers = isset($post->geodir_special_offers) ? $post->geodir_special_offers : ''; |
| 1430 | 1439 | |
| 1431 | - if (isset($post->post_images)) |
|
| 1432 | - $post->post_images = trim($post->post_images, ","); |
|
| 1440 | + if (isset($post->post_images)) { |
|
| 1441 | + $post->post_images = trim($post->post_images, ","); |
|
| 1442 | + } |
|
| 1433 | 1443 | |
| 1434 | - if (isset($post->post_images) && !empty($post->post_images)) |
|
| 1435 | - $post_images = explode(",", $post->post_images);
|
|
| 1444 | + if (isset($post->post_images) && !empty($post->post_images)) { |
|
| 1445 | + $post_images = explode(",", $post->post_images); |
|
| 1446 | + } |
|
| 1436 | 1447 | |
| 1437 | 1448 | $thumb_image = ''; |
| 1438 | 1449 | if (!empty($post_images)) {
|
@@ -325,7 +325,7 @@ discard block |
||
| 325 | 325 | * @global wpdb $wpdb WordPress database abstraction object. |
| 326 | 326 | * @deprecated 1.5.0 No longer required. |
| 327 | 327 | * @param string $rules mod_rewrite Rewrite rules formatted for .htaccess. |
| 328 | - * @return array Rewrite rules. |
|
| 328 | + * @return string Rewrite rules. |
|
| 329 | 329 | */ |
| 330 | 330 | function geodir_htaccess_contents($rules) |
| 331 | 331 | {
|
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | * @since 1.0.0 |
| 351 | 351 | * |
| 352 | 352 | * @param array $public_query_vars The array of query variables. |
| 353 | - * @return array Query variables. |
|
| 353 | + * @return string[] Query variables. |
|
| 354 | 354 | */ |
| 355 | 355 | function geodir_add_location_var($public_query_vars) |
| 356 | 356 | {
|
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | * @since 1.0.0 |
| 367 | 367 | * |
| 368 | 368 | * @param array $public_query_vars The array of query variables. |
| 369 | - * @return array Query variables. |
|
| 369 | + * @return string[] Query variables. |
|
| 370 | 370 | */ |
| 371 | 371 | function geodir_add_geodir_page_var($public_query_vars) |
| 372 | 372 | {
|
@@ -793,7 +793,6 @@ discard block |
||
| 793 | 793 | * |
| 794 | 794 | * @since 1.0.0 |
| 795 | 795 | * |
| 796 | - * @param object $wp The WordPress object. |
|
| 797 | 796 | */ |
| 798 | 797 | function geodir_custom_post_status() |
| 799 | 798 | {
|
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Geodirectory custom post types/taxonomies related functions. |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Geodirectory custom post types/taxonomies related functions. |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | /** |
| 10 | 10 | * Register the texonomies. |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | function geodir_post_type_args_modify($args, $post_type) |
| 102 | 102 | {
|
| 103 | 103 | $geodir_location_prefix = isset($_REQUEST['geodir_location_prefix']) ? trim($_REQUEST['geodir_location_prefix']) : get_option('geodir_location_prefix');
|
| 104 | - if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
|
|
| 104 | + if (isset($_REQUEST['geodir_listing_prefix']) && $_REQUEST['geodir_listing_prefix'] != '' && geodir_strtolower($_REQUEST['geodir_listing_prefix']) != geodir_strtolower($geodir_location_prefix)) {
|
|
| 105 | 105 | |
| 106 | 106 | $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); |
| 107 | 107 | |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | $taxonomies = get_option('geodir_taxonomies');
|
| 199 | 199 | $detail_url_seprator = get_option('geodir_detailurl_separator');
|
| 200 | 200 | |
| 201 | - // create rules for post listing |
|
| 201 | + // create rules for post listing |
|
| 202 | 202 | if (is_array($taxonomies)): |
| 203 | 203 | foreach ($taxonomies as $taxonomy => $args): |
| 204 | 204 | $post_type = $args['object_type']; |
@@ -224,47 +224,47 @@ discard block |
||
| 224 | 224 | if (!isset($location_prefix)) |
| 225 | 225 | $location_prefix = 'location'; |
| 226 | 226 | |
| 227 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 228 | - if ($location_manager) {
|
|
| 229 | - $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 230 | - $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 231 | - } |
|
| 232 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 227 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 228 | + if ($location_manager) {
|
|
| 229 | + $hide_country_part = get_option('geodir_location_hide_country_part');
|
|
| 230 | + $hide_region_part = get_option('geodir_location_hide_region_part');
|
|
| 231 | + } |
|
| 232 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 233 | 233 | |
| 234 | - if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
|
| 235 | - $matches2 = ''; |
|
| 236 | - $matches1 = ''; |
|
| 234 | + if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
|
| 235 | + $matches2 = ''; |
|
| 236 | + $matches1 = ''; |
|
| 237 | 237 | |
| 238 | - if (!$hide_country_part && $hide_region_part) { // country/city
|
|
| 239 | - $matches1 = 'gd_country'; |
|
| 240 | - $matches2 = 'gd_city'; |
|
| 241 | - } else if ($hide_country_part && !$hide_region_part) { // region/city
|
|
| 242 | - $matches1 = 'gd_region'; |
|
| 243 | - $matches2 = 'gd_city'; |
|
| 244 | - } else { // city
|
|
| 245 | - $matches1 = 'gd_city'; |
|
| 246 | - } |
|
| 238 | + if (!$hide_country_part && $hide_region_part) { // country/city
|
|
| 239 | + $matches1 = 'gd_country'; |
|
| 240 | + $matches2 = 'gd_city'; |
|
| 241 | + } else if ($hide_country_part && !$hide_region_part) { // region/city
|
|
| 242 | + $matches1 = 'gd_region'; |
|
| 243 | + $matches2 = 'gd_city'; |
|
| 244 | + } else { // city
|
|
| 245 | + $matches1 = 'gd_city'; |
|
| 246 | + } |
|
| 247 | 247 | |
| 248 | - if ($matches2) {
|
|
| 249 | - if ($neighbourhood_active) {
|
|
| 250 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 251 | - } |
|
| 252 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; |
|
| 253 | - } else {
|
|
| 254 | - if ($neighbourhood_active) {
|
|
| 255 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 256 | - } |
|
| 257 | - } |
|
| 248 | + if ($matches2) {
|
|
| 249 | + if ($neighbourhood_active) {
|
|
| 250 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 251 | + } |
|
| 252 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; |
|
| 253 | + } else {
|
|
| 254 | + if ($neighbourhood_active) {
|
|
| 255 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | 258 | |
| 259 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]'; |
|
| 260 | - } else { // country/region/city
|
|
| 261 | - if ($neighbourhood_active) {
|
|
| 262 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 263 | - } |
|
| 264 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 265 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 266 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]'; |
|
| 267 | - } |
|
| 259 | + $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&' . $matches1 . '=$matches[1]'; |
|
| 260 | + } else { // country/region/city
|
|
| 261 | + if ($neighbourhood_active) {
|
|
| 262 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 263 | + } |
|
| 264 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 265 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 266 | + $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $location_page . '&gd_country=$matches[1]'; |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | 269 | if ($location_page && function_exists('icl_object_id')) {
|
| 270 | 270 | foreach(icl_get_languages('skip_missing=N') as $lang){
|
@@ -273,40 +273,40 @@ discard block |
||
| 273 | 273 | if($alt_page_id){
|
| 274 | 274 | $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
|
| 275 | 275 | |
| 276 | - if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
|
| 277 | - $matches2 = ''; |
|
| 278 | - $matches1 = ''; |
|
| 276 | + if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
|
| 277 | + $matches2 = ''; |
|
| 278 | + $matches1 = ''; |
|
| 279 | 279 | |
| 280 | - if (!$hide_country_part && $hide_region_part) { // country/city
|
|
| 281 | - $matches1 = 'gd_country'; |
|
| 282 | - $matches2 = 'gd_city'; |
|
| 283 | - } else if ($hide_country_part && !$hide_region_part) { // region/city
|
|
| 284 | - $matches1 = 'gd_region'; |
|
| 285 | - $matches2 = 'gd_city'; |
|
| 286 | - } else { // city
|
|
| 287 | - $matches1 = 'gd_city'; |
|
| 288 | - } |
|
| 280 | + if (!$hide_country_part && $hide_region_part) { // country/city
|
|
| 281 | + $matches1 = 'gd_country'; |
|
| 282 | + $matches2 = 'gd_city'; |
|
| 283 | + } else if ($hide_country_part && !$hide_region_part) { // region/city
|
|
| 284 | + $matches1 = 'gd_region'; |
|
| 285 | + $matches2 = 'gd_city'; |
|
| 286 | + } else { // city
|
|
| 287 | + $matches1 = 'gd_city'; |
|
| 288 | + } |
|
| 289 | 289 | |
| 290 | - if ($matches2) {
|
|
| 291 | - if ($neighbourhood_active) {
|
|
| 292 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 293 | - } |
|
| 294 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; |
|
| 295 | - } else {
|
|
| 296 | - if ($neighbourhood_active) {
|
|
| 297 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 298 | - } |
|
| 299 | - } |
|
| 290 | + if ($matches2) {
|
|
| 291 | + if ($neighbourhood_active) {
|
|
| 292 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]&gd_neighbourhood=$matches[3]'; |
|
| 293 | + } |
|
| 294 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&' . $matches2 . '=$matches[2]'; |
|
| 295 | + } else {
|
|
| 296 | + if ($neighbourhood_active) {
|
|
| 297 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]&gd_neighbourhood=$matches[2]'; |
|
| 298 | + } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]'; |
|
| 302 | - } else { // country/region/city
|
|
| 303 | - if ($neighbourhood_active) {
|
|
| 304 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 305 | - } |
|
| 306 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 307 | - $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 308 | - $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]'; |
|
| 309 | - } |
|
| 301 | + $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&' . $matches1 . '=$matches[1]'; |
|
| 302 | + } else { // country/region/city
|
|
| 303 | + if ($neighbourhood_active) {
|
|
| 304 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]&gd_neighbourhood=$matches[4]'; |
|
| 305 | + } |
|
| 306 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]&gd_city=$matches[3]'; |
|
| 307 | + $newrules[$location_prefix . '/([^/]+)/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]&gd_region=$matches[2]'; |
|
| 308 | + $newrules[$location_prefix . '/([^/]+)/?$'] = 'index.php?page_id=' . $alt_page_id . '&gd_country=$matches[1]'; |
|
| 309 | + } |
|
| 310 | 310 | } |
| 311 | 311 | } |
| 312 | 312 | } |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | * @param object $wp The WordPress object. |
| 410 | 410 | */ |
| 411 | 411 | function geodir_set_location_var_in_session_in_core($wp) {
|
| 412 | - global $gd_session; |
|
| 412 | + global $gd_session; |
|
| 413 | 413 | |
| 414 | 414 | // Fix for WPML removing page_id query var: |
| 415 | 415 | if (isset($wp->query_vars['page']) && !isset($wp->query_vars['page_id']) && isset($wp->query_vars['pagename']) && !is_home()) {
|
@@ -426,16 +426,16 @@ discard block |
||
| 426 | 426 | } |
| 427 | 427 | } |
| 428 | 428 | |
| 429 | - // Query Vars will have page_id parameter |
|
| 430 | - // check if query var has page_id and that page id is location page |
|
| 429 | + // Query Vars will have page_id parameter |
|
| 430 | + // check if query var has page_id and that page id is location page |
|
| 431 | 431 | geodir_set_is_geodir_page($wp); |
| 432 | - // if is GD homepage set the page ID |
|
| 433 | - if (geodir_is_page('home')) {
|
|
| 434 | - $wp->query_vars['page_id'] = get_option('page_on_front');
|
|
| 435 | - } |
|
| 432 | + // if is GD homepage set the page ID |
|
| 433 | + if (geodir_is_page('home')) {
|
|
| 434 | + $wp->query_vars['page_id'] = get_option('page_on_front');
|
|
| 435 | + } |
|
| 436 | 436 | |
| 437 | - // The location url format (all or country_city or region_city or city). |
|
| 438 | - $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 437 | + // The location url format (all or country_city or region_city or city). |
|
| 438 | + $geodir_show_location_url = get_option('geodir_show_location_url');
|
|
| 439 | 439 | |
| 440 | 440 | if (isset($wp->query_vars['page_id']) && $wp->query_vars['page_id'] == geodir_location_page_id()) {
|
| 441 | 441 | $gd_country = ''; |
@@ -494,7 +494,7 @@ discard block |
||
| 494 | 494 | $gd_session->set('gd_region', $gd_region);
|
| 495 | 495 | $gd_session->set('gd_city', $gd_city);
|
| 496 | 496 | |
| 497 | - $wp->query_vars['gd_country'] = $gd_country; |
|
| 497 | + $wp->query_vars['gd_country'] = $gd_country; |
|
| 498 | 498 | $wp->query_vars['gd_region'] = $gd_region; |
| 499 | 499 | $wp->query_vars['gd_city'] = $gd_city; |
| 500 | 500 | } else {
|
@@ -510,7 +510,7 @@ discard block |
||
| 510 | 510 | // check if this post type is geodirectory post types |
| 511 | 511 | $post_type_array = geodir_get_posttypes(); |
| 512 | 512 | |
| 513 | - if (in_array($requested_post_type, $post_type_array)) {
|
|
| 513 | + if (in_array($requested_post_type, $post_type_array)) {
|
|
| 514 | 514 | // now u can apply geodirectory related manipulation. |
| 515 | 515 | } |
| 516 | 516 | } |
@@ -520,17 +520,17 @@ discard block |
||
| 520 | 520 | $gd_region = ''; |
| 521 | 521 | $gd_city = ''; |
| 522 | 522 | |
| 523 | - $is_geodir_taxonomy = false; |
|
| 523 | + $is_geodir_taxonomy = false; |
|
| 524 | 524 | $is_geodir_taxonomy_term = false; // the last term is real geodirectory taxonomy term or not |
| 525 | 525 | $is_geodir_location_found = false; |
| 526 | 526 | |
| 527 | - $geodir_taxonomy = ''; |
|
| 527 | + $geodir_taxonomy = ''; |
|
| 528 | 528 | $geodir_post_type = ''; |
| 529 | 529 | $geodir_term = ''; |
| 530 | 530 | $geodir_set_location_session = true; |
| 531 | 531 | $geodir_taxonomis = geodir_get_taxonomies('', true);
|
| 532 | 532 | |
| 533 | - foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 533 | + foreach ($geodir_taxonomis as $taxonomy) {
|
|
| 534 | 534 | if (array_key_exists($taxonomy, $wp->query_vars)) {
|
| 535 | 535 | $is_geodir_taxonomy = true; |
| 536 | 536 | $geodir_taxonomy = $taxonomy; |
@@ -547,52 +547,52 @@ discard block |
||
| 547 | 547 | if ($is_geodir_taxonomy) { // do all these only when it is a geodirectory taxonomy
|
| 548 | 548 | $wp->query_vars['post_type'] = $geodir_post_type; |
| 549 | 549 | |
| 550 | - // now check if last term is a post of geodirectory post types |
|
| 551 | - $geodir_post = get_posts(array( |
|
| 552 | - 'name' => $geodir_last_term, |
|
| 553 | - 'posts_per_page' => 1, |
|
| 554 | - 'post_type' => $geodir_post_type, |
|
| 550 | + // now check if last term is a post of geodirectory post types |
|
| 551 | + $geodir_post = get_posts(array( |
|
| 552 | + 'name' => $geodir_last_term, |
|
| 553 | + 'posts_per_page' => 1, |
|
| 554 | + 'post_type' => $geodir_post_type, |
|
| 555 | 555 | |
| 556 | 556 | |
| 557 | - )); |
|
| 557 | + )); |
|
| 558 | 558 | |
| 559 | - if (empty($geodir_post)) {
|
|
| 560 | - $geodir_post = get_posts(array( |
|
| 561 | - 'name' => $geodir_last_term, |
|
| 562 | - 'posts_per_page' => 1, |
|
| 563 | - 'post_type' => $geodir_post_type, |
|
| 564 | - 'post_status' => 'draft', |
|
| 565 | - 'suppress_filters' => false, |
|
| 559 | + if (empty($geodir_post)) {
|
|
| 560 | + $geodir_post = get_posts(array( |
|
| 561 | + 'name' => $geodir_last_term, |
|
| 562 | + 'posts_per_page' => 1, |
|
| 563 | + 'post_type' => $geodir_post_type, |
|
| 564 | + 'post_status' => 'draft', |
|
| 565 | + 'suppress_filters' => false, |
|
| 566 | 566 | |
| 567 | - )); |
|
| 568 | - } |
|
| 567 | + )); |
|
| 568 | + } |
|
| 569 | 569 | |
| 570 | - if (!empty($geodir_post)) {
|
|
| 570 | + if (!empty($geodir_post)) {
|
|
| 571 | 571 | |
| 572 | - if ($geodir_post[0]->post_status != 'publish') {
|
|
| 573 | - foreach ($wp->query_vars as $key => $vars) {
|
|
| 574 | - unset($wp->query_vars[$key]); |
|
| 575 | - } |
|
| 576 | - $wp->query_vars['error'] = '404'; |
|
| 577 | - // set it as 404 if post exists but its status is not published yet |
|
| 572 | + if ($geodir_post[0]->post_status != 'publish') {
|
|
| 573 | + foreach ($wp->query_vars as $key => $vars) {
|
|
| 574 | + unset($wp->query_vars[$key]); |
|
| 575 | + } |
|
| 576 | + $wp->query_vars['error'] = '404'; |
|
| 577 | + // set it as 404 if post exists but its status is not published yet |
|
| 578 | 578 | |
| 579 | - } else {
|
|
| 580 | - //$wp->query_vars[$geodir_taxonomy] = str_replace( '/'.$geodir_last_term , '' , $geodir_term); |
|
| 581 | - $wp->query_vars[$geodir_post_type] = $geodir_last_term; |
|
| 582 | - $wp->query_vars['name'] = $geodir_last_term; |
|
| 579 | + } else {
|
|
| 580 | + //$wp->query_vars[$geodir_taxonomy] = str_replace( '/'.$geodir_last_term , '' , $geodir_term); |
|
| 581 | + $wp->query_vars[$geodir_post_type] = $geodir_last_term; |
|
| 582 | + $wp->query_vars['name'] = $geodir_last_term; |
|
| 583 | 583 | |
| 584 | - } |
|
| 584 | + } |
|
| 585 | 585 | |
| 586 | 586 | |
| 587 | - $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
|
|
| 588 | - if (!$post_title_replace_count) |
|
| 589 | - $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); |
|
| 590 | - $geodir_terms = explode('/', $geodir_term);
|
|
| 591 | - $geodir_last_term = end($geodir_terms); |
|
| 587 | + $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
|
|
| 588 | + if (!$post_title_replace_count) |
|
| 589 | + $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); |
|
| 590 | + $geodir_terms = explode('/', $geodir_term);
|
|
| 591 | + $geodir_last_term = end($geodir_terms); |
|
| 592 | 592 | |
| 593 | - $geodir_set_location_session = false; |
|
| 594 | - //return ; |
|
| 595 | - } |
|
| 593 | + $geodir_set_location_session = false; |
|
| 594 | + //return ; |
|
| 595 | + } |
|
| 596 | 596 | |
| 597 | 597 | $geodir_location_terms = ''; |
| 598 | 598 | // if last term is not a post then check if last term is a term of the specific texonomy or not |
@@ -605,9 +605,9 @@ discard block |
||
| 605 | 605 | |
| 606 | 606 | // now check if there is location parts in the url or not |
| 607 | 607 | if (get_option('geodir_add_location_url')) {
|
| 608 | - $default_location = geodir_get_default_location(); |
|
| 608 | + $default_location = geodir_get_default_location(); |
|
| 609 | 609 | |
| 610 | - if ($geodir_show_location_url == 'all') {
|
|
| 610 | + if ($geodir_show_location_url == 'all') {
|
|
| 611 | 611 | if (count($geodir_terms) >= 3) {
|
| 612 | 612 | $gd_country = urldecode($geodir_terms[0]); |
| 613 | 613 | $gd_region = urldecode($geodir_terms[1]); |
@@ -658,7 +658,7 @@ discard block |
||
| 658 | 658 | if (!$is_geodir_location_found) {
|
| 659 | 659 | $gd_city = ''; |
| 660 | 660 | |
| 661 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 661 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 662 | 662 | $is_geodir_location_found = true; |
| 663 | 663 | } |
| 664 | 664 | } else if ($geodir_show_location_url == 'region_city') {
|
@@ -676,7 +676,7 @@ discard block |
||
| 676 | 676 | if (!$is_geodir_location_found) {
|
| 677 | 677 | $gd_city = ''; |
| 678 | 678 | |
| 679 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) |
|
| 679 | + if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) |
|
| 680 | 680 | $is_geodir_location_found = true; |
| 681 | 681 | } |
| 682 | 682 | } else {
|
@@ -697,14 +697,14 @@ discard block |
||
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | if ($geodir_show_location_url == 'all') {
|
| 700 | - } else if ($geodir_show_location_url == 'country_city') {
|
|
| 701 | - $gd_region = ''; |
|
| 702 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 703 | - $gd_country = ''; |
|
| 704 | - } else {
|
|
| 705 | - $gd_country = ''; |
|
| 700 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 701 | + $gd_region = ''; |
|
| 702 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 703 | + $gd_country = ''; |
|
| 704 | + } else {
|
|
| 705 | + $gd_country = ''; |
|
| 706 | 706 | $gd_region = ''; |
| 707 | - } |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | 709 | if ($is_geodir_location_found) {
|
| 710 | 710 | $wp->query_vars['gd_country'] = $gd_country; |
@@ -747,10 +747,10 @@ discard block |
||
| 747 | 747 | } |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | - // Unset location session if gd page and location not set. |
|
| 751 | - if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
|
|
| 752 | - $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 753 | - } |
|
| 750 | + // Unset location session if gd page and location not set. |
|
| 751 | + if (isset($wp->query_vars['gd_is_geodir_page']) && !isset($wp->query_vars['gd_country'])) {
|
|
| 752 | + $gd_session->un_set(array('gd_multi_location', 'gd_city', 'gd_region', 'gd_country'));
|
|
| 753 | + } |
|
| 754 | 754 | |
| 755 | 755 | if ($gd_session->get('gd_multi_location') == 1) {
|
| 756 | 756 | $wp->query_vars['gd_country'] = $gd_session->get('gd_country');
|
@@ -760,20 +760,20 @@ discard block |
||
| 760 | 760 | |
| 761 | 761 | // now check if there is location parts in the url or not |
| 762 | 762 | if (get_option('geodir_add_location_url')) {
|
| 763 | - if ($geodir_show_location_url == 'all') {
|
|
| 764 | - } else if ($geodir_show_location_url == 'country_city') {
|
|
| 765 | - if (isset($wp->query_vars['gd_region'])) |
|
| 763 | + if ($geodir_show_location_url == 'all') {
|
|
| 764 | + } else if ($geodir_show_location_url == 'country_city') {
|
|
| 765 | + if (isset($wp->query_vars['gd_region'])) |
|
| 766 | 766 | $wp->query_vars['gd_region'] = ''; |
| 767 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 768 | - if (isset($wp->query_vars['gd_country'])) |
|
| 767 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 768 | + if (isset($wp->query_vars['gd_country'])) |
|
| 769 | 769 | $wp->query_vars['gd_country'] = ''; |
| 770 | - } else {
|
|
| 771 | - if (isset($wp->query_vars['gd_country'])) |
|
| 770 | + } else {
|
|
| 771 | + if (isset($wp->query_vars['gd_country'])) |
|
| 772 | 772 | $wp->query_vars['gd_country'] = ''; |
| 773 | 773 | |
| 774 | 774 | if (isset($wp->query_vars['gd_region'])) |
| 775 | 775 | $wp->query_vars['gd_region'] = ''; |
| 776 | - } |
|
| 776 | + } |
|
| 777 | 777 | } else {
|
| 778 | 778 | if (isset($wp->query_vars['gd_country'])) |
| 779 | 779 | $wp->query_vars['gd_country'] = ''; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | |
| 71 | 71 | if (!empty($args['labels'])) {
|
| 72 | 72 | foreach ($args['labels'] as $key => $val) {
|
| 73 | - $args['labels'][$key] = __($val, 'geodirectory');// allow translation |
|
| 73 | + $args['labels'][$key] = __($val, 'geodirectory'); // allow translation |
|
| 74 | 74 | } |
| 75 | 75 | } |
| 76 | 76 | |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | |
| 112 | 112 | if (array_key_exists('rewrite', $args)) {
|
| 113 | 113 | if (array_key_exists('slug', $args['rewrite']))
|
| 114 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 114 | + $args['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%'; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | $geodir_post_types = get_option('geodir_post_types');
|
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
|
| 125 | 125 | if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
| 126 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 126 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; // . '/%gd_taxonomy%'; |
|
| 127 | 127 | |
| 128 | 128 | update_option('geodir_post_types', $geodir_post_types);
|
| 129 | 129 | |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | $newrules[$listing_slug . '/(.+?)/?$'] = 'index.php?' . $taxonomy . '=$matches[1]'; |
| 210 | 210 | } else {
|
| 211 | 211 | // use this loop to add paging for details page comments paging |
| 212 | - $newrules[str_replace("/tags","",$listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
|
|
| 212 | + $newrules[str_replace("/tags", "", $listing_slug) . '/(.+?)/comment-page-([0-9]{1,})/?$'] = 'index.php?' . $taxonomy . '=$matches[1]&cpage=$matches[2]';
|
|
| 213 | 213 | } |
| 214 | 214 | endforeach; |
| 215 | 215 | endif; |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | // create rules for location listing |
| 218 | 218 | $location_page = get_option('geodir_location_page');
|
| 219 | 219 | |
| 220 | - if($location_page) {
|
|
| 220 | + if ($location_page) {
|
|
| 221 | 221 | global $wpdb; |
| 222 | 222 | $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
|
| 223 | 223 | } |
@@ -267,10 +267,10 @@ discard block |
||
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | if ($location_page && function_exists('icl_object_id')) {
|
| 270 | - foreach(icl_get_languages('skip_missing=N') as $lang){
|
|
| 270 | + foreach (icl_get_languages('skip_missing=N') as $lang) {
|
|
| 271 | 271 | $alt_page_id = ''; |
| 272 | - $alt_page_id = icl_object_id($location_page, 'page', false,$lang['language_code']); |
|
| 273 | - if($alt_page_id){
|
|
| 272 | + $alt_page_id = icl_object_id($location_page, 'page', false, $lang['language_code']); |
|
| 273 | + if ($alt_page_id) {
|
|
| 274 | 274 | $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $alt_page_id));
|
| 275 | 275 | |
| 276 | 276 | if ($location_manager && ($hide_country_part || $hide_region_part)) {
|
@@ -416,12 +416,12 @@ discard block |
||
| 416 | 416 | global $wpdb; |
| 417 | 417 | |
| 418 | 418 | $page_for_posts = get_option('page_for_posts');
|
| 419 | - $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s",$wp->query_vars['pagename']));
|
|
| 419 | + $real_page_id = $wpdb->get_var($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_name=%s", $wp->query_vars['pagename']));
|
|
| 420 | 420 | |
| 421 | 421 | if (function_exists('icl_object_id')) {
|
| 422 | 422 | $real_page_id = icl_object_id($real_page_id, 'page', true, ICL_LANGUAGE_CODE); |
| 423 | 423 | } |
| 424 | - if ($real_page_id && $real_page_id!=$page_for_posts) {
|
|
| 424 | + if ($real_page_id && $real_page_id != $page_for_posts) {
|
|
| 425 | 425 | $wp->query_vars['page_id'] = $real_page_id; |
| 426 | 426 | } |
| 427 | 427 | } |
@@ -661,7 +661,7 @@ discard block |
||
| 661 | 661 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
| 662 | 662 | $is_geodir_location_found = true; |
| 663 | 663 | } |
| 664 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 664 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 665 | 665 | if (count($geodir_terms) >= 2) {
|
| 666 | 666 | $gd_region = urldecode($geodir_terms[0]); |
| 667 | 667 | $gd_city = urldecode($geodir_terms[1]); |
@@ -106,24 +106,30 @@ discard block |
||
| 106 | 106 | $listing_slug = htmlentities(trim($_REQUEST['geodir_listing_prefix'])); |
| 107 | 107 | |
| 108 | 108 | if ($post_type == 'gd_place') {
|
| 109 | - if (array_key_exists('has_archive', $args))
|
|
| 110 | - $args['has_archive'] = $listing_slug; |
|
| 109 | + if (array_key_exists('has_archive', $args)) { |
|
| 110 | + $args['has_archive'] = $listing_slug; |
|
| 111 | + } |
|
| 111 | 112 | |
| 112 | 113 | if (array_key_exists('rewrite', $args)) {
|
| 113 | - if (array_key_exists('slug', $args['rewrite']))
|
|
| 114 | - $args['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 114 | + if (array_key_exists('slug', $args['rewrite'])) { |
|
| 115 | + $args['rewrite']['slug'] = $listing_slug; |
|
| 116 | + } |
|
| 117 | + // . '/%gd_taxonomy%'; |
|
| 115 | 118 | } |
| 116 | 119 | |
| 117 | 120 | $geodir_post_types = get_option('geodir_post_types');
|
| 118 | 121 | |
| 119 | 122 | if (array_key_exists($post_type, $geodir_post_types)) {
|
| 120 | 123 | |
| 121 | - if (array_key_exists('has_archive', $geodir_post_types[$post_type]))
|
|
| 122 | - $geodir_post_types[$post_type]['has_archive'] = $listing_slug; |
|
| 124 | + if (array_key_exists('has_archive', $geodir_post_types[$post_type])) { |
|
| 125 | + $geodir_post_types[$post_type]['has_archive'] = $listing_slug; |
|
| 126 | + } |
|
| 123 | 127 | |
| 124 | - if (array_key_exists('rewrite', $geodir_post_types[$post_type]))
|
|
| 125 | - if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
|
| 126 | - $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug;// . '/%gd_taxonomy%'; |
|
| 128 | + if (array_key_exists('rewrite', $geodir_post_types[$post_type])) { |
|
| 129 | + if (array_key_exists('slug', $geodir_post_types[$post_type]['rewrite']))
|
|
| 130 | + $geodir_post_types[$post_type]['rewrite']['slug'] = $listing_slug; |
|
| 131 | + } |
|
| 132 | + // . '/%gd_taxonomy%'; |
|
| 127 | 133 | |
| 128 | 134 | update_option('geodir_post_types', $geodir_post_types);
|
| 129 | 135 | |
@@ -138,10 +144,11 @@ discard block |
||
| 138 | 144 | if (array_key_exists('listing_slug', $geodir_taxonomies[$post_type . 'category'])) {
|
| 139 | 145 | $geodir_taxonomies[$post_type . 'category']['listing_slug'] = $listing_slug; |
| 140 | 146 | |
| 141 | - if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category']))
|
|
| 142 | - if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
|
|
| 147 | + if (array_key_exists('args', $geodir_taxonomies[$post_type . 'category'])) { |
|
| 148 | + if (array_key_exists('rewrite', $geodir_taxonomies[$post_type . 'category']['args']))
|
|
| 143 | 149 | if (array_key_exists('slug', $geodir_taxonomies[$post_type . 'category']['args']['rewrite']))
|
| 144 | - $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 150 | + $geodir_taxonomies[$post_type . 'category']['args']['rewrite']['slug'] = $listing_slug; |
|
| 151 | + } |
|
| 145 | 152 | |
| 146 | 153 | update_option('geodir_taxonomies', $geodir_taxonomies);
|
| 147 | 154 | |
@@ -152,10 +159,11 @@ discard block |
||
| 152 | 159 | if (array_key_exists('listing_slug', $geodir_taxonomies_tag[$post_type . '_tags'])) {
|
| 153 | 160 | $geodir_taxonomies_tag[$post_type . '_tags']['listing_slug'] = $listing_slug . '/tags'; |
| 154 | 161 | |
| 155 | - if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags']))
|
|
| 156 | - if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
|
|
| 162 | + if (array_key_exists('args', $geodir_taxonomies_tag[$post_type . '_tags'])) { |
|
| 163 | + if (array_key_exists('rewrite', $geodir_taxonomies_tag[$post_type . '_tags']['args']))
|
|
| 157 | 164 | if (array_key_exists('slug', $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']))
|
| 158 | - $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; |
|
| 165 | + $geodir_taxonomies_tag[$post_type . '_tags']['args']['rewrite']['slug'] = $listing_slug . '/tags'; |
|
| 166 | + } |
|
| 159 | 167 | |
| 160 | 168 | update_option('geodir_taxonomies', $geodir_taxonomies_tag);
|
| 161 | 169 | |
@@ -221,8 +229,9 @@ discard block |
||
| 221 | 229 | global $wpdb; |
| 222 | 230 | $location_prefix = $wpdb->get_var($wpdb->prepare("SELECT post_name FROM $wpdb->posts WHERE post_type='page' AND ID=%d", $location_page));
|
| 223 | 231 | } |
| 224 | - if (!isset($location_prefix)) |
|
| 225 | - $location_prefix = 'location'; |
|
| 232 | + if (!isset($location_prefix)) { |
|
| 233 | + $location_prefix = 'location'; |
|
| 234 | + } |
|
| 226 | 235 | |
| 227 | 236 | $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
| 228 | 237 | if ($location_manager) {
|
@@ -441,14 +450,17 @@ discard block |
||
| 441 | 450 | $gd_country = ''; |
| 442 | 451 | $gd_region = ''; |
| 443 | 452 | $gd_city = ''; |
| 444 | - if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') |
|
| 445 | - $gd_country = urldecode($wp->query_vars['gd_country']); |
|
| 453 | + if (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') { |
|
| 454 | + $gd_country = urldecode($wp->query_vars['gd_country']); |
|
| 455 | + } |
|
| 446 | 456 | |
| 447 | - if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') |
|
| 448 | - $gd_region = urldecode($wp->query_vars['gd_region']); |
|
| 457 | + if (isset($wp->query_vars['gd_region']) && $wp->query_vars['gd_region'] != '') { |
|
| 458 | + $gd_region = urldecode($wp->query_vars['gd_region']); |
|
| 459 | + } |
|
| 449 | 460 | |
| 450 | - if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') |
|
| 451 | - $gd_city = urldecode($wp->query_vars['gd_city']); |
|
| 461 | + if (isset($wp->query_vars['gd_city']) && $wp->query_vars['gd_city'] != '') { |
|
| 462 | + $gd_city = urldecode($wp->query_vars['gd_city']); |
|
| 463 | + } |
|
| 452 | 464 | |
| 453 | 465 | if (!($gd_country == '' && $gd_region == '' && $gd_city == '')) {
|
| 454 | 466 | $default_location = geodir_get_default_location(); |
@@ -456,17 +468,19 @@ discard block |
||
| 456 | 468 | if (get_option('geodir_add_location_url')) {
|
| 457 | 469 | if ($geodir_show_location_url != 'all') {
|
| 458 | 470 | if ($gd_region == '') {
|
| 459 | - if ($gd_ses_region = $gd_session->get('gd_region'))
|
|
| 460 | - $gd_region = $gd_ses_region; |
|
| 461 | - else |
|
| 462 | - $gd_region = $default_location->region_slug; |
|
| 471 | + if ($gd_ses_region = $gd_session->get('gd_region')) { |
|
| 472 | + $gd_region = $gd_ses_region; |
|
| 473 | + } else { |
|
| 474 | + $gd_region = $default_location->region_slug; |
|
| 475 | + } |
|
| 463 | 476 | } |
| 464 | 477 | |
| 465 | 478 | if ($gd_city == '') {
|
| 466 | - if ($gd_ses_city = $gd_session->get('gd_city'))
|
|
| 467 | - $gd_city = $gd_ses_city; |
|
| 468 | - else |
|
| 469 | - $gd_city = $default_location->city_slug; |
|
| 479 | + if ($gd_ses_city = $gd_session->get('gd_city')) { |
|
| 480 | + $gd_city = $gd_ses_city; |
|
| 481 | + } else { |
|
| 482 | + $gd_city = $default_location->city_slug; |
|
| 483 | + } |
|
| 470 | 484 | |
| 471 | 485 | $base_location_link = geodir_get_location_link('base');
|
| 472 | 486 | wp_redirect($base_location_link . '/' . $gd_country . '/' . $gd_region . '/' . $gd_city); |
@@ -585,8 +599,9 @@ discard block |
||
| 585 | 599 | |
| 586 | 600 | |
| 587 | 601 | $geodir_term = str_replace('/' . $geodir_last_term, '', $geodir_term, $post_title_replace_count);
|
| 588 | - if (!$post_title_replace_count) |
|
| 589 | - $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); |
|
| 602 | + if (!$post_title_replace_count) { |
|
| 603 | + $geodir_term = str_replace($geodir_last_term, '', $geodir_term, $post_title_replace_count); |
|
| 604 | + } |
|
| 590 | 605 | $geodir_terms = explode('/', $geodir_term);
|
| 591 | 606 | $geodir_last_term = end($geodir_terms); |
| 592 | 607 | |
@@ -622,8 +637,9 @@ discard block |
||
| 622 | 637 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
| 623 | 638 | geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && |
| 624 | 639 | geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city) |
| 625 | - ) |
|
| 626 | - $is_geodir_location_found = true; |
|
| 640 | + ) { |
|
| 641 | + $is_geodir_location_found = true; |
|
| 642 | + } |
|
| 627 | 643 | |
| 628 | 644 | // if location has not been found for country , region and city then search for country and region only |
| 629 | 645 | |
@@ -631,8 +647,9 @@ discard block |
||
| 631 | 647 | $gd_city = ''; |
| 632 | 648 | if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && |
| 633 | 649 | geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) |
| 634 | - ) |
|
| 635 | - $is_geodir_location_found = true; |
|
| 650 | + ) { |
|
| 651 | + $is_geodir_location_found = true; |
|
| 652 | + } |
|
| 636 | 653 | |
| 637 | 654 | } |
| 638 | 655 | |
@@ -640,8 +657,9 @@ discard block |
||
| 640 | 657 | if (!$is_geodir_location_found) {
|
| 641 | 658 | $gd_city = ''; |
| 642 | 659 | $gd_region = ''; |
| 643 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 644 | - $is_geodir_location_found = true; |
|
| 660 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) { |
|
| 661 | + $is_geodir_location_found = true; |
|
| 662 | + } |
|
| 645 | 663 | } |
| 646 | 664 | } else if ($geodir_show_location_url == 'country_city') {
|
| 647 | 665 | if (count($geodir_terms) >= 2) {
|
@@ -651,17 +669,19 @@ discard block |
||
| 651 | 669 | $gd_country = urldecode($geodir_terms[0]); |
| 652 | 670 | } |
| 653 | 671 | |
| 654 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 655 | - $is_geodir_location_found = true; |
|
| 672 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { |
|
| 673 | + $is_geodir_location_found = true; |
|
| 674 | + } |
|
| 656 | 675 | |
| 657 | 676 | // if location has not been found for country and city then search for country only |
| 658 | 677 | if (!$is_geodir_location_found) {
|
| 659 | 678 | $gd_city = ''; |
| 660 | 679 | |
| 661 | - if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) |
|
| 662 | - $is_geodir_location_found = true; |
|
| 680 | + if (geodir_strtolower($default_location->country_slug) == geodir_strtolower($gd_country)) { |
|
| 681 | + $is_geodir_location_found = true; |
|
| 682 | + } |
|
| 663 | 683 | } |
| 664 | - } else if ($geodir_show_location_url == 'region_city') {
|
|
| 684 | + } else if ($geodir_show_location_url == 'region_city') {
|
|
| 665 | 685 | if (count($geodir_terms) >= 2) {
|
| 666 | 686 | $gd_region = urldecode($geodir_terms[0]); |
| 667 | 687 | $gd_city = urldecode($geodir_terms[1]); |
@@ -669,15 +689,17 @@ discard block |
||
| 669 | 689 | $gd_region = urldecode($geodir_terms[0]); |
| 670 | 690 | } |
| 671 | 691 | |
| 672 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) |
|
| 673 | - $is_geodir_location_found = true; |
|
| 692 | + if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region) && geodir_strtolower($default_location->city_slug) == geodir_strtolower($gd_city)) { |
|
| 693 | + $is_geodir_location_found = true; |
|
| 694 | + } |
|
| 674 | 695 | |
| 675 | 696 | // if location has not been found for region and city then search for region only |
| 676 | 697 | if (!$is_geodir_location_found) {
|
| 677 | 698 | $gd_city = ''; |
| 678 | 699 | |
| 679 | - if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) |
|
| 680 | - $is_geodir_location_found = true; |
|
| 700 | + if (geodir_strtolower($default_location->region_slug) == geodir_strtolower($gd_region)) { |
|
| 701 | + $is_geodir_location_found = true; |
|
| 702 | + } |
|
| 681 | 703 | } |
| 682 | 704 | } else {
|
| 683 | 705 | $gd_city = $geodir_terms[0]; |
@@ -719,14 +741,17 @@ discard block |
||
| 719 | 741 | |
| 720 | 742 | $wp->query_vars[$geodir_taxonomy] = $geodir_term; |
| 721 | 743 | // eliminate location related terms from taxonomy term |
| 722 | - if ($gd_country != '') |
|
| 723 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 744 | + if ($gd_country != '') { |
|
| 745 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_country) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); |
|
| 746 | + } |
|
| 724 | 747 | |
| 725 | - if ($gd_region != '') |
|
| 726 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 748 | + if ($gd_region != '') { |
|
| 749 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_region) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); |
|
| 750 | + } |
|
| 727 | 751 | |
| 728 | - if ($gd_city != '') |
|
| 729 | - $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1);
|
|
| 752 | + if ($gd_city != '') { |
|
| 753 | + $wp->query_vars[$geodir_taxonomy] = preg_replace('/' . urlencode($gd_city) . '/', '', $wp->query_vars[$geodir_taxonomy], 1); |
|
| 754 | + } |
|
| 730 | 755 | |
| 731 | 756 | |
| 732 | 757 | $wp->query_vars[$geodir_taxonomy] = str_replace('///', '', $wp->query_vars[$geodir_taxonomy]);
|
@@ -762,27 +787,34 @@ discard block |
||
| 762 | 787 | if (get_option('geodir_add_location_url')) {
|
| 763 | 788 | if ($geodir_show_location_url == 'all') {
|
| 764 | 789 | } else if ($geodir_show_location_url == 'country_city') {
|
| 765 | - if (isset($wp->query_vars['gd_region'])) |
|
| 766 | - $wp->query_vars['gd_region'] = ''; |
|
| 790 | + if (isset($wp->query_vars['gd_region'])) { |
|
| 791 | + $wp->query_vars['gd_region'] = ''; |
|
| 792 | + } |
|
| 767 | 793 | } else if ($geodir_show_location_url == 'region_city') {
|
| 768 | - if (isset($wp->query_vars['gd_country'])) |
|
| 769 | - $wp->query_vars['gd_country'] = ''; |
|
| 794 | + if (isset($wp->query_vars['gd_country'])) { |
|
| 795 | + $wp->query_vars['gd_country'] = ''; |
|
| 796 | + } |
|
| 770 | 797 | } else {
|
| 771 | - if (isset($wp->query_vars['gd_country'])) |
|
| 772 | - $wp->query_vars['gd_country'] = ''; |
|
| 798 | + if (isset($wp->query_vars['gd_country'])) { |
|
| 799 | + $wp->query_vars['gd_country'] = ''; |
|
| 800 | + } |
|
| 773 | 801 | |
| 774 | - if (isset($wp->query_vars['gd_region'])) |
|
| 775 | - $wp->query_vars['gd_region'] = ''; |
|
| 802 | + if (isset($wp->query_vars['gd_region'])) { |
|
| 803 | + $wp->query_vars['gd_region'] = ''; |
|
| 804 | + } |
|
| 776 | 805 | } |
| 777 | 806 | } else {
|
| 778 | - if (isset($wp->query_vars['gd_country'])) |
|
| 779 | - $wp->query_vars['gd_country'] = ''; |
|
| 807 | + if (isset($wp->query_vars['gd_country'])) { |
|
| 808 | + $wp->query_vars['gd_country'] = ''; |
|
| 809 | + } |
|
| 780 | 810 | |
| 781 | - if (isset($wp->query_vars['gd_region'])) |
|
| 782 | - $wp->query_vars['gd_region'] = ''; |
|
| 811 | + if (isset($wp->query_vars['gd_region'])) { |
|
| 812 | + $wp->query_vars['gd_region'] = ''; |
|
| 813 | + } |
|
| 783 | 814 | |
| 784 | - if (isset($wp->query_vars['gd_city'])) |
|
| 785 | - $wp->query_vars['gd_city'] = ''; |
|
| 815 | + if (isset($wp->query_vars['gd_city'])) { |
|
| 816 | + $wp->query_vars['gd_city'] = ''; |
|
| 817 | + } |
|
| 786 | 818 | } |
| 787 | 819 | } |
| 788 | 820 | |
@@ -894,8 +926,9 @@ discard block |
||
| 894 | 926 | function geodir_exclude_page_where($where) |
| 895 | 927 | {
|
| 896 | 928 | global $wpdb; |
| 897 | - if (is_admin()) |
|
| 898 | - $where .= " AND $wpdb->posts.post_status != 'virtual'"; |
|
| 929 | + if (is_admin()) { |
|
| 930 | + $where .= " AND $wpdb->posts.post_status != 'virtual'"; |
|
| 931 | + } |
|
| 899 | 932 | |
| 900 | 933 | return $where; |
| 901 | 934 | } |
@@ -1732,7 +1732,7 @@ discard block |
||
| 1732 | 1732 | * @global string $plugin_prefix Geodirectory plugin table prefix. |
| 1733 | 1733 | * @global string $table_prefix WordPress Database Table prefix. |
| 1734 | 1734 | * @param array $query_args The query array. |
| 1735 | - * @param int|bool $count_only If true returns listings count only, otherwise returns array |
|
| 1735 | + * @param boolean $count_only If true returns listings count only, otherwise returns array |
|
| 1736 | 1736 | * @return mixed Result object. |
| 1737 | 1737 | */ |
| 1738 | 1738 | function geodir_get_widget_listings($query_args = array(), $count_only = false) |
@@ -3264,7 +3264,7 @@ discard block |
||
| 3264 | 3264 | * |
| 3265 | 3265 | * @since 1.0.0 |
| 3266 | 3266 | * @package GeoDirectory |
| 3267 | - * @return bool |
|
| 3267 | + * @return null|boolean |
|
| 3268 | 3268 | */ |
| 3269 | 3269 | function geodir_term_review_count_force_update($new_status, $old_status='', $post='') |
| 3270 | 3270 | {
|
@@ -1,10 +1,10 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | - * Plugin general functions |
|
| 4 | - * |
|
| 5 | - * @since 1.0.0 |
|
| 6 | - * @package GeoDirectory |
|
| 7 | - */ |
|
| 3 | + * Plugin general functions |
|
| 4 | + * |
|
| 5 | + * @since 1.0.0 |
|
| 6 | + * @package GeoDirectory |
|
| 7 | + */ |
|
| 8 | 8 | |
| 9 | 9 | |
| 10 | 10 | /** |
@@ -304,11 +304,11 @@ discard block |
||
| 304 | 304 | if (is_author() && isset($_REQUEST['geodir_dashbord'])) |
| 305 | 305 | return true; |
| 306 | 306 | |
| 307 | - if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
|
|
| 308 | - if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
|
|
| 309 | - return true; |
|
| 310 | - } |
|
| 311 | - } |
|
| 307 | + if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
|
|
| 308 | + if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
|
|
| 309 | + return true; |
|
| 310 | + } |
|
| 311 | + } |
|
| 312 | 312 | break; |
| 313 | 313 | case 'search': |
| 314 | 314 | if (is_search() && isset($_REQUEST['geodir_search'])) |
@@ -664,13 +664,13 @@ discard block |
||
| 664 | 664 | $message = get_option('geodir_post_published_email_content');
|
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - if (!empty($subject)) {
|
|
| 668 | - $subject = __(stripslashes_deep($subject),'geodirectory'); |
|
| 669 | - } |
|
| 667 | + if (!empty($subject)) {
|
|
| 668 | + $subject = __(stripslashes_deep($subject),'geodirectory'); |
|
| 669 | + } |
|
| 670 | 670 | |
| 671 | - if (!empty($message)) {
|
|
| 672 | - $message = __(stripslashes_deep($message),'geodirectory'); |
|
| 673 | - } |
|
| 671 | + if (!empty($message)) {
|
|
| 672 | + $message = __(stripslashes_deep($message),'geodirectory'); |
|
| 673 | + } |
|
| 674 | 674 | |
| 675 | 675 | $to_message = nl2br($to_message); |
| 676 | 676 | $sitefromEmail = get_option('site_email');
|
@@ -856,18 +856,18 @@ discard block |
||
| 856 | 856 | if (geodir_is_page('detail') || geodir_is_page('listing')) {
|
| 857 | 857 | global $post; |
| 858 | 858 | $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
| 859 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 859 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 860 | 860 | |
| 861 | - if(geodir_is_page('detail') && isset($post->country_slug)){
|
|
| 861 | + if(geodir_is_page('detail') && isset($post->country_slug)){
|
|
| 862 | 862 | $location_terms = array( |
| 863 | 863 | 'gd_country' => $post->country_slug, |
| 864 | 864 | 'gd_region' => $post->region_slug, |
| 865 | 865 | 'gd_city' => $post->city_slug |
| 866 | 866 | ); |
| 867 | 867 | |
| 868 | - if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 869 | - $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 870 | - } |
|
| 868 | + if ($neighbourhood_active && !empty($location_terms['gd_city']) && $gd_ses_neighbourhood = $gd_session->get('gd_neighbourhood')) {
|
|
| 869 | + $location_terms['gd_neighbourhood'] = $gd_ses_neighbourhood; |
|
| 870 | + } |
|
| 871 | 871 | } |
| 872 | 872 | |
| 873 | 873 | $geodir_show_location_url = get_option('geodir_show_location_url');
|
@@ -3553,20 +3553,20 @@ discard block |
||
| 3553 | 3553 | if (!empty($row->required_msg)) |
| 3554 | 3554 | $translation_texts[] = stripslashes_deep($row->required_msg); |
| 3555 | 3555 | |
| 3556 | - if (!empty($row->default_value)) |
|
| 3556 | + if (!empty($row->default_value)) |
|
| 3557 | 3557 | $translation_texts[] = stripslashes_deep($row->default_value); |
| 3558 | 3558 | |
| 3559 | - if (!empty($row->option_values)) {
|
|
| 3560 | - $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); |
|
| 3559 | + if (!empty($row->option_values)) {
|
|
| 3560 | + $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); |
|
| 3561 | 3561 | |
| 3562 | - if (!empty($option_values)) {
|
|
| 3563 | - foreach ($option_values as $option_value) {
|
|
| 3564 | - if (!empty($option_value['label'])) {
|
|
| 3565 | - $translation_texts[] = $option_value['label']; |
|
| 3566 | - } |
|
| 3567 | - } |
|
| 3568 | - } |
|
| 3569 | - } |
|
| 3562 | + if (!empty($option_values)) {
|
|
| 3563 | + foreach ($option_values as $option_value) {
|
|
| 3564 | + if (!empty($option_value['label'])) {
|
|
| 3565 | + $translation_texts[] = $option_value['label']; |
|
| 3566 | + } |
|
| 3567 | + } |
|
| 3568 | + } |
|
| 3569 | + } |
|
| 3570 | 3570 | } |
| 3571 | 3571 | } |
| 3572 | 3572 | |
@@ -3587,24 +3587,24 @@ discard block |
||
| 3587 | 3587 | } |
| 3588 | 3588 | } |
| 3589 | 3589 | |
| 3590 | - // Advance search filter fields table |
|
| 3591 | - if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
|
|
| 3592 | - $sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE; |
|
| 3593 | - $rows = $wpdb->get_results($sql); |
|
| 3594 | - |
|
| 3595 | - if (!empty($rows)) {
|
|
| 3596 | - foreach($rows as $row) {
|
|
| 3597 | - if (!empty($row->field_site_name)) |
|
| 3598 | - $translation_texts[] = stripslashes_deep($row->field_site_name); |
|
| 3599 | - |
|
| 3600 | - if (!empty($row->front_search_title)) |
|
| 3601 | - $translation_texts[] = stripslashes_deep($row->front_search_title); |
|
| 3602 | - |
|
| 3603 | - if (!empty($row->field_desc)) |
|
| 3604 | - $translation_texts[] = stripslashes_deep($row->field_desc); |
|
| 3605 | - } |
|
| 3606 | - } |
|
| 3607 | - } |
|
| 3590 | + // Advance search filter fields table |
|
| 3591 | + if (defined('GEODIR_ADVANCE_SEARCH_TABLE')) {
|
|
| 3592 | + $sql = "SELECT field_site_name, front_search_title, field_desc FROM " . GEODIR_ADVANCE_SEARCH_TABLE; |
|
| 3593 | + $rows = $wpdb->get_results($sql); |
|
| 3594 | + |
|
| 3595 | + if (!empty($rows)) {
|
|
| 3596 | + foreach($rows as $row) {
|
|
| 3597 | + if (!empty($row->field_site_name)) |
|
| 3598 | + $translation_texts[] = stripslashes_deep($row->field_site_name); |
|
| 3599 | + |
|
| 3600 | + if (!empty($row->front_search_title)) |
|
| 3601 | + $translation_texts[] = stripslashes_deep($row->front_search_title); |
|
| 3602 | + |
|
| 3603 | + if (!empty($row->field_desc)) |
|
| 3604 | + $translation_texts[] = stripslashes_deep($row->field_desc); |
|
| 3605 | + } |
|
| 3606 | + } |
|
| 3607 | + } |
|
| 3608 | 3608 | |
| 3609 | 3609 | $translation_texts = !empty($translation_texts) ? array_unique($translation_texts) : $translation_texts; |
| 3610 | 3610 | |
@@ -30,8 +30,10 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | if (is_ssl()) : |
| 32 | 32 | return str_replace('http://', 'https://', WP_PLUGIN_URL) . "/" . plugin_basename(dirname(dirname(__FILE__)));
|
| 33 | - else : |
|
| 34 | - return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 33 | + else { |
|
| 34 | + : |
|
| 35 | + return WP_PLUGIN_URL . "/" . plugin_basename(dirname(dirname(__FILE__))); |
|
| 36 | + } |
|
| 35 | 37 | endif; |
| 36 | 38 | } |
| 37 | 39 | |
@@ -63,7 +65,9 @@ discard block |
||
| 63 | 65 | {
|
| 64 | 66 | $active_plugins = get_option('active_plugins');
|
| 65 | 67 | foreach ($active_plugins as $key => $active_plugin) {
|
| 66 | - if (strstr($active_plugin, $plugin)) return true; |
|
| 68 | + if (strstr($active_plugin, $plugin)) { |
|
| 69 | + return true; |
|
| 70 | + } |
|
| 67 | 71 | } |
| 68 | 72 | return false; |
| 69 | 73 | } |
@@ -114,12 +118,25 @@ discard block |
||
| 114 | 118 | */ |
| 115 | 119 | function geodir_getlink($url, $params = array(), $use_existing_arguments = false) |
| 116 | 120 | {
|
| 117 | - if ($use_existing_arguments) $params = $params + $_GET; |
|
| 118 | - if (!$params) return $url; |
|
| 121 | + if ($use_existing_arguments) { |
|
| 122 | + $params = $params + $_GET; |
|
| 123 | + } |
|
| 124 | + if (!$params) { |
|
| 125 | + return $url; |
|
| 126 | + } |
|
| 119 | 127 | $link = $url; |
| 120 | - if (strpos($link, '?') === false) $link .= '?'; //If there is no '?' add one at the end |
|
| 121 | - elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) $link .= '&'; //If there is no '&' at the END, add one. |
|
| 122 | - elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) $link .= '&'; //If there is no '&' at the END, add one.
|
|
| 128 | + if (strpos($link, '?') === false) { |
|
| 129 | + $link .= '?'; |
|
| 130 | + } |
|
| 131 | + //If there is no '?' add one at the end |
|
| 132 | + elseif (strpos($link, '//maps.google.com/maps/api/js?language=')) { |
|
| 133 | + $link .= '&'; |
|
| 134 | + } |
|
| 135 | + //If there is no '&' at the END, add one. |
|
| 136 | + elseif (!preg_match('/(\?|\&(amp;)?)$/', $link)) { |
|
| 137 | + $link .= '&'; |
|
| 138 | + } |
|
| 139 | + //If there is no '&' at the END, add one. |
|
| 123 | 140 | |
| 124 | 141 | $params_arr = array(); |
| 125 | 142 | foreach ($params as $key => $value) {
|
@@ -157,9 +174,10 @@ discard block |
||
| 157 | 174 | $add_listing_link = get_page_link(geodir_add_listing_page_id()); |
| 158 | 175 | |
| 159 | 176 | return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
|
| 160 | - } else |
|
| 161 | - return get_bloginfo('url');
|
|
| 162 | -} |
|
| 177 | + } else { |
|
| 178 | + return get_bloginfo('url'); |
|
| 179 | + } |
|
| 180 | + } |
|
| 163 | 181 | |
| 164 | 182 | /** |
| 165 | 183 | * Get the current page URL. |
@@ -264,20 +282,24 @@ discard block |
||
| 264 | 282 | case 'preview': |
| 265 | 283 | if ((is_page() && get_query_var('page_id') == geodir_preview_page_id()) && isset($_REQUEST['listing_type'])
|
| 266 | 284 | && in_array($_REQUEST['listing_type'], geodir_get_posttypes()) |
| 267 | - ) |
|
| 268 | - return true; |
|
| 285 | + ) { |
|
| 286 | + return true; |
|
| 287 | + } |
|
| 269 | 288 | break; |
| 270 | 289 | case 'listing-success': |
| 271 | - if (is_page() && get_query_var('page_id') == geodir_success_page_id())
|
|
| 272 | - return true; |
|
| 290 | + if (is_page() && get_query_var('page_id') == geodir_success_page_id()) { |
|
| 291 | + return true; |
|
| 292 | + } |
|
| 273 | 293 | break; |
| 274 | 294 | case 'detail': |
| 275 | - if (is_single() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
|
|
| 276 | - return true; |
|
| 295 | + if (is_single() && in_array(get_query_var('post_type'), geodir_get_posttypes())) { |
|
| 296 | + return true; |
|
| 297 | + } |
|
| 277 | 298 | break; |
| 278 | 299 | case 'pt': |
| 279 | - if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()) && !is_tax())
|
|
| 280 | - return true; |
|
| 300 | + if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()) && !is_tax()) { |
|
| 301 | + return true; |
|
| 302 | + } |
|
| 281 | 303 | |
| 282 | 304 | break; |
| 283 | 305 | case 'listing': |
@@ -286,23 +308,27 @@ discard block |
||
| 286 | 308 | |
| 287 | 309 | return true; |
| 288 | 310 | } |
| 289 | - if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes()))
|
|
| 290 | - return true; |
|
| 311 | + if (is_post_type_archive() && in_array(get_query_var('post_type'), geodir_get_posttypes())) { |
|
| 312 | + return true; |
|
| 313 | + } |
|
| 291 | 314 | |
| 292 | 315 | break; |
| 293 | 316 | case 'home': |
| 294 | 317 | |
| 295 | - if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home())
|
|
| 296 | - return true; |
|
| 318 | + if ((is_page() && get_query_var('page_id') == geodir_home_page_id()) || is_page_geodir_home()) { |
|
| 319 | + return true; |
|
| 320 | + } |
|
| 297 | 321 | |
| 298 | 322 | break; |
| 299 | 323 | case 'location': |
| 300 | - if (is_page() && get_query_var('page_id') == geodir_location_page_id())
|
|
| 301 | - return true; |
|
| 324 | + if (is_page() && get_query_var('page_id') == geodir_location_page_id()) { |
|
| 325 | + return true; |
|
| 326 | + } |
|
| 302 | 327 | break; |
| 303 | 328 | case 'author': |
| 304 | - if (is_author() && isset($_REQUEST['geodir_dashbord'])) |
|
| 305 | - return true; |
|
| 329 | + if (is_author() && isset($_REQUEST['geodir_dashbord'])) { |
|
| 330 | + return true; |
|
| 331 | + } |
|
| 306 | 332 | |
| 307 | 333 | if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
|
| 308 | 334 | if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
|
@@ -311,24 +337,29 @@ discard block |
||
| 311 | 337 | } |
| 312 | 338 | break; |
| 313 | 339 | case 'search': |
| 314 | - if (is_search() && isset($_REQUEST['geodir_search'])) |
|
| 315 | - return true; |
|
| 340 | + if (is_search() && isset($_REQUEST['geodir_search'])) { |
|
| 341 | + return true; |
|
| 342 | + } |
|
| 316 | 343 | break; |
| 317 | 344 | case 'info': |
| 318 | - if (is_page() && get_query_var('page_id') == geodir_info_page_id())
|
|
| 319 | - return true; |
|
| 345 | + if (is_page() && get_query_var('page_id') == geodir_info_page_id()) { |
|
| 346 | + return true; |
|
| 347 | + } |
|
| 320 | 348 | break; |
| 321 | 349 | case 'login': |
| 322 | - if (is_page() && get_query_var('page_id') == geodir_login_page_id())
|
|
| 323 | - return true; |
|
| 350 | + if (is_page() && get_query_var('page_id') == geodir_login_page_id()) { |
|
| 351 | + return true; |
|
| 352 | + } |
|
| 324 | 353 | break; |
| 325 | 354 | case 'checkout': |
| 326 | - if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id())
|
|
| 327 | - return true; |
|
| 355 | + if (is_page() && function_exists('geodir_payment_checkout_page_id') && get_query_var('page_id') == geodir_payment_checkout_page_id()) { |
|
| 356 | + return true; |
|
| 357 | + } |
|
| 328 | 358 | break; |
| 329 | 359 | case 'invoices': |
| 330 | - if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id())
|
|
| 331 | - return true; |
|
| 360 | + if (is_page() && function_exists('geodir_payment_invoices_page_id') && get_query_var('page_id') == geodir_payment_invoices_page_id()) { |
|
| 361 | + return true; |
|
| 362 | + } |
|
| 332 | 363 | break; |
| 333 | 364 | default: |
| 334 | 365 | return false; |
@@ -356,8 +387,9 @@ discard block |
||
| 356 | 387 | //$wp->query_vars['gd_is_geodir_page'] = false; |
| 357 | 388 | //print_r() |
| 358 | 389 | if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
|
| 359 | - if (get_option('geodir_set_as_home'))
|
|
| 360 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 390 | + if (get_option('geodir_set_as_home')) { |
|
| 391 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 392 | + } |
|
| 361 | 393 | if(geodir_is_page('home')){
|
| 362 | 394 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 363 | 395 | } |
@@ -376,8 +408,9 @@ discard block |
||
| 376 | 408 | || $wp->query_vars['page_id'] == geodir_login_page_id() |
| 377 | 409 | || (function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
| 378 | 410 | || (function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
| 379 | - ) |
|
| 380 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 411 | + ) { |
|
| 412 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 413 | + } |
|
| 381 | 414 | } |
| 382 | 415 | |
| 383 | 416 | if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['pagename'])) {
|
@@ -394,8 +427,9 @@ discard block |
||
| 394 | 427 | || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_checkout_page_id') && $wp->query_vars['page_id'] == geodir_payment_checkout_page_id())
|
| 395 | 428 | || (isset($wp->query_vars['page_id']) && function_exists('geodir_payment_invoices_page_id') && $wp->query_vars['page_id'] == geodir_payment_invoices_page_id())
|
| 396 | 429 | ) |
| 397 | - ) |
|
| 398 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 430 | + ) { |
|
| 431 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 432 | + } |
|
| 399 | 433 | } |
| 400 | 434 | |
| 401 | 435 | |
@@ -418,12 +452,14 @@ discard block |
||
| 418 | 452 | } |
| 419 | 453 | } |
| 420 | 454 | |
| 421 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) |
|
| 422 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 455 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($wp->query_vars['author_name']) && isset($_REQUEST['geodir_dashbord'])) { |
|
| 456 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 457 | + } |
|
| 423 | 458 | |
| 424 | 459 | |
| 425 | - if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) |
|
| 426 | - $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 460 | + if (!isset($wp->query_vars['gd_is_geodir_page']) && isset($_REQUEST['geodir_search'])) { |
|
| 461 | + $wp->query_vars['gd_is_geodir_page'] = true; |
|
| 462 | + } |
|
| 427 | 463 | |
| 428 | 464 | |
| 429 | 465 | //check if homepage |
@@ -453,11 +489,12 @@ discard block |
||
| 453 | 489 | function geodir_is_geodir_page() |
| 454 | 490 | {
|
| 455 | 491 | global $wp; |
| 456 | - if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) |
|
| 457 | - return true; |
|
| 458 | - else |
|
| 459 | - return false; |
|
| 460 | -} |
|
| 492 | + if (isset($wp->query_vars['gd_is_geodir_page']) && $wp->query_vars['gd_is_geodir_page']) { |
|
| 493 | + return true; |
|
| 494 | + } else { |
|
| 495 | + return false; |
|
| 496 | + } |
|
| 497 | + } |
|
| 461 | 498 | |
| 462 | 499 | if (!function_exists('geodir_get_imagesize')) {
|
| 463 | 500 | /** |
@@ -754,20 +791,16 @@ discard block |
||
| 754 | 791 | $subject .= ' - ADMIN BCC COPY'; |
| 755 | 792 | $admin_bcc = true; |
| 756 | 793 | |
| 757 | - } |
|
| 758 | - elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 794 | + } elseif ($message_type == 'registration' && get_option('geodir_bcc_new_user')) {
|
|
| 759 | 795 | $subject .= ' - ADMIN BCC COPY'; |
| 760 | 796 | $admin_bcc = true; |
| 761 | - } |
|
| 762 | - elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 797 | + } elseif ($message_type == 'send_friend' && get_option('geodir_bcc_friend')) {
|
|
| 763 | 798 | $subject .= ' - ADMIN BCC COPY'; |
| 764 | 799 | $admin_bcc = true; |
| 765 | - } |
|
| 766 | - elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 800 | + } elseif ($message_type == 'send_enquiry' && get_option('geodir_bcc_enquiry')) {
|
|
| 767 | 801 | $subject .= ' - ADMIN BCC COPY'; |
| 768 | 802 | $admin_bcc = true; |
| 769 | - } |
|
| 770 | - elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 803 | + } elseif ($message_type == 'listing_published' && get_option('geodir_bcc_listing_published')) {
|
|
| 771 | 804 | $subject .= ' - ADMIN BCC COPY'; |
| 772 | 805 | $admin_bcc = true; |
| 773 | 806 | } |
@@ -936,21 +969,24 @@ discard block |
||
| 936 | 969 | $is_location_last = ''; |
| 937 | 970 | $is_taxonomy_last = ''; |
| 938 | 971 | $breadcrumb .= '<li>'; |
| 939 | - if (get_query_var($gd_post_type . 'category')) |
|
| 940 | - $gd_taxonomy = $gd_post_type . 'category'; |
|
| 941 | - elseif (get_query_var($gd_post_type . '_tags')) |
|
| 942 | - $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 972 | + if (get_query_var($gd_post_type . 'category')) { |
|
| 973 | + $gd_taxonomy = $gd_post_type . 'category'; |
|
| 974 | + } elseif (get_query_var($gd_post_type . '_tags')) { |
|
| 975 | + $gd_taxonomy = $gd_post_type . '_tags'; |
|
| 976 | + } |
|
| 943 | 977 | |
| 944 | 978 | $breadcrumb .= $separator . '<a href="' . $listing_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
| 945 | - if (!empty($gd_taxonomy) || geodir_is_page('detail'))
|
|
| 946 | - $is_location_last = false; |
|
| 947 | - else |
|
| 948 | - $is_location_last = true; |
|
| 949 | - |
|
| 950 | - if (!empty($gd_taxonomy) && geodir_is_page('listing'))
|
|
| 951 | - $is_taxonomy_last = true; |
|
| 952 | - else |
|
| 953 | - $is_taxonomy_last = false; |
|
| 979 | + if (!empty($gd_taxonomy) || geodir_is_page('detail')) { |
|
| 980 | + $is_location_last = false; |
|
| 981 | + } else { |
|
| 982 | + $is_location_last = true; |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + if (!empty($gd_taxonomy) && geodir_is_page('listing')) { |
|
| 986 | + $is_taxonomy_last = true; |
|
| 987 | + } else { |
|
| 988 | + $is_taxonomy_last = false; |
|
| 989 | + } |
|
| 954 | 990 | |
| 955 | 991 | if (!empty($location_terms)) {
|
| 956 | 992 | $geodir_get_locations = function_exists('get_actual_location_name') ? true : false;
|
@@ -1032,8 +1068,9 @@ discard block |
||
| 1032 | 1068 | {
|
| 1033 | 1069 | if (get_query_var($gd_post_type . '_tags')) {
|
| 1034 | 1070 | $cat_link = $listing_link . 'tags/'; |
| 1035 | - } else |
|
| 1036 | - $cat_link = $listing_link; |
|
| 1071 | + } else { |
|
| 1072 | + $cat_link = $listing_link; |
|
| 1073 | + } |
|
| 1037 | 1074 | |
| 1038 | 1075 | foreach ($location_terms as $key => $location_term) {
|
| 1039 | 1076 | if ($location_manager && in_array($key, $hide_url_part)) {
|
@@ -1060,9 +1097,9 @@ discard block |
||
| 1060 | 1097 | $term_link_text = geodir_ucwords(urldecode($term_link_text)); |
| 1061 | 1098 | } |
| 1062 | 1099 | |
| 1063 | - if ($term_index == count($term_array) && $is_taxonomy_last) |
|
| 1064 | - $breadcrumb .= $separator . $term_link_text; |
|
| 1065 | - else {
|
|
| 1100 | + if ($term_index == count($term_array) && $is_taxonomy_last) { |
|
| 1101 | + $breadcrumb .= $separator . $term_link_text; |
|
| 1102 | + } else {
|
|
| 1066 | 1103 | $cat_link .= $term . '/'; |
| 1067 | 1104 | $breadcrumb .= $separator . '<a href="' . $cat_link . '">' . $term_link_text . '</a>'; |
| 1068 | 1105 | } |
@@ -1073,8 +1110,9 @@ discard block |
||
| 1073 | 1110 | |
| 1074 | 1111 | } |
| 1075 | 1112 | |
| 1076 | - if (geodir_is_page('detail'))
|
|
| 1077 | - $breadcrumb .= $separator . get_the_title(); |
|
| 1113 | + if (geodir_is_page('detail')) { |
|
| 1114 | + $breadcrumb .= $separator . get_the_title(); |
|
| 1115 | + } |
|
| 1078 | 1116 | |
| 1079 | 1117 | $breadcrumb .= '</li>'; |
| 1080 | 1118 | |
@@ -1111,8 +1149,9 @@ discard block |
||
| 1111 | 1149 | |
| 1112 | 1150 | $breadcrumb .= $separator . '<a href="' . $author_link . '">' . __(ucfirst($post_type_info->label), 'geodirectory') . '</a>'; |
| 1113 | 1151 | $breadcrumb .= $separator . ucfirst(__('My', 'geodirectory') . ' ' . $_REQUEST['list']);
|
| 1114 | - } else |
|
| 1115 | - $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1152 | + } else { |
|
| 1153 | + $breadcrumb .= $separator . __(ucfirst($post_type_info->label), 'geodirectory'); |
|
| 1154 | + } |
|
| 1116 | 1155 | |
| 1117 | 1156 | $breadcrumb .= '</li>'; |
| 1118 | 1157 | } elseif (is_category() || is_single()) {
|
@@ -1187,12 +1226,14 @@ discard block |
||
| 1187 | 1226 | function geodir_allow_wpadmin() |
| 1188 | 1227 | {
|
| 1189 | 1228 | global $wpdb; |
| 1190 | - if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) // checking action in request to allow ajax request go through
|
|
| 1229 | + if (get_option('geodir_allow_wpadmin') == '0' && is_user_logged_in() && (!isset($_REQUEST['action']))) { |
|
| 1230 | + // checking action in request to allow ajax request go through |
|
| 1191 | 1231 | {
|
| 1192 | 1232 | if (current_user_can('manage_options')) {
|
| 1193 | 1233 | } else {
|
| 1194 | 1234 | |
| 1195 | - wp_redirect(home_url()); |
|
| 1235 | + wp_redirect(home_url()); |
|
| 1236 | + } |
|
| 1196 | 1237 | exit; |
| 1197 | 1238 | } |
| 1198 | 1239 | |
@@ -1224,8 +1265,9 @@ discard block |
||
| 1224 | 1265 | $post_upload_date = isset($post['upload_date']) ? $post['upload_date'] : ''; |
| 1225 | 1266 | |
| 1226 | 1267 | $upload = wp_upload_bits($file_name, 0, '', $post_upload_date); |
| 1227 | - if ($upload['error']) |
|
| 1228 | - return new WP_Error('upload_dir_error', $upload['error']);
|
|
| 1268 | + if ($upload['error']) { |
|
| 1269 | + return new WP_Error('upload_dir_error', $upload['error']); |
|
| 1270 | + } |
|
| 1229 | 1271 | |
| 1230 | 1272 | // fetch the remote url and write it to the placeholder file |
| 1231 | 1273 | $headers = wp_get_http($url, $upload['file']); |
@@ -1239,11 +1281,9 @@ discard block |
||
| 1239 | 1281 | // make sure the fetch was successful |
| 1240 | 1282 | elseif ($headers['response'] != '200') {
|
| 1241 | 1283 | $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
| 1242 | - } |
|
| 1243 | - elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
|
|
| 1284 | + } elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
|
|
| 1244 | 1285 | $log_message = __('Remote file is incorrect size', 'geodirectory');
|
| 1245 | - } |
|
| 1246 | - elseif (0 == $filesize) {
|
|
| 1286 | + } elseif (0 == $filesize) {
|
|
| 1247 | 1287 | $log_message = __('Zero size file downloaded', 'geodirectory');
|
| 1248 | 1288 | } |
| 1249 | 1289 | |
@@ -1295,10 +1335,11 @@ discard block |
||
| 1295 | 1335 | function geodir_dummy_folder_exists() |
| 1296 | 1336 | {
|
| 1297 | 1337 | $path = geodir_plugin_path() . '/geodirectory-admin/dummy/'; |
| 1298 | - if (!is_dir($path)) |
|
| 1299 | - return false; |
|
| 1300 | - else |
|
| 1301 | - return true; |
|
| 1338 | + if (!is_dir($path)) { |
|
| 1339 | + return false; |
|
| 1340 | + } else { |
|
| 1341 | + return true; |
|
| 1342 | + } |
|
| 1302 | 1343 | |
| 1303 | 1344 | } |
| 1304 | 1345 | |
@@ -1516,12 +1557,10 @@ discard block |
||
| 1516 | 1557 | if ($message_type == 'registration' && get_option('bcc_new_user')) {
|
| 1517 | 1558 | $subject .= ' - ADMIN BCC COPY'; |
| 1518 | 1559 | $admin_bcc = true; |
| 1519 | - } |
|
| 1520 | - elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1560 | + } elseif ($message_type == 'send_friend' && get_option('bcc_friend')) {
|
|
| 1521 | 1561 | $subject .= ' - ADMIN BCC COPY'; |
| 1522 | 1562 | $admin_bcc = true; |
| 1523 | - } |
|
| 1524 | - elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1563 | + } elseif ($message_type == 'send_enquiry' && get_option('bcc_enquiry')) {
|
|
| 1525 | 1564 | $subject .= ' - ADMIN BCC COPY'; |
| 1526 | 1565 | $admin_bcc = true; |
| 1527 | 1566 | } |
@@ -1565,7 +1604,9 @@ discard block |
||
| 1565 | 1604 | $res = array(); |
| 1566 | 1605 | foreach ($ids_array as $id) {
|
| 1567 | 1606 | $xlat = icl_object_id($id, $type, false); |
| 1568 | - if (!is_null($xlat)) $res[] = $xlat; |
|
| 1607 | + if (!is_null($xlat)) { |
|
| 1608 | + $res[] = $xlat; |
|
| 1609 | + } |
|
| 1569 | 1610 | } |
| 1570 | 1611 | return $res; |
| 1571 | 1612 | } else {
|
@@ -1907,8 +1948,9 @@ discard block |
||
| 1907 | 1948 | $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
| 1908 | 1949 | |
| 1909 | 1950 | $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
| 1910 | - if ( !$page ) |
|
| 1911 | - $page = 1; |
|
| 1951 | + if ( !$page ) { |
|
| 1952 | + $page = 1; |
|
| 1953 | + } |
|
| 1912 | 1954 | |
| 1913 | 1955 | $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
| 1914 | 1956 | |
@@ -2252,7 +2294,7 @@ discard block |
||
| 2252 | 2294 | $home_url = str_replace("www.", "", $home_url);
|
| 2253 | 2295 | if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
|
| 2254 | 2296 | return true; |
| 2255 | - }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2297 | + } elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2256 | 2298 | return true; |
| 2257 | 2299 | } else {
|
| 2258 | 2300 | return false; |
@@ -2746,8 +2788,9 @@ discard block |
||
| 2746 | 2788 | $name = $postobj->labels->name; |
| 2747 | 2789 | |
| 2748 | 2790 | $selected = ''; |
| 2749 | - if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing'))
|
|
| 2750 | - $selected = 'selected="selected"'; |
|
| 2791 | + if (geodir_get_current_posttype() == $key && geodir_is_page('add-listing')) { |
|
| 2792 | + $selected = 'selected="selected"'; |
|
| 2793 | + } |
|
| 2751 | 2794 | |
| 2752 | 2795 | /** |
| 2753 | 2796 | * Filter add listing link. |
@@ -3214,8 +3257,9 @@ discard block |
||
| 3214 | 3257 | $geodir_is_widget_listing = false; |
| 3215 | 3258 | |
| 3216 | 3259 | $GLOBALS['post'] = $current_post; |
| 3217 | - if (!empty($current_post)) |
|
| 3218 | - setup_postdata($current_post); |
|
| 3260 | + if (!empty($current_post)) { |
|
| 3261 | + setup_postdata($current_post); |
|
| 3262 | + } |
|
| 3219 | 3263 | $map_jason = $current_map_jason; |
| 3220 | 3264 | $map_canvas_arr = $current_map_canvas_arr; |
| 3221 | 3265 | ?> |
@@ -3531,11 +3575,15 @@ discard block |
||
| 3531 | 3575 | |
| 3532 | 3576 | $language_file = geodir_plugin_path() . '/db-language.php'; |
| 3533 | 3577 | |
| 3534 | - if(is_file($language_file) && !is_writable($language_file)) |
|
| 3535 | - return false; // Not possible to create. |
|
| 3578 | + if(is_file($language_file) && !is_writable($language_file)) { |
|
| 3579 | + return false; |
|
| 3580 | + } |
|
| 3581 | + // Not possible to create. |
|
| 3536 | 3582 | |
| 3537 | - if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3538 | - return false; // Not possible to create. |
|
| 3583 | + if(!is_file($language_file) && !is_writable(dirname($language_file))) { |
|
| 3584 | + return false; |
|
| 3585 | + } |
|
| 3586 | + // Not possible to create. |
|
| 3539 | 3587 | |
| 3540 | 3588 | $contents_strings = array(); |
| 3541 | 3589 | |
@@ -3578,8 +3626,10 @@ discard block |
||
| 3578 | 3626 | |
| 3579 | 3627 | $contents .= implode(PHP_EOL, $contents_foot); |
| 3580 | 3628 | |
| 3581 | - if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3582 | - return false; // Failure; could not write file. |
|
| 3629 | + if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) { |
|
| 3630 | + return false; |
|
| 3631 | + } |
|
| 3632 | + // Failure; could not write file. |
|
| 3583 | 3633 | |
| 3584 | 3634 | return true; |
| 3585 | 3635 | } |
@@ -3605,23 +3655,29 @@ discard block |
||
| 3605 | 3655 | |
| 3606 | 3656 | if (!empty($rows)) {
|
| 3607 | 3657 | foreach($rows as $row) {
|
| 3608 | - if (!empty($row->admin_title)) |
|
| 3609 | - $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3658 | + if (!empty($row->admin_title)) { |
|
| 3659 | + $translation_texts[] = stripslashes_deep($row->admin_title); |
|
| 3660 | + } |
|
| 3610 | 3661 | |
| 3611 | - if (!empty($row->admin_desc)) |
|
| 3612 | - $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3662 | + if (!empty($row->admin_desc)) { |
|
| 3663 | + $translation_texts[] = stripslashes_deep($row->admin_desc); |
|
| 3664 | + } |
|
| 3613 | 3665 | |
| 3614 | - if (!empty($row->site_title)) |
|
| 3615 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3666 | + if (!empty($row->site_title)) { |
|
| 3667 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3668 | + } |
|
| 3616 | 3669 | |
| 3617 | - if (!empty($row->clabels)) |
|
| 3618 | - $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3670 | + if (!empty($row->clabels)) { |
|
| 3671 | + $translation_texts[] = stripslashes_deep($row->clabels); |
|
| 3672 | + } |
|
| 3619 | 3673 | |
| 3620 | - if (!empty($row->required_msg)) |
|
| 3621 | - $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3674 | + if (!empty($row->required_msg)) { |
|
| 3675 | + $translation_texts[] = stripslashes_deep($row->required_msg); |
|
| 3676 | + } |
|
| 3622 | 3677 | |
| 3623 | - if (!empty($row->default_value)) |
|
| 3624 | - $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3678 | + if (!empty($row->default_value)) { |
|
| 3679 | + $translation_texts[] = stripslashes_deep($row->default_value); |
|
| 3680 | + } |
|
| 3625 | 3681 | |
| 3626 | 3682 | if (!empty($row->option_values)) {
|
| 3627 | 3683 | $option_values = geodir_string_values_to_options(stripslashes_deep($row->option_values)); |
@@ -3643,14 +3699,17 @@ discard block |
||
| 3643 | 3699 | |
| 3644 | 3700 | if (!empty($rows)) {
|
| 3645 | 3701 | foreach($rows as $row) {
|
| 3646 | - if (!empty($row->site_title)) |
|
| 3647 | - $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3702 | + if (!empty($row->site_title)) { |
|
| 3703 | + $translation_texts[] = stripslashes_deep($row->site_title); |
|
| 3704 | + } |
|
| 3648 | 3705 | |
| 3649 | - if (!empty($row->asc_title)) |
|
| 3650 | - $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3706 | + if (!empty($row->asc_title)) { |
|
| 3707 | + $translation_texts[] = stripslashes_deep($row->asc_title); |
|
| 3708 | + } |
|
| 3651 | 3709 | |
| 3652 | - if (!empty($row->desc_title)) |
|
| 3653 | - $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3710 | + if (!empty($row->desc_title)) { |
|
| 3711 | + $translation_texts[] = stripslashes_deep($row->desc_title); |
|
| 3712 | + } |
|
| 3654 | 3713 | } |
| 3655 | 3714 | } |
| 3656 | 3715 | |
@@ -3661,14 +3720,17 @@ discard block |
||
| 3661 | 3720 | |
| 3662 | 3721 | if (!empty($rows)) {
|
| 3663 | 3722 | foreach($rows as $row) {
|
| 3664 | - if (!empty($row->field_site_name)) |
|
| 3665 | - $translation_texts[] = stripslashes_deep($row->field_site_name); |
|
| 3723 | + if (!empty($row->field_site_name)) { |
|
| 3724 | + $translation_texts[] = stripslashes_deep($row->field_site_name); |
|
| 3725 | + } |
|
| 3666 | 3726 | |
| 3667 | - if (!empty($row->front_search_title)) |
|
| 3668 | - $translation_texts[] = stripslashes_deep($row->front_search_title); |
|
| 3727 | + if (!empty($row->front_search_title)) { |
|
| 3728 | + $translation_texts[] = stripslashes_deep($row->front_search_title); |
|
| 3729 | + } |
|
| 3669 | 3730 | |
| 3670 | - if (!empty($row->field_desc)) |
|
| 3671 | - $translation_texts[] = stripslashes_deep($row->field_desc); |
|
| 3731 | + if (!empty($row->field_desc)) { |
|
| 3732 | + $translation_texts[] = stripslashes_deep($row->field_desc); |
|
| 3733 | + } |
|
| 3672 | 3734 | } |
| 3673 | 3735 | } |
| 3674 | 3736 | } |
@@ -3986,7 +4048,7 @@ discard block |
||
| 3986 | 4048 | if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
| 3987 | 4049 | $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
| 3988 | 4050 | } |
| 3989 | - }elseif($gd_page=='add-listing'){
|
|
| 4051 | + } elseif($gd_page=='add-listing'){
|
|
| 3990 | 4052 | $geodir_post_types = get_option('geodir_post_types');
|
| 3991 | 4053 | $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
| 3992 | 4054 | if(!$spt && isset($_REQUEST['pid'])){
|
@@ -3996,8 +4058,7 @@ discard block |
||
| 3996 | 4058 | if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
| 3997 | 4059 | $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
| 3998 | 4060 | } |
| 3999 | - } |
|
| 4000 | - elseif($post->post_type){
|
|
| 4061 | + } elseif($post->post_type){
|
|
| 4001 | 4062 | $geodir_post_types = get_option('geodir_post_types');
|
| 4002 | 4063 | if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
| 4003 | 4064 | $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
@@ -4016,15 +4077,14 @@ discard block |
||
| 4016 | 4077 | if(isset($geodir_post_types[$spt]['labels']['name'])){
|
| 4017 | 4078 | $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
| 4018 | 4079 | } |
| 4019 | - }elseif($gd_page=='add-listing'){
|
|
| 4080 | + } elseif($gd_page=='add-listing'){
|
|
| 4020 | 4081 | $geodir_post_types = get_option('geodir_post_types');
|
| 4021 | 4082 | $spt = esc_attr($_REQUEST['listing_type']); |
| 4022 | 4083 | if(!$spt){$spt='gd_place';}
|
| 4023 | 4084 | if(isset($geodir_post_types[$spt]['labels']['name'])){
|
| 4024 | 4085 | $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
| 4025 | 4086 | } |
| 4026 | - } |
|
| 4027 | - elseif(isset($post->post_type) && $post->post_type){
|
|
| 4087 | + } elseif(isset($post->post_type) && $post->post_type){
|
|
| 4028 | 4088 | $geodir_post_types = get_option('geodir_post_types');
|
| 4029 | 4089 | if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
| 4030 | 4090 | $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
@@ -4044,7 +4104,7 @@ discard block |
||
| 4044 | 4104 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4045 | 4105 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4046 | 4106 | } |
| 4047 | - }elseif($gd_page=='listing'){
|
|
| 4107 | + } elseif($gd_page=='listing'){
|
|
| 4048 | 4108 | $queried_object = get_queried_object(); |
| 4049 | 4109 | if(isset($queried_object->name)){
|
| 4050 | 4110 | $cat_name = $queried_object->name; |
@@ -4061,7 +4121,7 @@ discard block |
||
| 4061 | 4121 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4062 | 4122 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4063 | 4123 | } |
| 4064 | - }elseif($gd_page=='listing'){
|
|
| 4124 | + } elseif($gd_page=='listing'){
|
|
| 4065 | 4125 | $queried_object = get_queried_object(); |
| 4066 | 4126 | if(isset($queried_object->name)){
|
| 4067 | 4127 | $cat_name = $queried_object->name; |
@@ -4229,8 +4289,7 @@ discard block |
||
| 4229 | 4289 | |
| 4230 | 4290 | if(strpos($title,'%%name%%') !== false){
|
| 4231 | 4291 | $author_name = ''; |
| 4232 | - if($author_name = get_the_author()){}
|
|
| 4233 | - else{
|
|
| 4292 | + if($author_name = get_the_author()){} else{
|
|
| 4234 | 4293 | $queried_object = get_queried_object(); |
| 4235 | 4294 | if(isset($queried_object->data->user_nicename)){
|
| 4236 | 4295 | $author_name = $queried_object->data->user_nicename; |
@@ -4276,38 +4335,54 @@ discard block |
||
| 4276 | 4335 | $seo = isset($cpt_info['seo']) ? $cpt_info['seo'] : ''; |
| 4277 | 4336 | |
| 4278 | 4337 | if (!empty($labels)) {
|
| 4279 | - if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) |
|
| 4280 | - $translation_texts[] = $labels['name']; |
|
| 4281 | - if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) |
|
| 4282 | - $translation_texts[] = $labels['singular_name']; |
|
| 4283 | - if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) |
|
| 4284 | - $translation_texts[] = $labels['add_new']; |
|
| 4285 | - if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) |
|
| 4286 | - $translation_texts[] = $labels['add_new_item']; |
|
| 4287 | - if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) |
|
| 4288 | - $translation_texts[] = $labels['edit_item']; |
|
| 4289 | - if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) |
|
| 4290 | - $translation_texts[] = $labels['new_item']; |
|
| 4291 | - if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) |
|
| 4292 | - $translation_texts[] = $labels['view_item']; |
|
| 4293 | - if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) |
|
| 4294 | - $translation_texts[] = $labels['search_items']; |
|
| 4295 | - if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) |
|
| 4296 | - $translation_texts[] = $labels['not_found']; |
|
| 4297 | - if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) |
|
| 4298 | - $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4299 | - if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) |
|
| 4300 | - $translation_texts[] = $labels['label_post_profile']; |
|
| 4301 | - if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) |
|
| 4302 | - $translation_texts[] = $labels['label_post_info']; |
|
| 4303 | - if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) |
|
| 4304 | - $translation_texts[] = $labels['label_post_images']; |
|
| 4305 | - if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) |
|
| 4306 | - $translation_texts[] = $labels['label_post_map']; |
|
| 4307 | - if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) |
|
| 4308 | - $translation_texts[] = $labels['label_reviews']; |
|
| 4309 | - if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) |
|
| 4310 | - $translation_texts[] = $labels['label_related_listing']; |
|
| 4338 | + if ($labels['name'] != '' && !in_array($labels['name'], $translation_texts)) { |
|
| 4339 | + $translation_texts[] = $labels['name']; |
|
| 4340 | + } |
|
| 4341 | + if ($labels['singular_name'] != '' && !in_array($labels['singular_name'], $translation_texts)) { |
|
| 4342 | + $translation_texts[] = $labels['singular_name']; |
|
| 4343 | + } |
|
| 4344 | + if ($labels['add_new'] != '' && !in_array($labels['add_new'], $translation_texts)) { |
|
| 4345 | + $translation_texts[] = $labels['add_new']; |
|
| 4346 | + } |
|
| 4347 | + if ($labels['add_new_item'] != '' && !in_array($labels['add_new_item'], $translation_texts)) { |
|
| 4348 | + $translation_texts[] = $labels['add_new_item']; |
|
| 4349 | + } |
|
| 4350 | + if ($labels['edit_item'] != '' && !in_array($labels['edit_item'], $translation_texts)) { |
|
| 4351 | + $translation_texts[] = $labels['edit_item']; |
|
| 4352 | + } |
|
| 4353 | + if ($labels['new_item'] != '' && !in_array($labels['new_item'], $translation_texts)) { |
|
| 4354 | + $translation_texts[] = $labels['new_item']; |
|
| 4355 | + } |
|
| 4356 | + if ($labels['view_item'] != '' && !in_array($labels['view_item'], $translation_texts)) { |
|
| 4357 | + $translation_texts[] = $labels['view_item']; |
|
| 4358 | + } |
|
| 4359 | + if ($labels['search_items'] != '' && !in_array($labels['search_items'], $translation_texts)) { |
|
| 4360 | + $translation_texts[] = $labels['search_items']; |
|
| 4361 | + } |
|
| 4362 | + if ($labels['not_found'] != '' && !in_array($labels['not_found'], $translation_texts)) { |
|
| 4363 | + $translation_texts[] = $labels['not_found']; |
|
| 4364 | + } |
|
| 4365 | + if ($labels['not_found_in_trash'] != '' && !in_array($labels['not_found_in_trash'], $translation_texts)) { |
|
| 4366 | + $translation_texts[] = $labels['not_found_in_trash']; |
|
| 4367 | + } |
|
| 4368 | + if (isset($labels['label_post_profile']) && $labels['label_post_profile'] != '' && !in_array($labels['label_post_profile'], $translation_texts)) { |
|
| 4369 | + $translation_texts[] = $labels['label_post_profile']; |
|
| 4370 | + } |
|
| 4371 | + if (isset($labels['label_post_info']) && $labels['label_post_info'] != '' && !in_array($labels['label_post_info'], $translation_texts)) { |
|
| 4372 | + $translation_texts[] = $labels['label_post_info']; |
|
| 4373 | + } |
|
| 4374 | + if (isset($labels['label_post_images']) && $labels['label_post_images'] != '' && !in_array($labels['label_post_images'], $translation_texts)) { |
|
| 4375 | + $translation_texts[] = $labels['label_post_images']; |
|
| 4376 | + } |
|
| 4377 | + if (isset($labels['label_post_map']) && $labels['label_post_map'] != '' && !in_array($labels['label_post_map'], $translation_texts)) { |
|
| 4378 | + $translation_texts[] = $labels['label_post_map']; |
|
| 4379 | + } |
|
| 4380 | + if (isset($labels['label_reviews']) && $labels['label_reviews'] != '' && !in_array($labels['label_reviews'], $translation_texts)) { |
|
| 4381 | + $translation_texts[] = $labels['label_reviews']; |
|
| 4382 | + } |
|
| 4383 | + if (isset($labels['label_related_listing']) && $labels['label_related_listing'] != '' && !in_array($labels['label_related_listing'], $translation_texts)) { |
|
| 4384 | + $translation_texts[] = $labels['label_related_listing']; |
|
| 4385 | + } |
|
| 4311 | 4386 | } |
| 4312 | 4387 | |
| 4313 | 4388 | if ($description != '' && !in_array($description, $translation_texts)) {
|
@@ -4315,11 +4390,13 @@ discard block |
||
| 4315 | 4390 | } |
| 4316 | 4391 | |
| 4317 | 4392 | if (!empty($seo)) {
|
| 4318 | - if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) |
|
| 4319 | - $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4393 | + if (isset($seo['meta_keyword']) && $seo['meta_keyword'] != '' && !in_array($seo['meta_keyword'], $translation_texts)) { |
|
| 4394 | + $translation_texts[] = normalize_whitespace($seo['meta_keyword']); |
|
| 4395 | + } |
|
| 4320 | 4396 | |
| 4321 | - if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) |
|
| 4322 | - $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4397 | + if (isset($seo['meta_description']) && $seo['meta_description'] != '' && !in_array($seo['meta_description'], $translation_texts)) { |
|
| 4398 | + $translation_texts[] = normalize_whitespace($seo['meta_description']); |
|
| 4399 | + } |
|
| 4323 | 4400 | } |
| 4324 | 4401 | } |
| 4325 | 4402 | } |
@@ -4345,16 +4422,20 @@ discard block |
||
| 4345 | 4422 | $hide_region_part = get_option('geodir_location_hide_region_part');
|
| 4346 | 4423 | |
| 4347 | 4424 | if ($hide_region_part && $hide_country_part) {
|
| 4348 | - if (isset($location_terms['gd_country'])) |
|
| 4349 | - unset($location_terms['gd_country']); |
|
| 4350 | - if (isset($location_terms['gd_region'])) |
|
| 4351 | - unset($location_terms['gd_region']); |
|
| 4425 | + if (isset($location_terms['gd_country'])) { |
|
| 4426 | + unset($location_terms['gd_country']); |
|
| 4427 | + } |
|
| 4428 | + if (isset($location_terms['gd_region'])) { |
|
| 4429 | + unset($location_terms['gd_region']); |
|
| 4430 | + } |
|
| 4352 | 4431 | } else if ($hide_region_part && !$hide_country_part) {
|
| 4353 | - if (isset($location_terms['gd_region'])) |
|
| 4354 | - unset($location_terms['gd_region']); |
|
| 4432 | + if (isset($location_terms['gd_region'])) { |
|
| 4433 | + unset($location_terms['gd_region']); |
|
| 4434 | + } |
|
| 4355 | 4435 | } else if (!$hide_region_part && $hide_country_part) {
|
| 4356 | - if (isset($location_terms['gd_country'])) |
|
| 4357 | - unset($location_terms['gd_country']); |
|
| 4436 | + if (isset($location_terms['gd_country'])) { |
|
| 4437 | + unset($location_terms['gd_country']); |
|
| 4438 | + } |
|
| 4358 | 4439 | } |
| 4359 | 4440 | } |
| 4360 | 4441 | |
@@ -156,7 +156,7 @@ discard block |
||
| 156 | 156 | |
| 157 | 157 | $add_listing_link = get_page_link(geodir_add_listing_page_id()); |
| 158 | 158 | |
| 159 | - return esc_url( add_query_arg(array('listing_type' => $post_type), $add_listing_link) );
|
|
| 159 | + return esc_url(add_query_arg(array('listing_type' => $post_type), $add_listing_link));
|
|
| 160 | 160 | } else |
| 161 | 161 | return get_bloginfo('url');
|
| 162 | 162 | } |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | function geodir_is_page($gdpage = '') |
| 249 | 249 | {
|
| 250 | 250 | |
| 251 | - global $wp_query, $post,$wp; |
|
| 251 | + global $wp_query, $post, $wp; |
|
| 252 | 252 | //if(!is_admin()): |
| 253 | 253 | |
| 254 | 254 | switch ($gdpage): |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | if (is_author() && isset($_REQUEST['geodir_dashbord'])) |
| 305 | 305 | return true; |
| 306 | 306 | |
| 307 | - if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int)bp_loggedin_user_id()) {
|
|
| 308 | - if (((bool)bp_is_current_component('listings') || (bool)bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int)bp_displayed_user_id()) {
|
|
| 307 | + if (function_exists('bp_loggedin_user_id') && function_exists('bp_displayed_user_id') && $my_id = (int) bp_loggedin_user_id()) {
|
|
| 308 | + if (((bool) bp_is_current_component('listings') || (bool) bp_is_current_component('favorites')) && $my_id > 0 && $my_id == (int) bp_displayed_user_id()) {
|
|
| 309 | 309 | return true; |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -358,7 +358,7 @@ discard block |
||
| 358 | 358 | if (empty($wp->query_vars) || !array_diff(array_keys($wp->query_vars), array('preview', 'page', 'paged', 'cpage'))) {
|
| 359 | 359 | if (get_option('geodir_set_as_home'))
|
| 360 | 360 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 361 | - if(geodir_is_page('home')){
|
|
| 361 | + if (geodir_is_page('home')) {
|
|
| 362 | 362 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 363 | 363 | } |
| 364 | 364 | |
@@ -427,10 +427,10 @@ discard block |
||
| 427 | 427 | |
| 428 | 428 | |
| 429 | 429 | //check if homepage |
| 430 | - if(!isset($wp->query_vars['gd_is_geodir_page']) |
|
| 430 | + if (!isset($wp->query_vars['gd_is_geodir_page']) |
|
| 431 | 431 | && !isset($wp->query_vars['page_id']) |
| 432 | 432 | && !isset($wp->query_vars['pagename']) |
| 433 | - && is_page_geodir_home()){
|
|
| 433 | + && is_page_geodir_home()) {
|
|
| 434 | 434 | $wp->query_vars['gd_is_geodir_page'] = true; |
| 435 | 435 | } |
| 436 | 436 | //echo $wp->query_vars['gd_is_geodir_page'] ; |
@@ -531,7 +531,7 @@ discard block |
||
| 531 | 531 | function createRandomString() |
| 532 | 532 | {
|
| 533 | 533 | $chars = "abcdefghijkmlnopqrstuvwxyz1023456789"; |
| 534 | - srand((double)microtime() * 1000000); |
|
| 534 | + srand((double) microtime() * 1000000); |
|
| 535 | 535 | $i = 0; |
| 536 | 536 | $rstring = ''; |
| 537 | 537 | while ($i <= 25) {
|
@@ -665,11 +665,11 @@ discard block |
||
| 665 | 665 | } |
| 666 | 666 | |
| 667 | 667 | if (!empty($subject)) {
|
| 668 | - $subject = __(stripslashes_deep($subject),'geodirectory'); |
|
| 668 | + $subject = __(stripslashes_deep($subject), 'geodirectory'); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | if (!empty($message)) {
|
| 672 | - $message = __(stripslashes_deep($message),'geodirectory'); |
|
| 672 | + $message = __(stripslashes_deep($message), 'geodirectory'); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | $to_message = nl2br($to_message); |
@@ -704,12 +704,12 @@ discard block |
||
| 704 | 704 | $fromEmailName = get_option('site_email_name');
|
| 705 | 705 | } |
| 706 | 706 | |
| 707 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]');
|
|
| 708 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login); |
|
| 707 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]');
|
|
| 708 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login); |
|
| 709 | 709 | $message = str_replace($search_array, $replace_array, $message); |
| 710 | 710 | |
| 711 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#from_email#]','[#user_login#]','[#username#]');
|
|
| 712 | - $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date,$fromEmail, $user_login, $user_login); |
|
| 711 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#from_email#]', '[#user_login#]', '[#username#]');
|
|
| 712 | + $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $fromEmail, $user_login, $user_login); |
|
| 713 | 713 | $subject = str_replace($search_array, $replace_array, $subject); |
| 714 | 714 | |
| 715 | 715 | $headers = 'MIME-Version: 1.0' . "\r\n"; |
@@ -720,18 +720,18 @@ discard block |
||
| 720 | 720 | $to = $toEmail; |
| 721 | 721 | $sent = wp_mail($to, $subject, $message, $headers); |
| 722 | 722 | |
| 723 | - if( ! $sent ) {
|
|
| 724 | - if ( is_array( $to ) ) {
|
|
| 725 | - $to = implode( ',', $to ); |
|
| 723 | + if (!$sent) {
|
|
| 724 | + if (is_array($to)) {
|
|
| 725 | + $to = implode(',', $to);
|
|
| 726 | 726 | } |
| 727 | 727 | $log_message = sprintf( |
| 728 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 728 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 729 | 729 | $message_type, |
| 730 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 730 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 731 | 731 | $to, |
| 732 | 732 | $subject |
| 733 | 733 | ); |
| 734 | - geodir_error_log( $log_message ); |
|
| 734 | + geodir_error_log($log_message); |
|
| 735 | 735 | } |
| 736 | 736 | |
| 737 | 737 | ///////// ADMIN BCC EMIALS |
@@ -743,11 +743,11 @@ discard block |
||
| 743 | 743 | $subject = __(stripslashes_deep(get_option('geodir_post_submited_success_email_subject_admin')), 'geodirectory');
|
| 744 | 744 | $message = __(stripslashes_deep(get_option('geodir_post_submited_success_email_content_admin')), 'geodirectory');
|
| 745 | 745 | |
| 746 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 746 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#comments#]', '[#login_url#]', '[#login_details#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
|
|
| 747 | 747 | $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $to_message, $loginurl_link, $login_details, $toEmailName, $posted_date, $user_login, $user_login); |
| 748 | 748 | $message = str_replace($search_array, $replace_array, $message); |
| 749 | 749 | |
| 750 | - $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]','[#user_login#]','[#username#]');
|
|
| 750 | + $search_array = array('[#listing_link#]', '[#site_name_url#]', '[#post_id#]', '[#site_name#]', '[#to_name#]', '[#from_name#]', '[#subject#]', '[#client_name#]', '[#posted_date#]', '[#user_login#]', '[#username#]');
|
|
| 751 | 751 | $replace_array = array($listingLink, $siteurl_link, $post_id, $sitefromEmailName, $toEmailName, $fromEmailName, $to_subject, $toEmailName, $posted_date, $user_login, $user_login); |
| 752 | 752 | $subject = str_replace($search_array, $replace_array, $subject); |
| 753 | 753 | |
@@ -772,21 +772,21 @@ discard block |
||
| 772 | 772 | $admin_bcc = true; |
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - if($admin_bcc===true){
|
|
| 775 | + if ($admin_bcc === true) {
|
|
| 776 | 776 | $sent = wp_mail($to, $subject, $message, $headers); |
| 777 | 777 | |
| 778 | - if( ! $sent ) {
|
|
| 779 | - if ( is_array( $to ) ) {
|
|
| 780 | - $to = implode( ',', $to ); |
|
| 778 | + if (!$sent) {
|
|
| 779 | + if (is_array($to)) {
|
|
| 780 | + $to = implode(',', $to);
|
|
| 781 | 781 | } |
| 782 | 782 | $log_message = sprintf( |
| 783 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 783 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 784 | 784 | $message_type, |
| 785 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 785 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 786 | 786 | $to, |
| 787 | 787 | $subject |
| 788 | 788 | ); |
| 789 | - geodir_error_log( $log_message ); |
|
| 789 | + geodir_error_log($log_message); |
|
| 790 | 790 | } |
| 791 | 791 | } |
| 792 | 792 | |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | $location_manager = defined('POST_LOCATION_TABLE') ? true : false;
|
| 882 | 882 | $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
| 883 | 883 | |
| 884 | - if(geodir_is_page('detail') && isset($post->country_slug)){
|
|
| 884 | + if (geodir_is_page('detail') && isset($post->country_slug)) {
|
|
| 885 | 885 | $location_terms = array( |
| 886 | 886 | 'gd_country' => $post->country_slug, |
| 887 | 887 | 'gd_region' => $post->region_slug, |
@@ -1136,7 +1136,7 @@ discard block |
||
| 1136 | 1136 | $breadcrumb .= stripslashes_deep($page_title); |
| 1137 | 1137 | $breadcrumb .= '</li>'; |
| 1138 | 1138 | } else if (is_tag()) {
|
| 1139 | - $breadcrumb .= "<li> " . $separator . single_tag_title('',false) . '</li>';
|
|
| 1139 | + $breadcrumb .= "<li> " . $separator . single_tag_title('', false) . '</li>';
|
|
| 1140 | 1140 | } else if (is_day()) {
|
| 1141 | 1141 | $breadcrumb .= "<li> " . $separator . __(" Archive for", 'geodirectory') . " ";
|
| 1142 | 1142 | the_time('F jS, Y');
|
@@ -1241,16 +1241,16 @@ discard block |
||
| 1241 | 1241 | $log_message = sprintf(__('Remote server returned error response %1$d %2$s', 'geodirectory'), esc_html($headers['response']), get_status_header_desc($headers['response']));
|
| 1242 | 1242 | } |
| 1243 | 1243 | elseif (isset($headers['content-length']) && $filesize != $headers['content-length']) {
|
| 1244 | - $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1244 | + $log_message = __('Remote file is incorrect size', 'geodirectory');
|
|
| 1245 | 1245 | } |
| 1246 | 1246 | elseif (0 == $filesize) {
|
| 1247 | 1247 | $log_message = __('Zero size file downloaded', 'geodirectory');
|
| 1248 | 1248 | } |
| 1249 | 1249 | |
| 1250 | - if($log_message){
|
|
| 1250 | + if ($log_message) {
|
|
| 1251 | 1251 | $del = unlink($upload['file']); |
| 1252 | - if(!$del){geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory'));}
|
|
| 1253 | - return new WP_Error('import_file_error',$log_message );
|
|
| 1252 | + if (!$del) {geodir_error_log(__('GeoDirectory: fetch_remote_file() failed to delete temp file.', 'geodirectory')); }
|
|
| 1253 | + return new WP_Error('import_file_error', $log_message);
|
|
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | 1256 | |
@@ -1266,10 +1266,10 @@ discard block |
||
| 1266 | 1266 | */ |
| 1267 | 1267 | function geodir_max_upload_size() |
| 1268 | 1268 | {
|
| 1269 | - $max_filesize = (float)get_option('geodir_upload_max_filesize', 2);
|
|
| 1269 | + $max_filesize = (float) get_option('geodir_upload_max_filesize', 2);
|
|
| 1270 | 1270 | |
| 1271 | 1271 | if ($max_filesize > 0 && $max_filesize < 1) {
|
| 1272 | - $max_filesize = (int)($max_filesize * 1024) . 'kb'; |
|
| 1272 | + $max_filesize = (int) ($max_filesize * 1024) . 'kb'; |
|
| 1273 | 1273 | } else {
|
| 1274 | 1274 | $max_filesize = $max_filesize > 0 ? $max_filesize . 'mb' : '2mb'; |
| 1275 | 1275 | } |
@@ -1338,35 +1338,35 @@ discard block |
||
| 1338 | 1338 | {
|
| 1339 | 1339 | global $wpdb; |
| 1340 | 1340 | if ($message_type == 'expiration') {
|
| 1341 | - $subject = stripslashes(__(get_option('renew_email_subject'),'geodirectory'));
|
|
| 1342 | - $client_message = stripslashes(__(get_option('renew_email_content'),'geodirectory'));
|
|
| 1341 | + $subject = stripslashes(__(get_option('renew_email_subject'), 'geodirectory'));
|
|
| 1342 | + $client_message = stripslashes(__(get_option('renew_email_content'), 'geodirectory'));
|
|
| 1343 | 1343 | } elseif ($message_type == 'post_submited') {
|
| 1344 | - $subject = __(get_option('post_submited_success_email_subject_admin'),'geodirectory');
|
|
| 1345 | - $client_message = __(get_option('post_submited_success_email_content_admin'),'geodirectory');
|
|
| 1344 | + $subject = __(get_option('post_submited_success_email_subject_admin'), 'geodirectory');
|
|
| 1345 | + $client_message = __(get_option('post_submited_success_email_content_admin'), 'geodirectory');
|
|
| 1346 | 1346 | } elseif ($message_type == 'renew') {
|
| 1347 | - $subject = __(get_option('post_renew_success_email_subject_admin'),'geodirectory');
|
|
| 1348 | - $client_message = __(get_option('post_renew_success_email_content_admin'),'geodirectory');
|
|
| 1347 | + $subject = __(get_option('post_renew_success_email_subject_admin'), 'geodirectory');
|
|
| 1348 | + $client_message = __(get_option('post_renew_success_email_content_admin'), 'geodirectory');
|
|
| 1349 | 1349 | } elseif ($message_type == 'upgrade') {
|
| 1350 | - $subject = __(get_option('post_upgrade_success_email_subject_admin'),'geodirectory');
|
|
| 1351 | - $client_message = __(get_option('post_upgrade_success_email_content_admin'),'geodirectory');
|
|
| 1350 | + $subject = __(get_option('post_upgrade_success_email_subject_admin'), 'geodirectory');
|
|
| 1351 | + $client_message = __(get_option('post_upgrade_success_email_content_admin'), 'geodirectory');
|
|
| 1352 | 1352 | } elseif ($message_type == 'claim_approved') {
|
| 1353 | - $subject = __(get_option('claim_approved_email_subject'),'geodirectory');
|
|
| 1354 | - $client_message = __(get_option('claim_approved_email_content'),'geodirectory');
|
|
| 1353 | + $subject = __(get_option('claim_approved_email_subject'), 'geodirectory');
|
|
| 1354 | + $client_message = __(get_option('claim_approved_email_content'), 'geodirectory');
|
|
| 1355 | 1355 | } elseif ($message_type == 'claim_rejected') {
|
| 1356 | - $subject = __(get_option('claim_rejected_email_subject'),'geodirectory');
|
|
| 1357 | - $client_message = __(get_option('claim_rejected_email_content'),'geodirectory');
|
|
| 1356 | + $subject = __(get_option('claim_rejected_email_subject'), 'geodirectory');
|
|
| 1357 | + $client_message = __(get_option('claim_rejected_email_content'), 'geodirectory');
|
|
| 1358 | 1358 | } elseif ($message_type == 'claim_requested') {
|
| 1359 | - $subject = __(get_option('claim_email_subject_admin'),'geodirectory');
|
|
| 1360 | - $client_message = __(get_option('claim_email_content_admin'),'geodirectory');
|
|
| 1359 | + $subject = __(get_option('claim_email_subject_admin'), 'geodirectory');
|
|
| 1360 | + $client_message = __(get_option('claim_email_content_admin'), 'geodirectory');
|
|
| 1361 | 1361 | } elseif ($message_type == 'auto_claim') {
|
| 1362 | - $subject = __(get_option('auto_claim_email_subject'),'geodirectory');
|
|
| 1363 | - $client_message = __(get_option('auto_claim_email_content'),'geodirectory');
|
|
| 1362 | + $subject = __(get_option('auto_claim_email_subject'), 'geodirectory');
|
|
| 1363 | + $client_message = __(get_option('auto_claim_email_content'), 'geodirectory');
|
|
| 1364 | 1364 | } elseif ($message_type == 'payment_success') {
|
| 1365 | - $subject = __(get_option('post_payment_success_admin_email_subject'),'geodirectory');
|
|
| 1366 | - $client_message = __(get_option('post_payment_success_admin_email_content'),'geodirectory');
|
|
| 1365 | + $subject = __(get_option('post_payment_success_admin_email_subject'), 'geodirectory');
|
|
| 1366 | + $client_message = __(get_option('post_payment_success_admin_email_content'), 'geodirectory');
|
|
| 1367 | 1367 | } elseif ($message_type == 'payment_fail') {
|
| 1368 | - $subject = __(get_option('post_payment_fail_admin_email_subject'),'geodirectory');
|
|
| 1369 | - $client_message = __(get_option('post_payment_fail_admin_email_content'),'geodirectory');
|
|
| 1368 | + $subject = __(get_option('post_payment_fail_admin_email_subject'), 'geodirectory');
|
|
| 1369 | + $client_message = __(get_option('post_payment_fail_admin_email_content'), 'geodirectory');
|
|
| 1370 | 1370 | } |
| 1371 | 1371 | $transaction_details = $custom_1; |
| 1372 | 1372 | $fromEmail = get_option('site_email');
|
@@ -1407,18 +1407,18 @@ discard block |
||
| 1407 | 1407 | $to = $fromEmail; |
| 1408 | 1408 | $message = $client_message; |
| 1409 | 1409 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1410 | - if( ! $sent ) {
|
|
| 1411 | - if ( is_array( $to ) ) {
|
|
| 1412 | - $to = implode( ',', $to ); |
|
| 1410 | + if (!$sent) {
|
|
| 1411 | + if (is_array($to)) {
|
|
| 1412 | + $to = implode(',', $to);
|
|
| 1413 | 1413 | } |
| 1414 | 1414 | $log_message = sprintf( |
| 1415 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1415 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1416 | 1416 | $message_type, |
| 1417 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1417 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1418 | 1418 | $to, |
| 1419 | 1419 | $subject |
| 1420 | 1420 | ); |
| 1421 | - geodir_error_log( $log_message ); |
|
| 1421 | + geodir_error_log($log_message); |
|
| 1422 | 1422 | } |
| 1423 | 1423 | } |
| 1424 | 1424 | } |
@@ -1444,18 +1444,18 @@ discard block |
||
| 1444 | 1444 | {
|
| 1445 | 1445 | $login_details = ''; |
| 1446 | 1446 | if ($message_type == 'send_friend') {
|
| 1447 | - $subject = stripslashes(__(get_option('email_friend_subject'),'geodirectory'));
|
|
| 1448 | - $message = stripslashes(__(get_option('email_friend_content'),'geodirectory'));
|
|
| 1447 | + $subject = stripslashes(__(get_option('email_friend_subject'), 'geodirectory'));
|
|
| 1448 | + $message = stripslashes(__(get_option('email_friend_content'), 'geodirectory'));
|
|
| 1449 | 1449 | } elseif ($message_type == 'send_enquiry') {
|
| 1450 | - $subject = __(get_option('email_enquiry_subject'),'geodirectory');
|
|
| 1451 | - $message = __(get_option('email_enquiry_content'),'geodirectory');
|
|
| 1450 | + $subject = __(get_option('email_enquiry_subject'), 'geodirectory');
|
|
| 1451 | + $message = __(get_option('email_enquiry_content'), 'geodirectory');
|
|
| 1452 | 1452 | } elseif ($message_type == 'forgot_password') {
|
| 1453 | - $subject = __(get_option('forgot_password_subject'),'geodirectory');
|
|
| 1454 | - $message = __(get_option('forgot_password_content'),'geodirectory');
|
|
| 1453 | + $subject = __(get_option('forgot_password_subject'), 'geodirectory');
|
|
| 1454 | + $message = __(get_option('forgot_password_content'), 'geodirectory');
|
|
| 1455 | 1455 | $login_details = $to_message; |
| 1456 | 1456 | } elseif ($message_type == 'registration') {
|
| 1457 | - $subject = __(get_option('registration_success_email_subject'),'geodirectory');
|
|
| 1458 | - $message = __(get_option('registration_success_email_content'),'geodirectory');
|
|
| 1457 | + $subject = __(get_option('registration_success_email_subject'), 'geodirectory');
|
|
| 1458 | + $message = __(get_option('registration_success_email_content'), 'geodirectory');
|
|
| 1459 | 1459 | $login_details = $to_message; |
| 1460 | 1460 | } |
| 1461 | 1461 | $to_message = nl2br($to_message); |
@@ -1489,18 +1489,18 @@ discard block |
||
| 1489 | 1489 | $to = $toEmail; |
| 1490 | 1490 | |
| 1491 | 1491 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1492 | - if( ! $sent ) {
|
|
| 1493 | - if ( is_array( $to ) ) {
|
|
| 1494 | - $to = implode( ',', $to ); |
|
| 1492 | + if (!$sent) {
|
|
| 1493 | + if (is_array($to)) {
|
|
| 1494 | + $to = implode(',', $to);
|
|
| 1495 | 1495 | } |
| 1496 | 1496 | $log_message = sprintf( |
| 1497 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1497 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1498 | 1498 | $message_type, |
| 1499 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1499 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1500 | 1500 | $to, |
| 1501 | 1501 | $subject |
| 1502 | 1502 | ); |
| 1503 | - geodir_error_log( $log_message ); |
|
| 1503 | + geodir_error_log($log_message); |
|
| 1504 | 1504 | } |
| 1505 | 1505 | |
| 1506 | 1506 | ///////// ADMIN BCC EMIALS |
@@ -1526,20 +1526,20 @@ discard block |
||
| 1526 | 1526 | $admin_bcc = true; |
| 1527 | 1527 | } |
| 1528 | 1528 | |
| 1529 | - if($admin_bcc === true){
|
|
| 1529 | + if ($admin_bcc === true) {
|
|
| 1530 | 1530 | $sent = wp_mail($to, $subject, $message, $headers); |
| 1531 | - if( ! $sent ) {
|
|
| 1532 | - if ( is_array( $to ) ) {
|
|
| 1533 | - $to = implode( ',', $to ); |
|
| 1531 | + if (!$sent) {
|
|
| 1532 | + if (is_array($to)) {
|
|
| 1533 | + $to = implode(',', $to);
|
|
| 1534 | 1534 | } |
| 1535 | 1535 | $log_message = sprintf( |
| 1536 | - __( "Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory' ), |
|
| 1536 | + __("Email from GeoDirectory failed to send.\nMessage type: %s\nSend time: %s\nTo: %s\nSubject: %s\n\n", 'geodirectory'),
|
|
| 1537 | 1537 | $message_type, |
| 1538 | - date_i18n( 'F j Y H:i:s', current_time( 'timestamp' ) ), |
|
| 1538 | + date_i18n('F j Y H:i:s', current_time('timestamp')),
|
|
| 1539 | 1539 | $to, |
| 1540 | 1540 | $subject |
| 1541 | 1541 | ); |
| 1542 | - geodir_error_log( $log_message ); |
|
| 1542 | + geodir_error_log($log_message); |
|
| 1543 | 1543 | } |
| 1544 | 1544 | } |
| 1545 | 1545 | |
@@ -1587,7 +1587,7 @@ discard block |
||
| 1587 | 1587 | function geodir_custom_posts_body_class($classes) {
|
| 1588 | 1588 | global $wpdb, $wp; |
| 1589 | 1589 | $post_types = geodir_get_posttypes('object');
|
| 1590 | - if (!empty($post_types) && count((array)$post_types) > 1) {
|
|
| 1590 | + if (!empty($post_types) && count((array) $post_types) > 1) {
|
|
| 1591 | 1591 | $classes[] = 'geodir_custom_posts'; |
| 1592 | 1592 | } |
| 1593 | 1593 | |
@@ -1881,7 +1881,7 @@ discard block |
||
| 1881 | 1881 | $sql = "SELECT COUNT(" . $wpdb->posts . ".ID) AS total FROM " . $wpdb->posts . "
|
| 1882 | 1882 | " . $join . " |
| 1883 | 1883 | " . $where; |
| 1884 | - $rows = (int)$wpdb->get_var($sql); |
|
| 1884 | + $rows = (int) $wpdb->get_var($sql); |
|
| 1885 | 1885 | } else {
|
| 1886 | 1886 | $orderby = geodir_widget_listings_get_order($query_args); |
| 1887 | 1887 | /** |
@@ -1907,10 +1907,10 @@ discard block |
||
| 1907 | 1907 | $limit = apply_filters('geodir_filter_widget_listings_limit', $limit, $post_type);
|
| 1908 | 1908 | |
| 1909 | 1909 | $page = !empty($query_args['pageno']) ? absint($query_args['pageno']) : 1; |
| 1910 | - if ( !$page ) |
|
| 1910 | + if (!$page) |
|
| 1911 | 1911 | $page = 1; |
| 1912 | 1912 | |
| 1913 | - $limit = (int)$limit > 0 ? " LIMIT " . absint( ( $page - 1 ) * (int)$limit ) . ", " . (int)$limit : ""; |
|
| 1913 | + $limit = (int) $limit > 0 ? " LIMIT " . absint(($page - 1) * (int) $limit) . ", " . (int) $limit : ""; |
|
| 1914 | 1914 | |
| 1915 | 1915 | $sql = "SELECT SQL_CALC_FOUND_ROWS " . $fields . " FROM " . $wpdb->posts . " |
| 1916 | 1916 | " . $join . " |
@@ -2107,7 +2107,7 @@ discard block |
||
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | if (!empty($query_args) && !empty($query_args['posts_per_page'])) {
|
| 2110 | - $limit = (int)$query_args['posts_per_page']; |
|
| 2110 | + $limit = (int) $query_args['posts_per_page']; |
|
| 2111 | 2111 | } |
| 2112 | 2112 | |
| 2113 | 2113 | return $limit; |
@@ -2250,9 +2250,9 @@ discard block |
||
| 2250 | 2250 | add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
| 2251 | 2251 | } |
| 2252 | 2252 | $home_url = str_replace("www.", "", $home_url);
|
| 2253 | - if ( (strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')) ) {
|
|
| 2253 | + if ((strpos($home_url, $cur_url) !== false || strpos($home_url . '/', $cur_url) !== false) && ('page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page'))) {
|
|
| 2254 | 2254 | return true; |
| 2255 | - }elseif(get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front')==get_option('geodir_home_page')){
|
|
| 2255 | + }elseif (get_query_var('page_id') == get_option('page_on_front') && 'page' == get_option('show_on_front') && get_option('page_on_front') && get_option('page_on_front') == get_option('geodir_home_page')) {
|
|
| 2256 | 2256 | return true; |
| 2257 | 2257 | } else {
|
| 2258 | 2258 | return false; |
@@ -2335,7 +2335,7 @@ discard block |
||
| 2335 | 2335 | |
| 2336 | 2336 | $gd_post_type = geodir_get_current_posttype(); |
| 2337 | 2337 | |
| 2338 | - $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int)$instance['category_limit'] : 15; |
|
| 2338 | + $category_limit = isset($instance['category_limit']) && $instance['category_limit'] > 0 ? (int) $instance['category_limit'] : 15; |
|
| 2339 | 2339 | $default_post_type = !empty($gd_post_type) ? $gd_post_type : (isset($instance['default_post_type']) && gdsc_is_post_type_valid($instance['default_post_type']) ? $instance['default_post_type'] : ''); |
| 2340 | 2340 | |
| 2341 | 2341 | $taxonomy = array(); |
@@ -2368,14 +2368,14 @@ discard block |
||
| 2368 | 2368 | foreach ($b_terms as $key => $val) {
|
| 2369 | 2369 | $ptype = get_post_type_object(str_replace("category", "", $key));
|
| 2370 | 2370 | $cpt_name = __($ptype->labels->singular_name, 'geodirectory'); |
| 2371 | - $tax_change_output .= "<option value='$key' ". selected($key, $default_taxonomy, false) .">" . sprintf(__('%s Categories', 'geodirectory'),$cpt_name) . "</option>";
|
|
| 2371 | + $tax_change_output .= "<option value='$key' " . selected($key, $default_taxonomy, false) . ">" . sprintf(__('%s Categories', 'geodirectory'), $cpt_name) . "</option>";
|
|
| 2372 | 2372 | } |
| 2373 | 2373 | $tax_change_output .= "</select>"; |
| 2374 | 2374 | } |
| 2375 | 2375 | |
| 2376 | 2376 | if (!empty($b_terms)) {
|
| 2377 | - $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms);// get the first array |
|
| 2378 | - global $cat_count;//make global so we can change via function |
|
| 2377 | + $terms = $default_taxonomy != '' && isset($b_terms[$default_taxonomy]) ? $b_terms[$default_taxonomy] : reset($b_terms); // get the first array |
|
| 2378 | + global $cat_count; //make global so we can change via function |
|
| 2379 | 2379 | $cat_count = 0; |
| 2380 | 2380 | ?> |
| 2381 | 2381 | <div class="geodir-category-list-in clearfix"> |
@@ -2439,7 +2439,7 @@ discard block |
||
| 2439 | 2439 | $class_row = $cat_count > $category_limit ? 'geodir-pcat-hide geodir-hide' : 'geodir-pcat-show'; |
| 2440 | 2440 | $total_post = $cat->count; |
| 2441 | 2441 | |
| 2442 | - $term_link = get_term_link( $cat, $cat->taxonomy ); |
|
| 2442 | + $term_link = get_term_link($cat, $cat->taxonomy); |
|
| 2443 | 2443 | /** |
| 2444 | 2444 | * Filer the category term link. |
| 2445 | 2445 | * |
@@ -2448,7 +2448,7 @@ discard block |
||
| 2448 | 2448 | * @param int $cat->term_id The term id. |
| 2449 | 2449 | * @param string $post_type Wordpress post type. |
| 2450 | 2450 | */ |
| 2451 | - $term_link = apply_filters( 'geodir_category_term_link', $term_link, $cat->term_id, $post_type ); |
|
| 2451 | + $term_link = apply_filters('geodir_category_term_link', $term_link, $cat->term_id, $post_type);
|
|
| 2452 | 2452 | |
| 2453 | 2453 | echo '<li class="' . $class_row . '"><a href="' . $term_link . '">'; |
| 2454 | 2454 | echo '<img alt="' . esc_attr($cat->name) . ' icon" style="height:20px;vertical-align:middle;" src="' . $term_icon_url . '"/> <span class="cat-link">'; echo geodir_ucwords($cat->name) . '</span> <span class="geodir_term_class geodir_link_span geodir_category_class_' . $post_type . '_' . $cat->term_id . '">(' . $total_post . ')</span> ';
|
@@ -2582,28 +2582,28 @@ discard block |
||
| 2582 | 2582 | itemWidth: 75, |
| 2583 | 2583 | itemMargin: 5, |
| 2584 | 2584 | asNavFor: '#geodir_widget_slider', |
| 2585 | - rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 2585 | + rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 2586 | 2586 | }); |
| 2587 | 2587 | |
| 2588 | 2588 | jQuery('#geodir_widget_slider').flexslider({
|
| 2589 | - animation: "<?php echo $animation;?>", |
|
| 2589 | + animation: "<?php echo $animation; ?>", |
|
| 2590 | 2590 | selector: ".geodir-slides > li", |
| 2591 | 2591 | namespace: "geodir-", |
| 2592 | 2592 | controlNav: true, |
| 2593 | - animationLoop: <?php echo $animationLoop;?>, |
|
| 2594 | - slideshow: <?php echo $slideshow;?>, |
|
| 2595 | - slideshowSpeed: <?php echo $slideshowSpeed;?>, |
|
| 2596 | - animationSpeed: <?php echo $animationSpeed;?>, |
|
| 2597 | - directionNav: <?php echo $directionNav;?>, |
|
| 2598 | - maxItems: <?php echo $max_show;?>, |
|
| 2599 | - <?php if($slide_width){ echo "itemWidth: ".$slide_width.",";}?>
|
|
| 2593 | + animationLoop: <?php echo $animationLoop; ?>, |
|
| 2594 | + slideshow: <?php echo $slideshow; ?>, |
|
| 2595 | + slideshowSpeed: <?php echo $slideshowSpeed; ?>, |
|
| 2596 | + animationSpeed: <?php echo $animationSpeed; ?>, |
|
| 2597 | + directionNav: <?php echo $directionNav; ?>, |
|
| 2598 | + maxItems: <?php echo $max_show; ?>, |
|
| 2599 | + <?php if ($slide_width) { echo "itemWidth: " . $slide_width . ","; }?>
|
|
| 2600 | 2600 | sync: "#geodir_widget_carousel", |
| 2601 | 2601 | start: function (slider) {
|
| 2602 | 2602 | jQuery('.geodir-listing-flex-loader').hide();
|
| 2603 | 2603 | jQuery('#geodir_widget_slider').css({'visibility': 'visible'});
|
| 2604 | 2604 | jQuery('#geodir_widget_carousel').css({'visibility': 'visible'});
|
| 2605 | 2605 | }, |
| 2606 | - rtl: <?php echo ( is_rtl() ? 'true' : 'false' ); /* fix rtl issue */ ?> |
|
| 2606 | + rtl: <?php echo (is_rtl() ? 'true' : 'false'); /* fix rtl issue */ ?> |
|
| 2607 | 2607 | }); |
| 2608 | 2608 | }); |
| 2609 | 2609 | </script> |
@@ -2644,7 +2644,7 @@ discard block |
||
| 2644 | 2644 | |
| 2645 | 2645 | global $post; |
| 2646 | 2646 | |
| 2647 | - $current_post = $post;// keep current post info |
|
| 2647 | + $current_post = $post; // keep current post info |
|
| 2648 | 2648 | |
| 2649 | 2649 | $widget_main_slides = ''; |
| 2650 | 2650 | $nav_slides = ''; |
@@ -3087,7 +3087,7 @@ discard block |
||
| 3087 | 3087 | $geodir_add_location_url = '1'; |
| 3088 | 3088 | } |
| 3089 | 3089 | |
| 3090 | - $viewall_url = get_term_link((int)$category[0], $post_type . 'category'); |
|
| 3090 | + $viewall_url = get_term_link((int) $category[0], $post_type . 'category'); |
|
| 3091 | 3091 | |
| 3092 | 3092 | $geodir_add_location_url = NULL; |
| 3093 | 3093 | } |
@@ -3095,7 +3095,7 @@ discard block |
||
| 3095 | 3095 | $gd_session->set('gd_multi_location', 1);
|
| 3096 | 3096 | } |
| 3097 | 3097 | |
| 3098 | - if(is_wp_error( $viewall_url )){$viewall_url = '';}
|
|
| 3098 | + if (is_wp_error($viewall_url)) {$viewall_url = ''; }
|
|
| 3099 | 3099 | |
| 3100 | 3100 | $query_args = array( |
| 3101 | 3101 | 'posts_per_page' => $post_number, |
@@ -3333,14 +3333,14 @@ discard block |
||
| 3333 | 3333 | * @package GeoDirectory |
| 3334 | 3334 | * @return bool |
| 3335 | 3335 | */ |
| 3336 | -function geodir_term_review_count_force_update($new_status, $old_status='', $post='') |
|
| 3336 | +function geodir_term_review_count_force_update($new_status, $old_status = '', $post = '') |
|
| 3337 | 3337 | {
|
| 3338 | - if(isset($_REQUEST['action']) && $_REQUEST['action']=='geodir_import_export'){return;}//do not run if importing listings
|
|
| 3338 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'geodir_import_export') {return; }//do not run if importing listings
|
|
| 3339 | 3339 | |
| 3340 | - if(isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')){
|
|
| 3340 | + if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
|
|
| 3341 | 3341 | return; |
| 3342 | 3342 | } |
| 3343 | - if($new_status!=$old_status) {
|
|
| 3343 | + if ($new_status != $old_status) {
|
|
| 3344 | 3344 | geodir_count_reviews_by_terms(true); |
| 3345 | 3345 | } |
| 3346 | 3346 | return true; |
@@ -3505,7 +3505,7 @@ discard block |
||
| 3505 | 3505 | */ |
| 3506 | 3506 | try {
|
| 3507 | 3507 | require_once($language_file); |
| 3508 | - } catch(Exception $e) {
|
|
| 3508 | + } catch (Exception $e) {
|
|
| 3509 | 3509 | error_log('Language Error: ' . $e->getMessage());
|
| 3510 | 3510 | } |
| 3511 | 3511 | } |
@@ -3523,18 +3523,18 @@ discard block |
||
| 3523 | 3523 | */ |
| 3524 | 3524 | function geodirectory_load_db_language() {
|
| 3525 | 3525 | global $wp_filesystem; |
| 3526 | - if( empty( $wp_filesystem ) ) {
|
|
| 3527 | - require_once( ABSPATH .'/wp-admin/includes/file.php' ); |
|
| 3526 | + if (empty($wp_filesystem)) {
|
|
| 3527 | + require_once(ABSPATH . '/wp-admin/includes/file.php'); |
|
| 3528 | 3528 | WP_Filesystem(); |
| 3529 | 3529 | global $wp_filesystem; |
| 3530 | 3530 | } |
| 3531 | 3531 | |
| 3532 | 3532 | $language_file = geodir_plugin_path() . '/db-language.php'; |
| 3533 | 3533 | |
| 3534 | - if(is_file($language_file) && !is_writable($language_file)) |
|
| 3534 | + if (is_file($language_file) && !is_writable($language_file)) |
|
| 3535 | 3535 | return false; // Not possible to create. |
| 3536 | 3536 | |
| 3537 | - if(!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3537 | + if (!is_file($language_file) && !is_writable(dirname($language_file))) |
|
| 3538 | 3538 | return false; // Not possible to create. |
| 3539 | 3539 | |
| 3540 | 3540 | $contents_strings = array(); |
@@ -3568,7 +3568,7 @@ discard block |
||
| 3568 | 3568 | $contents = implode(PHP_EOL, $contents_head); |
| 3569 | 3569 | |
| 3570 | 3570 | if (!empty($contents_strings)) {
|
| 3571 | - foreach ( $contents_strings as $string ) {
|
|
| 3571 | + foreach ($contents_strings as $string) {
|
|
| 3572 | 3572 | if (is_scalar($string) && $string != '') {
|
| 3573 | 3573 | $string = str_replace("'", "\'", $string);
|
| 3574 | 3574 | $contents .= PHP_EOL . "__('" . $string . "', 'geodirectory');";
|
@@ -3578,7 +3578,7 @@ discard block |
||
| 3578 | 3578 | |
| 3579 | 3579 | $contents .= implode(PHP_EOL, $contents_foot); |
| 3580 | 3580 | |
| 3581 | - if($wp_filesystem->put_contents( $language_file, $contents, FS_CHMOD_FILE)) |
|
| 3581 | + if ($wp_filesystem->put_contents($language_file, $contents, FS_CHMOD_FILE)) |
|
| 3582 | 3582 | return false; // Failure; could not write file. |
| 3583 | 3583 | |
| 3584 | 3584 | return true; |
@@ -3604,7 +3604,7 @@ discard block |
||
| 3604 | 3604 | $rows = $wpdb->get_results($sql); |
| 3605 | 3605 | |
| 3606 | 3606 | if (!empty($rows)) {
|
| 3607 | - foreach($rows as $row) {
|
|
| 3607 | + foreach ($rows as $row) {
|
|
| 3608 | 3608 | if (!empty($row->admin_title)) |
| 3609 | 3609 | $translation_texts[] = stripslashes_deep($row->admin_title); |
| 3610 | 3610 | |
@@ -3642,7 +3642,7 @@ discard block |
||
| 3642 | 3642 | $rows = $wpdb->get_results($sql); |
| 3643 | 3643 | |
| 3644 | 3644 | if (!empty($rows)) {
|
| 3645 | - foreach($rows as $row) {
|
|
| 3645 | + foreach ($rows as $row) {
|
|
| 3646 | 3646 | if (!empty($row->site_title)) |
| 3647 | 3647 | $translation_texts[] = stripslashes_deep($row->site_title); |
| 3648 | 3648 | |
@@ -3660,7 +3660,7 @@ discard block |
||
| 3660 | 3660 | $rows = $wpdb->get_results($sql); |
| 3661 | 3661 | |
| 3662 | 3662 | if (!empty($rows)) {
|
| 3663 | - foreach($rows as $row) {
|
|
| 3663 | + foreach ($rows as $row) {
|
|
| 3664 | 3664 | if (!empty($row->field_site_name)) |
| 3665 | 3665 | $translation_texts[] = stripslashes_deep($row->field_site_name); |
| 3666 | 3666 | |
@@ -3695,7 +3695,7 @@ discard block |
||
| 3695 | 3695 | * |
| 3696 | 3696 | * @param array $geodir_allowed_mime_types and file extensions. |
| 3697 | 3697 | */ |
| 3698 | - return apply_filters( 'geodir_allowed_mime_types', array( |
|
| 3698 | + return apply_filters('geodir_allowed_mime_types', array(
|
|
| 3699 | 3699 | 'Image' => array( // Image formats. |
| 3700 | 3700 | 'jpg' => 'image/jpeg', |
| 3701 | 3701 | 'jpe' => 'image/jpeg', |
@@ -3784,13 +3784,13 @@ discard block |
||
| 3784 | 3784 | |
| 3785 | 3785 | |
| 3786 | 3786 | |
| 3787 | -add_filter('wpseo_replacements','geodir_wpseo_replacements',10,1);
|
|
| 3787 | +add_filter('wpseo_replacements', 'geodir_wpseo_replacements', 10, 1);
|
|
| 3788 | 3788 | /* |
| 3789 | 3789 | * Add location variables to wpseo replacements. |
| 3790 | 3790 | * |
| 3791 | 3791 | * @since 1.5.4 |
| 3792 | 3792 | */ |
| 3793 | -function geodir_wpseo_replacements($vars){
|
|
| 3793 | +function geodir_wpseo_replacements($vars) {
|
|
| 3794 | 3794 | |
| 3795 | 3795 | global $wp; |
| 3796 | 3796 | $title = ''; |
@@ -3805,12 +3805,12 @@ discard block |
||
| 3805 | 3805 | * @param array $location_array The array of location variables. |
| 3806 | 3806 | * @param array $vars The page title variables. |
| 3807 | 3807 | */ |
| 3808 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo',$location_array, $vars);
|
|
| 3808 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr_seo', $location_array, $vars);
|
|
| 3809 | 3809 | $location_titles = array(); |
| 3810 | - if(get_query_var( 'gd_country_full' )){
|
|
| 3811 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 3812 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 3813 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 3810 | + if (get_query_var('gd_country_full')) {
|
|
| 3811 | + if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
|
|
| 3812 | + if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
|
|
| 3813 | + if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
|
|
| 3814 | 3814 | } |
| 3815 | 3815 | $location_single = ''; |
| 3816 | 3816 | $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
@@ -3882,23 +3882,23 @@ discard block |
||
| 3882 | 3882 | } |
| 3883 | 3883 | |
| 3884 | 3884 | |
| 3885 | - if(!empty($location_titles)) {
|
|
| 3885 | + if (!empty($location_titles)) {
|
|
| 3886 | 3886 | $vars['%%location%%'] = implode(", ", $location_titles);
|
| 3887 | 3887 | } |
| 3888 | 3888 | |
| 3889 | 3889 | |
| 3890 | - if(!empty($location_titles)) {
|
|
| 3890 | + if (!empty($location_titles)) {
|
|
| 3891 | 3891 | $vars['%%in_location%%'] = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
| 3892 | 3892 | } |
| 3893 | 3893 | |
| 3894 | 3894 | |
| 3895 | 3895 | |
| 3896 | - if($location_single) {
|
|
| 3897 | - $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 3896 | + if ($location_single) {
|
|
| 3897 | + $vars['%%in_location_single%%'] = __('in', 'geodirectory') . ' ' . $location_single;
|
|
| 3898 | 3898 | } |
| 3899 | 3899 | |
| 3900 | 3900 | |
| 3901 | - if($location_single) {
|
|
| 3901 | + if ($location_single) {
|
|
| 3902 | 3902 | $vars['%%location_single%%'] = $location_single; |
| 3903 | 3903 | } |
| 3904 | 3904 | |
@@ -3910,17 +3910,17 @@ discard block |
||
| 3910 | 3910 | * @param string $vars The title with variables. |
| 3911 | 3911 | * @param array $location_array The array of location variables. |
| 3912 | 3912 | */ |
| 3913 | - return apply_filters('geodir_wpseo_replacements_vars',$vars,$location_array);
|
|
| 3913 | + return apply_filters('geodir_wpseo_replacements_vars', $vars, $location_array);
|
|
| 3914 | 3914 | } |
| 3915 | 3915 | |
| 3916 | 3916 | |
| 3917 | -add_filter('geodir_seo_meta_title','geodir_filter_title_variables',10,3);
|
|
| 3918 | -add_filter('geodir_seo_page_title','geodir_filter_title_variables',10,2);
|
|
| 3919 | -add_filter('geodir_seo_meta_description_pre','geodir_filter_title_variables',10,3);
|
|
| 3920 | -function geodir_filter_title_variables($title, $gd_page, $sep=''){
|
|
| 3917 | +add_filter('geodir_seo_meta_title', 'geodir_filter_title_variables', 10, 3);
|
|
| 3918 | +add_filter('geodir_seo_page_title', 'geodir_filter_title_variables', 10, 2);
|
|
| 3919 | +add_filter('geodir_seo_meta_description_pre', 'geodir_filter_title_variables', 10, 3);
|
|
| 3920 | +function geodir_filter_title_variables($title, $gd_page, $sep = '') {
|
|
| 3921 | 3921 | |
| 3922 | 3922 | |
| 3923 | - if(!$gd_page || !$title){return $title;}// if no a GD page then bail.
|
|
| 3923 | + if (!$gd_page || !$title) {return $title; }// if no a GD page then bail.
|
|
| 3924 | 3924 | global $post; |
| 3925 | 3925 | //print_r($post); |
| 3926 | 3926 | /* |
@@ -3962,119 +3962,119 @@ discard block |
||
| 3962 | 3962 | } |
| 3963 | 3963 | |
| 3964 | 3964 | |
| 3965 | - if(strpos($title,'%%title%%') !== false){
|
|
| 3966 | - $title = str_replace("%%title%%",$post->post_title,$title);
|
|
| 3965 | + if (strpos($title, '%%title%%') !== false) {
|
|
| 3966 | + $title = str_replace("%%title%%", $post->post_title, $title);
|
|
| 3967 | 3967 | } |
| 3968 | 3968 | |
| 3969 | - if(strpos($title,'%%sitename%%') !== false){
|
|
| 3970 | - $title = str_replace("%%sitename%%",get_bloginfo('name'),$title);
|
|
| 3969 | + if (strpos($title, '%%sitename%%') !== false) {
|
|
| 3970 | + $title = str_replace("%%sitename%%", get_bloginfo('name'), $title);
|
|
| 3971 | 3971 | } |
| 3972 | 3972 | |
| 3973 | - if(strpos($title,'%%sitedesc%%') !== false){
|
|
| 3974 | - $title = str_replace("%%sitedesc%%",get_bloginfo('description'),$title);
|
|
| 3973 | + if (strpos($title, '%%sitedesc%%') !== false) {
|
|
| 3974 | + $title = str_replace("%%sitedesc%%", get_bloginfo('description'), $title);
|
|
| 3975 | 3975 | } |
| 3976 | 3976 | |
| 3977 | - if(strpos($title,'%%excerpt%%') !== false){
|
|
| 3978 | - $title = str_replace("%%excerpt%%",strip_tags(get_the_excerpt()),$title);
|
|
| 3977 | + if (strpos($title, '%%excerpt%%') !== false) {
|
|
| 3978 | + $title = str_replace("%%excerpt%%", strip_tags(get_the_excerpt()), $title);
|
|
| 3979 | 3979 | } |
| 3980 | 3980 | |
| 3981 | - if(strpos($title,'%%pt_single%%') !== false){
|
|
| 3981 | + if (strpos($title, '%%pt_single%%') !== false) {
|
|
| 3982 | 3982 | $single_name = ''; |
| 3983 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 3983 | + if ($gd_page == 'search' || $gd_page == 'author') {
|
|
| 3984 | 3984 | $geodir_post_types = get_option('geodir_post_types');
|
| 3985 | 3985 | $spt = esc_attr($_REQUEST['stype']); |
| 3986 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 3987 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 3986 | + if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
|
|
| 3987 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); |
|
| 3988 | 3988 | } |
| 3989 | - }elseif($gd_page=='add-listing'){
|
|
| 3989 | + }elseif ($gd_page == 'add-listing') {
|
|
| 3990 | 3990 | $geodir_post_types = get_option('geodir_post_types');
|
| 3991 | 3991 | $spt = isset($_REQUEST['listing_type']) ? esc_attr($_REQUEST['listing_type']) : ''; |
| 3992 | - if(!$spt && isset($_REQUEST['pid'])){
|
|
| 3993 | - $spt = get_post_type( $_REQUEST['pid'] ); |
|
| 3992 | + if (!$spt && isset($_REQUEST['pid'])) {
|
|
| 3993 | + $spt = get_post_type($_REQUEST['pid']); |
|
| 3994 | 3994 | } |
| 3995 | - if(!$spt){$spt='gd_place';}
|
|
| 3996 | - if(isset($geodir_post_types[$spt]['labels']['singular_name'])){
|
|
| 3997 | - $single_name = __($geodir_post_types[$spt]['labels']['singular_name'],'geodirectory'); |
|
| 3995 | + if (!$spt) {$spt = 'gd_place'; }
|
|
| 3996 | + if (isset($geodir_post_types[$spt]['labels']['singular_name'])) {
|
|
| 3997 | + $single_name = __($geodir_post_types[$spt]['labels']['singular_name'], 'geodirectory'); |
|
| 3998 | 3998 | } |
| 3999 | 3999 | } |
| 4000 | - elseif($post->post_type){
|
|
| 4000 | + elseif ($post->post_type) {
|
|
| 4001 | 4001 | $geodir_post_types = get_option('geodir_post_types');
|
| 4002 | - if(isset($geodir_post_types[$post->post_type]['labels']['singular_name'])){
|
|
| 4003 | - $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'],'geodirectory'); |
|
| 4002 | + if (isset($geodir_post_types[$post->post_type]['labels']['singular_name'])) {
|
|
| 4003 | + $single_name = __($geodir_post_types[$post->post_type]['labels']['singular_name'], 'geodirectory'); |
|
| 4004 | 4004 | } |
| 4005 | 4005 | |
| 4006 | 4006 | |
| 4007 | 4007 | } |
| 4008 | - $title = str_replace("%%pt_single%%",$single_name,$title);
|
|
| 4008 | + $title = str_replace("%%pt_single%%", $single_name, $title);
|
|
| 4009 | 4009 | } |
| 4010 | 4010 | |
| 4011 | - if(strpos($title,'%%pt_plural%%') !== false){
|
|
| 4011 | + if (strpos($title, '%%pt_plural%%') !== false) {
|
|
| 4012 | 4012 | $plural_name = ''; |
| 4013 | - if($gd_page=='search' || $gd_page=='author'){
|
|
| 4013 | + if ($gd_page == 'search' || $gd_page == 'author') {
|
|
| 4014 | 4014 | $geodir_post_types = get_option('geodir_post_types');
|
| 4015 | 4015 | $spt = esc_attr($_REQUEST['stype']); |
| 4016 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4017 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4016 | + if (isset($geodir_post_types[$spt]['labels']['name'])) {
|
|
| 4017 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); |
|
| 4018 | 4018 | } |
| 4019 | - }elseif($gd_page=='add-listing'){
|
|
| 4019 | + }elseif ($gd_page == 'add-listing') {
|
|
| 4020 | 4020 | $geodir_post_types = get_option('geodir_post_types');
|
| 4021 | 4021 | $spt = esc_attr($_REQUEST['listing_type']); |
| 4022 | - if(!$spt){$spt='gd_place';}
|
|
| 4023 | - if(isset($geodir_post_types[$spt]['labels']['name'])){
|
|
| 4024 | - $plural_name = __($geodir_post_types[$spt]['labels']['name'],'geodirectory'); |
|
| 4022 | + if (!$spt) {$spt = 'gd_place'; }
|
|
| 4023 | + if (isset($geodir_post_types[$spt]['labels']['name'])) {
|
|
| 4024 | + $plural_name = __($geodir_post_types[$spt]['labels']['name'], 'geodirectory'); |
|
| 4025 | 4025 | } |
| 4026 | 4026 | } |
| 4027 | - elseif(isset($post->post_type) && $post->post_type){
|
|
| 4027 | + elseif (isset($post->post_type) && $post->post_type) {
|
|
| 4028 | 4028 | $geodir_post_types = get_option('geodir_post_types');
|
| 4029 | - if(isset($geodir_post_types[$post->post_type]['labels']['name'])){
|
|
| 4030 | - $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'],'geodirectory'); |
|
| 4029 | + if (isset($geodir_post_types[$post->post_type]['labels']['name'])) {
|
|
| 4030 | + $plural_name = __($geodir_post_types[$post->post_type]['labels']['name'], 'geodirectory'); |
|
| 4031 | 4031 | } |
| 4032 | 4032 | |
| 4033 | 4033 | } |
| 4034 | - $title = str_replace("%%pt_plural%%",$plural_name,$title);
|
|
| 4034 | + $title = str_replace("%%pt_plural%%", $plural_name, $title);
|
|
| 4035 | 4035 | } |
| 4036 | 4036 | |
| 4037 | 4037 | |
| 4038 | 4038 | |
| 4039 | - if(strpos($title,'%%category%%') !== false){
|
|
| 4039 | + if (strpos($title, '%%category%%') !== false) {
|
|
| 4040 | 4040 | $cat_name = ''; |
| 4041 | 4041 | |
| 4042 | - if($gd_page=='detail') {
|
|
| 4042 | + if ($gd_page == 'detail') {
|
|
| 4043 | 4043 | if ($post->default_category) {
|
| 4044 | 4044 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4045 | 4045 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4046 | 4046 | } |
| 4047 | - }elseif($gd_page=='listing'){
|
|
| 4047 | + }elseif ($gd_page == 'listing') {
|
|
| 4048 | 4048 | $queried_object = get_queried_object(); |
| 4049 | - if(isset($queried_object->name)){
|
|
| 4049 | + if (isset($queried_object->name)) {
|
|
| 4050 | 4050 | $cat_name = $queried_object->name; |
| 4051 | 4051 | } |
| 4052 | 4052 | } |
| 4053 | - $title = str_replace("%%category%%",$cat_name,$title);
|
|
| 4053 | + $title = str_replace("%%category%%", $cat_name, $title);
|
|
| 4054 | 4054 | } |
| 4055 | 4055 | |
| 4056 | - if(strpos($title,'%%tag%%') !== false){
|
|
| 4056 | + if (strpos($title, '%%tag%%') !== false) {
|
|
| 4057 | 4057 | $cat_name = ''; |
| 4058 | 4058 | |
| 4059 | - if($gd_page=='detail') {
|
|
| 4059 | + if ($gd_page == 'detail') {
|
|
| 4060 | 4060 | if ($post->default_category) {
|
| 4061 | 4061 | $cat = get_term($post->default_category, $post->post_type . 'category'); |
| 4062 | 4062 | $cat_name = (isset($cat->name)) ? $cat->name : ''; |
| 4063 | 4063 | } |
| 4064 | - }elseif($gd_page=='listing'){
|
|
| 4064 | + }elseif ($gd_page == 'listing') {
|
|
| 4065 | 4065 | $queried_object = get_queried_object(); |
| 4066 | - if(isset($queried_object->name)){
|
|
| 4066 | + if (isset($queried_object->name)) {
|
|
| 4067 | 4067 | $cat_name = $queried_object->name; |
| 4068 | 4068 | } |
| 4069 | 4069 | } |
| 4070 | - $title = str_replace("%%tag%%",$cat_name,$title);
|
|
| 4070 | + $title = str_replace("%%tag%%", $cat_name, $title);
|
|
| 4071 | 4071 | } |
| 4072 | 4072 | |
| 4073 | 4073 | |
| 4074 | 4074 | |
| 4075 | - if(strpos($title,'%%id%%') !== false){
|
|
| 4075 | + if (strpos($title, '%%id%%') !== false) {
|
|
| 4076 | 4076 | $ID = (isset($post->ID)) ? $post->ID : ''; |
| 4077 | - $title = str_replace("%%id%%",$ID,$title);
|
|
| 4077 | + $title = str_replace("%%id%%", $ID, $title);
|
|
| 4078 | 4078 | } |
| 4079 | 4079 | |
| 4080 | 4080 | /* |
@@ -4087,8 +4087,8 @@ discard block |
||
| 4087 | 4087 | } |
| 4088 | 4088 | */ |
| 4089 | 4089 | |
| 4090 | - if(strpos($title,'%%sep%%') !== false){
|
|
| 4091 | - $title = str_replace("%%sep%%",$sep,$title);
|
|
| 4090 | + if (strpos($title, '%%sep%%') !== false) {
|
|
| 4091 | + $title = str_replace("%%sep%%", $sep, $title);
|
|
| 4092 | 4092 | } |
| 4093 | 4093 | |
| 4094 | 4094 | |
@@ -4106,12 +4106,12 @@ discard block |
||
| 4106 | 4106 | * @param string $gd_page The page being filtered. |
| 4107 | 4107 | * @param string $sep The separator, default: `|`. |
| 4108 | 4108 | */ |
| 4109 | - $location_array = apply_filters('geodir_filter_title_variables_location_arr',$location_array,$title, $gd_page, $sep);
|
|
| 4109 | + $location_array = apply_filters('geodir_filter_title_variables_location_arr', $location_array, $title, $gd_page, $sep);
|
|
| 4110 | 4110 | $location_titles = array(); |
| 4111 | - if($gd_page=='location' && get_query_var( 'gd_country_full' )){
|
|
| 4112 | - if(get_query_var( 'gd_country_full' )){$location_array['gd_country'] = get_query_var( 'gd_country_full' );}
|
|
| 4113 | - if(get_query_var( 'gd_region_full' )){$location_array['gd_region'] = get_query_var( 'gd_region_full' );}
|
|
| 4114 | - if(get_query_var( 'gd_city_full' )){$location_array['gd_city'] = get_query_var( 'gd_city_full' );}
|
|
| 4111 | + if ($gd_page == 'location' && get_query_var('gd_country_full')) {
|
|
| 4112 | + if (get_query_var('gd_country_full')) {$location_array['gd_country'] = get_query_var('gd_country_full'); }
|
|
| 4113 | + if (get_query_var('gd_region_full')) {$location_array['gd_region'] = get_query_var('gd_region_full'); }
|
|
| 4114 | + if (get_query_var('gd_city_full')) {$location_array['gd_city'] = get_query_var('gd_city_full'); }
|
|
| 4115 | 4115 | } |
| 4116 | 4116 | $location_single = ''; |
| 4117 | 4117 | $gd_country = (isset($wp->query_vars['gd_country']) && $wp->query_vars['gd_country'] != '') ? $wp->query_vars['gd_country'] : ''; |
@@ -4183,65 +4183,65 @@ discard block |
||
| 4183 | 4183 | } |
| 4184 | 4184 | |
| 4185 | 4185 | |
| 4186 | - if(strpos($title,'%%location%%') !== false){
|
|
| 4186 | + if (strpos($title, '%%location%%') !== false) {
|
|
| 4187 | 4187 | $location = ''; |
| 4188 | - if($location_titles) {
|
|
| 4188 | + if ($location_titles) {
|
|
| 4189 | 4189 | $location = implode(", ", $location_titles);
|
| 4190 | 4190 | } |
| 4191 | - $title = str_replace("%%location%%",$location,$title);
|
|
| 4191 | + $title = str_replace("%%location%%", $location, $title);
|
|
| 4192 | 4192 | } |
| 4193 | 4193 | |
| 4194 | - if(strpos($title,'%%in_location%%') !== false){
|
|
| 4194 | + if (strpos($title, '%%in_location%%') !== false) {
|
|
| 4195 | 4195 | $location = ''; |
| 4196 | - if($location_titles) {
|
|
| 4196 | + if ($location_titles) {
|
|
| 4197 | 4197 | $location = __('in ', 'geodirectory') . implode(", ", $location_titles);
|
| 4198 | 4198 | } |
| 4199 | - $title = str_replace("%%in_location%%",$location,$title);
|
|
| 4199 | + $title = str_replace("%%in_location%%", $location, $title);
|
|
| 4200 | 4200 | } |
| 4201 | 4201 | |
| 4202 | - if(strpos($title,'%%in_location_single%%') !== false){
|
|
| 4203 | - if($location_single) {
|
|
| 4204 | - $location_single = __('in', 'geodirectory') . ' ' .$location_single;
|
|
| 4202 | + if (strpos($title, '%%in_location_single%%') !== false) {
|
|
| 4203 | + if ($location_single) {
|
|
| 4204 | + $location_single = __('in', 'geodirectory') . ' ' . $location_single;
|
|
| 4205 | 4205 | } |
| 4206 | - $title = str_replace("%%in_location_single%%",$location_single,$title);
|
|
| 4206 | + $title = str_replace("%%in_location_single%%", $location_single, $title);
|
|
| 4207 | 4207 | } |
| 4208 | 4208 | |
| 4209 | - if(strpos($title,'%%location_single%%') !== false){
|
|
| 4210 | - $title = str_replace("%%location_single%%",$location_single,$title);
|
|
| 4209 | + if (strpos($title, '%%location_single%%') !== false) {
|
|
| 4210 | + $title = str_replace("%%location_single%%", $location_single, $title);
|
|
| 4211 | 4211 | } |
| 4212 | 4212 | |
| 4213 | 4213 | |
| 4214 | - if(strpos($title,'%%search_term%%') !== false){
|
|
| 4214 | + if (strpos($title, '%%search_term%%') !== false) {
|
|
| 4215 | 4215 | $search_term = ''; |
| 4216 | - if(isset($_REQUEST['s'])){
|
|
| 4216 | + if (isset($_REQUEST['s'])) {
|
|
| 4217 | 4217 | $search_term = esc_attr($_REQUEST['s']); |
| 4218 | 4218 | } |
| 4219 | - $title = str_replace("%%search_term%%",$search_term,$title);
|
|
| 4219 | + $title = str_replace("%%search_term%%", $search_term, $title);
|
|
| 4220 | 4220 | } |
| 4221 | 4221 | |
| 4222 | - if(strpos($title,'%%search_near%%') !== false){
|
|
| 4222 | + if (strpos($title, '%%search_near%%') !== false) {
|
|
| 4223 | 4223 | $search_term = ''; |
| 4224 | - if(isset($_REQUEST['snear'])){
|
|
| 4224 | + if (isset($_REQUEST['snear'])) {
|
|
| 4225 | 4225 | $search_term = esc_attr($_REQUEST['snear']); |
| 4226 | 4226 | } |
| 4227 | - $title = str_replace("%%search_near%%",$search_term,$title);
|
|
| 4227 | + $title = str_replace("%%search_near%%", $search_term, $title);
|
|
| 4228 | 4228 | } |
| 4229 | 4229 | |
| 4230 | - if(strpos($title,'%%name%%') !== false){
|
|
| 4230 | + if (strpos($title, '%%name%%') !== false) {
|
|
| 4231 | 4231 | $author_name = ''; |
| 4232 | - if($author_name = get_the_author()){}
|
|
| 4233 | - else{
|
|
| 4232 | + if ($author_name = get_the_author()) {}
|
|
| 4233 | + else {
|
|
| 4234 | 4234 | $queried_object = get_queried_object(); |
| 4235 | - if(isset($queried_object->data->user_nicename)){
|
|
| 4235 | + if (isset($queried_object->data->user_nicename)) {
|
|
| 4236 | 4236 | $author_name = $queried_object->data->user_nicename; |
| 4237 | 4237 | } |
| 4238 | 4238 | } |
| 4239 | - $title = str_replace("%%name%%",$author_name,$title);
|
|
| 4239 | + $title = str_replace("%%name%%", $author_name, $title);
|
|
| 4240 | 4240 | } |
| 4241 | 4241 | |
| 4242 | - $title = wptexturize( $title ); |
|
| 4243 | - $title = convert_chars( $title ); |
|
| 4244 | - $title = esc_html( $title ); |
|
| 4242 | + $title = wptexturize($title); |
|
| 4243 | + $title = convert_chars($title); |
|
| 4244 | + $title = esc_html($title); |
|
| 4245 | 4245 | |
| 4246 | 4246 | /** |
| 4247 | 4247 | * Filter the title variables after standard ones have been filtered. |
@@ -4254,7 +4254,7 @@ discard block |
||
| 4254 | 4254 | * @param string $sep The separator, default: `|`. |
| 4255 | 4255 | */ |
| 4256 | 4256 | |
| 4257 | - return apply_filters('geodir_filter_title_variables_vars',$title,$location_array, $gd_page, $sep);
|
|
| 4257 | + return apply_filters('geodir_filter_title_variables_vars', $title, $location_array, $gd_page, $sep);
|
|
| 4258 | 4258 | } |
| 4259 | 4259 | |
| 4260 | 4260 | /** |
@@ -151,8 +151,7 @@ discard block |
||
| 151 | 151 | * @since 1.5.7 |
| 152 | 152 | * |
| 153 | 153 | * @param string|array $key Session key. |
| 154 | - * @param integer $value Session variable. |
|
| 155 | - * @return string Session variable. |
|
| 154 | + * @return boolean Session variable. |
|
| 156 | 155 | */ |
| 157 | 156 | public function un_set( $key ) { |
| 158 | 157 | if ( empty( $key ) ) { |
@@ -188,8 +187,7 @@ discard block |
||
| 188 | 187 | * @since 1.5.7 |
| 189 | 188 | * |
| 190 | 189 | * @param string $key Session key. |
| 191 | - * @param integer $value Session variable. |
|
| 192 | - * @return string Session variable. |
|
| 190 | + * @return boolean Session variable. |
|
| 193 | 191 | */ |
| 194 | 192 | public function is_set( $key ) { |
| 195 | 193 | $key = sanitize_key( $key ); |
@@ -8,294 +8,294 @@ |
||
| 8 | 8 | * @since 1.5.7 |
| 9 | 9 | */ |
| 10 | 10 | class Geodir_Session { |
| 11 | - /** |
|
| 12 | - * Holds our session data. |
|
| 13 | - * |
|
| 14 | - * @var array |
|
| 15 | - * @access private |
|
| 16 | - * @since 1.5.7 |
|
| 17 | - */ |
|
| 18 | - private $session; |
|
| 19 | - |
|
| 20 | - /** |
|
| 21 | - * Whether to use PHP $_SESSION or WP_Session. |
|
| 22 | - * |
|
| 23 | - * @var bool |
|
| 24 | - * @access private |
|
| 25 | - * @since 1.5.7 |
|
| 26 | - */ |
|
| 27 | - private $use_php_sessions = false; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Session index prefix. |
|
| 31 | - * |
|
| 32 | - * @var string |
|
| 33 | - * @access private |
|
| 34 | - * @since 1.5.7 |
|
| 35 | - */ |
|
| 36 | - private $prefix = ''; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Get things started. |
|
| 40 | - * |
|
| 41 | - * Defines our WP_Session constants, includes the necessary libraries and |
|
| 42 | - * retrieves the WP Session instance. |
|
| 43 | - * |
|
| 44 | - * @since 1.5.7 |
|
| 45 | - */ |
|
| 46 | - public function __construct() { |
|
| 47 | - $this->use_php_sessions = $this->use_php_sessions(); |
|
| 48 | - |
|
| 49 | - if ( $this->use_php_sessions ) { |
|
| 50 | - if ( is_multisite() ) { |
|
| 51 | - $this->prefix = '_' . get_current_blog_id(); |
|
| 52 | - } |
|
| 53 | - |
|
| 54 | - // Use PHP SESSION (must be enabled via the GEODIR_USE_PHP_SESSIONS constant) |
|
| 55 | - add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); |
|
| 56 | - } else { |
|
| 57 | - // Use WP_Session (default) |
|
| 58 | - if ( !defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 59 | - define( 'WP_SESSION_COOKIE', 'geodir_wp_session' ); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ( !class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 63 | - require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-recursive-arrayaccess.php'; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - if ( !class_exists( 'WP_Session' ) ) { |
|
| 67 | - require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-wp-session.php'; |
|
| 68 | - require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/wp-session.php'; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 72 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 76 | - add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); |
|
| 77 | - } else { |
|
| 78 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
| 79 | - } |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * Setup the WP_Session instance. |
|
| 84 | - * |
|
| 85 | - * @access public |
|
| 86 | - * @since 1.5.7 |
|
| 87 | - * @return void |
|
| 88 | - */ |
|
| 89 | - public function init() { |
|
| 90 | - if ( $this->use_php_sessions ) { |
|
| 91 | - $this->session = isset( $_SESSION['gd' . $this->prefix ] ) && is_array( $_SESSION['gd' . $this->prefix ] ) ? $_SESSION['gd' . $this->prefix ] : array(); |
|
| 92 | - } else { |
|
| 93 | - $this->session = WP_Session::get_instance(); |
|
| 94 | - } |
|
| 95 | - |
|
| 96 | - return $this->session; |
|
| 97 | - } |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * Retrieve session ID. |
|
| 101 | - * |
|
| 102 | - * @access public |
|
| 103 | - * @since 1.5.7 |
|
| 104 | - * @return string Session ID |
|
| 105 | - */ |
|
| 106 | - public function get_id() { |
|
| 107 | - return $this->session->session_id; |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - /** |
|
| 111 | - * Retrieve a session variable. |
|
| 112 | - * |
|
| 113 | - * @access public |
|
| 114 | - * @since 1.5.7 |
|
| 115 | - * @param string $key Session key |
|
| 116 | - * @return string Session variable |
|
| 117 | - */ |
|
| 118 | - public function get( $key ) { |
|
| 119 | - $key = sanitize_key( $key ); |
|
| 120 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
| 121 | - } |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * Set a session variable |
|
| 125 | - * |
|
| 126 | - * @since 1.5.7 |
|
| 127 | - * |
|
| 128 | - * @param string $key Session key |
|
| 129 | - * @param integer $value Session variable |
|
| 130 | - * @return string Session variable |
|
| 131 | - */ |
|
| 132 | - public function set( $key, $value ) { |
|
| 133 | - $key = sanitize_key( $key ); |
|
| 134 | - |
|
| 135 | - if ( is_array( $value ) ) { |
|
| 136 | - $this->session[ $key ] = maybe_serialize( $value ); |
|
| 137 | - } else { |
|
| 138 | - $this->session[ $key ] = $value; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - if ( $this->use_php_sessions ) { |
|
| 142 | - $_SESSION['gd' . $this->prefix ] = $this->session; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - return $this->session[ $key ]; |
|
| 146 | - } |
|
| 11 | + /** |
|
| 12 | + * Holds our session data. |
|
| 13 | + * |
|
| 14 | + * @var array |
|
| 15 | + * @access private |
|
| 16 | + * @since 1.5.7 |
|
| 17 | + */ |
|
| 18 | + private $session; |
|
| 19 | + |
|
| 20 | + /** |
|
| 21 | + * Whether to use PHP $_SESSION or WP_Session. |
|
| 22 | + * |
|
| 23 | + * @var bool |
|
| 24 | + * @access private |
|
| 25 | + * @since 1.5.7 |
|
| 26 | + */ |
|
| 27 | + private $use_php_sessions = false; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Session index prefix. |
|
| 31 | + * |
|
| 32 | + * @var string |
|
| 33 | + * @access private |
|
| 34 | + * @since 1.5.7 |
|
| 35 | + */ |
|
| 36 | + private $prefix = ''; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Get things started. |
|
| 40 | + * |
|
| 41 | + * Defines our WP_Session constants, includes the necessary libraries and |
|
| 42 | + * retrieves the WP Session instance. |
|
| 43 | + * |
|
| 44 | + * @since 1.5.7 |
|
| 45 | + */ |
|
| 46 | + public function __construct() { |
|
| 47 | + $this->use_php_sessions = $this->use_php_sessions(); |
|
| 48 | + |
|
| 49 | + if ( $this->use_php_sessions ) { |
|
| 50 | + if ( is_multisite() ) { |
|
| 51 | + $this->prefix = '_' . get_current_blog_id(); |
|
| 52 | + } |
|
| 53 | + |
|
| 54 | + // Use PHP SESSION (must be enabled via the GEODIR_USE_PHP_SESSIONS constant) |
|
| 55 | + add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); |
|
| 56 | + } else { |
|
| 57 | + // Use WP_Session (default) |
|
| 58 | + if ( !defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 59 | + define( 'WP_SESSION_COOKIE', 'geodir_wp_session' ); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ( !class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 63 | + require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-recursive-arrayaccess.php'; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + if ( !class_exists( 'WP_Session' ) ) { |
|
| 67 | + require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-wp-session.php'; |
|
| 68 | + require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/wp-session.php'; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 72 | + add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 76 | + add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); |
|
| 77 | + } else { |
|
| 78 | + add_action( 'init', array( $this, 'init' ), -1 ); |
|
| 79 | + } |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * Setup the WP_Session instance. |
|
| 84 | + * |
|
| 85 | + * @access public |
|
| 86 | + * @since 1.5.7 |
|
| 87 | + * @return void |
|
| 88 | + */ |
|
| 89 | + public function init() { |
|
| 90 | + if ( $this->use_php_sessions ) { |
|
| 91 | + $this->session = isset( $_SESSION['gd' . $this->prefix ] ) && is_array( $_SESSION['gd' . $this->prefix ] ) ? $_SESSION['gd' . $this->prefix ] : array(); |
|
| 92 | + } else { |
|
| 93 | + $this->session = WP_Session::get_instance(); |
|
| 94 | + } |
|
| 95 | + |
|
| 96 | + return $this->session; |
|
| 97 | + } |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * Retrieve session ID. |
|
| 101 | + * |
|
| 102 | + * @access public |
|
| 103 | + * @since 1.5.7 |
|
| 104 | + * @return string Session ID |
|
| 105 | + */ |
|
| 106 | + public function get_id() { |
|
| 107 | + return $this->session->session_id; |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + /** |
|
| 111 | + * Retrieve a session variable. |
|
| 112 | + * |
|
| 113 | + * @access public |
|
| 114 | + * @since 1.5.7 |
|
| 115 | + * @param string $key Session key |
|
| 116 | + * @return string Session variable |
|
| 117 | + */ |
|
| 118 | + public function get( $key ) { |
|
| 119 | + $key = sanitize_key( $key ); |
|
| 120 | + return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
| 121 | + } |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * Set a session variable |
|
| 125 | + * |
|
| 126 | + * @since 1.5.7 |
|
| 127 | + * |
|
| 128 | + * @param string $key Session key |
|
| 129 | + * @param integer $value Session variable |
|
| 130 | + * @return string Session variable |
|
| 131 | + */ |
|
| 132 | + public function set( $key, $value ) { |
|
| 133 | + $key = sanitize_key( $key ); |
|
| 134 | + |
|
| 135 | + if ( is_array( $value ) ) { |
|
| 136 | + $this->session[ $key ] = maybe_serialize( $value ); |
|
| 137 | + } else { |
|
| 138 | + $this->session[ $key ] = $value; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + if ( $this->use_php_sessions ) { |
|
| 142 | + $_SESSION['gd' . $this->prefix ] = $this->session; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + return $this->session[ $key ]; |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Unset a session variable. |
|
| 150 | - * |
|
| 151 | - * @since 1.5.7 |
|
| 152 | - * |
|
| 153 | - * @param string|array $key Session key. |
|
| 154 | - * @param integer $value Session variable. |
|
| 155 | - * @return string Session variable. |
|
| 156 | - */ |
|
| 157 | - public function un_set( $key ) { |
|
| 158 | - if ( empty( $key ) ) { |
|
| 159 | - return false; |
|
| 160 | - } |
|
| 148 | + /** |
|
| 149 | + * Unset a session variable. |
|
| 150 | + * |
|
| 151 | + * @since 1.5.7 |
|
| 152 | + * |
|
| 153 | + * @param string|array $key Session key. |
|
| 154 | + * @param integer $value Session variable. |
|
| 155 | + * @return string Session variable. |
|
| 156 | + */ |
|
| 157 | + public function un_set( $key ) { |
|
| 158 | + if ( empty( $key ) ) { |
|
| 159 | + return false; |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - if ( is_array( $key ) ) { |
|
| 163 | - foreach ($key as $index) { |
|
| 164 | - $index = sanitize_key( $index ); |
|
| 162 | + if ( is_array( $key ) ) { |
|
| 163 | + foreach ($key as $index) { |
|
| 164 | + $index = sanitize_key( $index ); |
|
| 165 | 165 | |
| 166 | - if ( $index && isset( $this->session[ $index ] ) ) { |
|
| 167 | - unset( $this->session[ $index ] ); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - } else { |
|
| 171 | - $key = sanitize_key( $key ); |
|
| 166 | + if ( $index && isset( $this->session[ $index ] ) ) { |
|
| 167 | + unset( $this->session[ $index ] ); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + } else { |
|
| 171 | + $key = sanitize_key( $key ); |
|
| 172 | 172 | |
| 173 | - if ( isset( $this->session[ $key ] ) ) { |
|
| 174 | - unset( $this->session[ $key ] ); |
|
| 175 | - } |
|
| 176 | - } |
|
| 173 | + if ( isset( $this->session[ $key ] ) ) { |
|
| 174 | + unset( $this->session[ $key ] ); |
|
| 175 | + } |
|
| 176 | + } |
|
| 177 | 177 | |
| 178 | - if ( $this->use_php_sessions ) { |
|
| 179 | - $_SESSION['gd' . $this->prefix ] = $this->session; |
|
| 180 | - } |
|
| 178 | + if ( $this->use_php_sessions ) { |
|
| 179 | + $_SESSION['gd' . $this->prefix ] = $this->session; |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - return true; |
|
| 183 | - } |
|
| 182 | + return true; |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - /** |
|
| 186 | - * Check a session variable is set or not. |
|
| 187 | - * |
|
| 188 | - * @since 1.5.7 |
|
| 189 | - * |
|
| 190 | - * @param string $key Session key. |
|
| 191 | - * @param integer $value Session variable. |
|
| 192 | - * @return string Session variable. |
|
| 193 | - */ |
|
| 194 | - public function is_set( $key ) { |
|
| 195 | - $key = sanitize_key( $key ); |
|
| 185 | + /** |
|
| 186 | + * Check a session variable is set or not. |
|
| 187 | + * |
|
| 188 | + * @since 1.5.7 |
|
| 189 | + * |
|
| 190 | + * @param string $key Session key. |
|
| 191 | + * @param integer $value Session variable. |
|
| 192 | + * @return string Session variable. |
|
| 193 | + */ |
|
| 194 | + public function is_set( $key ) { |
|
| 195 | + $key = sanitize_key( $key ); |
|
| 196 | 196 | |
| 197 | - if ( empty( $key ) ) { |
|
| 198 | - return false; |
|
| 199 | - } |
|
| 200 | - |
|
| 201 | - if ( isset( $this->session[ $key ] ) ) { |
|
| 202 | - return true; |
|
| 203 | - } |
|
| 204 | - |
|
| 205 | - return false; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - /** |
|
| 209 | - * Force the cookie expiration variant time to 23 hours |
|
| 210 | - * |
|
| 211 | - * @access public |
|
| 212 | - * @since 1.5.7 |
|
| 213 | - * @param int $exp Default expiration (1 hour) |
|
| 214 | - * @return int |
|
| 215 | - */ |
|
| 216 | - public function set_expiration_variant_time( $exp ) { |
|
| 217 | - return ( 30 * 60 * 23 ); |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Force the cookie expiration time to 24 hours |
|
| 222 | - * |
|
| 223 | - * @access public |
|
| 224 | - * @since 1.5.7 |
|
| 225 | - * @param int $exp Default expiration (1 hour) |
|
| 226 | - * @return int |
|
| 227 | - */ |
|
| 228 | - public function set_expiration_time( $exp ) { |
|
| 229 | - return ( 30 * 60 * 24 ); |
|
| 230 | - } |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * Starts a new session if one hasn't started yet. |
|
| 234 | - * |
|
| 235 | - * @return boolean |
|
| 236 | - * Checks to see if the server supports PHP sessions |
|
| 237 | - * or if the GEODIR_USE_PHP_SESSIONS constant is defined |
|
| 238 | - * |
|
| 239 | - * @access public |
|
| 240 | - * @since 1.5.7 |
|
| 241 | - * @return boolean $ret True if we are using PHP sessions, false otherwise |
|
| 242 | - */ |
|
| 243 | - public function use_php_sessions() { |
|
| 244 | - $ret = false; |
|
| 245 | - |
|
| 246 | - // If the database variable is already set, no need to run autodetection |
|
| 247 | - $geodir_use_php_sessions = (bool)get_option( 'geodir_use_php_sessions' ); |
|
| 248 | - |
|
| 249 | - if (!$geodir_use_php_sessions ) { |
|
| 250 | - // Attempt to detect if the server supports PHP sessions |
|
| 251 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 252 | - $this->set( 'geodir_use_php_sessions', 1 ); |
|
| 197 | + if ( empty( $key ) ) { |
|
| 198 | + return false; |
|
| 199 | + } |
|
| 200 | + |
|
| 201 | + if ( isset( $this->session[ $key ] ) ) { |
|
| 202 | + return true; |
|
| 203 | + } |
|
| 204 | + |
|
| 205 | + return false; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + /** |
|
| 209 | + * Force the cookie expiration variant time to 23 hours |
|
| 210 | + * |
|
| 211 | + * @access public |
|
| 212 | + * @since 1.5.7 |
|
| 213 | + * @param int $exp Default expiration (1 hour) |
|
| 214 | + * @return int |
|
| 215 | + */ |
|
| 216 | + public function set_expiration_variant_time( $exp ) { |
|
| 217 | + return ( 30 * 60 * 23 ); |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Force the cookie expiration time to 24 hours |
|
| 222 | + * |
|
| 223 | + * @access public |
|
| 224 | + * @since 1.5.7 |
|
| 225 | + * @param int $exp Default expiration (1 hour) |
|
| 226 | + * @return int |
|
| 227 | + */ |
|
| 228 | + public function set_expiration_time( $exp ) { |
|
| 229 | + return ( 30 * 60 * 24 ); |
|
| 230 | + } |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * Starts a new session if one hasn't started yet. |
|
| 234 | + * |
|
| 235 | + * @return boolean |
|
| 236 | + * Checks to see if the server supports PHP sessions |
|
| 237 | + * or if the GEODIR_USE_PHP_SESSIONS constant is defined |
|
| 238 | + * |
|
| 239 | + * @access public |
|
| 240 | + * @since 1.5.7 |
|
| 241 | + * @return boolean $ret True if we are using PHP sessions, false otherwise |
|
| 242 | + */ |
|
| 243 | + public function use_php_sessions() { |
|
| 244 | + $ret = false; |
|
| 245 | + |
|
| 246 | + // If the database variable is already set, no need to run autodetection |
|
| 247 | + $geodir_use_php_sessions = (bool)get_option( 'geodir_use_php_sessions' ); |
|
| 248 | + |
|
| 249 | + if (!$geodir_use_php_sessions ) { |
|
| 250 | + // Attempt to detect if the server supports PHP sessions |
|
| 251 | + if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 252 | + $this->set( 'geodir_use_php_sessions', 1 ); |
|
| 253 | 253 | |
| 254 | - if ( $this->get( 'geodir_use_php_sessions' ) ) { |
|
| 255 | - $ret = true; |
|
| 256 | - |
|
| 257 | - // Set the database option |
|
| 258 | - update_option( 'geodir_use_php_sessions', true ); |
|
| 259 | - } |
|
| 260 | - } |
|
| 261 | - } else { |
|
| 262 | - $ret = $geodir_use_php_sessions; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - // Enable or disable PHP Sessions based on the GEODIR_USE_PHP_SESSIONS constant |
|
| 266 | - if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && GEODIR_USE_PHP_SESSIONS ) { |
|
| 267 | - $ret = true; |
|
| 268 | - } else if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && ! GEODIR_USE_PHP_SESSIONS ) { |
|
| 269 | - $ret = false; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - return (bool) apply_filters( 'geodir_use_php_sessions', $ret ); |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - /** |
|
| 276 | - * Starts a new session if one hasn't started yet. |
|
| 277 | - */ |
|
| 278 | - public function maybe_start_session() { |
|
| 279 | - if ( !session_id() && !headers_sent() ) { |
|
| 280 | - session_start(); |
|
| 281 | - } |
|
| 282 | - } |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * Determines if a user has set the GEODIR_USE_CART_COOKIE |
|
| 286 | - * |
|
| 287 | - * @since 1.5.7 |
|
| 288 | - * @return bool If the store should use the geodir_items_in_cart cookie to help avoid caching |
|
| 289 | - */ |
|
| 290 | - public function use_cart_cookie() { |
|
| 291 | - $ret = true; |
|
| 292 | - |
|
| 293 | - if ( defined( 'GEODIR_USE_CART_COOKIE' ) && ! GEODIR_USE_CART_COOKIE ) { |
|
| 294 | - $ret = false; |
|
| 295 | - } |
|
| 296 | - |
|
| 297 | - return (bool) apply_filters( 'geodir_use_cart_cookie', $ret ); |
|
| 298 | - } |
|
| 254 | + if ( $this->get( 'geodir_use_php_sessions' ) ) { |
|
| 255 | + $ret = true; |
|
| 256 | + |
|
| 257 | + // Set the database option |
|
| 258 | + update_option( 'geodir_use_php_sessions', true ); |
|
| 259 | + } |
|
| 260 | + } |
|
| 261 | + } else { |
|
| 262 | + $ret = $geodir_use_php_sessions; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + // Enable or disable PHP Sessions based on the GEODIR_USE_PHP_SESSIONS constant |
|
| 266 | + if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && GEODIR_USE_PHP_SESSIONS ) { |
|
| 267 | + $ret = true; |
|
| 268 | + } else if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && ! GEODIR_USE_PHP_SESSIONS ) { |
|
| 269 | + $ret = false; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + return (bool) apply_filters( 'geodir_use_php_sessions', $ret ); |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + /** |
|
| 276 | + * Starts a new session if one hasn't started yet. |
|
| 277 | + */ |
|
| 278 | + public function maybe_start_session() { |
|
| 279 | + if ( !session_id() && !headers_sent() ) { |
|
| 280 | + session_start(); |
|
| 281 | + } |
|
| 282 | + } |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * Determines if a user has set the GEODIR_USE_CART_COOKIE |
|
| 286 | + * |
|
| 287 | + * @since 1.5.7 |
|
| 288 | + * @return bool If the store should use the geodir_items_in_cart cookie to help avoid caching |
|
| 289 | + */ |
|
| 290 | + public function use_cart_cookie() { |
|
| 291 | + $ret = true; |
|
| 292 | + |
|
| 293 | + if ( defined( 'GEODIR_USE_CART_COOKIE' ) && ! GEODIR_USE_CART_COOKIE ) { |
|
| 294 | + $ret = false; |
|
| 295 | + } |
|
| 296 | + |
|
| 297 | + return (bool) apply_filters( 'geodir_use_cart_cookie', $ret ); |
|
| 298 | + } |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | global $gd_session; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined('ABSPATH')) exit; |
|
| 4 | 4 | |
| 5 | 5 | /** |
| 6 | 6 | * Geodir_Session Class. |
@@ -46,36 +46,36 @@ discard block |
||
| 46 | 46 | public function __construct() { |
| 47 | 47 | $this->use_php_sessions = $this->use_php_sessions(); |
| 48 | 48 | |
| 49 | - if ( $this->use_php_sessions ) { |
|
| 50 | - if ( is_multisite() ) { |
|
| 49 | + if ($this->use_php_sessions) { |
|
| 50 | + if (is_multisite()) { |
|
| 51 | 51 | $this->prefix = '_' . get_current_blog_id(); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | // Use PHP SESSION (must be enabled via the GEODIR_USE_PHP_SESSIONS constant) |
| 55 | - add_action( 'init', array( $this, 'maybe_start_session' ), -2 ); |
|
| 55 | + add_action('init', array($this, 'maybe_start_session'), -2); |
|
| 56 | 56 | } else { |
| 57 | 57 | // Use WP_Session (default) |
| 58 | - if ( !defined( 'WP_SESSION_COOKIE' ) ) { |
|
| 59 | - define( 'WP_SESSION_COOKIE', 'geodir_wp_session' ); |
|
| 58 | + if (!defined('WP_SESSION_COOKIE')) { |
|
| 59 | + define('WP_SESSION_COOKIE', 'geodir_wp_session'); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - if ( !class_exists( 'Recursive_ArrayAccess' ) ) { |
|
| 62 | + if (!class_exists('Recursive_ArrayAccess')) { |
|
| 63 | 63 | require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-recursive-arrayaccess.php'; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - if ( !class_exists( 'WP_Session' ) ) { |
|
| 66 | + if (!class_exists('WP_Session')) { |
|
| 67 | 67 | require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/class-wp-session.php'; |
| 68 | 68 | require_once GEODIRECTORY_PLUGIN_DIR . 'wp-session/wp-session.php'; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - add_filter( 'wp_session_expiration_variant', array( $this, 'set_expiration_variant_time' ), 99999 ); |
|
| 72 | - add_filter( 'wp_session_expiration', array( $this, 'set_expiration_time' ), 99999 ); |
|
| 71 | + add_filter('wp_session_expiration_variant', array($this, 'set_expiration_variant_time'), 99999); |
|
| 72 | + add_filter('wp_session_expiration', array($this, 'set_expiration_time'), 99999); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - if ( empty( $this->session ) && ! $this->use_php_sessions ) { |
|
| 76 | - add_action( 'plugins_loaded', array( $this, 'init' ), -1 ); |
|
| 75 | + if (empty($this->session) && !$this->use_php_sessions) { |
|
| 76 | + add_action('plugins_loaded', array($this, 'init'), -1); |
|
| 77 | 77 | } else { |
| 78 | - add_action( 'init', array( $this, 'init' ), -1 ); |
|
| 78 | + add_action('init', array($this, 'init'), -1); |
|
| 79 | 79 | } |
| 80 | 80 | } |
| 81 | 81 | |
@@ -87,8 +87,8 @@ discard block |
||
| 87 | 87 | * @return void |
| 88 | 88 | */ |
| 89 | 89 | public function init() { |
| 90 | - if ( $this->use_php_sessions ) { |
|
| 91 | - $this->session = isset( $_SESSION['gd' . $this->prefix ] ) && is_array( $_SESSION['gd' . $this->prefix ] ) ? $_SESSION['gd' . $this->prefix ] : array(); |
|
| 90 | + if ($this->use_php_sessions) { |
|
| 91 | + $this->session = isset($_SESSION['gd' . $this->prefix]) && is_array($_SESSION['gd' . $this->prefix]) ? $_SESSION['gd' . $this->prefix] : array(); |
|
| 92 | 92 | } else { |
| 93 | 93 | $this->session = WP_Session::get_instance(); |
| 94 | 94 | } |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | * @param string $key Session key |
| 116 | 116 | * @return string Session variable |
| 117 | 117 | */ |
| 118 | - public function get( $key ) { |
|
| 119 | - $key = sanitize_key( $key ); |
|
| 120 | - return isset( $this->session[ $key ] ) ? maybe_unserialize( $this->session[ $key ] ) : false; |
|
| 118 | + public function get($key) { |
|
| 119 | + $key = sanitize_key($key); |
|
| 120 | + return isset($this->session[$key]) ? maybe_unserialize($this->session[$key]) : false; |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -129,20 +129,20 @@ discard block |
||
| 129 | 129 | * @param integer $value Session variable |
| 130 | 130 | * @return string Session variable |
| 131 | 131 | */ |
| 132 | - public function set( $key, $value ) { |
|
| 133 | - $key = sanitize_key( $key ); |
|
| 132 | + public function set($key, $value) { |
|
| 133 | + $key = sanitize_key($key); |
|
| 134 | 134 | |
| 135 | - if ( is_array( $value ) ) { |
|
| 136 | - $this->session[ $key ] = maybe_serialize( $value ); |
|
| 135 | + if (is_array($value)) { |
|
| 136 | + $this->session[$key] = maybe_serialize($value); |
|
| 137 | 137 | } else { |
| 138 | - $this->session[ $key ] = $value; |
|
| 138 | + $this->session[$key] = $value; |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | - if ( $this->use_php_sessions ) { |
|
| 142 | - $_SESSION['gd' . $this->prefix ] = $this->session; |
|
| 141 | + if ($this->use_php_sessions) { |
|
| 142 | + $_SESSION['gd' . $this->prefix] = $this->session; |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - return $this->session[ $key ]; |
|
| 145 | + return $this->session[$key]; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -154,29 +154,29 @@ discard block |
||
| 154 | 154 | * @param integer $value Session variable. |
| 155 | 155 | * @return string Session variable. |
| 156 | 156 | */ |
| 157 | - public function un_set( $key ) { |
|
| 158 | - if ( empty( $key ) ) { |
|
| 157 | + public function un_set($key) { |
|
| 158 | + if (empty($key)) { |
|
| 159 | 159 | return false; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | - if ( is_array( $key ) ) { |
|
| 162 | + if (is_array($key)) { |
|
| 163 | 163 | foreach ($key as $index) { |
| 164 | - $index = sanitize_key( $index ); |
|
| 164 | + $index = sanitize_key($index); |
|
| 165 | 165 | |
| 166 | - if ( $index && isset( $this->session[ $index ] ) ) { |
|
| 167 | - unset( $this->session[ $index ] ); |
|
| 166 | + if ($index && isset($this->session[$index])) { |
|
| 167 | + unset($this->session[$index]); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | } else { |
| 171 | - $key = sanitize_key( $key ); |
|
| 171 | + $key = sanitize_key($key); |
|
| 172 | 172 | |
| 173 | - if ( isset( $this->session[ $key ] ) ) { |
|
| 174 | - unset( $this->session[ $key ] ); |
|
| 173 | + if (isset($this->session[$key])) { |
|
| 174 | + unset($this->session[$key]); |
|
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - if ( $this->use_php_sessions ) { |
|
| 179 | - $_SESSION['gd' . $this->prefix ] = $this->session; |
|
| 178 | + if ($this->use_php_sessions) { |
|
| 179 | + $_SESSION['gd' . $this->prefix] = $this->session; |
|
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | return true; |
@@ -191,14 +191,14 @@ discard block |
||
| 191 | 191 | * @param integer $value Session variable. |
| 192 | 192 | * @return string Session variable. |
| 193 | 193 | */ |
| 194 | - public function is_set( $key ) { |
|
| 195 | - $key = sanitize_key( $key ); |
|
| 194 | + public function is_set($key) { |
|
| 195 | + $key = sanitize_key($key); |
|
| 196 | 196 | |
| 197 | - if ( empty( $key ) ) { |
|
| 197 | + if (empty($key)) { |
|
| 198 | 198 | return false; |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - if ( isset( $this->session[ $key ] ) ) { |
|
| 201 | + if (isset($this->session[$key])) { |
|
| 202 | 202 | return true; |
| 203 | 203 | } |
| 204 | 204 | |
@@ -213,8 +213,8 @@ discard block |
||
| 213 | 213 | * @param int $exp Default expiration (1 hour) |
| 214 | 214 | * @return int |
| 215 | 215 | */ |
| 216 | - public function set_expiration_variant_time( $exp ) { |
|
| 217 | - return ( 30 * 60 * 23 ); |
|
| 216 | + public function set_expiration_variant_time($exp) { |
|
| 217 | + return (30 * 60 * 23); |
|
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | /** |
@@ -225,8 +225,8 @@ discard block |
||
| 225 | 225 | * @param int $exp Default expiration (1 hour) |
| 226 | 226 | * @return int |
| 227 | 227 | */ |
| 228 | - public function set_expiration_time( $exp ) { |
|
| 229 | - return ( 30 * 60 * 24 ); |
|
| 228 | + public function set_expiration_time($exp) { |
|
| 229 | + return (30 * 60 * 24); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | /** |
@@ -244,18 +244,18 @@ discard block |
||
| 244 | 244 | $ret = false; |
| 245 | 245 | |
| 246 | 246 | // If the database variable is already set, no need to run autodetection |
| 247 | - $geodir_use_php_sessions = (bool)get_option( 'geodir_use_php_sessions' ); |
|
| 247 | + $geodir_use_php_sessions = (bool) get_option('geodir_use_php_sessions'); |
|
| 248 | 248 | |
| 249 | - if (!$geodir_use_php_sessions ) { |
|
| 249 | + if (!$geodir_use_php_sessions) { |
|
| 250 | 250 | // Attempt to detect if the server supports PHP sessions |
| 251 | - if ( function_exists( 'session_start' ) && ! ini_get( 'safe_mode' ) ) { |
|
| 252 | - $this->set( 'geodir_use_php_sessions', 1 ); |
|
| 251 | + if (function_exists('session_start') && !ini_get('safe_mode')) { |
|
| 252 | + $this->set('geodir_use_php_sessions', 1); |
|
| 253 | 253 | |
| 254 | - if ( $this->get( 'geodir_use_php_sessions' ) ) { |
|
| 254 | + if ($this->get('geodir_use_php_sessions')) { |
|
| 255 | 255 | $ret = true; |
| 256 | 256 | |
| 257 | 257 | // Set the database option |
| 258 | - update_option( 'geodir_use_php_sessions', true ); |
|
| 258 | + update_option('geodir_use_php_sessions', true); |
|
| 259 | 259 | } |
| 260 | 260 | } |
| 261 | 261 | } else { |
@@ -263,20 +263,20 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // Enable or disable PHP Sessions based on the GEODIR_USE_PHP_SESSIONS constant |
| 266 | - if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && GEODIR_USE_PHP_SESSIONS ) { |
|
| 266 | + if (defined('GEODIR_USE_PHP_SESSIONS') && GEODIR_USE_PHP_SESSIONS) { |
|
| 267 | 267 | $ret = true; |
| 268 | - } else if ( defined( 'GEODIR_USE_PHP_SESSIONS' ) && ! GEODIR_USE_PHP_SESSIONS ) { |
|
| 268 | + } else if (defined('GEODIR_USE_PHP_SESSIONS') && !GEODIR_USE_PHP_SESSIONS) { |
|
| 269 | 269 | $ret = false; |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - return (bool) apply_filters( 'geodir_use_php_sessions', $ret ); |
|
| 272 | + return (bool) apply_filters('geodir_use_php_sessions', $ret); |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * Starts a new session if one hasn't started yet. |
| 277 | 277 | */ |
| 278 | 278 | public function maybe_start_session() { |
| 279 | - if ( !session_id() && !headers_sent() ) { |
|
| 279 | + if (!session_id() && !headers_sent()) { |
|
| 280 | 280 | session_start(); |
| 281 | 281 | } |
| 282 | 282 | } |
@@ -290,11 +290,11 @@ discard block |
||
| 290 | 290 | public function use_cart_cookie() { |
| 291 | 291 | $ret = true; |
| 292 | 292 | |
| 293 | - if ( defined( 'GEODIR_USE_CART_COOKIE' ) && ! GEODIR_USE_CART_COOKIE ) { |
|
| 293 | + if (defined('GEODIR_USE_CART_COOKIE') && !GEODIR_USE_CART_COOKIE) { |
|
| 294 | 294 | $ret = false; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | - return (bool) apply_filters( 'geodir_use_cart_cookie', $ret ); |
|
| 297 | + return (bool) apply_filters('geodir_use_cart_cookie', $ret); |
|
| 298 | 298 | } |
| 299 | 299 | } |
| 300 | 300 | |
@@ -1,6 +1,8 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | // Exit if accessed directly. |
| 3 | -if (!defined( 'ABSPATH' ) ) exit; |
|
| 3 | +if (!defined( 'ABSPATH' ) ) { |
|
| 4 | + exit; |
|
| 5 | +} |
|
| 4 | 6 | |
| 5 | 7 | /** |
| 6 | 8 | * Geodir_Session Class. |