@@ -20,492 +20,492 @@ discard block |
||
| 20 | 20 | function geodir_set_postcat_structure($post_id, $taxonomy, $default_cat = '', $category_str = '') |
| 21 | 21 | {
|
| 22 | 22 | |
| 23 | - $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
| 24 | - if (!empty($post_cat_ids)) |
|
| 25 | - $post_cat_array = explode(",", trim($post_cat_ids, ","));
|
|
| 26 | - |
|
| 27 | - if (!isset($default_cat) || empty($default_cat)) {
|
|
| 28 | - $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
| 29 | - }else{
|
|
| 30 | - if(!is_int($default_cat)){
|
|
| 31 | - $category = get_term_by('name', $default_cat, $taxonomy);
|
|
| 32 | - if(isset($category->term_id)){
|
|
| 33 | - $default_cat = $category->term_id; |
|
| 34 | - } |
|
| 35 | - } |
|
| 23 | + $post_cat_ids = geodir_get_post_meta($post_id, $taxonomy); |
|
| 24 | + if (!empty($post_cat_ids)) |
|
| 25 | + $post_cat_array = explode(",", trim($post_cat_ids, ","));
|
|
| 26 | + |
|
| 27 | + if (!isset($default_cat) || empty($default_cat)) {
|
|
| 28 | + $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
|
| 29 | + }else{
|
|
| 30 | + if(!is_int($default_cat)){
|
|
| 31 | + $category = get_term_by('name', $default_cat, $taxonomy);
|
|
| 32 | + if(isset($category->term_id)){
|
|
| 33 | + $default_cat = $category->term_id; |
|
| 34 | + } |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | 39 | |
| 40 | - geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
| 40 | + geodir_save_post_meta($post_id, 'default_category', $default_cat); |
|
| 41 | 41 | |
| 42 | - if (isset($category_str) && empty($category_str)) {
|
|
| 42 | + if (isset($category_str) && empty($category_str)) {
|
|
| 43 | 43 | |
| 44 | - $post_cat_str = ''; |
|
| 45 | - $post_categories = array(); |
|
| 46 | - if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
|
|
| 47 | - $post_cat_str = implode(",y:#", $post_cat_array);
|
|
| 48 | - $post_cat_str .= ",y:"; |
|
| 49 | - $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
|
|
| 50 | - } |
|
| 51 | - $post_categories[$taxonomy] = $post_cat_str; |
|
| 52 | - $category_str = $post_categories; |
|
| 53 | - } |
|
| 44 | + $post_cat_str = ''; |
|
| 45 | + $post_categories = array(); |
|
| 46 | + if (isset($post_cat_array) && is_array($post_cat_array) && !empty($post_cat_array)) {
|
|
| 47 | + $post_cat_str = implode(",y:#", $post_cat_array);
|
|
| 48 | + $post_cat_str .= ",y:"; |
|
| 49 | + $post_cat_str = substr_replace($post_cat_str, ',y,d:', strpos($post_cat_str, ',y:'), strlen(',y:'));
|
|
| 50 | + } |
|
| 51 | + $post_categories[$taxonomy] = $post_cat_str; |
|
| 52 | + $category_str = $post_categories; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - $change_cat_str = $category_str[$taxonomy]; |
|
| 55 | + $change_cat_str = $category_str[$taxonomy]; |
|
| 56 | 56 | |
| 57 | - $default_pos = strpos($change_cat_str, 'd:'); |
|
| 57 | + $default_pos = strpos($change_cat_str, 'd:'); |
|
| 58 | 58 | |
| 59 | - if ($default_pos === false) {
|
|
| 59 | + if ($default_pos === false) {
|
|
| 60 | 60 | |
| 61 | - $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 61 | + $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 62 | 62 | |
| 63 | - } |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - $category_str[$taxonomy] = $change_cat_str; |
|
| 65 | + $category_str[$taxonomy] = $change_cat_str; |
|
| 66 | 66 | |
| 67 | - update_post_meta($post_id, 'post_categories', $category_str); |
|
| 67 | + update_post_meta($post_id, 'post_categories', $category_str); |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | |
| 72 | 72 | if (!function_exists('geodir_save_listing')) {
|
| 73 | - /** |
|
| 74 | - * Saves listing in the database using given information. |
|
| 75 | - * |
|
| 76 | - * @since 1.0.0 |
|
| 77 | - * @since 1.5.4 New parameter $wp_error added. |
|
| 78 | - * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED |
|
| 79 | - * @package GeoDirectory |
|
| 80 | - * @global object $wpdb WordPress Database object. |
|
| 81 | - * @global object $post The current post object. |
|
| 82 | - * @global object $current_user Current user object. |
|
| 83 | - * @global object $gd_session GeoDirectory Session object. |
|
| 84 | - * @param array $request_info {
|
|
| 85 | - * Array of request info arguments. |
|
| 86 | - * |
|
| 87 | - * @type string $action Ajax action name. |
|
| 88 | - * @type string $geodir_ajax Ajax type. |
|
| 89 | - * @type string $ajax_action Ajax action. |
|
| 90 | - * @type string $listing_type Listing type. |
|
| 91 | - * @type string $pid Default Post ID. |
|
| 92 | - * @type string $preview Todo Desc needed. |
|
| 93 | - * @type string $add_listing_page_id Add listing page ID. |
|
| 94 | - * @type string $post_title Listing title. |
|
| 95 | - * @type string $post_desc Listing Description. |
|
| 96 | - * @type string $post_tags Listing tags. |
|
| 97 | - * @type array $cat_limit Category limit. |
|
| 98 | - * @type array $post_category Category IDs. |
|
| 99 | - * @type array $post_category_str Category string. |
|
| 100 | - * @type string $post_default_category Default category ID. |
|
| 101 | - * @type string $post_address Listing address. |
|
| 102 | - * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
| 103 | - * @type string $post_country Listing country. |
|
| 104 | - * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
| 105 | - * @type string $post_region Listing region. |
|
| 106 | - * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
| 107 | - * @type string $post_city Listing city. |
|
| 108 | - * @type string $post_zip Listing zip. |
|
| 109 | - * @type string $post_latitude Listing latitude. |
|
| 110 | - * @type string $post_longitude Listing longitude. |
|
| 111 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 112 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 113 | - * @type string $geodir_timing Business timing info. |
|
| 114 | - * @type string $geodir_contact Contact number. |
|
| 115 | - * @type string $geodir_email Business contact email. |
|
| 116 | - * @type string $geodir_website Business website. |
|
| 117 | - * @type string $geodir_twitter Twitter link. |
|
| 118 | - * @type string $geodir_facebook Facebook link. |
|
| 119 | - * @type string $geodir_video Video link. |
|
| 120 | - * @type string $geodir_special_offers Special offers. |
|
| 121 | - * @type string $post_images Post image urls. |
|
| 122 | - * @type string $post_imagesimage_limit Post images limit. |
|
| 123 | - * @type string $post_imagestotImg Todo Desc needed. |
|
| 124 | - * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
| 125 | - * @type string $geodir_spamblocker Todo Desc needed. |
|
| 126 | - * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
| 127 | - * |
|
| 128 | - * } |
|
| 129 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 130 | - * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
| 131 | - * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
| 132 | - */ |
|
| 133 | - function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
| 134 | - {
|
|
| 135 | - global $wpdb, $current_user, $gd_session; |
|
| 136 | - |
|
| 137 | - $last_post_id = ''; |
|
| 138 | - |
|
| 139 | - if ($gd_session->get('listing') && !$dummy) {
|
|
| 140 | - $request_info = array(); |
|
| 141 | - $request_session = $gd_session->get('listing');
|
|
| 142 | - $request_info = array_merge($_REQUEST, $request_session); |
|
| 143 | - } else if (!$gd_session->get('listing') && !$dummy) {
|
|
| 144 | - global $post; |
|
| 73 | + /** |
|
| 74 | + * Saves listing in the database using given information. |
|
| 75 | + * |
|
| 76 | + * @since 1.0.0 |
|
| 77 | + * @since 1.5.4 New parameter $wp_error added. |
|
| 78 | + * @since 1.6.18 Admin use only date field should not lost value if saved by user - FIXED |
|
| 79 | + * @package GeoDirectory |
|
| 80 | + * @global object $wpdb WordPress Database object. |
|
| 81 | + * @global object $post The current post object. |
|
| 82 | + * @global object $current_user Current user object. |
|
| 83 | + * @global object $gd_session GeoDirectory Session object. |
|
| 84 | + * @param array $request_info {
|
|
| 85 | + * Array of request info arguments. |
|
| 86 | + * |
|
| 87 | + * @type string $action Ajax action name. |
|
| 88 | + * @type string $geodir_ajax Ajax type. |
|
| 89 | + * @type string $ajax_action Ajax action. |
|
| 90 | + * @type string $listing_type Listing type. |
|
| 91 | + * @type string $pid Default Post ID. |
|
| 92 | + * @type string $preview Todo Desc needed. |
|
| 93 | + * @type string $add_listing_page_id Add listing page ID. |
|
| 94 | + * @type string $post_title Listing title. |
|
| 95 | + * @type string $post_desc Listing Description. |
|
| 96 | + * @type string $post_tags Listing tags. |
|
| 97 | + * @type array $cat_limit Category limit. |
|
| 98 | + * @type array $post_category Category IDs. |
|
| 99 | + * @type array $post_category_str Category string. |
|
| 100 | + * @type string $post_default_category Default category ID. |
|
| 101 | + * @type string $post_address Listing address. |
|
| 102 | + * @type string $geodir_location_add_listing_country_val Add listing country value. |
|
| 103 | + * @type string $post_country Listing country. |
|
| 104 | + * @type string $geodir_location_add_listing_region_val Add listing region value. |
|
| 105 | + * @type string $post_region Listing region. |
|
| 106 | + * @type string $geodir_location_add_listing_city_val Add listing city value. |
|
| 107 | + * @type string $post_city Listing city. |
|
| 108 | + * @type string $post_zip Listing zip. |
|
| 109 | + * @type string $post_latitude Listing latitude. |
|
| 110 | + * @type string $post_longitude Listing longitude. |
|
| 111 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 112 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 113 | + * @type string $geodir_timing Business timing info. |
|
| 114 | + * @type string $geodir_contact Contact number. |
|
| 115 | + * @type string $geodir_email Business contact email. |
|
| 116 | + * @type string $geodir_website Business website. |
|
| 117 | + * @type string $geodir_twitter Twitter link. |
|
| 118 | + * @type string $geodir_facebook Facebook link. |
|
| 119 | + * @type string $geodir_video Video link. |
|
| 120 | + * @type string $geodir_special_offers Special offers. |
|
| 121 | + * @type string $post_images Post image urls. |
|
| 122 | + * @type string $post_imagesimage_limit Post images limit. |
|
| 123 | + * @type string $post_imagestotImg Todo Desc needed. |
|
| 124 | + * @type string $geodir_accept_term_condition Has accepted terms and conditions?. |
|
| 125 | + * @type string $geodir_spamblocker Todo Desc needed. |
|
| 126 | + * @type string $geodir_filled_by_spam_bot Todo Desc needed. |
|
| 127 | + * |
|
| 128 | + * } |
|
| 129 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 130 | + * @param bool $wp_error Optional. Allow return of WP_Error on failure. Default false. |
|
| 131 | + * @return int|string|WP_Error Created post id or WP_Error on failure. |
|
| 132 | + */ |
|
| 133 | + function geodir_save_listing($request_info = array(), $dummy = false, $wp_error = false) |
|
| 134 | + {
|
|
| 135 | + global $wpdb, $current_user, $gd_session; |
|
| 136 | + |
|
| 137 | + $last_post_id = ''; |
|
| 138 | + |
|
| 139 | + if ($gd_session->get('listing') && !$dummy) {
|
|
| 140 | + $request_info = array(); |
|
| 141 | + $request_session = $gd_session->get('listing');
|
|
| 142 | + $request_info = array_merge($_REQUEST, $request_session); |
|
| 143 | + } else if (!$gd_session->get('listing') && !$dummy) {
|
|
| 144 | + global $post; |
|
| 145 | 145 | |
| 146 | - $gd_post = $post; |
|
| 147 | - if (!empty($gd_post) && is_array($gd_post)) {
|
|
| 148 | - $gd_post = (object)$post; |
|
| 146 | + $gd_post = $post; |
|
| 147 | + if (!empty($gd_post) && is_array($gd_post)) {
|
|
| 148 | + $gd_post = (object)$post; |
|
| 149 | 149 | |
| 150 | - // Fix WPML duplicate. |
|
| 151 | - if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
|
|
| 152 | - return false; |
|
| 153 | - } |
|
| 154 | - } |
|
| 150 | + // Fix WPML duplicate. |
|
| 151 | + if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
|
|
| 152 | + return false; |
|
| 153 | + } |
|
| 154 | + } |
|
| 155 | 155 | |
| 156 | - $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
| 157 | - $request_info['post_title'] = $request_info['post_title']; |
|
| 158 | - $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid'])); |
|
| 159 | - $request_info['post_desc'] = $request_info['content']; |
|
| 160 | - } else if (!$dummy) {
|
|
| 161 | - return false; |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * Filter the request_info array. |
|
| 166 | - * |
|
| 167 | - * You can use this filter to modify request_info array. |
|
| 168 | - * |
|
| 169 | - * @since 1.0.0 |
|
| 170 | - * @package GeoDirectory |
|
| 171 | - * @param array $request_info See {@see geodir_save_listing()} for accepted args.
|
|
| 172 | - */ |
|
| 173 | - $request_info = apply_filters('geodir_action_get_request_info', $request_info);
|
|
| 174 | - |
|
| 175 | - // Check if we need to save post location as new location |
|
| 176 | - $location_result = geodir_get_default_location(); |
|
| 177 | - |
|
| 178 | - if ($location_result->location_id > 0) {
|
|
| 179 | - if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
|
|
| 180 | - $request_info['post_location'] = array( |
|
| 181 | - 'city' => $request_info['post_city'], |
|
| 182 | - 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
| 183 | - 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
| 184 | - 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
| 185 | - 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
| 186 | - ); |
|
| 187 | - |
|
| 188 | - $post_location_info = $request_info['post_location']; |
|
| 189 | - |
|
| 190 | - if ($location_id = geodir_add_new_location($post_location_info)) {
|
|
| 191 | - $post_location_id = $location_id; |
|
| 192 | - } |
|
| 193 | - } else {
|
|
| 194 | - $post_location_id = $location_result->location_id; |
|
| 195 | - } |
|
| 196 | - } else {
|
|
| 197 | - $post_location_id = $location_result->location_id; |
|
| 198 | - } |
|
| 199 | - |
|
| 200 | - if ($dummy) {
|
|
| 201 | - $post_status = 'publish'; |
|
| 202 | - } else {
|
|
| 203 | - $post_status = geodir_new_post_default_status(); |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 207 | - $post_status = get_post_status($request_info['pid']); |
|
| 208 | - } |
|
| 209 | - |
|
| 210 | - /* fix change of slug on every title edit */ |
|
| 211 | - if (!isset($request_info['post_name'])) {
|
|
| 212 | - $request_info['post_name'] = $request_info['post_title']; |
|
| 213 | - |
|
| 214 | - if (!empty($request_info['pid'])) {
|
|
| 215 | - $post_info = get_post($request_info['pid']); |
|
| 216 | - |
|
| 217 | - if (!empty($post_info) && isset($post_info->post_name)) {
|
|
| 218 | - $request_info['post_name'] = $post_info->post_name; |
|
| 219 | - } |
|
| 220 | - } |
|
| 221 | - } |
|
| 222 | - |
|
| 223 | - $post = array( |
|
| 224 | - 'post_content' => $request_info['post_desc'], |
|
| 225 | - 'post_status' => $post_status, |
|
| 226 | - 'post_title' => $request_info['post_title'], |
|
| 227 | - 'post_name' => $request_info['post_name'], |
|
| 228 | - 'post_type' => $request_info['listing_type'] |
|
| 229 | - ); |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * Called before a listing is saved to the database. |
|
| 233 | - * |
|
| 234 | - * @since 1.0.0 |
|
| 235 | - * @param object $post The post object. |
|
| 236 | - */ |
|
| 237 | - do_action_ref_array('geodir_before_save_listing', $post);
|
|
| 156 | + $request_info['pid'] = !empty($gd_post->ID) ? $gd_post->ID : (!empty($request_info['post_id']) ? $request_info['post_id'] : NULL); |
|
| 157 | + $request_info['post_title'] = $request_info['post_title']; |
|
| 158 | + $request_info['listing_type'] = !empty($gd_post->post_type) ? $gd_post->post_type : (!empty($request_info['post_type']) ? $request_info['post_type'] : get_post_type($request_info['pid'])); |
|
| 159 | + $request_info['post_desc'] = $request_info['content']; |
|
| 160 | + } else if (!$dummy) {
|
|
| 161 | + return false; |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * Filter the request_info array. |
|
| 166 | + * |
|
| 167 | + * You can use this filter to modify request_info array. |
|
| 168 | + * |
|
| 169 | + * @since 1.0.0 |
|
| 170 | + * @package GeoDirectory |
|
| 171 | + * @param array $request_info See {@see geodir_save_listing()} for accepted args.
|
|
| 172 | + */ |
|
| 173 | + $request_info = apply_filters('geodir_action_get_request_info', $request_info);
|
|
| 174 | + |
|
| 175 | + // Check if we need to save post location as new location |
|
| 176 | + $location_result = geodir_get_default_location(); |
|
| 177 | + |
|
| 178 | + if ($location_result->location_id > 0) {
|
|
| 179 | + if (isset($request_info['post_city']) && isset($request_info['post_region'])) {
|
|
| 180 | + $request_info['post_location'] = array( |
|
| 181 | + 'city' => $request_info['post_city'], |
|
| 182 | + 'region' => isset($request_info['post_region']) ? $request_info['post_region'] : '', |
|
| 183 | + 'country' => isset($request_info['post_country']) ? $request_info['post_country'] : '', |
|
| 184 | + 'geo_lat' => isset($request_info['post_latitude']) ? $request_info['post_latitude'] : '', |
|
| 185 | + 'geo_lng' => isset($request_info['post_longitude']) ? $request_info['post_longitude'] : '' |
|
| 186 | + ); |
|
| 187 | + |
|
| 188 | + $post_location_info = $request_info['post_location']; |
|
| 189 | + |
|
| 190 | + if ($location_id = geodir_add_new_location($post_location_info)) {
|
|
| 191 | + $post_location_id = $location_id; |
|
| 192 | + } |
|
| 193 | + } else {
|
|
| 194 | + $post_location_id = $location_result->location_id; |
|
| 195 | + } |
|
| 196 | + } else {
|
|
| 197 | + $post_location_id = $location_result->location_id; |
|
| 198 | + } |
|
| 238 | 199 | |
| 239 | - $send_post_submit_mail = false; |
|
| 200 | + if ($dummy) {
|
|
| 201 | + $post_status = 'publish'; |
|
| 202 | + } else {
|
|
| 203 | + $post_status = geodir_new_post_default_status(); |
|
| 204 | + } |
|
| 240 | 205 | |
| 241 | - // unhook this function so it doesn't loop infinitely |
|
| 242 | - remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 206 | + if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 207 | + $post_status = get_post_status($request_info['pid']); |
|
| 208 | + } |
|
| 243 | 209 | |
| 244 | - if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 245 | - $post['ID'] = $request_info['pid']; |
|
| 210 | + /* fix change of slug on every title edit */ |
|
| 211 | + if (!isset($request_info['post_name'])) {
|
|
| 212 | + $request_info['post_name'] = $request_info['post_title']; |
|
| 246 | 213 | |
| 247 | - $last_post_id = wp_update_post($post, $wp_error); |
|
| 248 | - } else {
|
|
| 249 | - $last_post_id = wp_insert_post($post, $wp_error); |
|
| 214 | + if (!empty($request_info['pid'])) {
|
|
| 215 | + $post_info = get_post($request_info['pid']); |
|
| 250 | 216 | |
| 251 | - if (!$dummy && $last_post_id) {
|
|
| 252 | - $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
| 253 | - //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
|
|
| 254 | - } |
|
| 255 | - } |
|
| 217 | + if (!empty($post_info) && isset($post_info->post_name)) {
|
|
| 218 | + $request_info['post_name'] = $post_info->post_name; |
|
| 219 | + } |
|
| 220 | + } |
|
| 221 | + } |
|
| 222 | + |
|
| 223 | + $post = array( |
|
| 224 | + 'post_content' => $request_info['post_desc'], |
|
| 225 | + 'post_status' => $post_status, |
|
| 226 | + 'post_title' => $request_info['post_title'], |
|
| 227 | + 'post_name' => $request_info['post_name'], |
|
| 228 | + 'post_type' => $request_info['listing_type'] |
|
| 229 | + ); |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * Called before a listing is saved to the database. |
|
| 233 | + * |
|
| 234 | + * @since 1.0.0 |
|
| 235 | + * @param object $post The post object. |
|
| 236 | + */ |
|
| 237 | + do_action_ref_array('geodir_before_save_listing', $post);
|
|
| 238 | + |
|
| 239 | + $send_post_submit_mail = false; |
|
| 240 | + |
|
| 241 | + // unhook this function so it doesn't loop infinitely |
|
| 242 | + remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 243 | + |
|
| 244 | + if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
|
| 245 | + $post['ID'] = $request_info['pid']; |
|
| 246 | + |
|
| 247 | + $last_post_id = wp_update_post($post, $wp_error); |
|
| 248 | + } else {
|
|
| 249 | + $last_post_id = wp_insert_post($post, $wp_error); |
|
| 250 | + |
|
| 251 | + if (!$dummy && $last_post_id) {
|
|
| 252 | + $send_post_submit_mail = true; // we move post_submit email from here so the rest of the variables are added to the db first(was breaking permalink in email) |
|
| 253 | + //geodir_sendEmail('','',$current_user->user_email,$current_user->display_name,'','',$request_info,'post_submit',$last_post_id,$current_user->ID);
|
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - if ($wp_error && is_wp_error($last_post_id)) {
|
|
| 258 | - return $last_post_id; // Return WP_Error on save failure. |
|
| 259 | - } |
|
| 257 | + if ($wp_error && is_wp_error($last_post_id)) {
|
|
| 258 | + return $last_post_id; // Return WP_Error on save failure. |
|
| 259 | + } |
|
| 260 | 260 | |
| 261 | - if (!$last_post_id) {
|
|
| 262 | - return false; // Save failure. |
|
| 263 | - } |
|
| 261 | + if (!$last_post_id) {
|
|
| 262 | + return false; // Save failure. |
|
| 263 | + } |
|
| 264 | 264 | |
| 265 | - // re-hook this function |
|
| 266 | - add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 265 | + // re-hook this function |
|
| 266 | + add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 267 | 267 | |
| 268 | - $post_tags = ''; |
|
| 269 | - if (!isset($request_info['post_tags'])) {
|
|
| 268 | + $post_tags = ''; |
|
| 269 | + if (!isset($request_info['post_tags'])) {
|
|
| 270 | 270 | |
| 271 | - $post_type = $request_info['listing_type']; |
|
| 272 | - $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 271 | + $post_type = $request_info['listing_type']; |
|
| 272 | + $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 273 | 273 | |
| 274 | - } |
|
| 274 | + } |
|
| 275 | 275 | |
| 276 | - $gd_post_info = array( |
|
| 277 | - "post_title" => $request_info['post_title'], |
|
| 278 | - "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
| 279 | - "post_status" => $post_status, |
|
| 280 | - "post_location_id" => $post_location_id, |
|
| 281 | - "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
| 282 | - "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
| 283 | - "submit_time" => time(), |
|
| 284 | - "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
| 285 | - ); |
|
| 276 | + $gd_post_info = array( |
|
| 277 | + "post_title" => $request_info['post_title'], |
|
| 278 | + "post_tags" => isset($request_info['post_tags']) ? $request_info['post_tags'] : $post_tags, |
|
| 279 | + "post_status" => $post_status, |
|
| 280 | + "post_location_id" => $post_location_id, |
|
| 281 | + "claimed" => isset($request_info['claimed']) ? $request_info['claimed'] : '', |
|
| 282 | + "businesses" => isset($request_info['a_businesses']) ? $request_info['a_businesses'] : '', |
|
| 283 | + "submit_time" => time(), |
|
| 284 | + "submit_ip" => $_SERVER['REMOTE_ADDR'], |
|
| 285 | + ); |
|
| 286 | 286 | |
| 287 | - $payment_info = array(); |
|
| 288 | - $package_info = array(); |
|
| 287 | + $payment_info = array(); |
|
| 288 | + $package_info = array(); |
|
| 289 | 289 | |
| 290 | - $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 290 | + $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 291 | 291 | |
| 292 | - $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
| 292 | + $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
|
| 293 | 293 | |
| 294 | - if (!empty($package_info) && !$post_package_id) {
|
|
| 295 | - if (isset($package_info['days']) && $package_info['days'] != 0) {
|
|
| 296 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 297 | - } else {
|
|
| 298 | - $payment_info['expire_date'] = 'Never'; |
|
| 299 | - } |
|
| 294 | + if (!empty($package_info) && !$post_package_id) {
|
|
| 295 | + if (isset($package_info['days']) && $package_info['days'] != 0) {
|
|
| 296 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 297 | + } else {
|
|
| 298 | + $payment_info['expire_date'] = 'Never'; |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - $payment_info['package_id'] = $package_info['pid']; |
|
| 302 | - $payment_info['alive_days'] = $package_info['days']; |
|
| 303 | - $payment_info['is_featured'] = $package_info['is_featured']; |
|
| 301 | + $payment_info['package_id'] = $package_info['pid']; |
|
| 302 | + $payment_info['alive_days'] = $package_info['days']; |
|
| 303 | + $payment_info['is_featured'] = $package_info['is_featured']; |
|
| 304 | 304 | |
| 305 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 306 | - } |
|
| 305 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 306 | + } |
|
| 307 | 307 | |
| 308 | - $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
|
|
| 308 | + $custom_metaboxes = geodir_post_custom_fields('', 'all', $request_info['listing_type']);
|
|
| 309 | 309 | |
| 310 | - foreach ($custom_metaboxes as $key => $val): |
|
| 310 | + foreach ($custom_metaboxes as $key => $val): |
|
| 311 | 311 | |
| 312 | - $name = $val['name']; |
|
| 313 | - $type = $val['type']; |
|
| 314 | - $extrafields = $val['extra_fields']; |
|
| 312 | + $name = $val['name']; |
|
| 313 | + $type = $val['type']; |
|
| 314 | + $extrafields = $val['extra_fields']; |
|
| 315 | 315 | |
| 316 | - if (trim($type) == 'address') {
|
|
| 317 | - $prefix = $name . '_'; |
|
| 318 | - $address = $prefix . 'address'; |
|
| 316 | + if (trim($type) == 'address') {
|
|
| 317 | + $prefix = $name . '_'; |
|
| 318 | + $address = $prefix . 'address'; |
|
| 319 | 319 | |
| 320 | - if (isset($request_info[$address]) && $request_info[$address] != '') {
|
|
| 321 | - $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
| 322 | - } |
|
| 320 | + if (isset($request_info[$address]) && $request_info[$address] != '') {
|
|
| 321 | + $gd_post_info[$address] = wp_slash($request_info[$address]); |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - if ($extrafields != '') {
|
|
| 325 | - $extrafields = unserialize($extrafields); |
|
| 324 | + if ($extrafields != '') {
|
|
| 325 | + $extrafields = unserialize($extrafields); |
|
| 326 | 326 | |
| 327 | 327 | |
| 328 | - if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 328 | + if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 329 | 329 | |
| 330 | - $location_result = geodir_get_default_location(); |
|
| 330 | + $location_result = geodir_get_default_location(); |
|
| 331 | 331 | |
| 332 | - $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 333 | - $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 334 | - $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 332 | + $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 333 | + $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 334 | + $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 335 | 335 | |
| 336 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 336 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 337 | 337 | |
| 338 | - } else {
|
|
| 338 | + } else {
|
|
| 339 | 339 | |
| 340 | - $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 341 | - $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 342 | - $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 340 | + $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 341 | + $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 342 | + $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 343 | 343 | |
| 344 | - //----------set post locations when import dummy data------- |
|
| 345 | - $location_result = geodir_get_default_location(); |
|
| 344 | + //----------set post locations when import dummy data------- |
|
| 345 | + $location_result = geodir_get_default_location(); |
|
| 346 | 346 | |
| 347 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 348 | - //----------------------------------------------------------------- |
|
| 347 | + $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 348 | + //----------------------------------------------------------------- |
|
| 349 | 349 | |
| 350 | - } |
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | 352 | |
| 353 | - if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 354 | - $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 355 | - } |
|
| 353 | + if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 354 | + $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | 357 | |
| 358 | - if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
|
| 358 | + if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
|
| 359 | 359 | |
| 360 | - if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 361 | - $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 362 | - } |
|
| 360 | + if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 361 | + $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 365 | - $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 366 | - } |
|
| 364 | + if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 365 | + $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 366 | + } |
|
| 367 | 367 | |
| 368 | - if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 369 | - $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 370 | - } |
|
| 368 | + if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 369 | + $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 373 | - $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 374 | - } |
|
| 372 | + if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 373 | + $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 374 | + } |
|
| 375 | 375 | |
| 376 | - } |
|
| 376 | + } |
|
| 377 | 377 | |
| 378 | - // show lat lng |
|
| 379 | - if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 380 | - $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 381 | - } |
|
| 382 | - } |
|
| 378 | + // show lat lng |
|
| 379 | + if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 380 | + $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 381 | + } |
|
| 382 | + } |
|
| 383 | 383 | |
| 384 | - } elseif (trim($type) == 'file') {
|
|
| 385 | - if (isset($request_info[$name])) {
|
|
| 386 | - $request_files = array(); |
|
| 387 | - if ($request_info[$name] != '') |
|
| 388 | - $request_files = explode(",", $request_info[$name]);
|
|
| 384 | + } elseif (trim($type) == 'file') {
|
|
| 385 | + if (isset($request_info[$name])) {
|
|
| 386 | + $request_files = array(); |
|
| 387 | + if ($request_info[$name] != '') |
|
| 388 | + $request_files = explode(",", $request_info[$name]);
|
|
| 389 | 389 | |
| 390 | - $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
| 391 | - geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
| 392 | - } |
|
| 393 | - } elseif (trim($type) == 'datepicker') {
|
|
| 394 | - if (isset($request_info[$name])) {
|
|
| 395 | - $datetime = ''; |
|
| 390 | + $extrafields = $extrafields != '' ? maybe_unserialize($extrafields) : NULL; |
|
| 391 | + geodir_save_post_file_fields($last_post_id, $name, $request_files, $extrafields); |
|
| 392 | + } |
|
| 393 | + } elseif (trim($type) == 'datepicker') {
|
|
| 394 | + if (isset($request_info[$name])) {
|
|
| 395 | + $datetime = ''; |
|
| 396 | 396 | |
| 397 | - if (!empty($request_info[$name])) {
|
|
| 398 | - $date_format = geodir_default_date_format(); |
|
| 399 | - if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
|
|
| 400 | - $extra_fields = unserialize($val['extra_fields']); |
|
| 401 | - $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // check if we need to change the format or not |
|
| 405 | - $date_format_len = strlen(str_replace(' ', '', $date_format));
|
|
| 406 | - if($date_format_len>5){// if greater then 5 then it's the old style format.
|
|
| 397 | + if (!empty($request_info[$name])) {
|
|
| 398 | + $date_format = geodir_default_date_format(); |
|
| 399 | + if (isset($val['extra_fields']) && $val['extra_fields'] != '') {
|
|
| 400 | + $extra_fields = unserialize($val['extra_fields']); |
|
| 401 | + $date_format = isset($extra_fields['date_format']) && $extra_fields['date_format'] != '' ? $extra_fields['date_format'] : $date_format; |
|
| 402 | + } |
|
| 407 | 403 | |
| 408 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 409 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 404 | + // check if we need to change the format or not |
|
| 405 | + $date_format_len = strlen(str_replace(' ', '', $date_format));
|
|
| 406 | + if($date_format_len>5){// if greater then 5 then it's the old style format.
|
|
| 410 | 407 | |
| 411 | - $date_format = str_replace($search, $replace, $date_format); |
|
| 408 | + $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 409 | + $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 412 | 410 | |
| 413 | - $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
|
|
| 411 | + $date_format = str_replace($search, $replace, $date_format); |
|
| 414 | 412 | |
| 415 | - }else{
|
|
| 416 | - $post_htmlvar_value = $request_info[$name]; |
|
| 417 | - } |
|
| 413 | + $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
|
|
| 418 | 414 | |
| 419 | - $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d |
|
| 420 | - $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated |
|
| 421 | - } |
|
| 415 | + }else{
|
|
| 416 | + $post_htmlvar_value = $request_info[$name]; |
|
| 417 | + } |
|
| 422 | 418 | |
| 423 | - $gd_post_info[$name] = $datetime; |
|
| 424 | - } |
|
| 425 | - } else if ($type == 'multiselect') {
|
|
| 426 | - if (isset($request_info[$name])) {
|
|
| 427 | - $gd_post_info[$name] = $request_info[$name]; |
|
| 428 | - } else {
|
|
| 429 | - if (isset($request_info['gd_field_' . $name])) {
|
|
| 430 | - $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
| 431 | - } |
|
| 432 | - } |
|
| 433 | - } else if (isset($request_info[$name])) {
|
|
| 434 | - $gd_post_info[$name] = $request_info[$name]; |
|
| 435 | - } |
|
| 419 | + $post_htmlvar_value = geodir_date($post_htmlvar_value, 'Y-m-d', $date_format); // save as sql format Y-m-d |
|
| 420 | + $datetime = geodir_maybe_untranslate_date($post_htmlvar_value); // maybe untranslate date string if it was translated |
|
| 421 | + } |
|
| 436 | 422 | |
| 437 | - endforeach; |
|
| 423 | + $gd_post_info[$name] = $datetime; |
|
| 424 | + } |
|
| 425 | + } else if ($type == 'multiselect') {
|
|
| 426 | + if (isset($request_info[$name])) {
|
|
| 427 | + $gd_post_info[$name] = $request_info[$name]; |
|
| 428 | + } else {
|
|
| 429 | + if (isset($request_info['gd_field_' . $name])) {
|
|
| 430 | + $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
|
| 431 | + } |
|
| 432 | + } |
|
| 433 | + } else if (isset($request_info[$name])) {
|
|
| 434 | + $gd_post_info[$name] = $request_info[$name]; |
|
| 435 | + } |
|
| 438 | 436 | |
| 439 | - if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
|
|
| 440 | - $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
| 441 | - } |
|
| 437 | + endforeach; |
|
| 442 | 438 | |
| 443 | - // Save post detail info in detail table |
|
| 444 | - if (!empty($gd_post_info)) {
|
|
| 445 | - geodir_save_post_info($last_post_id, $gd_post_info); |
|
| 446 | - } |
|
| 439 | + if (isset($request_info['post_dummy']) && $request_info['post_dummy'] != '') {
|
|
| 440 | + $gd_post_info['post_dummy'] = $request_info['post_dummy']; |
|
| 441 | + } |
|
| 447 | 442 | |
| 443 | + // Save post detail info in detail table |
|
| 444 | + if (!empty($gd_post_info)) {
|
|
| 445 | + geodir_save_post_info($last_post_id, $gd_post_info); |
|
| 446 | + } |
|
| 448 | 447 | |
| 449 | - // Set categories to the listing |
|
| 450 | - if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
|
|
| 451 | - $post_category = array(); |
|
| 452 | 448 | |
| 453 | - foreach ($request_info['post_category'] as $taxonomy => $cat) {
|
|
| 449 | + // Set categories to the listing |
|
| 450 | + if (isset($request_info['post_category']) && !empty($request_info['post_category'])) {
|
|
| 451 | + $post_category = array(); |
|
| 454 | 452 | |
| 455 | - if ($dummy) |
|
| 456 | - $post_category = $cat; |
|
| 457 | - else {
|
|
| 453 | + foreach ($request_info['post_category'] as $taxonomy => $cat) {
|
|
| 458 | 454 | |
| 459 | - if (!is_array($cat) && strstr($cat, ',')) |
|
| 460 | - $cat = explode(',', $cat);
|
|
| 455 | + if ($dummy) |
|
| 456 | + $post_category = $cat; |
|
| 457 | + else {
|
|
| 461 | 458 | |
| 462 | - if (!empty($cat) && is_array($cat)) |
|
| 463 | - $post_category = array_map('intval', $cat);
|
|
| 464 | - } |
|
| 459 | + if (!is_array($cat) && strstr($cat, ',')) |
|
| 460 | + $cat = explode(',', $cat);
|
|
| 465 | 461 | |
| 466 | - wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
| 467 | - } |
|
| 462 | + if (!empty($cat) && is_array($cat)) |
|
| 463 | + $post_category = array_map('intval', $cat);
|
|
| 464 | + } |
|
| 468 | 465 | |
| 469 | - $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
| 466 | + wp_set_object_terms($last_post_id, $post_category, $taxonomy); |
|
| 467 | + } |
|
| 470 | 468 | |
| 471 | - $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
| 472 | - geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
| 469 | + $post_default_category = isset($request_info['post_default_category']) ? $request_info['post_default_category'] : ''; |
|
| 473 | 470 | |
| 474 | - } |
|
| 471 | + $post_category_str = isset($request_info['post_category_str']) ? $request_info['post_category_str'] : ''; |
|
| 472 | + geodir_set_postcat_structure($last_post_id, $taxonomy, $post_default_category, $post_category_str); |
|
| 475 | 473 | |
| 476 | - $post_tags = ''; |
|
| 477 | - // Set tags to the listing |
|
| 478 | - if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
|
|
| 479 | - $post_tags = explode(",", $request_info['post_tags']);
|
|
| 480 | - } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
|
|
| 481 | - if ($dummy) |
|
| 482 | - $post_tags = $request_info['post_tags']; |
|
| 483 | - } else {
|
|
| 484 | - if ($dummy) |
|
| 485 | - $post_tags = array($request_info['post_title']); |
|
| 486 | - } |
|
| 474 | + } |
|
| 487 | 475 | |
| 488 | - if (is_array($post_tags)) {
|
|
| 489 | - $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 490 | - wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
| 491 | - } |
|
| 476 | + $post_tags = ''; |
|
| 477 | + // Set tags to the listing |
|
| 478 | + if (isset($request_info['post_tags']) && !is_array($request_info['post_tags']) && !empty($request_info['post_tags'])) {
|
|
| 479 | + $post_tags = explode(",", $request_info['post_tags']);
|
|
| 480 | + } elseif (isset($request_info['post_tags']) && is_array($request_info['post_tags'])) {
|
|
| 481 | + if ($dummy) |
|
| 482 | + $post_tags = $request_info['post_tags']; |
|
| 483 | + } else {
|
|
| 484 | + if ($dummy) |
|
| 485 | + $post_tags = array($request_info['post_title']); |
|
| 486 | + } |
|
| 492 | 487 | |
| 488 | + if (is_array($post_tags)) {
|
|
| 489 | + $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 490 | + wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
|
| 491 | + } |
|
| 493 | 492 | |
| 494 | - // Insert attachment |
|
| 495 | 493 | |
| 496 | - if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
|
|
| 497 | - if (!$dummy) {
|
|
| 498 | - $tmpimgArr = trim($request_info['post_images'], ","); |
|
| 499 | - $tmpimgArr = explode(",", $tmpimgArr);
|
|
| 500 | - geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
| 501 | - } else{
|
|
| 502 | - geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
| 503 | - } |
|
| 494 | + // Insert attachment |
|
| 495 | + |
|
| 496 | + if (isset($request_info['post_images']) && !is_wp_error($last_post_id)) {
|
|
| 497 | + if (!$dummy) {
|
|
| 498 | + $tmpimgArr = trim($request_info['post_images'], ","); |
|
| 499 | + $tmpimgArr = explode(",", $tmpimgArr);
|
|
| 500 | + geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
|
| 501 | + } else{
|
|
| 502 | + geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
|
| 503 | + } |
|
| 504 | 504 | |
| 505 | 505 | |
| 506 | - } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
|
|
| 506 | + } elseif (!isset($request_info['post_images']) || $request_info['post_images'] == '') {
|
|
| 507 | 507 | |
| 508 | - /* Delete Attachments |
|
| 508 | + /* Delete Attachments |
|
| 509 | 509 | $postcurr_images = geodir_get_images($last_post_id); |
| 510 | 510 | |
| 511 | 511 | $wpdb->query( |
@@ -521,34 +521,34 @@ discard block |
||
| 521 | 521 | geodir_save_post_info($last_post_id, $gd_post_featured_img); |
| 522 | 522 | */ |
| 523 | 523 | |
| 524 | - } |
|
| 524 | + } |
|
| 525 | 525 | |
| 526 | - geodir_remove_temp_images(); |
|
| 527 | - geodir_set_wp_featured_image($last_post_id); |
|
| 526 | + geodir_remove_temp_images(); |
|
| 527 | + geodir_set_wp_featured_image($last_post_id); |
|
| 528 | 528 | |
| 529 | - /** |
|
| 530 | - * Called after a listing is saved to the database and before any email have been sent. |
|
| 531 | - * |
|
| 532 | - * @since 1.0.0 |
|
| 533 | - * @param int $last_post_id The saved post ID. |
|
| 534 | - * @param array $request_info The post details in an array. |
|
| 535 | - * @see 'geodir_after_save_listinginfo' |
|
| 536 | - */ |
|
| 537 | - do_action('geodir_after_save_listing', $last_post_id, $request_info);
|
|
| 529 | + /** |
|
| 530 | + * Called after a listing is saved to the database and before any email have been sent. |
|
| 531 | + * |
|
| 532 | + * @since 1.0.0 |
|
| 533 | + * @param int $last_post_id The saved post ID. |
|
| 534 | + * @param array $request_info The post details in an array. |
|
| 535 | + * @see 'geodir_after_save_listinginfo' |
|
| 536 | + */ |
|
| 537 | + do_action('geodir_after_save_listing', $last_post_id, $request_info);
|
|
| 538 | 538 | |
| 539 | - //die; |
|
| 539 | + //die; |
|
| 540 | 540 | |
| 541 | - if ($send_post_submit_mail) { // if new post send out email
|
|
| 542 | - $to_name = geodir_get_client_name($current_user->ID); |
|
| 543 | - geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
|
|
| 544 | - } |
|
| 545 | - /* |
|
| 541 | + if ($send_post_submit_mail) { // if new post send out email
|
|
| 542 | + $to_name = geodir_get_client_name($current_user->ID); |
|
| 543 | + geodir_sendEmail('', '', $current_user->user_email, $to_name, '', '', $request_info, 'post_submit', $last_post_id, $current_user->ID);
|
|
| 544 | + } |
|
| 545 | + /* |
|
| 546 | 546 | * Unset the session so we don't loop. |
| 547 | 547 | */ |
| 548 | - $gd_session->un_set('listing');
|
|
| 549 | - return $last_post_id; |
|
| 548 | + $gd_session->un_set('listing');
|
|
| 549 | + return $last_post_id; |
|
| 550 | 550 | |
| 551 | - } |
|
| 551 | + } |
|
| 552 | 552 | |
| 553 | 553 | } |
| 554 | 554 | |
@@ -567,611 +567,611 @@ discard block |
||
| 567 | 567 | function geodir_get_post_info($post_id = '') |
| 568 | 568 | {
|
| 569 | 569 | |
| 570 | - global $wpdb, $plugin_prefix, $post, $post_info; |
|
| 570 | + global $wpdb, $plugin_prefix, $post, $post_info; |
|
| 571 | 571 | |
| 572 | - if ($post_id == '' && !empty($post)) |
|
| 573 | - $post_id = $post->ID; |
|
| 572 | + if ($post_id == '' && !empty($post)) |
|
| 573 | + $post_id = $post->ID; |
|
| 574 | 574 | |
| 575 | - $post_type = get_post_type($post_id); |
|
| 575 | + $post_type = get_post_type($post_id); |
|
| 576 | 576 | |
| 577 | - $all_postypes = geodir_get_posttypes(); |
|
| 577 | + $all_postypes = geodir_get_posttypes(); |
|
| 578 | 578 | |
| 579 | - if (!in_array($post_type, $all_postypes)) |
|
| 580 | - return false; |
|
| 579 | + if (!in_array($post_type, $all_postypes)) |
|
| 580 | + return false; |
|
| 581 | 581 | |
| 582 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 582 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 583 | 583 | |
| 584 | - /** |
|
| 585 | - * Apply Filter to change Post info |
|
| 586 | - * |
|
| 587 | - * You can use this filter to change Post info. |
|
| 588 | - * |
|
| 589 | - * @since 1.0.0 |
|
| 590 | - * @package GeoDirectory |
|
| 591 | - */ |
|
| 592 | - $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 584 | + /** |
|
| 585 | + * Apply Filter to change Post info |
|
| 586 | + * |
|
| 587 | + * You can use this filter to change Post info. |
|
| 588 | + * |
|
| 589 | + * @since 1.0.0 |
|
| 590 | + * @package GeoDirectory |
|
| 591 | + */ |
|
| 592 | + $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 593 | 593 | WHERE p.ID = pd.post_id |
| 594 | 594 | AND pd.post_id = %d", $post_id)); |
| 595 | 595 | |
| 596 | - $post_detail = $wpdb->get_row($query); |
|
| 596 | + $post_detail = $wpdb->get_row($query); |
|
| 597 | 597 | |
| 598 | - return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
| 598 | + return (!empty($post_detail)) ? $post_info = $post_detail : $post_info = false; |
|
| 599 | 599 | |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | |
| 603 | 603 | if (!function_exists('geodir_save_post_info')) {
|
| 604 | - /** |
|
| 605 | - * Saves post detail info in detail table. |
|
| 606 | - * |
|
| 607 | - * @since 1.0.0 |
|
| 608 | - * @package GeoDirectory |
|
| 609 | - * @global object $wpdb WordPress Database object. |
|
| 610 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 611 | - * @param int $post_id The post ID. |
|
| 612 | - * @param array $postinfo_array {
|
|
| 613 | - * Post info that needs to be saved in detail table. |
|
| 614 | - * |
|
| 615 | - * @type string $post_title Listing title. |
|
| 616 | - * @type string $post_tags Listing tags. |
|
| 617 | - * @type string $post_status Listing post status. |
|
| 618 | - * @type string $post_location_id Listing location ID. |
|
| 619 | - * @type string $claimed Todo Desc needed. |
|
| 620 | - * @type string $businesses Todo Desc needed. |
|
| 621 | - * @type int $submit_time Submitted time in unix timestamp. |
|
| 622 | - * @type string $submit_ip Submitted IP. |
|
| 623 | - * @type string $expire_date Listing expiration date. |
|
| 624 | - * @type int $package_id Listing package ID. |
|
| 625 | - * @type int $alive_days Todo Desc needed. |
|
| 626 | - * @type int $is_featured Is this a featured listing?. |
|
| 627 | - * @type string $post_address Listing address. |
|
| 628 | - * @type string $post_city Listing city. |
|
| 629 | - * @type string $post_region Listing region. |
|
| 630 | - * @type string $post_country Listing country. |
|
| 631 | - * @type string $post_locations Listing locations. |
|
| 632 | - * @type string $post_zip Listing zip. |
|
| 633 | - * @type string $post_latitude Listing latitude. |
|
| 634 | - * @type string $post_longitude Listing longitude. |
|
| 635 | - * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 636 | - * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 637 | - * @type string $geodir_timing Business timing info. |
|
| 638 | - * @type string $geodir_contact Contact number. |
|
| 639 | - * @type string $geodir_email Business contact email. |
|
| 640 | - * @type string $geodir_website Business website. |
|
| 641 | - * @type string $geodir_twitter Twitter link. |
|
| 642 | - * @type string $geodir_facebook Facebook link. |
|
| 643 | - * @type string $geodir_video Video link. |
|
| 644 | - * @type string $geodir_special_offers Special offers. |
|
| 645 | - * |
|
| 646 | - * } |
|
| 647 | - * @return bool |
|
| 648 | - */ |
|
| 649 | - function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
| 650 | - {
|
|
| 651 | - global $wpdb, $plugin_prefix; |
|
| 652 | - |
|
| 653 | - $post_type = get_post_type($post_id); |
|
| 654 | - |
|
| 655 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 656 | - |
|
| 657 | - /** |
|
| 658 | - * Filter to change Post info |
|
| 659 | - * |
|
| 660 | - * You can use this filter to change Post info. |
|
| 661 | - * |
|
| 662 | - * @since 1.0.0 |
|
| 663 | - * @package GeoDirectory |
|
| 664 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 665 | - * @param int $post_id The post ID. |
|
| 666 | - */ |
|
| 667 | - $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
|
|
| 604 | + /** |
|
| 605 | + * Saves post detail info in detail table. |
|
| 606 | + * |
|
| 607 | + * @since 1.0.0 |
|
| 608 | + * @package GeoDirectory |
|
| 609 | + * @global object $wpdb WordPress Database object. |
|
| 610 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 611 | + * @param int $post_id The post ID. |
|
| 612 | + * @param array $postinfo_array {
|
|
| 613 | + * Post info that needs to be saved in detail table. |
|
| 614 | + * |
|
| 615 | + * @type string $post_title Listing title. |
|
| 616 | + * @type string $post_tags Listing tags. |
|
| 617 | + * @type string $post_status Listing post status. |
|
| 618 | + * @type string $post_location_id Listing location ID. |
|
| 619 | + * @type string $claimed Todo Desc needed. |
|
| 620 | + * @type string $businesses Todo Desc needed. |
|
| 621 | + * @type int $submit_time Submitted time in unix timestamp. |
|
| 622 | + * @type string $submit_ip Submitted IP. |
|
| 623 | + * @type string $expire_date Listing expiration date. |
|
| 624 | + * @type int $package_id Listing package ID. |
|
| 625 | + * @type int $alive_days Todo Desc needed. |
|
| 626 | + * @type int $is_featured Is this a featured listing?. |
|
| 627 | + * @type string $post_address Listing address. |
|
| 628 | + * @type string $post_city Listing city. |
|
| 629 | + * @type string $post_region Listing region. |
|
| 630 | + * @type string $post_country Listing country. |
|
| 631 | + * @type string $post_locations Listing locations. |
|
| 632 | + * @type string $post_zip Listing zip. |
|
| 633 | + * @type string $post_latitude Listing latitude. |
|
| 634 | + * @type string $post_longitude Listing longitude. |
|
| 635 | + * @type string $post_mapview Listing mapview. Default "ROADMAP". |
|
| 636 | + * @type string $post_mapzoom Listing mapzoom Default "9". |
|
| 637 | + * @type string $geodir_timing Business timing info. |
|
| 638 | + * @type string $geodir_contact Contact number. |
|
| 639 | + * @type string $geodir_email Business contact email. |
|
| 640 | + * @type string $geodir_website Business website. |
|
| 641 | + * @type string $geodir_twitter Twitter link. |
|
| 642 | + * @type string $geodir_facebook Facebook link. |
|
| 643 | + * @type string $geodir_video Video link. |
|
| 644 | + * @type string $geodir_special_offers Special offers. |
|
| 645 | + * |
|
| 646 | + * } |
|
| 647 | + * @return bool |
|
| 648 | + */ |
|
| 649 | + function geodir_save_post_info($post_id, $postinfo_array = array()) |
|
| 650 | + {
|
|
| 651 | + global $wpdb, $plugin_prefix; |
|
| 652 | + |
|
| 653 | + $post_type = get_post_type($post_id); |
|
| 654 | + |
|
| 655 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 656 | + |
|
| 657 | + /** |
|
| 658 | + * Filter to change Post info |
|
| 659 | + * |
|
| 660 | + * You can use this filter to change Post info. |
|
| 661 | + * |
|
| 662 | + * @since 1.0.0 |
|
| 663 | + * @package GeoDirectory |
|
| 664 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 665 | + * @param int $post_id The post ID. |
|
| 666 | + */ |
|
| 667 | + $postmeta = apply_filters('geodir_listinginfo_request', $postinfo_array, $post_id);
|
|
| 668 | + |
|
| 669 | + $query_string_escaped = ''; |
|
| 670 | + $query_string_array = array(); |
|
| 671 | + |
|
| 672 | + if (!empty($postmeta) && $post_id) {
|
|
| 673 | + |
|
| 674 | + $columns = $wpdb->get_col("show columns from $table");
|
|
| 675 | + foreach ($postmeta as $mkey => $mval) {
|
|
| 676 | + if(in_array($mkey,$columns)) {
|
|
| 677 | + if (is_array($mval)) {
|
|
| 678 | + $mval = implode(",", $mval);
|
|
| 679 | + } |
|
| 680 | + $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above |
|
| 681 | + $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare |
|
| 668 | 682 | |
| 669 | - $query_string_escaped = ''; |
|
| 670 | - $query_string_array = array(); |
|
| 683 | + } |
|
| 684 | + } |
|
| 671 | 685 | |
| 672 | - if (!empty($postmeta) && $post_id) {
|
|
| 686 | + $query_string_escaped = trim($query_string_escaped, ", "); |
|
| 673 | 687 | |
| 674 | - $columns = $wpdb->get_col("show columns from $table");
|
|
| 675 | - foreach ($postmeta as $mkey => $mval) {
|
|
| 676 | - if(in_array($mkey,$columns)) {
|
|
| 677 | - if (is_array($mval)) {
|
|
| 678 | - $mval = implode(",", $mval);
|
|
| 679 | - } |
|
| 680 | - $query_string_escaped .= " $mkey = %s, "; // we can set the key here as we check if the column exists above |
|
| 681 | - $query_string_array[] = stripslashes($mval); // we strip slashes as we are using wpdb prepare |
|
| 688 | + if (empty($query_string_array) || trim($query_string_escaped) == '') {
|
|
| 689 | + return false; |
|
| 690 | + } |
|
| 682 | 691 | |
| 683 | - } |
|
| 684 | - } |
|
| 692 | + $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
|
|
| 685 | 693 | |
| 686 | - $query_string_escaped = trim($query_string_escaped, ", "); |
|
| 687 | 694 | |
| 688 | - if (empty($query_string_array) || trim($query_string_escaped) == '') {
|
|
| 689 | - return false; |
|
| 690 | - } |
|
| 695 | + /** |
|
| 696 | + * Called before saving the listing info. |
|
| 697 | + * |
|
| 698 | + * @since 1.0.0 |
|
| 699 | + * @package GeoDirectory |
|
| 700 | + * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 701 | + * @param int $post_id The post ID. |
|
| 702 | + */ |
|
| 703 | + do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
|
| 691 | 704 | |
| 692 | - $query_string_array = str_replace(array("'%", "%'"), array("'%%", "%%'"), $query_string_array);
|
|
| 705 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 693 | 706 | |
| 707 | + $query_string_array[] = $post_id; |
|
| 708 | + $wpdb->query( |
|
| 709 | + $wpdb->prepare( |
|
| 710 | + "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
| 711 | + $query_string_array |
|
| 712 | + ) |
|
| 713 | + ); |
|
| 694 | 714 | |
| 695 | - /** |
|
| 696 | - * Called before saving the listing info. |
|
| 697 | - * |
|
| 698 | - * @since 1.0.0 |
|
| 699 | - * @package GeoDirectory |
|
| 700 | - * @param array $postinfo_array See {@see geodir_save_post_info()} for accepted args.
|
|
| 701 | - * @param int $post_id The post ID. |
|
| 702 | - */ |
|
| 703 | - do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
|
| 704 | 715 | |
| 705 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 716 | + } else {
|
|
| 706 | 717 | |
| 707 | - $query_string_array[] = $post_id; |
|
| 708 | - $wpdb->query( |
|
| 709 | - $wpdb->prepare( |
|
| 710 | - "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
| 711 | - $query_string_array |
|
| 712 | - ) |
|
| 713 | - ); |
|
| 718 | + array_unshift($query_string_array, $post_id); |
|
| 719 | + $wpdb->query( |
|
| 720 | + $wpdb->prepare( |
|
| 721 | + "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
| 722 | + $query_string_array |
|
| 723 | + ) |
|
| 724 | + ); |
|
| 725 | + |
|
| 726 | + } |
|
| 714 | 727 | |
| 728 | + /** |
|
| 729 | + * Called after saving the listing info. |
|
| 730 | + * |
|
| 731 | + * @since 1.0.0 |
|
| 732 | + * @package GeoDirectory |
|
| 733 | + * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
| 734 | + * @param int $post_id The post ID. |
|
| 735 | + * @see 'geodir_after_save_listing' |
|
| 736 | + */ |
|
| 737 | + do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
|
|
| 738 | + |
|
| 739 | + return true; |
|
| 740 | + } else |
|
| 741 | + return false; |
|
| 715 | 742 | |
| 716 | - } else {
|
|
| 743 | + } |
|
| 744 | +} |
|
| 717 | 745 | |
| 718 | - array_unshift($query_string_array, $post_id); |
|
| 719 | - $wpdb->query( |
|
| 720 | - $wpdb->prepare( |
|
| 721 | - "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
| 722 | - $query_string_array |
|
| 723 | - ) |
|
| 724 | - ); |
|
| 725 | - |
|
| 726 | - } |
|
| 727 | 746 | |
| 728 | - /** |
|
| 729 | - * Called after saving the listing info. |
|
| 730 | - * |
|
| 731 | - * @since 1.0.0 |
|
| 732 | - * @package GeoDirectory |
|
| 733 | - * @param array $postinfo_array Post info that needs to be saved in detail table. |
|
| 734 | - * @param int $post_id The post ID. |
|
| 735 | - * @see 'geodir_after_save_listing' |
|
| 736 | - */ |
|
| 737 | - do_action('geodir_after_save_listinginfo', $postinfo_array, $post_id);
|
|
| 747 | +if (!function_exists('geodir_save_post_meta')) {
|
|
| 748 | + /** |
|
| 749 | + * Save or update post custom fields. |
|
| 750 | + * |
|
| 751 | + * @since 1.0.0 |
|
| 752 | + * @package GeoDirectory |
|
| 753 | + * @global object $wpdb WordPress Database object. |
|
| 754 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 755 | + * @param int $post_id The post ID. |
|
| 756 | + * @param string $postmeta Detail table column name. |
|
| 757 | + * @param string $meta_value Detail table column value. |
|
| 758 | + * @return void|bool |
|
| 759 | + */ |
|
| 760 | + function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
| 761 | + {
|
|
| 762 | + |
|
| 763 | + global $wpdb, $plugin_prefix; |
|
| 764 | + |
|
| 765 | + $post_type = get_post_type($post_id); |
|
| 766 | + |
|
| 767 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 768 | + |
|
| 769 | + if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
|
| 770 | + |
|
| 771 | + if (is_array($meta_value)) {
|
|
| 772 | + $meta_value = implode(",", $meta_value);
|
|
| 773 | + } |
|
| 738 | 774 | |
| 739 | - return true; |
|
| 740 | - } else |
|
| 741 | - return false; |
|
| 775 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 742 | 776 | |
| 743 | - } |
|
| 744 | -} |
|
| 777 | + $wpdb->query( |
|
| 778 | + $wpdb->prepare( |
|
| 779 | + "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 780 | + array($post_id) |
|
| 781 | + ) |
|
| 782 | + ); |
|
| 745 | 783 | |
| 784 | + } else {
|
|
| 746 | 785 | |
| 747 | -if (!function_exists('geodir_save_post_meta')) {
|
|
| 748 | - /** |
|
| 749 | - * Save or update post custom fields. |
|
| 750 | - * |
|
| 751 | - * @since 1.0.0 |
|
| 752 | - * @package GeoDirectory |
|
| 753 | - * @global object $wpdb WordPress Database object. |
|
| 754 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 755 | - * @param int $post_id The post ID. |
|
| 756 | - * @param string $postmeta Detail table column name. |
|
| 757 | - * @param string $meta_value Detail table column value. |
|
| 758 | - * @return void|bool |
|
| 759 | - */ |
|
| 760 | - function geodir_save_post_meta($post_id, $postmeta = '', $meta_value = '') |
|
| 761 | - {
|
|
| 762 | - |
|
| 763 | - global $wpdb, $plugin_prefix; |
|
| 764 | - |
|
| 765 | - $post_type = get_post_type($post_id); |
|
| 766 | - |
|
| 767 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 768 | - |
|
| 769 | - if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
|
| 770 | - |
|
| 771 | - if (is_array($meta_value)) {
|
|
| 772 | - $meta_value = implode(",", $meta_value);
|
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 776 | - |
|
| 777 | - $wpdb->query( |
|
| 778 | - $wpdb->prepare( |
|
| 779 | - "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 780 | - array($post_id) |
|
| 781 | - ) |
|
| 782 | - ); |
|
| 783 | - |
|
| 784 | - } else {
|
|
| 785 | - |
|
| 786 | - $wpdb->query( |
|
| 787 | - $wpdb->prepare( |
|
| 788 | - "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 789 | - array($post_id) |
|
| 790 | - ) |
|
| 791 | - ); |
|
| 792 | - } |
|
| 793 | - |
|
| 794 | - |
|
| 795 | - } else |
|
| 796 | - return false; |
|
| 797 | - } |
|
| 786 | + $wpdb->query( |
|
| 787 | + $wpdb->prepare( |
|
| 788 | + "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 789 | + array($post_id) |
|
| 790 | + ) |
|
| 791 | + ); |
|
| 792 | + } |
|
| 793 | + |
|
| 794 | + |
|
| 795 | + } else |
|
| 796 | + return false; |
|
| 797 | + } |
|
| 798 | 798 | } |
| 799 | 799 | |
| 800 | 800 | if (!function_exists('geodir_delete_post_meta')) {
|
| 801 | - /** |
|
| 802 | - * Delete post custom fields. |
|
| 803 | - * |
|
| 804 | - * @since 1.0.0 |
|
| 805 | - * @package GeoDirectory |
|
| 806 | - * @global object $wpdb WordPress Database object. |
|
| 807 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 808 | - * @param int $post_id The post ID. |
|
| 809 | - * @param string $postmeta Detail table column name. |
|
| 810 | - * @todo check if this is depreciated |
|
| 811 | - * @todo Fix unknown variable mval |
|
| 812 | - * @return bool |
|
| 813 | - */ |
|
| 814 | - function geodir_delete_post_meta($post_id, $postmeta) |
|
| 815 | - {
|
|
| 816 | - |
|
| 817 | - global $wpdb, $plugin_prefix; |
|
| 818 | - |
|
| 819 | - $post_type = get_post_type($post_id); |
|
| 820 | - |
|
| 821 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 822 | - |
|
| 823 | - if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
|
| 824 | - $post_meta_set_query = ''; |
|
| 825 | - |
|
| 826 | - foreach ($postmeta as $mkey) {
|
|
| 827 | - if ($mval != '') |
|
| 828 | - $post_meta_set_query .= $mkey . " = '', "; |
|
| 829 | - } |
|
| 830 | - |
|
| 831 | - $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 801 | + /** |
|
| 802 | + * Delete post custom fields. |
|
| 803 | + * |
|
| 804 | + * @since 1.0.0 |
|
| 805 | + * @package GeoDirectory |
|
| 806 | + * @global object $wpdb WordPress Database object. |
|
| 807 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 808 | + * @param int $post_id The post ID. |
|
| 809 | + * @param string $postmeta Detail table column name. |
|
| 810 | + * @todo check if this is depreciated |
|
| 811 | + * @todo Fix unknown variable mval |
|
| 812 | + * @return bool |
|
| 813 | + */ |
|
| 814 | + function geodir_delete_post_meta($post_id, $postmeta) |
|
| 815 | + {
|
|
| 816 | + |
|
| 817 | + global $wpdb, $plugin_prefix; |
|
| 818 | + |
|
| 819 | + $post_type = get_post_type($post_id); |
|
| 820 | + |
|
| 821 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 822 | + |
|
| 823 | + if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
|
| 824 | + $post_meta_set_query = ''; |
|
| 825 | + |
|
| 826 | + foreach ($postmeta as $mkey) {
|
|
| 827 | + if ($mval != '') |
|
| 828 | + $post_meta_set_query .= $mkey . " = '', "; |
|
| 829 | + } |
|
| 830 | + |
|
| 831 | + $post_meta_set_query = trim($post_meta_set_query, ", "); |
|
| 832 | 832 | |
| 833 | - if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
|
|
| 834 | - return false; |
|
| 835 | - } |
|
| 836 | - |
|
| 837 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 838 | - |
|
| 839 | - $wpdb->query( |
|
| 840 | - $wpdb->prepare( |
|
| 841 | - "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 842 | - array($post_id) |
|
| 843 | - ) |
|
| 844 | - ); |
|
| 845 | - |
|
| 846 | - return true; |
|
| 847 | - } |
|
| 848 | - |
|
| 849 | - } elseif ($postmeta != '' && $post_id) {
|
|
| 850 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 851 | - |
|
| 852 | - $wpdb->query( |
|
| 853 | - $wpdb->prepare( |
|
| 854 | - "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 855 | - array($post_id) |
|
| 856 | - ) |
|
| 857 | - ); |
|
| 858 | - |
|
| 859 | - return true; |
|
| 860 | - } |
|
| 861 | - |
|
| 862 | - } else |
|
| 863 | - return false; |
|
| 864 | - } |
|
| 833 | + if (empty($post_meta_set_query) || trim($post_meta_set_query) == '') {
|
|
| 834 | + return false; |
|
| 835 | + } |
|
| 836 | + |
|
| 837 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 838 | + |
|
| 839 | + $wpdb->query( |
|
| 840 | + $wpdb->prepare( |
|
| 841 | + "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 842 | + array($post_id) |
|
| 843 | + ) |
|
| 844 | + ); |
|
| 845 | + |
|
| 846 | + return true; |
|
| 847 | + } |
|
| 848 | + |
|
| 849 | + } elseif ($postmeta != '' && $post_id) {
|
|
| 850 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 851 | + |
|
| 852 | + $wpdb->query( |
|
| 853 | + $wpdb->prepare( |
|
| 854 | + "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 855 | + array($post_id) |
|
| 856 | + ) |
|
| 857 | + ); |
|
| 858 | + |
|
| 859 | + return true; |
|
| 860 | + } |
|
| 861 | + |
|
| 862 | + } else |
|
| 863 | + return false; |
|
| 864 | + } |
|
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | |
| 868 | 868 | if (!function_exists('geodir_get_post_meta')) {
|
| 869 | - /** |
|
| 870 | - * Get post custom meta. |
|
| 871 | - * |
|
| 872 | - * @since 1.0.0 |
|
| 873 | - * @since 1.6.20 Hook added to filter value. |
|
| 874 | - * @package GeoDirectory |
|
| 875 | - * @global object $wpdb WordPress Database object. |
|
| 876 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 877 | - * @param int $post_id The post ID. |
|
| 878 | - * @param string $meta_key The meta key to retrieve. |
|
| 879 | - * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 880 | - * @todo single variable not yet implemented. |
|
| 881 | - * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 882 | - */ |
|
| 883 | - function geodir_get_post_meta($post_id, $meta_key, $single = false) {
|
|
| 884 | - if (!$post_id) {
|
|
| 885 | - return false; |
|
| 886 | - } |
|
| 887 | - global $wpdb, $plugin_prefix; |
|
| 888 | - |
|
| 889 | - $all_postypes = geodir_get_posttypes(); |
|
| 890 | - |
|
| 891 | - $post_type = get_post_type($post_id); |
|
| 892 | - |
|
| 893 | - if (!in_array($post_type, $all_postypes)) |
|
| 894 | - return false; |
|
| 895 | - |
|
| 896 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 897 | - |
|
| 898 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 899 | - $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 869 | + /** |
|
| 870 | + * Get post custom meta. |
|
| 871 | + * |
|
| 872 | + * @since 1.0.0 |
|
| 873 | + * @since 1.6.20 Hook added to filter value. |
|
| 874 | + * @package GeoDirectory |
|
| 875 | + * @global object $wpdb WordPress Database object. |
|
| 876 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 877 | + * @param int $post_id The post ID. |
|
| 878 | + * @param string $meta_key The meta key to retrieve. |
|
| 879 | + * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 880 | + * @todo single variable not yet implemented. |
|
| 881 | + * @return bool|mixed|null|string Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 882 | + */ |
|
| 883 | + function geodir_get_post_meta($post_id, $meta_key, $single = false) {
|
|
| 884 | + if (!$post_id) {
|
|
| 885 | + return false; |
|
| 886 | + } |
|
| 887 | + global $wpdb, $plugin_prefix; |
|
| 888 | + |
|
| 889 | + $all_postypes = geodir_get_posttypes(); |
|
| 890 | + |
|
| 891 | + $post_type = get_post_type($post_id); |
|
| 892 | + |
|
| 893 | + if (!in_array($post_type, $all_postypes)) |
|
| 894 | + return false; |
|
| 895 | + |
|
| 896 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 897 | + |
|
| 898 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 899 | + $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 900 | 900 | |
| 901 | - if ($meta_value && $meta_value !== '') {
|
|
| 902 | - $meta_value = maybe_serialize($meta_value); |
|
| 903 | - } |
|
| 904 | - } else {
|
|
| 905 | - $meta_value = false; |
|
| 906 | - } |
|
| 901 | + if ($meta_value && $meta_value !== '') {
|
|
| 902 | + $meta_value = maybe_serialize($meta_value); |
|
| 903 | + } |
|
| 904 | + } else {
|
|
| 905 | + $meta_value = false; |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | - /** |
|
| 909 | - * Filter the listing custom meta. |
|
| 910 | - * |
|
| 911 | - * @since 1.6.20 |
|
| 912 | - * |
|
| 913 | - * @param bool|mixed|null|string $meta_value Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 914 | - * @param int $post_id The post ID. |
|
| 915 | - * @param string $meta_key The meta key to retrieve. |
|
| 916 | - * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 917 | - */ |
|
| 918 | - return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single ); |
|
| 919 | - } |
|
| 908 | + /** |
|
| 909 | + * Filter the listing custom meta. |
|
| 910 | + * |
|
| 911 | + * @since 1.6.20 |
|
| 912 | + * |
|
| 913 | + * @param bool|mixed|null|string $meta_value Will be an array if $single is false. Will be value of meta data field if $single is true. |
|
| 914 | + * @param int $post_id The post ID. |
|
| 915 | + * @param string $meta_key The meta key to retrieve. |
|
| 916 | + * @param bool $single Optional. Whether to return a single value. Default false. |
|
| 917 | + */ |
|
| 918 | + return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single ); |
|
| 919 | + } |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | |
| 923 | 923 | if (!function_exists('geodir_save_post_images')) {
|
| 924 | - /** |
|
| 925 | - * Save post attachments. |
|
| 926 | - * |
|
| 927 | - * @since 1.0.0 |
|
| 928 | - * @package GeoDirectory |
|
| 929 | - * @global object $wpdb WordPress Database object. |
|
| 930 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 931 | - * @global object $current_user Current user object. |
|
| 932 | - * @param int $post_id The post ID. |
|
| 933 | - * @param array $post_image Post image urls as an array. |
|
| 934 | - * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 935 | - */ |
|
| 936 | - function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
| 937 | - {
|
|
| 924 | + /** |
|
| 925 | + * Save post attachments. |
|
| 926 | + * |
|
| 927 | + * @since 1.0.0 |
|
| 928 | + * @package GeoDirectory |
|
| 929 | + * @global object $wpdb WordPress Database object. |
|
| 930 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 931 | + * @global object $current_user Current user object. |
|
| 932 | + * @param int $post_id The post ID. |
|
| 933 | + * @param array $post_image Post image urls as an array. |
|
| 934 | + * @param bool $dummy Optional. Is this a dummy listing? Default false. |
|
| 935 | + */ |
|
| 936 | + function geodir_save_post_images($post_id = 0, $post_image = array(), $dummy = false) |
|
| 937 | + {
|
|
| 938 | 938 | |
| 939 | 939 | |
| 940 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 940 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 941 | 941 | |
| 942 | - $post_type = get_post_type($post_id); |
|
| 942 | + $post_type = get_post_type($post_id); |
|
| 943 | 943 | |
| 944 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 944 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 945 | 945 | |
| 946 | - $post_images = geodir_get_images($post_id); |
|
| 946 | + $post_images = geodir_get_images($post_id); |
|
| 947 | 947 | |
| 948 | - $wpdb->query( |
|
| 949 | - $wpdb->prepare( |
|
| 950 | - "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 951 | - array($post_id) |
|
| 952 | - ) |
|
| 953 | - ); |
|
| 948 | + $wpdb->query( |
|
| 949 | + $wpdb->prepare( |
|
| 950 | + "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 951 | + array($post_id) |
|
| 952 | + ) |
|
| 953 | + ); |
|
| 954 | 954 | |
| 955 | - $invalid_files = $post_images; |
|
| 956 | - $valid_file_ids = array(); |
|
| 957 | - $valid_files_condition = ''; |
|
| 958 | - $geodir_uploaddir = ''; |
|
| 955 | + $invalid_files = $post_images; |
|
| 956 | + $valid_file_ids = array(); |
|
| 957 | + $valid_files_condition = ''; |
|
| 958 | + $geodir_uploaddir = ''; |
|
| 959 | 959 | |
| 960 | - $remove_files = array(); |
|
| 960 | + $remove_files = array(); |
|
| 961 | 961 | |
| 962 | - if (!empty($post_image)) {
|
|
| 962 | + if (!empty($post_image)) {
|
|
| 963 | 963 | |
| 964 | - $uploads = wp_upload_dir(); |
|
| 965 | - $uploads_dir = $uploads['path']; |
|
| 964 | + $uploads = wp_upload_dir(); |
|
| 965 | + $uploads_dir = $uploads['path']; |
|
| 966 | 966 | |
| 967 | - $geodir_uploadpath = $uploads['path']; |
|
| 968 | - $geodir_uploadurl = $uploads['url']; |
|
| 969 | - $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
| 967 | + $geodir_uploadpath = $uploads['path']; |
|
| 968 | + $geodir_uploadurl = $uploads['url']; |
|
| 969 | + $sub_dir = isset($uploads['subdir']) ? $uploads['subdir'] : ''; |
|
| 970 | 970 | |
| 971 | - $invalid_files = array(); |
|
| 972 | - $postcurr_images = array(); |
|
| 971 | + $invalid_files = array(); |
|
| 972 | + $postcurr_images = array(); |
|
| 973 | 973 | |
| 974 | - for ($m = 0; $m < count($post_image); $m++) {
|
|
| 975 | - $menu_order = $m + 1; |
|
| 974 | + for ($m = 0; $m < count($post_image); $m++) {
|
|
| 975 | + $menu_order = $m + 1; |
|
| 976 | 976 | |
| 977 | - $file_path = ''; |
|
| 978 | - /* --------- start ------- */ |
|
| 977 | + $file_path = ''; |
|
| 978 | + /* --------- start ------- */ |
|
| 979 | 979 | |
| 980 | - $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 980 | + $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 981 | 981 | |
| 982 | - $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 982 | + $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
|
| 983 | 983 | |
| 984 | 984 | |
| 985 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 985 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 986 | 986 | |
| 987 | - /* --------- end ------- */ |
|
| 988 | - $curr_img_url = $post_image[$m]; |
|
| 987 | + /* --------- end ------- */ |
|
| 988 | + $curr_img_url = $post_image[$m]; |
|
| 989 | 989 | |
| 990 | - $image_name_arr = explode('/', $curr_img_url);
|
|
| 990 | + $image_name_arr = explode('/', $curr_img_url);
|
|
| 991 | 991 | |
| 992 | - $count_image_name_arr = count($image_name_arr) - 2; |
|
| 992 | + $count_image_name_arr = count($image_name_arr) - 2; |
|
| 993 | 993 | |
| 994 | - $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
| 994 | + $count_image_name_arr = ($count_image_name_arr >= 0) ? $count_image_name_arr : 0; |
|
| 995 | 995 | |
| 996 | - $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
| 996 | + $curr_img_dir = $image_name_arr[$count_image_name_arr]; |
|
| 997 | 997 | |
| 998 | - $filename = end($image_name_arr); |
|
| 999 | - if (strpos($filename, '?') !== false) {
|
|
| 1000 | - list($filename) = explode('?', $filename);
|
|
| 1001 | - } |
|
| 998 | + $filename = end($image_name_arr); |
|
| 999 | + if (strpos($filename, '?') !== false) {
|
|
| 1000 | + list($filename) = explode('?', $filename);
|
|
| 1001 | + } |
|
| 1002 | 1002 | |
| 1003 | - $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
| 1004 | - $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
| 1003 | + $curr_img_dir = str_replace($uploads['baseurl'], "", $curr_img_url); |
|
| 1004 | + $curr_img_dir = str_replace($filename, "", $curr_img_dir); |
|
| 1005 | 1005 | |
| 1006 | - $img_name_arr = explode('.', $filename);
|
|
| 1006 | + $img_name_arr = explode('.', $filename);
|
|
| 1007 | 1007 | |
| 1008 | - $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
| 1009 | - if (!empty($img_name_arr) && count($img_name_arr) > 2) {
|
|
| 1010 | - $new_img_name_arr = $img_name_arr; |
|
| 1011 | - if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
|
|
| 1012 | - unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
| 1013 | - $file_title = implode('.', $new_img_name_arr);
|
|
| 1014 | - } |
|
| 1015 | - } |
|
| 1016 | - $file_title = sanitize_file_name($file_title); |
|
| 1017 | - $file_name = sanitize_file_name($filename); |
|
| 1008 | + $file_title = isset($img_name_arr[0]) ? $img_name_arr[0] : $filename; |
|
| 1009 | + if (!empty($img_name_arr) && count($img_name_arr) > 2) {
|
|
| 1010 | + $new_img_name_arr = $img_name_arr; |
|
| 1011 | + if (isset($new_img_name_arr[count($img_name_arr) - 1])) {
|
|
| 1012 | + unset($new_img_name_arr[count($img_name_arr) - 1]); |
|
| 1013 | + $file_title = implode('.', $new_img_name_arr);
|
|
| 1014 | + } |
|
| 1015 | + } |
|
| 1016 | + $file_title = sanitize_file_name($file_title); |
|
| 1017 | + $file_name = sanitize_file_name($filename); |
|
| 1018 | 1018 | |
| 1019 | - $arr_file_type = wp_check_filetype($filename); |
|
| 1019 | + $arr_file_type = wp_check_filetype($filename); |
|
| 1020 | 1020 | |
| 1021 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 1021 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 1022 | 1022 | |
| 1023 | - // Set an array containing a list of acceptable formats |
|
| 1024 | - $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
|
|
| 1023 | + // Set an array containing a list of acceptable formats |
|
| 1024 | + $allowed_file_types = array('image/jpg', 'image/jpeg', 'image/gif', 'image/png');
|
|
| 1025 | 1025 | |
| 1026 | - // If the uploaded file is the right format |
|
| 1027 | - if (in_array($uploaded_file_type, $allowed_file_types)) {
|
|
| 1028 | - if (!function_exists('wp_handle_upload')) {
|
|
| 1029 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1030 | - } |
|
| 1026 | + // If the uploaded file is the right format |
|
| 1027 | + if (in_array($uploaded_file_type, $allowed_file_types)) {
|
|
| 1028 | + if (!function_exists('wp_handle_upload')) {
|
|
| 1029 | + require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1030 | + } |
|
| 1031 | 1031 | |
| 1032 | - if (!is_dir($geodir_uploadpath)) {
|
|
| 1033 | - mkdir($geodir_uploadpath); |
|
| 1034 | - } |
|
| 1032 | + if (!is_dir($geodir_uploadpath)) {
|
|
| 1033 | + mkdir($geodir_uploadpath); |
|
| 1034 | + } |
|
| 1035 | 1035 | |
| 1036 | - $external_img = false; |
|
| 1037 | - if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
|
|
| 1038 | - } else {
|
|
| 1039 | - $external_img = true; |
|
| 1040 | - } |
|
| 1036 | + $external_img = false; |
|
| 1037 | + if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
|
|
| 1038 | + } else {
|
|
| 1039 | + $external_img = true; |
|
| 1040 | + } |
|
| 1041 | 1041 | |
| 1042 | - if ($dummy || $external_img) {
|
|
| 1043 | - $uploaded_file = array(); |
|
| 1044 | - $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 1042 | + if ($dummy || $external_img) {
|
|
| 1043 | + $uploaded_file = array(); |
|
| 1044 | + $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 1045 | 1045 | |
| 1046 | - if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
|
| 1047 | - $new_name = basename($uploaded['file']); |
|
| 1048 | - $uploaded_file = $uploaded; |
|
| 1049 | - }else{
|
|
| 1050 | - print_r($uploaded);exit; |
|
| 1051 | - } |
|
| 1052 | - $external_img = false; |
|
| 1053 | - } else {
|
|
| 1054 | - $new_name = $post_id . '_' . $file_name; |
|
| 1046 | + if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
|
| 1047 | + $new_name = basename($uploaded['file']); |
|
| 1048 | + $uploaded_file = $uploaded; |
|
| 1049 | + }else{
|
|
| 1050 | + print_r($uploaded);exit; |
|
| 1051 | + } |
|
| 1052 | + $external_img = false; |
|
| 1053 | + } else {
|
|
| 1054 | + $new_name = $post_id . '_' . $file_name; |
|
| 1055 | 1055 | |
| 1056 | - if ($curr_img_dir == $sub_dir) {
|
|
| 1057 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1058 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1059 | - } else {
|
|
| 1060 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1061 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1062 | - } |
|
| 1056 | + if ($curr_img_dir == $sub_dir) {
|
|
| 1057 | + $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1058 | + $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1059 | + } else {
|
|
| 1060 | + $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1061 | + $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1062 | + } |
|
| 1063 | 1063 | |
| 1064 | - $uploaded_file = ''; |
|
| 1064 | + $uploaded_file = ''; |
|
| 1065 | 1065 | |
| 1066 | - if (file_exists($img_path)) {
|
|
| 1067 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1068 | - $file_path = ''; |
|
| 1069 | - } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1070 | - $uploaded_file = true; |
|
| 1071 | - $file_path = $curr_img_dir . '/' . $filename; |
|
| 1072 | - } |
|
| 1066 | + if (file_exists($img_path)) {
|
|
| 1067 | + $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1068 | + $file_path = ''; |
|
| 1069 | + } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1070 | + $uploaded_file = true; |
|
| 1071 | + $file_path = $curr_img_dir . '/' . $filename; |
|
| 1072 | + } |
|
| 1073 | 1073 | |
| 1074 | - if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
| 1075 | - unlink($img_path); |
|
| 1076 | - } |
|
| 1074 | + if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
|
| 1075 | + unlink($img_path); |
|
| 1076 | + } |
|
| 1077 | 1077 | |
| 1078 | - if (!empty($uploaded_file)) {
|
|
| 1079 | - if (!isset($file_path) || !$file_path) {
|
|
| 1080 | - $file_path = $sub_dir . '/' . $new_name; |
|
| 1081 | - } |
|
| 1078 | + if (!empty($uploaded_file)) {
|
|
| 1079 | + if (!isset($file_path) || !$file_path) {
|
|
| 1080 | + $file_path = $sub_dir . '/' . $new_name; |
|
| 1081 | + } |
|
| 1082 | 1082 | |
| 1083 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1083 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1084 | 1084 | |
| 1085 | - if ($menu_order == 1) {
|
|
| 1085 | + if ($menu_order == 1) {
|
|
| 1086 | 1086 | |
| 1087 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1087 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1088 | 1088 | |
| 1089 | - } |
|
| 1089 | + } |
|
| 1090 | 1090 | |
| 1091 | - // Set up options array to add this file as an attachment |
|
| 1092 | - $attachment = array(); |
|
| 1093 | - $attachment['post_id'] = $post_id; |
|
| 1094 | - $attachment['title'] = $file_title; |
|
| 1095 | - $attachment['content'] = ''; |
|
| 1096 | - $attachment['file'] = $file_path; |
|
| 1097 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 1098 | - $attachment['menu_order'] = $menu_order; |
|
| 1099 | - $attachment['is_featured'] = 0; |
|
| 1091 | + // Set up options array to add this file as an attachment |
|
| 1092 | + $attachment = array(); |
|
| 1093 | + $attachment['post_id'] = $post_id; |
|
| 1094 | + $attachment['title'] = $file_title; |
|
| 1095 | + $attachment['content'] = ''; |
|
| 1096 | + $attachment['file'] = $file_path; |
|
| 1097 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 1098 | + $attachment['menu_order'] = $menu_order; |
|
| 1099 | + $attachment['is_featured'] = 0; |
|
| 1100 | 1100 | |
| 1101 | - $attachment_set = ''; |
|
| 1101 | + $attachment_set = ''; |
|
| 1102 | 1102 | |
| 1103 | - foreach ($attachment as $key => $val) {
|
|
| 1104 | - if ($val != '') |
|
| 1105 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1106 | - } |
|
| 1103 | + foreach ($attachment as $key => $val) {
|
|
| 1104 | + if ($val != '') |
|
| 1105 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1106 | + } |
|
| 1107 | 1107 | |
| 1108 | - $attachment_set = trim($attachment_set, ", "); |
|
| 1108 | + $attachment_set = trim($attachment_set, ", "); |
|
| 1109 | + |
|
| 1110 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1109 | 1111 | |
| 1110 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1112 | + $valid_file_ids[] = $wpdb->insert_id; |
|
| 1113 | + } |
|
| 1111 | 1114 | |
| 1112 | - $valid_file_ids[] = $wpdb->insert_id; |
|
| 1113 | - } |
|
| 1115 | + } |
|
| 1114 | 1116 | |
| 1115 | - } |
|
| 1116 | 1117 | |
| 1118 | + } else {
|
|
| 1119 | + $valid_file_ids[] = $find_image; |
|
| 1117 | 1120 | |
| 1118 | - } else {
|
|
| 1119 | - $valid_file_ids[] = $find_image; |
|
| 1120 | - |
|
| 1121 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1121 | + $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1122 | 1122 | |
| 1123 | - $wpdb->query( |
|
| 1124 | - $wpdb->prepare( |
|
| 1125 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1126 | - array($menu_order, $split_img_path[1], $post_id) |
|
| 1127 | - ) |
|
| 1128 | - ); |
|
| 1123 | + $wpdb->query( |
|
| 1124 | + $wpdb->prepare( |
|
| 1125 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1126 | + array($menu_order, $split_img_path[1], $post_id) |
|
| 1127 | + ) |
|
| 1128 | + ); |
|
| 1129 | 1129 | |
| 1130 | - if ($menu_order == 1) |
|
| 1131 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1130 | + if ($menu_order == 1) |
|
| 1131 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1132 | 1132 | |
| 1133 | - } |
|
| 1133 | + } |
|
| 1134 | 1134 | |
| 1135 | 1135 | |
| 1136 | - } |
|
| 1136 | + } |
|
| 1137 | 1137 | |
| 1138 | - if (!empty($valid_file_ids)) {
|
|
| 1138 | + if (!empty($valid_file_ids)) {
|
|
| 1139 | 1139 | |
| 1140 | - $remove_files = $valid_file_ids; |
|
| 1140 | + $remove_files = $valid_file_ids; |
|
| 1141 | 1141 | |
| 1142 | - $remove_files_length = count($remove_files); |
|
| 1143 | - $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
| 1144 | - $format = implode(',', $remove_files_format);
|
|
| 1145 | - $valid_files_condition = " ID NOT IN ($format) AND "; |
|
| 1142 | + $remove_files_length = count($remove_files); |
|
| 1143 | + $remove_files_format = array_fill(0, $remove_files_length, '%d'); |
|
| 1144 | + $format = implode(',', $remove_files_format);
|
|
| 1145 | + $valid_files_condition = " ID NOT IN ($format) AND "; |
|
| 1146 | 1146 | |
| 1147 | - } |
|
| 1147 | + } |
|
| 1148 | 1148 | |
| 1149 | - //Get and remove all old images of post from database to set by new order |
|
| 1149 | + //Get and remove all old images of post from database to set by new order |
|
| 1150 | 1150 | |
| 1151 | - if (!empty($post_images)) {
|
|
| 1151 | + if (!empty($post_images)) {
|
|
| 1152 | 1152 | |
| 1153 | - foreach ($post_images as $img) {
|
|
| 1153 | + foreach ($post_images as $img) {
|
|
| 1154 | 1154 | |
| 1155 | - if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1155 | + if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1156 | 1156 | |
| 1157 | - $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1157 | + $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1158 | 1158 | |
| 1159 | - } |
|
| 1159 | + } |
|
| 1160 | 1160 | |
| 1161 | - } |
|
| 1161 | + } |
|
| 1162 | 1162 | |
| 1163 | - } |
|
| 1163 | + } |
|
| 1164 | 1164 | |
| 1165 | - $invalid_files = (object)$invalid_files; |
|
| 1166 | - } |
|
| 1165 | + $invalid_files = (object)$invalid_files; |
|
| 1166 | + } |
|
| 1167 | 1167 | |
| 1168 | - $remove_files[] = $post_id; |
|
| 1168 | + $remove_files[] = $post_id; |
|
| 1169 | 1169 | |
| 1170 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1170 | + $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1171 | 1171 | |
| 1172 | - if (!empty($invalid_files)) |
|
| 1173 | - geodir_remove_attachments($invalid_files); |
|
| 1174 | - } |
|
| 1172 | + if (!empty($invalid_files)) |
|
| 1173 | + geodir_remove_attachments($invalid_files); |
|
| 1174 | + } |
|
| 1175 | 1175 | |
| 1176 | 1176 | } |
| 1177 | 1177 | |
@@ -1185,12 +1185,12 @@ discard block |
||
| 1185 | 1185 | function geodir_remove_temp_images() |
| 1186 | 1186 | {
|
| 1187 | 1187 | |
| 1188 | - global $current_user; |
|
| 1188 | + global $current_user; |
|
| 1189 | 1189 | |
| 1190 | - $uploads = wp_upload_dir(); |
|
| 1191 | - $uploads_dir = $uploads['path']; |
|
| 1190 | + $uploads = wp_upload_dir(); |
|
| 1191 | + $uploads_dir = $uploads['path']; |
|
| 1192 | 1192 | |
| 1193 | - /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
|
|
| 1193 | + /* if(is_dir($uploads_dir.'/temp_'.$current_user->data->ID)){
|
|
| 1194 | 1194 | |
| 1195 | 1195 | $dirPath = $uploads_dir.'/temp_'.$current_user->data->ID; |
| 1196 | 1196 | if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') {
|
@@ -1207,8 +1207,8 @@ discard block |
||
| 1207 | 1207 | rmdir($dirPath); |
| 1208 | 1208 | } */ |
| 1209 | 1209 | |
| 1210 | - $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1211 | - geodir_delete_directory($dirname); |
|
| 1210 | + $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1211 | + geodir_delete_directory($dirname); |
|
| 1212 | 1212 | } |
| 1213 | 1213 | |
| 1214 | 1214 | |
@@ -1222,137 +1222,137 @@ discard block |
||
| 1222 | 1222 | */ |
| 1223 | 1223 | function geodir_delete_directory($dirname) |
| 1224 | 1224 | {
|
| 1225 | - $dir_handle = ''; |
|
| 1226 | - if (is_dir($dirname)) |
|
| 1227 | - $dir_handle = opendir($dirname); |
|
| 1228 | - if (!$dir_handle) |
|
| 1229 | - return false; |
|
| 1230 | - while ($file = readdir($dir_handle)) {
|
|
| 1231 | - if ($file != "." && $file != "..") {
|
|
| 1232 | - if (!is_dir($dirname . "/" . $file)) |
|
| 1233 | - unlink($dirname . "/" . $file); |
|
| 1234 | - else |
|
| 1235 | - geodir_delete_directory($dirname . '/' . $file); |
|
| 1236 | - } |
|
| 1237 | - } |
|
| 1238 | - closedir($dir_handle); |
|
| 1239 | - rmdir($dirname); |
|
| 1240 | - return true; |
|
| 1225 | + $dir_handle = ''; |
|
| 1226 | + if (is_dir($dirname)) |
|
| 1227 | + $dir_handle = opendir($dirname); |
|
| 1228 | + if (!$dir_handle) |
|
| 1229 | + return false; |
|
| 1230 | + while ($file = readdir($dir_handle)) {
|
|
| 1231 | + if ($file != "." && $file != "..") {
|
|
| 1232 | + if (!is_dir($dirname . "/" . $file)) |
|
| 1233 | + unlink($dirname . "/" . $file); |
|
| 1234 | + else |
|
| 1235 | + geodir_delete_directory($dirname . '/' . $file); |
|
| 1236 | + } |
|
| 1237 | + } |
|
| 1238 | + closedir($dir_handle); |
|
| 1239 | + rmdir($dirname); |
|
| 1240 | + return true; |
|
| 1241 | 1241 | |
| 1242 | 1242 | } |
| 1243 | 1243 | |
| 1244 | 1244 | |
| 1245 | 1245 | if (!function_exists('geodir_remove_attachments')) {
|
| 1246 | - /** |
|
| 1247 | - * Remove post attachments. |
|
| 1248 | - * |
|
| 1249 | - * @since 1.0.0 |
|
| 1250 | - * @package GeoDirectory |
|
| 1251 | - * @param array $postcurr_images Array of image objects. |
|
| 1252 | - */ |
|
| 1253 | - function geodir_remove_attachments($postcurr_images = array()) |
|
| 1254 | - {
|
|
| 1255 | - // Unlink all past images of post |
|
| 1256 | - if (!empty($postcurr_images)) {
|
|
| 1257 | - |
|
| 1258 | - $uploads = wp_upload_dir(); |
|
| 1259 | - $uploads_dir = $uploads['path']; |
|
| 1260 | - |
|
| 1261 | - foreach ($postcurr_images as $postimg) {
|
|
| 1262 | - $image_name_arr = explode('/', $postimg->src);
|
|
| 1263 | - $filename = end($image_name_arr); |
|
| 1264 | - if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1265 | - unlink($uploads_dir . '/' . $filename); |
|
| 1266 | - } |
|
| 1267 | - |
|
| 1268 | - } // endif |
|
| 1269 | - // Unlink all past images of post end |
|
| 1270 | - } |
|
| 1246 | + /** |
|
| 1247 | + * Remove post attachments. |
|
| 1248 | + * |
|
| 1249 | + * @since 1.0.0 |
|
| 1250 | + * @package GeoDirectory |
|
| 1251 | + * @param array $postcurr_images Array of image objects. |
|
| 1252 | + */ |
|
| 1253 | + function geodir_remove_attachments($postcurr_images = array()) |
|
| 1254 | + {
|
|
| 1255 | + // Unlink all past images of post |
|
| 1256 | + if (!empty($postcurr_images)) {
|
|
| 1257 | + |
|
| 1258 | + $uploads = wp_upload_dir(); |
|
| 1259 | + $uploads_dir = $uploads['path']; |
|
| 1260 | + |
|
| 1261 | + foreach ($postcurr_images as $postimg) {
|
|
| 1262 | + $image_name_arr = explode('/', $postimg->src);
|
|
| 1263 | + $filename = end($image_name_arr); |
|
| 1264 | + if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1265 | + unlink($uploads_dir . '/' . $filename); |
|
| 1266 | + } |
|
| 1267 | + |
|
| 1268 | + } // endif |
|
| 1269 | + // Unlink all past images of post end |
|
| 1270 | + } |
|
| 1271 | 1271 | } |
| 1272 | 1272 | |
| 1273 | 1273 | if (!function_exists('geodir_get_featured_image')) {
|
| 1274 | - /** |
|
| 1275 | - * Gets the post featured image. |
|
| 1276 | - * |
|
| 1277 | - * @since 1.0.0 |
|
| 1278 | - * @package GeoDirectory |
|
| 1279 | - * @global object $wpdb WordPress Database object. |
|
| 1280 | - * @global object $post The current post object. |
|
| 1281 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1282 | - * @param int|string $post_id The post ID. |
|
| 1283 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1284 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1285 | - * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
| 1286 | - * @return bool|object Image details as an object. |
|
| 1287 | - */ |
|
| 1288 | - function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
| 1289 | - {
|
|
| 1290 | - |
|
| 1291 | - /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
| 1274 | + /** |
|
| 1275 | + * Gets the post featured image. |
|
| 1276 | + * |
|
| 1277 | + * @since 1.0.0 |
|
| 1278 | + * @package GeoDirectory |
|
| 1279 | + * @global object $wpdb WordPress Database object. |
|
| 1280 | + * @global object $post The current post object. |
|
| 1281 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1282 | + * @param int|string $post_id The post ID. |
|
| 1283 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1284 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1285 | + * @param bool|string $file Optional. The file path from which you want to get the image details. Default: false. |
|
| 1286 | + * @return bool|object Image details as an object. |
|
| 1287 | + */ |
|
| 1288 | + function geodir_get_featured_image($post_id = '', $size = '', $no_image = false, $file = false) |
|
| 1289 | + {
|
|
| 1290 | + |
|
| 1291 | + /*$img_arr['src'] = get_the_post_thumbnail_url( $post_id, 'medium');//medium/thumbnail |
|
| 1292 | 1292 | $img_arr['path'] = ''; |
| 1293 | 1293 | $img_arr['width'] = ''; |
| 1294 | 1294 | $img_arr['height'] = ''; |
| 1295 | 1295 | $img_arr['title'] = ''; |
| 1296 | 1296 | return (object)$img_arr;*/ |
| 1297 | - global $wpdb, $plugin_prefix, $post; |
|
| 1297 | + global $wpdb, $plugin_prefix, $post; |
|
| 1298 | 1298 | |
| 1299 | - if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
|
|
| 1300 | - $post_type = $post->post_type; |
|
| 1301 | - } else {
|
|
| 1302 | - $post_type = get_post_type($post_id); |
|
| 1303 | - } |
|
| 1299 | + if (isset($post->ID) && isset($post->post_type) && $post->ID == $post_id) {
|
|
| 1300 | + $post_type = $post->post_type; |
|
| 1301 | + } else {
|
|
| 1302 | + $post_type = get_post_type($post_id); |
|
| 1303 | + } |
|
| 1304 | 1304 | |
| 1305 | - if (!in_array($post_type, geodir_get_posttypes())) {
|
|
| 1306 | - return false;// if not a GD CPT return; |
|
| 1307 | - } |
|
| 1305 | + if (!in_array($post_type, geodir_get_posttypes())) {
|
|
| 1306 | + return false;// if not a GD CPT return; |
|
| 1307 | + } |
|
| 1308 | 1308 | |
| 1309 | 1309 | |
| 1310 | - $list_img_size = get_option('geodir_listing_img_size','default');
|
|
| 1310 | + $list_img_size = get_option('geodir_listing_img_size','default');
|
|
| 1311 | 1311 | |
| 1312 | - if( $size=='list-thumb' && $list_img_size != 'default' ){
|
|
| 1313 | - $fimg = get_the_post_thumbnail_url($post_id,$list_img_size); |
|
| 1314 | - if($fimg){
|
|
| 1315 | - $uploads = wp_upload_dir(); |
|
| 1316 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1317 | - $file = str_replace($uploads_baseurl,'',$fimg); |
|
| 1318 | - } |
|
| 1319 | - } |
|
| 1312 | + if( $size=='list-thumb' && $list_img_size != 'default' ){
|
|
| 1313 | + $fimg = get_the_post_thumbnail_url($post_id,$list_img_size); |
|
| 1314 | + if($fimg){
|
|
| 1315 | + $uploads = wp_upload_dir(); |
|
| 1316 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1317 | + $file = str_replace($uploads_baseurl,'',$fimg); |
|
| 1318 | + } |
|
| 1319 | + } |
|
| 1320 | 1320 | |
| 1321 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1321 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1322 | 1322 | |
| 1323 | - if (!$file) {
|
|
| 1324 | - if (isset($post->featured_image)) {
|
|
| 1325 | - $file = $post->featured_image; |
|
| 1326 | - } else {
|
|
| 1327 | - $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1328 | - } |
|
| 1329 | - } |
|
| 1323 | + if (!$file) {
|
|
| 1324 | + if (isset($post->featured_image)) {
|
|
| 1325 | + $file = $post->featured_image; |
|
| 1326 | + } else {
|
|
| 1327 | + $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1328 | + } |
|
| 1329 | + } |
|
| 1330 | 1330 | |
| 1331 | - if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
|
| 1332 | - $img_arr = array(); |
|
| 1331 | + if ($file != NULL && $file != '' && (($uploads = wp_upload_dir()) && false === $uploads['error'])) {
|
|
| 1332 | + $img_arr = array(); |
|
| 1333 | 1333 | |
| 1334 | - $file_info = pathinfo($file); |
|
| 1335 | - $sub_dir = ''; |
|
| 1336 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
|
|
| 1337 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1338 | - } |
|
| 1334 | + $file_info = pathinfo($file); |
|
| 1335 | + $sub_dir = ''; |
|
| 1336 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') {
|
|
| 1337 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1338 | + } |
|
| 1339 | 1339 | |
| 1340 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1341 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1342 | - $uploads_path = $uploads['path']; |
|
| 1340 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1341 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1342 | + $uploads_path = $uploads['path']; |
|
| 1343 | 1343 | |
| 1344 | - $file_name = $file_info['basename']; |
|
| 1344 | + $file_name = $file_info['basename']; |
|
| 1345 | 1345 | |
| 1346 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1346 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1347 | 1347 | |
| 1348 | - $img_src = $uploads_url . '/' . $file_name; |
|
| 1348 | + $img_src = $uploads_url . '/' . $file_name; |
|
| 1349 | 1349 | |
| 1350 | - // jetpack CDN check |
|
| 1351 | - if (strpos($file, '.wp.com/') !== false) {
|
|
| 1352 | - $img_src = $file; |
|
| 1353 | - } |
|
| 1350 | + // jetpack CDN check |
|
| 1351 | + if (strpos($file, '.wp.com/') !== false) {
|
|
| 1352 | + $img_src = $file; |
|
| 1353 | + } |
|
| 1354 | 1354 | |
| 1355 | - /* |
|
| 1355 | + /* |
|
| 1356 | 1356 | * Allows the filter of image src for such things as CDN change. |
| 1357 | 1357 | * |
| 1358 | 1358 | * @since 1.5.7 |
@@ -1361,158 +1361,158 @@ discard block |
||
| 1361 | 1361 | * @param string $uploads_url The server upload directory url. |
| 1362 | 1362 | * @param string $uploads_baseurl The uploads dir base url. |
| 1363 | 1363 | */ |
| 1364 | - $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$img_src,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1365 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1366 | - $width = 0; |
|
| 1367 | - $height = 0; |
|
| 1368 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1369 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1370 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1371 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1372 | - } |
|
| 1373 | - $img_arr['width'] = $width; |
|
| 1374 | - $img_arr['height'] = $height; |
|
| 1375 | - $img_arr['title'] = $post->post_title; |
|
| 1376 | - } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
|
|
| 1377 | - foreach ($post_images as $image) {
|
|
| 1378 | - return $image; |
|
| 1379 | - } |
|
| 1380 | - } else if ($no_image) {
|
|
| 1381 | - $img_arr = array(); |
|
| 1382 | - |
|
| 1383 | - $default_img = ''; |
|
| 1384 | - if (isset($post->default_category) && $post->default_category) {
|
|
| 1385 | - $default_cat = $post->default_category; |
|
| 1386 | - } else {
|
|
| 1387 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1388 | - } |
|
| 1389 | - |
|
| 1390 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1391 | - $default_img = $default_catimg['src']; |
|
| 1392 | - elseif ($no_image) {
|
|
| 1393 | - $default_img = get_option('geodir_listing_no_img');
|
|
| 1394 | - } |
|
| 1395 | - |
|
| 1396 | - if (!empty($default_img)) {
|
|
| 1397 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1398 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1399 | - $uploads_path = $uploads['path']; |
|
| 1400 | - |
|
| 1401 | - $img_arr = array(); |
|
| 1402 | - |
|
| 1403 | - $file_info = pathinfo($default_img); |
|
| 1404 | - |
|
| 1405 | - $file_name = $file_info['basename']; |
|
| 1406 | - |
|
| 1407 | - $img_arr['src'] = $default_img; |
|
| 1408 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1409 | - |
|
| 1410 | - $width = 0; |
|
| 1411 | - $height = 0; |
|
| 1412 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1413 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1414 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1415 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1416 | - } |
|
| 1417 | - $img_arr['width'] = $width; |
|
| 1418 | - $img_arr['height'] = $height; |
|
| 1419 | - |
|
| 1420 | - $img_arr['title'] = $post->post_title; // add the title to the array |
|
| 1421 | - } |
|
| 1422 | - } |
|
| 1423 | - |
|
| 1424 | - if (!empty($img_arr)) |
|
| 1425 | - return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1426 | - else |
|
| 1427 | - return false; |
|
| 1428 | - } |
|
| 1364 | + $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$img_src,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1365 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1366 | + $width = 0; |
|
| 1367 | + $height = 0; |
|
| 1368 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1369 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1370 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1371 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1372 | + } |
|
| 1373 | + $img_arr['width'] = $width; |
|
| 1374 | + $img_arr['height'] = $height; |
|
| 1375 | + $img_arr['title'] = $post->post_title; |
|
| 1376 | + } elseif ($post_images = geodir_get_images($post_id, $size, $no_image, 1)) {
|
|
| 1377 | + foreach ($post_images as $image) {
|
|
| 1378 | + return $image; |
|
| 1379 | + } |
|
| 1380 | + } else if ($no_image) {
|
|
| 1381 | + $img_arr = array(); |
|
| 1382 | + |
|
| 1383 | + $default_img = ''; |
|
| 1384 | + if (isset($post->default_category) && $post->default_category) {
|
|
| 1385 | + $default_cat = $post->default_category; |
|
| 1386 | + } else {
|
|
| 1387 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1388 | + } |
|
| 1389 | + |
|
| 1390 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1391 | + $default_img = $default_catimg['src']; |
|
| 1392 | + elseif ($no_image) {
|
|
| 1393 | + $default_img = get_option('geodir_listing_no_img');
|
|
| 1394 | + } |
|
| 1395 | + |
|
| 1396 | + if (!empty($default_img)) {
|
|
| 1397 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1398 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1399 | + $uploads_path = $uploads['path']; |
|
| 1400 | + |
|
| 1401 | + $img_arr = array(); |
|
| 1402 | + |
|
| 1403 | + $file_info = pathinfo($default_img); |
|
| 1404 | + |
|
| 1405 | + $file_name = $file_info['basename']; |
|
| 1406 | + |
|
| 1407 | + $img_arr['src'] = $default_img; |
|
| 1408 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1409 | + |
|
| 1410 | + $width = 0; |
|
| 1411 | + $height = 0; |
|
| 1412 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1413 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1414 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1415 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1416 | + } |
|
| 1417 | + $img_arr['width'] = $width; |
|
| 1418 | + $img_arr['height'] = $height; |
|
| 1419 | + |
|
| 1420 | + $img_arr['title'] = $post->post_title; // add the title to the array |
|
| 1421 | + } |
|
| 1422 | + } |
|
| 1423 | + |
|
| 1424 | + if (!empty($img_arr)) |
|
| 1425 | + return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1426 | + else |
|
| 1427 | + return false; |
|
| 1428 | + } |
|
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | if (!function_exists('geodir_show_featured_image')) {
|
| 1432 | - /** |
|
| 1433 | - * Gets the post featured image. |
|
| 1434 | - * |
|
| 1435 | - * @since 1.0.0 |
|
| 1436 | - * @package GeoDirectory |
|
| 1437 | - * @param int|string $post_id The post ID. |
|
| 1438 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1439 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1440 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1441 | - * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
| 1442 | - * @return bool|string Returns image html. |
|
| 1443 | - */ |
|
| 1444 | - function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
| 1445 | - {
|
|
| 1446 | - $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
| 1447 | - |
|
| 1448 | - $html = geodir_show_image($image, $size, $no_image, false); |
|
| 1449 | - |
|
| 1450 | - if (!empty($html) && $echo) {
|
|
| 1451 | - echo $html; |
|
| 1452 | - } elseif (!empty($html)) {
|
|
| 1453 | - return $html; |
|
| 1454 | - } else |
|
| 1455 | - return false; |
|
| 1456 | - } |
|
| 1432 | + /** |
|
| 1433 | + * Gets the post featured image. |
|
| 1434 | + * |
|
| 1435 | + * @since 1.0.0 |
|
| 1436 | + * @package GeoDirectory |
|
| 1437 | + * @param int|string $post_id The post ID. |
|
| 1438 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1439 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1440 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1441 | + * @param bool|string $fimage Optional. The file path from which you want to get the image details. Default: false. |
|
| 1442 | + * @return bool|string Returns image html. |
|
| 1443 | + */ |
|
| 1444 | + function geodir_show_featured_image($post_id = '', $size = 'thumbnail', $no_image = false, $echo = true, $fimage = false) |
|
| 1445 | + {
|
|
| 1446 | + $image = geodir_get_featured_image($post_id, $size, $no_image, $fimage); |
|
| 1447 | + |
|
| 1448 | + $html = geodir_show_image($image, $size, $no_image, false); |
|
| 1449 | + |
|
| 1450 | + if (!empty($html) && $echo) {
|
|
| 1451 | + echo $html; |
|
| 1452 | + } elseif (!empty($html)) {
|
|
| 1453 | + return $html; |
|
| 1454 | + } else |
|
| 1455 | + return false; |
|
| 1456 | + } |
|
| 1457 | 1457 | } |
| 1458 | 1458 | |
| 1459 | 1459 | if (!function_exists('geodir_get_images')) {
|
| 1460 | - /** |
|
| 1461 | - * Gets the post images. |
|
| 1462 | - * |
|
| 1463 | - * @since 1.0.0 |
|
| 1464 | - * @package GeoDirectory |
|
| 1465 | - * @global object $wpdb WordPress Database object. |
|
| 1466 | - * @param int $post_id The post ID. |
|
| 1467 | - * @param string $img_size Optional. Thumbnail size. |
|
| 1468 | - * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1469 | - * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
| 1470 | - * @param int|string $limit Optional. Number of images. |
|
| 1471 | - * @return array|bool Returns images as an array. Each item is an object. |
|
| 1472 | - */ |
|
| 1473 | - function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
| 1474 | - {
|
|
| 1475 | - global $wpdb; |
|
| 1476 | - if ($limit) {
|
|
| 1477 | - $limit_q = " LIMIT $limit "; |
|
| 1478 | - } else {
|
|
| 1479 | - $limit_q = ''; |
|
| 1480 | - } |
|
| 1481 | - $not_featured = ''; |
|
| 1482 | - $sub_dir = ''; |
|
| 1483 | - if (!$add_featured) |
|
| 1484 | - $not_featured = " AND is_featured = 0 "; |
|
| 1485 | - |
|
| 1486 | - $arrImages = $wpdb->get_results( |
|
| 1487 | - $wpdb->prepare( |
|
| 1488 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1489 | - array('%image%', $post_id)
|
|
| 1490 | - ) |
|
| 1491 | - ); |
|
| 1492 | - |
|
| 1493 | - $counter = 0; |
|
| 1494 | - $return_arr = array(); |
|
| 1495 | - |
|
| 1496 | - if (!empty($arrImages)) {
|
|
| 1497 | - foreach ($arrImages as $attechment) {
|
|
| 1498 | - |
|
| 1499 | - $img_arr = array(); |
|
| 1500 | - $img_arr['id'] = $attechment->ID; |
|
| 1501 | - $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
| 1502 | - |
|
| 1503 | - $file_info = pathinfo($attechment->file); |
|
| 1504 | - |
|
| 1505 | - if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1506 | - $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1507 | - |
|
| 1508 | - $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1509 | - $uploads_baseurl = $uploads['baseurl']; |
|
| 1510 | - $uploads_path = $uploads['path']; |
|
| 1511 | - |
|
| 1512 | - $file_name = $file_info['basename']; |
|
| 1513 | - |
|
| 1514 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1515 | - /* |
|
| 1460 | + /** |
|
| 1461 | + * Gets the post images. |
|
| 1462 | + * |
|
| 1463 | + * @since 1.0.0 |
|
| 1464 | + * @package GeoDirectory |
|
| 1465 | + * @global object $wpdb WordPress Database object. |
|
| 1466 | + * @param int $post_id The post ID. |
|
| 1467 | + * @param string $img_size Optional. Thumbnail size. |
|
| 1468 | + * @param bool $no_images Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1469 | + * @param bool $add_featured Optional. Do you want to include featured images too? Default: true. |
|
| 1470 | + * @param int|string $limit Optional. Number of images. |
|
| 1471 | + * @return array|bool Returns images as an array. Each item is an object. |
|
| 1472 | + */ |
|
| 1473 | + function geodir_get_images($post_id = 0, $img_size = '', $no_images = false, $add_featured = true, $limit = '') |
|
| 1474 | + {
|
|
| 1475 | + global $wpdb; |
|
| 1476 | + if ($limit) {
|
|
| 1477 | + $limit_q = " LIMIT $limit "; |
|
| 1478 | + } else {
|
|
| 1479 | + $limit_q = ''; |
|
| 1480 | + } |
|
| 1481 | + $not_featured = ''; |
|
| 1482 | + $sub_dir = ''; |
|
| 1483 | + if (!$add_featured) |
|
| 1484 | + $not_featured = " AND is_featured = 0 "; |
|
| 1485 | + |
|
| 1486 | + $arrImages = $wpdb->get_results( |
|
| 1487 | + $wpdb->prepare( |
|
| 1488 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1489 | + array('%image%', $post_id)
|
|
| 1490 | + ) |
|
| 1491 | + ); |
|
| 1492 | + |
|
| 1493 | + $counter = 0; |
|
| 1494 | + $return_arr = array(); |
|
| 1495 | + |
|
| 1496 | + if (!empty($arrImages)) {
|
|
| 1497 | + foreach ($arrImages as $attechment) {
|
|
| 1498 | + |
|
| 1499 | + $img_arr = array(); |
|
| 1500 | + $img_arr['id'] = $attechment->ID; |
|
| 1501 | + $img_arr['user_id'] = isset($attechment->user_id) ? $attechment->user_id : 0; |
|
| 1502 | + |
|
| 1503 | + $file_info = pathinfo($attechment->file); |
|
| 1504 | + |
|
| 1505 | + if ($file_info['dirname'] != '.' && $file_info['dirname'] != '..') |
|
| 1506 | + $sub_dir = stripslashes_deep($file_info['dirname']); |
|
| 1507 | + |
|
| 1508 | + $uploads = wp_upload_dir(trim($sub_dir, '/')); // Array of key => value pairs |
|
| 1509 | + $uploads_baseurl = $uploads['baseurl']; |
|
| 1510 | + $uploads_path = $uploads['path']; |
|
| 1511 | + |
|
| 1512 | + $file_name = $file_info['basename']; |
|
| 1513 | + |
|
| 1514 | + $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1515 | + /* |
|
| 1516 | 1516 | * Allows the filter of image src for such things as CDN change. |
| 1517 | 1517 | * |
| 1518 | 1518 | * @since 1.5.7 |
@@ -1521,532 +1521,532 @@ discard block |
||
| 1521 | 1521 | * @param string $uploads_url The server upload directory url. |
| 1522 | 1522 | * @param string $uploads_baseurl The uploads dir base url. |
| 1523 | 1523 | */ |
| 1524 | - $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1525 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1526 | - $width = 0; |
|
| 1527 | - $height = 0; |
|
| 1528 | - if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1529 | - $imagesize = getimagesize($img_arr['path']); |
|
| 1530 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1531 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1532 | - } |
|
| 1533 | - $img_arr['width'] = $width; |
|
| 1534 | - $img_arr['height'] = $height; |
|
| 1535 | - |
|
| 1536 | - $img_arr['file'] = $file_name; // add the title to the array |
|
| 1537 | - $img_arr['title'] = $attechment->title; // add the title to the array |
|
| 1538 | - $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
| 1539 | - $img_arr['content'] = $attechment->content; // add the description to the array |
|
| 1540 | - $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
| 1541 | - |
|
| 1542 | - $return_arr[] = (object)$img_arr; |
|
| 1543 | - |
|
| 1544 | - $counter++; |
|
| 1545 | - } |
|
| 1546 | - //return (object)$return_arr; |
|
| 1547 | - /** |
|
| 1548 | - * Filter the images array so things can be changed. |
|
| 1549 | - * |
|
| 1550 | - * @since 1.6.20 |
|
| 1551 | - * @param array $return_arr The array of image objects. |
|
| 1552 | - */ |
|
| 1553 | - return apply_filters('geodir_get_images_arr',$return_arr);
|
|
| 1554 | - } else if ($no_images) {
|
|
| 1555 | - $default_img = ''; |
|
| 1556 | - $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1557 | - $post_type = get_post_type($post_id); |
|
| 1558 | - if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1559 | - $default_img = $default_catimg['src']; |
|
| 1560 | - elseif ($no_images) {
|
|
| 1561 | - $default_img = get_option('geodir_listing_no_img');
|
|
| 1562 | - } |
|
| 1563 | - |
|
| 1564 | - if (!empty($default_img)) {
|
|
| 1565 | - $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1524 | + $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1525 | + $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1526 | + $width = 0; |
|
| 1527 | + $height = 0; |
|
| 1528 | + if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
|
| 1529 | + $imagesize = getimagesize($img_arr['path']); |
|
| 1530 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1531 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1532 | + } |
|
| 1533 | + $img_arr['width'] = $width; |
|
| 1534 | + $img_arr['height'] = $height; |
|
| 1535 | + |
|
| 1536 | + $img_arr['file'] = $file_name; // add the title to the array |
|
| 1537 | + $img_arr['title'] = $attechment->title; // add the title to the array |
|
| 1538 | + $img_arr['caption'] = isset($attechment->caption) ? $attechment->caption : ''; // add the caption to the array |
|
| 1539 | + $img_arr['content'] = $attechment->content; // add the description to the array |
|
| 1540 | + $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
|
| 1541 | + |
|
| 1542 | + $return_arr[] = (object)$img_arr; |
|
| 1543 | + |
|
| 1544 | + $counter++; |
|
| 1545 | + } |
|
| 1546 | + //return (object)$return_arr; |
|
| 1547 | + /** |
|
| 1548 | + * Filter the images array so things can be changed. |
|
| 1549 | + * |
|
| 1550 | + * @since 1.6.20 |
|
| 1551 | + * @param array $return_arr The array of image objects. |
|
| 1552 | + */ |
|
| 1553 | + return apply_filters('geodir_get_images_arr',$return_arr);
|
|
| 1554 | + } else if ($no_images) {
|
|
| 1555 | + $default_img = ''; |
|
| 1556 | + $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1557 | + $post_type = get_post_type($post_id); |
|
| 1558 | + if ($default_catimg = geodir_get_default_catimage($default_cat, $post_type)) |
|
| 1559 | + $default_img = $default_catimg['src']; |
|
| 1560 | + elseif ($no_images) {
|
|
| 1561 | + $default_img = get_option('geodir_listing_no_img');
|
|
| 1562 | + } |
|
| 1563 | + |
|
| 1564 | + if (!empty($default_img)) {
|
|
| 1565 | + $uploads = wp_upload_dir(); // Array of key => value pairs |
|
| 1566 | 1566 | |
| 1567 | - $image_path = $default_img; |
|
| 1568 | - if (!path_is_absolute($image_path)) {
|
|
| 1569 | - $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
| 1570 | - } |
|
| 1571 | - |
|
| 1572 | - $file_info = pathinfo($default_img); |
|
| 1573 | - $file_name = $file_info['basename']; |
|
| 1574 | - |
|
| 1575 | - $width = ''; |
|
| 1576 | - $height = ''; |
|
| 1577 | - if (is_file($image_path) && file_exists($image_path)) {
|
|
| 1578 | - $imagesize = getimagesize($image_path); |
|
| 1579 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1580 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1581 | - } |
|
| 1567 | + $image_path = $default_img; |
|
| 1568 | + if (!path_is_absolute($image_path)) {
|
|
| 1569 | + $image_path = str_replace($uploads['baseurl'], $uploads['basedir'], $image_path); |
|
| 1570 | + } |
|
| 1571 | + |
|
| 1572 | + $file_info = pathinfo($default_img); |
|
| 1573 | + $file_name = $file_info['basename']; |
|
| 1574 | + |
|
| 1575 | + $width = ''; |
|
| 1576 | + $height = ''; |
|
| 1577 | + if (is_file($image_path) && file_exists($image_path)) {
|
|
| 1578 | + $imagesize = getimagesize($image_path); |
|
| 1579 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1580 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1581 | + } |
|
| 1582 | 1582 | |
| 1583 | - $img_arr = array(); |
|
| 1584 | - $img_arr['src'] = $default_img; |
|
| 1585 | - $img_arr['path'] = $image_path; |
|
| 1586 | - $img_arr['width'] = $width; |
|
| 1587 | - $img_arr['height'] = $height; |
|
| 1588 | - $img_arr['file'] = $file_name; // add the title to the array |
|
| 1589 | - $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
| 1590 | - $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
| 1591 | - |
|
| 1592 | - $return_arr[] = (object)$img_arr; |
|
| 1593 | - |
|
| 1594 | - /** |
|
| 1595 | - * Filter the images array so things can be changed. |
|
| 1596 | - * |
|
| 1597 | - * @since 1.6.20 |
|
| 1598 | - * @param array $return_arr The array of image objects. |
|
| 1599 | - */ |
|
| 1600 | - return apply_filters('geodir_get_images_arr',$return_arr);
|
|
| 1601 | - } else |
|
| 1602 | - return false; |
|
| 1603 | - } |
|
| 1604 | - } |
|
| 1583 | + $img_arr = array(); |
|
| 1584 | + $img_arr['src'] = $default_img; |
|
| 1585 | + $img_arr['path'] = $image_path; |
|
| 1586 | + $img_arr['width'] = $width; |
|
| 1587 | + $img_arr['height'] = $height; |
|
| 1588 | + $img_arr['file'] = $file_name; // add the title to the array |
|
| 1589 | + $img_arr['title'] = $file_info['filename']; // add the title to the array |
|
| 1590 | + $img_arr['content'] = $file_info['filename']; // add the description to the array |
|
| 1591 | + |
|
| 1592 | + $return_arr[] = (object)$img_arr; |
|
| 1593 | + |
|
| 1594 | + /** |
|
| 1595 | + * Filter the images array so things can be changed. |
|
| 1596 | + * |
|
| 1597 | + * @since 1.6.20 |
|
| 1598 | + * @param array $return_arr The array of image objects. |
|
| 1599 | + */ |
|
| 1600 | + return apply_filters('geodir_get_images_arr',$return_arr);
|
|
| 1601 | + } else |
|
| 1602 | + return false; |
|
| 1603 | + } |
|
| 1604 | + } |
|
| 1605 | 1605 | } |
| 1606 | 1606 | |
| 1607 | 1607 | if (!function_exists('geodir_show_image')) {
|
| 1608 | - /** |
|
| 1609 | - * Show image using image details. |
|
| 1610 | - * |
|
| 1611 | - * @since 1.0.0 |
|
| 1612 | - * @package GeoDirectory |
|
| 1613 | - * @param array|object $request Image info either as an array or object. |
|
| 1614 | - * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1615 | - * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1616 | - * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1617 | - * @return bool|string Returns image html. |
|
| 1618 | - */ |
|
| 1619 | - function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
| 1620 | - {
|
|
| 1621 | - $image = new stdClass(); |
|
| 1622 | - |
|
| 1623 | - $html = ''; |
|
| 1624 | - if (!empty($request)) {
|
|
| 1625 | - if (!is_object($request)){
|
|
| 1626 | - $request = (object)$request; |
|
| 1627 | - } |
|
| 1628 | - |
|
| 1629 | - if (isset($request->src) && !isset($request->path)) {
|
|
| 1630 | - $request->path = $request->src; |
|
| 1631 | - } |
|
| 1632 | - |
|
| 1633 | - /* |
|
| 1608 | + /** |
|
| 1609 | + * Show image using image details. |
|
| 1610 | + * |
|
| 1611 | + * @since 1.0.0 |
|
| 1612 | + * @package GeoDirectory |
|
| 1613 | + * @param array|object $request Image info either as an array or object. |
|
| 1614 | + * @param string $size Optional. Thumbnail size. Default: thumbnail. |
|
| 1615 | + * @param bool $no_image Optional. Do you want to return the default image when no image is available? Default: false. |
|
| 1616 | + * @param bool $echo Optional. Do you want to print it instead of returning it? Default: true. |
|
| 1617 | + * @return bool|string Returns image html. |
|
| 1618 | + */ |
|
| 1619 | + function geodir_show_image($request = array(), $size = 'thumbnail', $no_image = false, $echo = true) |
|
| 1620 | + {
|
|
| 1621 | + $image = new stdClass(); |
|
| 1622 | + |
|
| 1623 | + $html = ''; |
|
| 1624 | + if (!empty($request)) {
|
|
| 1625 | + if (!is_object($request)){
|
|
| 1626 | + $request = (object)$request; |
|
| 1627 | + } |
|
| 1628 | + |
|
| 1629 | + if (isset($request->src) && !isset($request->path)) {
|
|
| 1630 | + $request->path = $request->src; |
|
| 1631 | + } |
|
| 1632 | + |
|
| 1633 | + /* |
|
| 1634 | 1634 | * getimagesize() works faster from path than url so we try and get path if we can. |
| 1635 | 1635 | */ |
| 1636 | - $upload_dir = wp_upload_dir(); |
|
| 1637 | - $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
|
| 1638 | - $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
|
| 1639 | - if (strpos($img_no_http, $upload_no_http) !== false) {
|
|
| 1640 | - $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1641 | - } |
|
| 1636 | + $upload_dir = wp_upload_dir(); |
|
| 1637 | + $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
|
| 1638 | + $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
|
| 1639 | + if (strpos($img_no_http, $upload_no_http) !== false) {
|
|
| 1640 | + $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1641 | + } |
|
| 1642 | 1642 | |
| 1643 | - $width = 0; |
|
| 1644 | - $height = 0; |
|
| 1645 | - if (is_file($request->path) && file_exists($request->path)) {
|
|
| 1646 | - $imagesize = getimagesize($request->path); |
|
| 1647 | - $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1648 | - $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1649 | - } |
|
| 1650 | - |
|
| 1651 | - |
|
| 1652 | - $image->src = $request->src; |
|
| 1653 | - $image->width = $width; |
|
| 1654 | - $image->height = $height; |
|
| 1655 | - $image->title = isset($request->title) ? $request->title : ''; |
|
| 1656 | - |
|
| 1657 | - $max_size = (object)geodir_get_imagesize($size); |
|
| 1658 | - |
|
| 1659 | - if (!is_wp_error($max_size)) {
|
|
| 1660 | - if ($image->width) {
|
|
| 1661 | - if ($image->height >= $image->width) {
|
|
| 1662 | - $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
| 1663 | - } else if ($image->width < ($max_size->h)) {
|
|
| 1664 | - $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
| 1665 | - } else |
|
| 1666 | - $width_per = 100; |
|
| 1667 | - } |
|
| 1668 | - |
|
| 1669 | - if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1670 | - $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1671 | - } else {
|
|
| 1672 | - if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1673 | - $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');" title="'.$image->title.'" aria-label="'.$image->title.'" ></div>'; |
|
| 1674 | - }else{
|
|
| 1675 | - $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" title="'.$image->title.'" aria-label="'.$image->title.'"></div>';
|
|
| 1676 | - } |
|
| 1677 | - |
|
| 1678 | - } |
|
| 1679 | - } |
|
| 1680 | - } |
|
| 1681 | - |
|
| 1682 | - if (!empty($html) && $echo) {
|
|
| 1683 | - echo $html; |
|
| 1684 | - } elseif (!empty($html)) {
|
|
| 1685 | - return $html; |
|
| 1686 | - } else |
|
| 1687 | - return false; |
|
| 1688 | - } |
|
| 1689 | -} |
|
| 1643 | + $width = 0; |
|
| 1644 | + $height = 0; |
|
| 1645 | + if (is_file($request->path) && file_exists($request->path)) {
|
|
| 1646 | + $imagesize = getimagesize($request->path); |
|
| 1647 | + $width = !empty($imagesize) && isset($imagesize[0]) ? $imagesize[0] : ''; |
|
| 1648 | + $height = !empty($imagesize) && isset($imagesize[1]) ? $imagesize[1] : ''; |
|
| 1649 | + } |
|
| 1690 | 1650 | |
| 1691 | -if (!function_exists('geodir_set_post_terms')) {
|
|
| 1692 | - /** |
|
| 1693 | - * Set post Categories. |
|
| 1694 | - * |
|
| 1695 | - * @since 1.0.0 |
|
| 1696 | - * @package GeoDirectory |
|
| 1697 | - * @global object $wpdb WordPress Database object. |
|
| 1698 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1699 | - * @param int $post_id The post ID. |
|
| 1700 | - * @param array $terms An array of term objects. |
|
| 1701 | - * @param array $tt_ids An array of term taxonomy IDs. |
|
| 1702 | - * @param string $taxonomy Taxonomy slug. |
|
| 1703 | - */ |
|
| 1704 | - function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
| 1705 | - {
|
|
| 1706 | - global $wpdb, $plugin_prefix; |
|
| 1707 | 1651 | |
| 1708 | - $post_type = get_post_type($post_id); |
|
| 1652 | + $image->src = $request->src; |
|
| 1653 | + $image->width = $width; |
|
| 1654 | + $image->height = $height; |
|
| 1655 | + $image->title = isset($request->title) ? $request->title : ''; |
|
| 1709 | 1656 | |
| 1710 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1657 | + $max_size = (object)geodir_get_imagesize($size); |
|
| 1711 | 1658 | |
| 1712 | - if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
|
| 1659 | + if (!is_wp_error($max_size)) {
|
|
| 1660 | + if ($image->width) {
|
|
| 1661 | + if ($image->height >= $image->width) {
|
|
| 1662 | + $width_per = round(((($image->width * ($max_size->h / $image->height)) / $max_size->w) * 100), 2); |
|
| 1663 | + } else if ($image->width < ($max_size->h)) {
|
|
| 1664 | + $width_per = round((($image->width / $max_size->w) * 100), 2); |
|
| 1665 | + } else |
|
| 1666 | + $width_per = 100; |
|
| 1667 | + } |
|
| 1713 | 1668 | |
| 1714 | - if ($taxonomy == $post_type . '_tags') {
|
|
| 1715 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1716 | - geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
| 1717 | - } |
|
| 1718 | - } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1719 | - $srcharr = array('"', '\\');
|
|
| 1720 | - $replarr = array(""", '');
|
|
| 1669 | + if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1670 | + $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1671 | + } else {
|
|
| 1672 | + if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1673 | + $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');" title="'.$image->title.'" aria-label="'.$image->title.'" ></div>'; |
|
| 1674 | + }else{
|
|
| 1675 | + $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" title="'.$image->title.'" aria-label="'.$image->title.'"></div>';
|
|
| 1676 | + } |
|
| 1721 | 1677 | |
| 1722 | - $post_obj = get_post($post_id); |
|
| 1678 | + } |
|
| 1679 | + } |
|
| 1680 | + } |
|
| 1681 | + |
|
| 1682 | + if (!empty($html) && $echo) {
|
|
| 1683 | + echo $html; |
|
| 1684 | + } elseif (!empty($html)) {
|
|
| 1685 | + return $html; |
|
| 1686 | + } else |
|
| 1687 | + return false; |
|
| 1688 | + } |
|
| 1689 | +} |
|
| 1723 | 1690 | |
| 1724 | - $cat_ids = array('0');
|
|
| 1725 | - if (is_array($tt_ids)) |
|
| 1726 | - $cat_ids = $tt_ids; |
|
| 1691 | +if (!function_exists('geodir_set_post_terms')) {
|
|
| 1692 | + /** |
|
| 1693 | + * Set post Categories. |
|
| 1694 | + * |
|
| 1695 | + * @since 1.0.0 |
|
| 1696 | + * @package GeoDirectory |
|
| 1697 | + * @global object $wpdb WordPress Database object. |
|
| 1698 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 1699 | + * @param int $post_id The post ID. |
|
| 1700 | + * @param array $terms An array of term objects. |
|
| 1701 | + * @param array $tt_ids An array of term taxonomy IDs. |
|
| 1702 | + * @param string $taxonomy Taxonomy slug. |
|
| 1703 | + */ |
|
| 1704 | + function geodir_set_post_terms($post_id, $terms, $tt_ids, $taxonomy) |
|
| 1705 | + {
|
|
| 1706 | + global $wpdb, $plugin_prefix; |
|
| 1707 | + |
|
| 1708 | + $post_type = get_post_type($post_id); |
|
| 1709 | + |
|
| 1710 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1711 | + |
|
| 1712 | + if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
|
| 1713 | + |
|
| 1714 | + if ($taxonomy == $post_type . '_tags') {
|
|
| 1715 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1716 | + geodir_save_post_meta($post_id, 'post_tags', $terms); |
|
| 1717 | + } |
|
| 1718 | + } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1719 | + $srcharr = array('"', '\\');
|
|
| 1720 | + $replarr = array(""", '');
|
|
| 1727 | 1721 | |
| 1722 | + $post_obj = get_post($post_id); |
|
| 1728 | 1723 | |
| 1729 | - if (!empty($cat_ids)) {
|
|
| 1730 | - $cat_ids_array = $cat_ids; |
|
| 1731 | - $cat_ids_length = count($cat_ids_array); |
|
| 1732 | - $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
| 1733 | - $format = implode(',', $cat_ids_format);
|
|
| 1724 | + $cat_ids = array('0');
|
|
| 1725 | + if (is_array($tt_ids)) |
|
| 1726 | + $cat_ids = $tt_ids; |
|
| 1734 | 1727 | |
| 1735 | - $cat_ids_array_del = $cat_ids_array; |
|
| 1736 | - $cat_ids_array_del[] = $post_id; |
|
| 1737 | 1728 | |
| 1738 | - $wpdb->get_var( |
|
| 1739 | - $wpdb->prepare( |
|
| 1740 | - "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1741 | - $cat_ids_array_del |
|
| 1742 | - ) |
|
| 1743 | - ); |
|
| 1729 | + if (!empty($cat_ids)) {
|
|
| 1730 | + $cat_ids_array = $cat_ids; |
|
| 1731 | + $cat_ids_length = count($cat_ids_array); |
|
| 1732 | + $cat_ids_format = array_fill(0, $cat_ids_length, '%d'); |
|
| 1733 | + $format = implode(',', $cat_ids_format);
|
|
| 1744 | 1734 | |
| 1735 | + $cat_ids_array_del = $cat_ids_array; |
|
| 1736 | + $cat_ids_array_del[] = $post_id; |
|
| 1745 | 1737 | |
| 1746 | - $post_term = $wpdb->get_col( |
|
| 1747 | - $wpdb->prepare( |
|
| 1748 | - "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1749 | - $cat_ids_array |
|
| 1750 | - ) |
|
| 1751 | - ); |
|
| 1738 | + $wpdb->get_var( |
|
| 1739 | + $wpdb->prepare( |
|
| 1740 | + "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1741 | + $cat_ids_array_del |
|
| 1742 | + ) |
|
| 1743 | + ); |
|
| 1752 | 1744 | |
| 1753 | - } |
|
| 1754 | 1745 | |
| 1755 | - $post_marker_json = ''; |
|
| 1746 | + $post_term = $wpdb->get_col( |
|
| 1747 | + $wpdb->prepare( |
|
| 1748 | + "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1749 | + $cat_ids_array |
|
| 1750 | + ) |
|
| 1751 | + ); |
|
| 1756 | 1752 | |
| 1757 | - if (!empty($post_term)): |
|
| 1753 | + } |
|
| 1758 | 1754 | |
| 1759 | - foreach ($post_term as $cat_id): |
|
| 1755 | + $post_marker_json = ''; |
|
| 1760 | 1756 | |
| 1761 | - $term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
| 1762 | - $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
| 1757 | + if (!empty($post_term)): |
|
| 1763 | 1758 | |
| 1764 | - $post_title = $post_obj->title; |
|
| 1765 | - $title = str_replace($srcharr, $replarr, $post_title); |
|
| 1759 | + foreach ($post_term as $cat_id): |
|
| 1766 | 1760 | |
| 1767 | - $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
| 1768 | - $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
| 1761 | + $term_icon_url = geodir_get_tax_meta($cat_id, 'ct_cat_icon', false, $post_type); |
|
| 1762 | + $term_icon = isset($term_icon_url['src']) ? $term_icon_url['src'] : ''; |
|
| 1769 | 1763 | |
| 1770 | - $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1771 | - $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1764 | + $post_title = $post_obj->title; |
|
| 1765 | + $title = str_replace($srcharr, $replarr, $post_title); |
|
| 1772 | 1766 | |
| 1773 | - $json = '{';
|
|
| 1774 | - $json .= '"id":"' . $post_id . '",'; |
|
| 1775 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1776 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 1777 | - $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1778 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 1779 | - $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1780 | - $json .= '}'; |
|
| 1767 | + $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
|
| 1768 | + $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
|
| 1781 | 1769 | |
| 1770 | + $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1771 | + $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1782 | 1772 | |
| 1783 | - if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
| 1784 | - $post_marker_json = $json; |
|
| 1773 | + $json = '{';
|
|
| 1774 | + $json .= '"id":"' . $post_id . '",'; |
|
| 1775 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1776 | + $json .= '"long_pos": "' . $lng . '",'; |
|
| 1777 | + $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1778 | + $json .= '"icon":"' . $term_icon . '",'; |
|
| 1779 | + $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1780 | + $json .= '}'; |
|
| 1785 | 1781 | |
| 1786 | 1782 | |
| 1787 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1783 | + if ($cat_id == geodir_get_post_meta($post_id, 'default_category', true)) |
|
| 1784 | + $post_marker_json = $json; |
|
| 1788 | 1785 | |
| 1789 | - $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1786 | + |
|
| 1787 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1788 | + |
|
| 1789 | + $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1790 | 1790 | post_title = %s, |
| 1791 | 1791 | json = %s |
| 1792 | 1792 | WHERE post_id = %d AND cat_id = %d ", |
| 1793 | - array($post_title, $json, $post_id, $cat_id)); |
|
| 1793 | + array($post_title, $json, $post_id, $cat_id)); |
|
| 1794 | 1794 | |
| 1795 | - } else {
|
|
| 1795 | + } else {
|
|
| 1796 | 1796 | |
| 1797 | - $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1797 | + $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1798 | 1798 | post_id = %d, |
| 1799 | 1799 | post_title = %s, |
| 1800 | 1800 | cat_id = %d, |
| 1801 | 1801 | json = %s", |
| 1802 | - array($post_id, $post_title, $cat_id, $json)); |
|
| 1802 | + array($post_id, $post_title, $cat_id, $json)); |
|
| 1803 | 1803 | |
| 1804 | - } |
|
| 1804 | + } |
|
| 1805 | 1805 | |
| 1806 | - $wpdb->query($json_query); |
|
| 1806 | + $wpdb->query($json_query); |
|
| 1807 | 1807 | |
| 1808 | - endforeach; |
|
| 1808 | + endforeach; |
|
| 1809 | 1809 | |
| 1810 | - endif; |
|
| 1810 | + endif; |
|
| 1811 | 1811 | |
| 1812 | - if (!empty($post_term) && is_array($post_term)) {
|
|
| 1813 | - $categories = implode(',', $post_term);
|
|
| 1812 | + if (!empty($post_term) && is_array($post_term)) {
|
|
| 1813 | + $categories = implode(',', $post_term);
|
|
| 1814 | 1814 | |
| 1815 | - if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1815 | + if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1816 | 1816 | |
| 1817 | - if (empty($post_marker_json)) |
|
| 1818 | - $post_marker_json = isset($json) ? $json : ''; |
|
| 1817 | + if (empty($post_marker_json)) |
|
| 1818 | + $post_marker_json = isset($json) ? $json : ''; |
|
| 1819 | 1819 | |
| 1820 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1820 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1821 | 1821 | |
| 1822 | - $wpdb->query( |
|
| 1823 | - $wpdb->prepare( |
|
| 1824 | - "UPDATE " . $table . " SET |
|
| 1822 | + $wpdb->query( |
|
| 1823 | + $wpdb->prepare( |
|
| 1824 | + "UPDATE " . $table . " SET |
|
| 1825 | 1825 | " . $taxonomy . " = %s, |
| 1826 | 1826 | marker_json = %s |
| 1827 | 1827 | where post_id = %d", |
| 1828 | - array($categories, $post_marker_json, $post_id) |
|
| 1829 | - ) |
|
| 1830 | - ); |
|
| 1828 | + array($categories, $post_marker_json, $post_id) |
|
| 1829 | + ) |
|
| 1830 | + ); |
|
| 1831 | 1831 | |
| 1832 | - if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
|
|
| 1832 | + if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'inline-save') {
|
|
| 1833 | 1833 | |
| 1834 | - $categories = trim($categories, ','); |
|
| 1834 | + $categories = trim($categories, ','); |
|
| 1835 | 1835 | |
| 1836 | - if ($categories) {
|
|
| 1836 | + if ($categories) {
|
|
| 1837 | 1837 | |
| 1838 | - $categories = explode(',', $categories);
|
|
| 1838 | + $categories = explode(',', $categories);
|
|
| 1839 | 1839 | |
| 1840 | - $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1840 | + $default_category = geodir_get_post_meta($post_id, 'default_category', true); |
|
| 1841 | 1841 | |
| 1842 | - if (!in_array($default_category, $categories)) {
|
|
| 1842 | + if (!in_array($default_category, $categories)) {
|
|
| 1843 | 1843 | |
| 1844 | - $wpdb->query( |
|
| 1845 | - $wpdb->prepare( |
|
| 1846 | - "UPDATE " . $table . " SET |
|
| 1844 | + $wpdb->query( |
|
| 1845 | + $wpdb->prepare( |
|
| 1846 | + "UPDATE " . $table . " SET |
|
| 1847 | 1847 | default_category = %s |
| 1848 | 1848 | where post_id = %d", |
| 1849 | - array($categories[0], $post_id) |
|
| 1850 | - ) |
|
| 1851 | - ); |
|
| 1849 | + array($categories[0], $post_id) |
|
| 1850 | + ) |
|
| 1851 | + ); |
|
| 1852 | 1852 | |
| 1853 | - $default_category = $categories[0]; |
|
| 1853 | + $default_category = $categories[0]; |
|
| 1854 | 1854 | |
| 1855 | - } |
|
| 1855 | + } |
|
| 1856 | 1856 | |
| 1857 | - if ($default_category == '') |
|
| 1858 | - $default_category = $categories[0]; |
|
| 1857 | + if ($default_category == '') |
|
| 1858 | + $default_category = $categories[0]; |
|
| 1859 | 1859 | |
| 1860 | - geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
| 1860 | + geodir_set_postcat_structure($post_id, $taxonomy, $default_category, ''); |
|
| 1861 | 1861 | |
| 1862 | - } |
|
| 1862 | + } |
|
| 1863 | 1863 | |
| 1864 | - } |
|
| 1864 | + } |
|
| 1865 | 1865 | |
| 1866 | 1866 | |
| 1867 | - } else {
|
|
| 1867 | + } else {
|
|
| 1868 | 1868 | |
| 1869 | - $wpdb->query( |
|
| 1870 | - $wpdb->prepare( |
|
| 1871 | - "INSERT INTO " . $table . " SET |
|
| 1869 | + $wpdb->query( |
|
| 1870 | + $wpdb->prepare( |
|
| 1871 | + "INSERT INTO " . $table . " SET |
|
| 1872 | 1872 | post_id = %d, |
| 1873 | 1873 | " . $taxonomy . " = %s, |
| 1874 | 1874 | marker_json = %s ", |
| 1875 | 1875 | |
| 1876 | - array($post_id, $categories, $post_marker_json) |
|
| 1877 | - ) |
|
| 1878 | - ); |
|
| 1879 | - } |
|
| 1880 | - } |
|
| 1881 | - } |
|
| 1882 | - } |
|
| 1883 | - } |
|
| 1876 | + array($post_id, $categories, $post_marker_json) |
|
| 1877 | + ) |
|
| 1878 | + ); |
|
| 1879 | + } |
|
| 1880 | + } |
|
| 1881 | + } |
|
| 1882 | + } |
|
| 1883 | + } |
|
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | 1886 | if (!function_exists('geodir_get_infowindow_html')) {
|
| 1887 | - /** |
|
| 1888 | - * Set post Map Marker info html. |
|
| 1889 | - * |
|
| 1890 | - * @since 1.0.0 |
|
| 1891 | - * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
| 1892 | - * @since 1.6.16 Changes for disable review stars for certain post type. |
|
| 1893 | - * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info. |
|
| 1894 | - * @package GeoDirectory |
|
| 1895 | - * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 1896 | - * @global object $gd_session GeoDirectory Session object. |
|
| 1897 | - * @param object $postinfo_obj The post details object. |
|
| 1898 | - * @param string $post_preview Is this a post preview?. |
|
| 1899 | - * @global object $post WordPress Post object. |
|
| 1900 | - * @return mixed|string|void |
|
| 1901 | - */ |
|
| 1902 | - function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
|
|
| 1903 | - global $preview, $post, $gd_session; |
|
| 1904 | - $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 1905 | - $replarr = array("′", "⁄", "–", "“", '');
|
|
| 1906 | - |
|
| 1907 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1908 | - $ID = ''; |
|
| 1909 | - $plink = ''; |
|
| 1910 | - |
|
| 1911 | - if (isset($postinfo_obj->pid)) {
|
|
| 1912 | - $ID = $postinfo_obj->pid; |
|
| 1913 | - $plink = get_permalink($ID); |
|
| 1914 | - } |
|
| 1915 | - |
|
| 1916 | - $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
| 1917 | - $lat = $postinfo_obj->post_latitude; |
|
| 1918 | - $lng = $postinfo_obj->post_longitude; |
|
| 1919 | - } else {
|
|
| 1920 | - $ID = $postinfo_obj->post_id; |
|
| 1921 | - $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1922 | - $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08 |
|
| 1923 | - $plink = get_permalink($ID); |
|
| 1924 | - $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
| 1925 | - $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
| 1926 | - } |
|
| 1887 | + /** |
|
| 1888 | + * Set post Map Marker info html. |
|
| 1889 | + * |
|
| 1890 | + * @since 1.0.0 |
|
| 1891 | + * @since 1.5.4 Modified to add new action "geodir_infowindow_meta_before". |
|
| 1892 | + * @since 1.6.16 Changes for disable review stars for certain post type. |
|
| 1893 | + * @since 1.6.18 Fix: Map marker not showing custom fields in bubble info. |
|
| 1894 | + * @package GeoDirectory |
|
| 1895 | + * @global array $geodir_addon_list List of active GeoDirectory extensions. |
|
| 1896 | + * @global object $gd_session GeoDirectory Session object. |
|
| 1897 | + * @param object $postinfo_obj The post details object. |
|
| 1898 | + * @param string $post_preview Is this a post preview?. |
|
| 1899 | + * @global object $post WordPress Post object. |
|
| 1900 | + * @return mixed|string|void |
|
| 1901 | + */ |
|
| 1902 | + function geodir_get_infowindow_html($postinfo_obj, $post_preview = '') {
|
|
| 1903 | + global $preview, $post, $gd_session; |
|
| 1904 | + $srcharr = array("'", "/", "-", '"', '\\');
|
|
| 1905 | + $replarr = array("′", "⁄", "–", "“", '');
|
|
| 1906 | + |
|
| 1907 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1908 | + $ID = ''; |
|
| 1909 | + $plink = ''; |
|
| 1910 | + |
|
| 1911 | + if (isset($postinfo_obj->pid)) {
|
|
| 1912 | + $ID = $postinfo_obj->pid; |
|
| 1913 | + $plink = get_permalink($ID); |
|
| 1914 | + } |
|
| 1915 | + |
|
| 1916 | + $title = str_replace($srcharr, $replarr, ($postinfo_obj->post_title)); |
|
| 1917 | + $lat = $postinfo_obj->post_latitude; |
|
| 1918 | + $lng = $postinfo_obj->post_longitude; |
|
| 1919 | + } else {
|
|
| 1920 | + $ID = $postinfo_obj->post_id; |
|
| 1921 | + $title = str_replace($srcharr, $replarr, htmlentities($postinfo_obj->post_title, ENT_COMPAT, 'UTF-8')); // fix by Stiofan |
|
| 1922 | + $title = wp_specialchars_decode($title); // Fixed #post-320722 on 2016-12-08 |
|
| 1923 | + $plink = get_permalink($ID); |
|
| 1924 | + $lat = htmlentities(geodir_get_post_meta($ID, 'post_latitude', true)); |
|
| 1925 | + $lng = htmlentities(geodir_get_post_meta($ID, 'post_longitude', true)); |
|
| 1926 | + } |
|
| 1927 | 1927 | |
| 1928 | - // Some theme overwrites global gd listing $post |
|
| 1929 | - if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
|
|
| 1930 | - $post = geodir_get_post_info($ID); |
|
| 1931 | - } |
|
| 1928 | + // Some theme overwrites global gd listing $post |
|
| 1929 | + if (!empty($ID) && (!empty($post->ID) && $post->ID != $ID) || empty($post)) {
|
|
| 1930 | + $post = geodir_get_post_info($ID); |
|
| 1931 | + } |
|
| 1932 | 1932 | |
| 1933 | - $post_type = $ID ? get_post_type($ID) : ''; |
|
| 1934 | - |
|
| 1935 | - // filter field as per price package |
|
| 1936 | - global $geodir_addon_list; |
|
| 1937 | - if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
|
|
| 1938 | - $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
| 1939 | - $field_name = 'geodir_contact'; |
|
| 1940 | - if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1941 | - $contact = ''; |
|
| 1942 | - } |
|
| 1943 | - |
|
| 1944 | - $field_name = 'geodir_timing'; |
|
| 1945 | - if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1946 | - $timing = ''; |
|
| 1947 | - } |
|
| 1948 | - } |
|
| 1949 | - |
|
| 1950 | - if ($lat && $lng) {
|
|
| 1951 | - ob_start(); ?> |
|
| 1933 | + $post_type = $ID ? get_post_type($ID) : ''; |
|
| 1934 | + |
|
| 1935 | + // filter field as per price package |
|
| 1936 | + global $geodir_addon_list; |
|
| 1937 | + if ($post_type && defined('GEODIRPAYMENT_VERSION')) {
|
|
| 1938 | + $package_id = isset($postinfo_obj->package_id) && $postinfo_obj->package_id ? $postinfo_obj->package_id : NULL; |
|
| 1939 | + $field_name = 'geodir_contact'; |
|
| 1940 | + if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1941 | + $contact = ''; |
|
| 1942 | + } |
|
| 1943 | + |
|
| 1944 | + $field_name = 'geodir_timing'; |
|
| 1945 | + if (!check_field_visibility($package_id, $field_name, $post_type)) {
|
|
| 1946 | + $timing = ''; |
|
| 1947 | + } |
|
| 1948 | + } |
|
| 1949 | + |
|
| 1950 | + if ($lat && $lng) {
|
|
| 1951 | + ob_start(); ?> |
|
| 1952 | 1952 | <div class="gd-bubble" style=""> |
| 1953 | 1953 | <div class="gd-bubble-inside"> |
| 1954 | 1954 | <?php |
| 1955 | - $comment_count = ''; |
|
| 1956 | - $rating_star = ''; |
|
| 1957 | - if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1958 | - $rating_star = ''; |
|
| 1959 | - $comment_count = geodir_get_review_count_total($ID); |
|
| 1960 | - |
|
| 1961 | - if (!$preview) {
|
|
| 1962 | - $post_avgratings = geodir_get_post_rating($ID); |
|
| 1963 | - |
|
| 1964 | - $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
| 1965 | - |
|
| 1966 | - /** |
|
| 1967 | - * Filter to change rating stars |
|
| 1968 | - * |
|
| 1969 | - * You can use this filter to change Rating stars. |
|
| 1970 | - * |
|
| 1971 | - * @since 1.0.0 |
|
| 1972 | - * @package GeoDirectory |
|
| 1973 | - * @param string $rating_star Rating stars. |
|
| 1974 | - * @param float $post_avgratings Average ratings of the post. |
|
| 1975 | - * @param int $ID The post ID. |
|
| 1976 | - */ |
|
| 1977 | - $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
|
|
| 1978 | - } |
|
| 1979 | - } |
|
| 1980 | - ?> |
|
| 1955 | + $comment_count = ''; |
|
| 1956 | + $rating_star = ''; |
|
| 1957 | + if ($ID != '' && $post_type != '' && !geodir_cpt_has_rating_disabled($post_type)) {
|
|
| 1958 | + $rating_star = ''; |
|
| 1959 | + $comment_count = geodir_get_review_count_total($ID); |
|
| 1960 | + |
|
| 1961 | + if (!$preview) {
|
|
| 1962 | + $post_avgratings = geodir_get_post_rating($ID); |
|
| 1963 | + |
|
| 1964 | + $rating_star = geodir_get_rating_stars($post_avgratings, $ID, false); |
|
| 1965 | + |
|
| 1966 | + /** |
|
| 1967 | + * Filter to change rating stars |
|
| 1968 | + * |
|
| 1969 | + * You can use this filter to change Rating stars. |
|
| 1970 | + * |
|
| 1971 | + * @since 1.0.0 |
|
| 1972 | + * @package GeoDirectory |
|
| 1973 | + * @param string $rating_star Rating stars. |
|
| 1974 | + * @param float $post_avgratings Average ratings of the post. |
|
| 1975 | + * @param int $ID The post ID. |
|
| 1976 | + */ |
|
| 1977 | + $rating_star = apply_filters('geodir_review_rating_stars_on_infowindow', $rating_star, $post_avgratings, $ID);
|
|
| 1978 | + } |
|
| 1979 | + } |
|
| 1980 | + ?> |
|
| 1981 | 1981 | <div class="geodir-bubble_desc"> |
| 1982 | 1982 | <h4> |
| 1983 | 1983 | <a href="<?php if ($plink != '') {
|
| 1984 | - echo $plink; |
|
| 1985 | - } else {
|
|
| 1986 | - echo 'javascript:void(0);'; |
|
| 1987 | - } ?>"><?php echo $title; ?></a> |
|
| 1984 | + echo $plink; |
|
| 1985 | + } else {
|
|
| 1986 | + echo 'javascript:void(0);'; |
|
| 1987 | + } ?>"><?php echo $title; ?></a> |
|
| 1988 | 1988 | </h4> |
| 1989 | 1989 | <?php |
| 1990 | - if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1991 | - $post_images = array(); |
|
| 1992 | - if (!empty($postinfo_obj->post_images)) {
|
|
| 1993 | - $post_images = explode(",", $postinfo_obj->post_images);
|
|
| 1994 | - } |
|
| 1995 | - |
|
| 1996 | - if (!empty($post_images)) {
|
|
| 1997 | - ?> |
|
| 1990 | + if ($gd_session->get('listing') && isset($post_preview) && $post_preview != '') {
|
|
| 1991 | + $post_images = array(); |
|
| 1992 | + if (!empty($postinfo_obj->post_images)) {
|
|
| 1993 | + $post_images = explode(",", $postinfo_obj->post_images);
|
|
| 1994 | + } |
|
| 1995 | + |
|
| 1996 | + if (!empty($post_images)) {
|
|
| 1997 | + ?> |
|
| 1998 | 1998 | <div class="geodir-bubble_image"><a href="<?php if ($plink != '') {
|
| 1999 | - echo $plink; |
|
| 2000 | - } else {
|
|
| 2001 | - echo 'javascript:void(0);'; |
|
| 2002 | - } ?>"><img alt="bubble image" style="max-height:50px;" |
|
| 1999 | + echo $plink; |
|
| 2000 | + } else {
|
|
| 2001 | + echo 'javascript:void(0);'; |
|
| 2002 | + } ?>"><img alt="bubble image" style="max-height:50px;" |
|
| 2003 | 2003 | src="<?php echo $post_images[0]; ?>"/></a></div> |
| 2004 | 2004 | <?php |
| 2005 | - }else{
|
|
| 2006 | - echo '<div class="geodir-bubble_image"></div>'; |
|
| 2007 | - } |
|
| 2008 | - } else {
|
|
| 2009 | - if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
|
|
| 2010 | - ?> |
|
| 2005 | + }else{
|
|
| 2006 | + echo '<div class="geodir-bubble_image"></div>'; |
|
| 2007 | + } |
|
| 2008 | + } else {
|
|
| 2009 | + if ($image = geodir_show_featured_image($ID, 'widget-thumb', true, false, $postinfo_obj->featured_image)) {
|
|
| 2010 | + ?> |
|
| 2011 | 2011 | <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div> |
| 2012 | 2012 | <?php |
| 2013 | - }else{
|
|
| 2014 | - echo '<div class="geodir-bubble_image"></div>'; |
|
| 2015 | - } |
|
| 2016 | - } |
|
| 2017 | - ?> |
|
| 2013 | + }else{
|
|
| 2014 | + echo '<div class="geodir-bubble_image"></div>'; |
|
| 2015 | + } |
|
| 2016 | + } |
|
| 2017 | + ?> |
|
| 2018 | 2018 | <div class="geodir-bubble-meta-side"> |
| 2019 | 2019 | <?php |
| 2020 | - /** |
|
| 2021 | - * Fires before the meta info in the map info window. |
|
| 2022 | - * |
|
| 2023 | - * This can be used to add more info to the map info window before the normal meta info. |
|
| 2024 | - * |
|
| 2025 | - * @since 1.5.4 |
|
| 2026 | - * @param int $ID The post id. |
|
| 2027 | - * @param object $postinfo_obj The posts info as an object. |
|
| 2028 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 2029 | - */ |
|
| 2030 | - do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
|
|
| 2031 | - |
|
| 2032 | - echo geodir_show_listing_info('mapbubble');
|
|
| 2033 | - |
|
| 2034 | - /** |
|
| 2035 | - * Fires after the meta info in the map info window. |
|
| 2036 | - * |
|
| 2037 | - * This can be used to add more info to the map info window after the normal meta info. |
|
| 2038 | - * |
|
| 2039 | - * @since 1.4.2 |
|
| 2040 | - * @param object $postinfo_obj The posts info as an object. |
|
| 2041 | - * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 2042 | - */ |
|
| 2043 | - do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 2044 | - ?> |
|
| 2020 | + /** |
|
| 2021 | + * Fires before the meta info in the map info window. |
|
| 2022 | + * |
|
| 2023 | + * This can be used to add more info to the map info window before the normal meta info. |
|
| 2024 | + * |
|
| 2025 | + * @since 1.5.4 |
|
| 2026 | + * @param int $ID The post id. |
|
| 2027 | + * @param object $postinfo_obj The posts info as an object. |
|
| 2028 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 2029 | + */ |
|
| 2030 | + do_action('geodir_infowindow_meta_before', $ID, $postinfo_obj, $post_preview);
|
|
| 2031 | + |
|
| 2032 | + echo geodir_show_listing_info('mapbubble');
|
|
| 2033 | + |
|
| 2034 | + /** |
|
| 2035 | + * Fires after the meta info in the map info window. |
|
| 2036 | + * |
|
| 2037 | + * This can be used to add more info to the map info window after the normal meta info. |
|
| 2038 | + * |
|
| 2039 | + * @since 1.4.2 |
|
| 2040 | + * @param object $postinfo_obj The posts info as an object. |
|
| 2041 | + * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
|
| 2042 | + */ |
|
| 2043 | + do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 2044 | + ?> |
|
| 2045 | 2045 | </div> |
| 2046 | 2046 | <?php |
| 2047 | - if ($ID) {
|
|
| 2048 | - $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
|
|
| 2049 | - ?> |
|
| 2047 | + if ($ID) {
|
|
| 2048 | + $post_author = isset($postinfo_obj->post_author) ? $postinfo_obj->post_author : get_post_field('post_author', $ID);
|
|
| 2049 | + ?> |
|
| 2050 | 2050 | <div class="geodir-bubble-meta-fade"></div> |
| 2051 | 2051 | <div class="geodir-bubble-meta-bottom"> |
| 2052 | 2052 | <?php if ($rating_star != '') { ?>
|
@@ -2062,22 +2062,22 @@ discard block |
||
| 2062 | 2062 | </div> |
| 2063 | 2063 | </div> |
| 2064 | 2064 | <?php |
| 2065 | - $html = ob_get_clean(); |
|
| 2066 | - /** |
|
| 2067 | - * Filter to change infowindow html |
|
| 2068 | - * |
|
| 2069 | - * You can use this filter to change infowindow html. |
|
| 2070 | - * |
|
| 2071 | - * @since 1.0.0 |
|
| 2072 | - * @package GeoDirectory |
|
| 2073 | - * @param string $html Infowindow html. |
|
| 2074 | - * @param object $postinfo_obj The Post object. |
|
| 2075 | - * @param bool|string $post_preview Is this a post preview? |
|
| 2076 | - */ |
|
| 2077 | - $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
|
|
| 2078 | - return $html; |
|
| 2079 | - } |
|
| 2080 | - } |
|
| 2065 | + $html = ob_get_clean(); |
|
| 2066 | + /** |
|
| 2067 | + * Filter to change infowindow html |
|
| 2068 | + * |
|
| 2069 | + * You can use this filter to change infowindow html. |
|
| 2070 | + * |
|
| 2071 | + * @since 1.0.0 |
|
| 2072 | + * @package GeoDirectory |
|
| 2073 | + * @param string $html Infowindow html. |
|
| 2074 | + * @param object $postinfo_obj The Post object. |
|
| 2075 | + * @param bool|string $post_preview Is this a post preview? |
|
| 2076 | + */ |
|
| 2077 | + $html = apply_filters('geodir_custom_infowindow_html', $html, $postinfo_obj, $post_preview);
|
|
| 2078 | + return $html; |
|
| 2079 | + } |
|
| 2080 | + } |
|
| 2081 | 2081 | } |
| 2082 | 2082 | |
| 2083 | 2083 | |
@@ -2091,47 +2091,47 @@ discard block |
||
| 2091 | 2091 | function geodir_new_post_default_status() |
| 2092 | 2092 | {
|
| 2093 | 2093 | |
| 2094 | - $status = get_option( 'geodir_new_post_default_status' ); |
|
| 2094 | + $status = get_option( 'geodir_new_post_default_status' ); |
|
| 2095 | 2095 | |
| 2096 | - if ( empty( $status ) ) {
|
|
| 2097 | - $status = 'publish'; |
|
| 2098 | - } |
|
| 2096 | + if ( empty( $status ) ) {
|
|
| 2097 | + $status = 'publish'; |
|
| 2098 | + } |
|
| 2099 | 2099 | |
| 2100 | - /** |
|
| 2101 | - * Filter the new post status. |
|
| 2102 | - * |
|
| 2103 | - * @since 1.6.23 |
|
| 2104 | - */ |
|
| 2105 | - return apply_filters( 'geodir_new_post_default_status', $status ); |
|
| 2100 | + /** |
|
| 2101 | + * Filter the new post status. |
|
| 2102 | + * |
|
| 2103 | + * @since 1.6.23 |
|
| 2104 | + */ |
|
| 2105 | + return apply_filters( 'geodir_new_post_default_status', $status ); |
|
| 2106 | 2106 | |
| 2107 | 2107 | } |
| 2108 | 2108 | |
| 2109 | 2109 | if (!function_exists('geodir_change_post_status')) {
|
| 2110 | - /** |
|
| 2111 | - * Change post status of a post. |
|
| 2112 | - * |
|
| 2113 | - * @global object $wpdb WordPress Database object. |
|
| 2114 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2115 | - * @param int|string $post_id The post ID. |
|
| 2116 | - * @param string $status New post status. Ex: draft, publish etc. |
|
| 2117 | - */ |
|
| 2118 | - function geodir_change_post_status($post_id = '', $status = '') |
|
| 2119 | - {
|
|
| 2120 | - global $wpdb, $plugin_prefix; |
|
| 2121 | - |
|
| 2122 | - $post_type = get_post_type($post_id); |
|
| 2123 | - |
|
| 2124 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2125 | - |
|
| 2126 | - $wpdb->query( |
|
| 2127 | - $wpdb->prepare( |
|
| 2128 | - "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2129 | - array($status, $post_id) |
|
| 2130 | - ) |
|
| 2131 | - ); |
|
| 2132 | - |
|
| 2133 | - |
|
| 2134 | - } |
|
| 2110 | + /** |
|
| 2111 | + * Change post status of a post. |
|
| 2112 | + * |
|
| 2113 | + * @global object $wpdb WordPress Database object. |
|
| 2114 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2115 | + * @param int|string $post_id The post ID. |
|
| 2116 | + * @param string $status New post status. Ex: draft, publish etc. |
|
| 2117 | + */ |
|
| 2118 | + function geodir_change_post_status($post_id = '', $status = '') |
|
| 2119 | + {
|
|
| 2120 | + global $wpdb, $plugin_prefix; |
|
| 2121 | + |
|
| 2122 | + $post_type = get_post_type($post_id); |
|
| 2123 | + |
|
| 2124 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2125 | + |
|
| 2126 | + $wpdb->query( |
|
| 2127 | + $wpdb->prepare( |
|
| 2128 | + "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2129 | + array($status, $post_id) |
|
| 2130 | + ) |
|
| 2131 | + ); |
|
| 2132 | + |
|
| 2133 | + |
|
| 2134 | + } |
|
| 2135 | 2135 | } |
| 2136 | 2136 | |
| 2137 | 2137 | /** |
@@ -2145,13 +2145,13 @@ discard block |
||
| 2145 | 2145 | */ |
| 2146 | 2146 | function geodir_set_post_status($pid, $status) |
| 2147 | 2147 | {
|
| 2148 | - if ($pid) {
|
|
| 2149 | - global $wpdb; |
|
| 2150 | - $my_post = array(); |
|
| 2151 | - $my_post['post_status'] = $status; |
|
| 2152 | - $my_post['ID'] = $pid; |
|
| 2153 | - $last_postid = wp_update_post($my_post); |
|
| 2154 | - } |
|
| 2148 | + if ($pid) {
|
|
| 2149 | + global $wpdb; |
|
| 2150 | + $my_post = array(); |
|
| 2151 | + $my_post['post_status'] = $status; |
|
| 2152 | + $my_post['ID'] = $pid; |
|
| 2153 | + $last_postid = wp_update_post($my_post); |
|
| 2154 | + } |
|
| 2155 | 2155 | } |
| 2156 | 2156 | |
| 2157 | 2157 | |
@@ -2167,403 +2167,403 @@ discard block |
||
| 2167 | 2167 | */ |
| 2168 | 2168 | function geodir_update_poststatus($new_status, $old_status, $post) |
| 2169 | 2169 | {
|
| 2170 | - global $wpdb; |
|
| 2170 | + global $wpdb; |
|
| 2171 | 2171 | |
| 2172 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 2172 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 2173 | 2173 | |
| 2174 | - if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 2174 | + if (!wp_is_post_revision($post->ID) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 2175 | 2175 | |
| 2176 | - geodir_change_post_status($post->ID, $new_status); |
|
| 2177 | - } |
|
| 2176 | + geodir_change_post_status($post->ID, $new_status); |
|
| 2177 | + } |
|
| 2178 | 2178 | } |
| 2179 | 2179 | |
| 2180 | 2180 | |
| 2181 | 2181 | if (!function_exists('geodir_update_listing_info')) {
|
| 2182 | - /** |
|
| 2183 | - * Update post info. |
|
| 2184 | - * |
|
| 2185 | - * @since 1.0.0 |
|
| 2186 | - * @package GeoDirectory |
|
| 2187 | - * @global object $wpdb WordPress Database object. |
|
| 2188 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2189 | - * @param int $updatingpost The updating post ID. |
|
| 2190 | - * @param int $temppost The temporary post ID. |
|
| 2191 | - * @todo fix post_id variable |
|
| 2192 | - */ |
|
| 2193 | - function geodir_update_listing_info($updatingpost, $temppost) |
|
| 2194 | - {
|
|
| 2195 | - |
|
| 2196 | - global $wpdb, $plugin_prefix; |
|
| 2197 | - |
|
| 2198 | - $post_type = get_post_type($post_id); |
|
| 2199 | - |
|
| 2200 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2201 | - |
|
| 2202 | - $wpdb->query( |
|
| 2203 | - $wpdb->prepare( |
|
| 2204 | - "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2205 | - array($updatingpost, $temppost) |
|
| 2206 | - ) |
|
| 2207 | - ); |
|
| 2208 | - |
|
| 2209 | - $wpdb->query( |
|
| 2210 | - $wpdb->prepare( |
|
| 2211 | - "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2212 | - array($updatingpost, $temppost) |
|
| 2213 | - ) |
|
| 2214 | - ); |
|
| 2215 | - |
|
| 2216 | - /* Update Attachments*/ |
|
| 2217 | - |
|
| 2218 | - $wpdb->query( |
|
| 2219 | - $wpdb->prepare( |
|
| 2220 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2221 | - array($updatingpost, $temppost) |
|
| 2222 | - ) |
|
| 2223 | - ); |
|
| 2224 | - |
|
| 2225 | - } |
|
| 2182 | + /** |
|
| 2183 | + * Update post info. |
|
| 2184 | + * |
|
| 2185 | + * @since 1.0.0 |
|
| 2186 | + * @package GeoDirectory |
|
| 2187 | + * @global object $wpdb WordPress Database object. |
|
| 2188 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2189 | + * @param int $updatingpost The updating post ID. |
|
| 2190 | + * @param int $temppost The temporary post ID. |
|
| 2191 | + * @todo fix post_id variable |
|
| 2192 | + */ |
|
| 2193 | + function geodir_update_listing_info($updatingpost, $temppost) |
|
| 2194 | + {
|
|
| 2195 | + |
|
| 2196 | + global $wpdb, $plugin_prefix; |
|
| 2197 | + |
|
| 2198 | + $post_type = get_post_type($post_id); |
|
| 2199 | + |
|
| 2200 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2201 | + |
|
| 2202 | + $wpdb->query( |
|
| 2203 | + $wpdb->prepare( |
|
| 2204 | + "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2205 | + array($updatingpost, $temppost) |
|
| 2206 | + ) |
|
| 2207 | + ); |
|
| 2208 | + |
|
| 2209 | + $wpdb->query( |
|
| 2210 | + $wpdb->prepare( |
|
| 2211 | + "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2212 | + array($updatingpost, $temppost) |
|
| 2213 | + ) |
|
| 2214 | + ); |
|
| 2215 | + |
|
| 2216 | + /* Update Attachments*/ |
|
| 2217 | + |
|
| 2218 | + $wpdb->query( |
|
| 2219 | + $wpdb->prepare( |
|
| 2220 | + "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2221 | + array($updatingpost, $temppost) |
|
| 2222 | + ) |
|
| 2223 | + ); |
|
| 2224 | + |
|
| 2225 | + } |
|
| 2226 | 2226 | } |
| 2227 | 2227 | |
| 2228 | 2228 | |
| 2229 | 2229 | if (!function_exists('geodir_delete_listing_info')) {
|
| 2230 | - /** |
|
| 2231 | - * Delete Listing info from details table for the given post id. |
|
| 2232 | - * |
|
| 2233 | - * @since 1.0.0 |
|
| 2234 | - * @package GeoDirectory |
|
| 2235 | - * @global object $wpdb WordPress Database object. |
|
| 2236 | - * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2237 | - * @param int $deleted_postid The post ID. |
|
| 2238 | - * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
| 2239 | - * @return bool|void |
|
| 2240 | - */ |
|
| 2241 | - function geodir_delete_listing_info($deleted_postid, $force = false) |
|
| 2242 | - {
|
|
| 2243 | - global $wpdb, $plugin_prefix; |
|
| 2244 | - |
|
| 2245 | - // check for multisite deletions |
|
| 2246 | - if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
|
|
| 2247 | - } else {
|
|
| 2248 | - return; |
|
| 2249 | - } |
|
| 2250 | - |
|
| 2251 | - $post_type = get_post_type($deleted_postid); |
|
| 2252 | - |
|
| 2253 | - $all_postypes = geodir_get_posttypes(); |
|
| 2254 | - |
|
| 2255 | - if (!in_array($post_type, $all_postypes)) |
|
| 2256 | - return false; |
|
| 2257 | - |
|
| 2258 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2259 | - |
|
| 2260 | - /* Delete custom post meta*/ |
|
| 2261 | - $wpdb->query( |
|
| 2262 | - $wpdb->prepare( |
|
| 2263 | - "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2264 | - array($deleted_postid) |
|
| 2265 | - ) |
|
| 2266 | - ); |
|
| 2267 | - |
|
| 2268 | - /* Delete post map icons*/ |
|
| 2269 | - |
|
| 2270 | - $wpdb->query( |
|
| 2271 | - $wpdb->prepare( |
|
| 2272 | - "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2273 | - array($deleted_postid) |
|
| 2274 | - ) |
|
| 2275 | - ); |
|
| 2276 | - |
|
| 2277 | - /* Delete Attachments*/ |
|
| 2278 | - $postcurr_images = geodir_get_images($deleted_postid); |
|
| 2279 | - |
|
| 2280 | - $wpdb->query( |
|
| 2281 | - $wpdb->prepare( |
|
| 2282 | - "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2283 | - array($deleted_postid) |
|
| 2284 | - ) |
|
| 2285 | - ); |
|
| 2286 | - geodir_remove_attachments($postcurr_images); |
|
| 2287 | - |
|
| 2288 | - } |
|
| 2230 | + /** |
|
| 2231 | + * Delete Listing info from details table for the given post id. |
|
| 2232 | + * |
|
| 2233 | + * @since 1.0.0 |
|
| 2234 | + * @package GeoDirectory |
|
| 2235 | + * @global object $wpdb WordPress Database object. |
|
| 2236 | + * @global string $plugin_prefix Geodirectory plugin table prefix. |
|
| 2237 | + * @param int $deleted_postid The post ID. |
|
| 2238 | + * @param bool $force Optional. Do you want to force delete it? Default: false. |
|
| 2239 | + * @return bool|void |
|
| 2240 | + */ |
|
| 2241 | + function geodir_delete_listing_info($deleted_postid, $force = false) |
|
| 2242 | + {
|
|
| 2243 | + global $wpdb, $plugin_prefix; |
|
| 2244 | + |
|
| 2245 | + // check for multisite deletions |
|
| 2246 | + if (strpos($plugin_prefix, $wpdb->prefix) !== false) {
|
|
| 2247 | + } else {
|
|
| 2248 | + return; |
|
| 2249 | + } |
|
| 2250 | + |
|
| 2251 | + $post_type = get_post_type($deleted_postid); |
|
| 2252 | + |
|
| 2253 | + $all_postypes = geodir_get_posttypes(); |
|
| 2254 | + |
|
| 2255 | + if (!in_array($post_type, $all_postypes)) |
|
| 2256 | + return false; |
|
| 2257 | + |
|
| 2258 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2259 | + |
|
| 2260 | + /* Delete custom post meta*/ |
|
| 2261 | + $wpdb->query( |
|
| 2262 | + $wpdb->prepare( |
|
| 2263 | + "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2264 | + array($deleted_postid) |
|
| 2265 | + ) |
|
| 2266 | + ); |
|
| 2267 | + |
|
| 2268 | + /* Delete post map icons*/ |
|
| 2269 | + |
|
| 2270 | + $wpdb->query( |
|
| 2271 | + $wpdb->prepare( |
|
| 2272 | + "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2273 | + array($deleted_postid) |
|
| 2274 | + ) |
|
| 2275 | + ); |
|
| 2276 | + |
|
| 2277 | + /* Delete Attachments*/ |
|
| 2278 | + $postcurr_images = geodir_get_images($deleted_postid); |
|
| 2279 | + |
|
| 2280 | + $wpdb->query( |
|
| 2281 | + $wpdb->prepare( |
|
| 2282 | + "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2283 | + array($deleted_postid) |
|
| 2284 | + ) |
|
| 2285 | + ); |
|
| 2286 | + geodir_remove_attachments($postcurr_images); |
|
| 2287 | + |
|
| 2288 | + } |
|
| 2289 | 2289 | } |
| 2290 | 2290 | |
| 2291 | 2291 | |
| 2292 | 2292 | if (!function_exists('geodir_add_to_favorite')) {
|
| 2293 | - /** |
|
| 2294 | - * This function would add listing to favorite listing. |
|
| 2295 | - * |
|
| 2296 | - * @since 1.0.0 |
|
| 2297 | - * @package GeoDirectory |
|
| 2298 | - * @global object $current_user Current user object. |
|
| 2299 | - * @param int $post_id The post ID. |
|
| 2300 | - */ |
|
| 2301 | - function geodir_add_to_favorite($post_id) |
|
| 2302 | - {
|
|
| 2303 | - |
|
| 2304 | - global $current_user; |
|
| 2305 | - |
|
| 2306 | - /** |
|
| 2307 | - * Filter to modify "Unfavorite" text |
|
| 2308 | - * |
|
| 2309 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2310 | - * |
|
| 2311 | - * @since 1.0.0 |
|
| 2312 | - * @package GeoDirectory |
|
| 2313 | - */ |
|
| 2314 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2315 | - |
|
| 2316 | - /** |
|
| 2317 | - * Filter to modify "Remove from Favorites" text |
|
| 2318 | - * |
|
| 2319 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2320 | - * |
|
| 2321 | - * @since 1.0.0 |
|
| 2322 | - * @package GeoDirectory |
|
| 2323 | - */ |
|
| 2324 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2325 | - |
|
| 2326 | - /** |
|
| 2327 | - * Filter to modify "fa fa-heart" icon |
|
| 2328 | - * |
|
| 2329 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2330 | - * |
|
| 2331 | - * @since 1.0.0 |
|
| 2332 | - * @package GeoDirectory |
|
| 2333 | - */ |
|
| 2334 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2335 | - |
|
| 2336 | - $site_id = ''; |
|
| 2337 | - if ( is_multisite() ) {
|
|
| 2338 | - $blog_id = get_current_blog_id(); |
|
| 2339 | - if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2340 | - } |
|
| 2341 | - |
|
| 2342 | - $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
|
| 2343 | - $user_meta_data = !empty($user_meta_data) && is_array($user_meta_data) ? $user_meta_data : array(); |
|
| 2344 | - |
|
| 2345 | - if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
|
|
| 2346 | - $user_meta_data[] = $post_id; |
|
| 2347 | - } |
|
| 2348 | - |
|
| 2349 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post'.$site_id, $user_meta_data); |
|
| 2350 | - |
|
| 2351 | - /** |
|
| 2352 | - * Called before adding the post from favourites. |
|
| 2353 | - * |
|
| 2354 | - * @since 1.0.0 |
|
| 2355 | - * @package GeoDirectory |
|
| 2356 | - * @param int $post_id The post ID. |
|
| 2357 | - */ |
|
| 2358 | - do_action('geodir_before_add_from_favorite', $post_id);
|
|
| 2359 | - |
|
| 2360 | - echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2361 | - |
|
| 2362 | - /** |
|
| 2363 | - * Called after adding the post from favourites. |
|
| 2364 | - * |
|
| 2365 | - * @since 1.0.0 |
|
| 2366 | - * @package GeoDirectory |
|
| 2367 | - * @param int $post_id The post ID. |
|
| 2368 | - */ |
|
| 2369 | - do_action('geodir_after_add_from_favorite', $post_id);
|
|
| 2293 | + /** |
|
| 2294 | + * This function would add listing to favorite listing. |
|
| 2295 | + * |
|
| 2296 | + * @since 1.0.0 |
|
| 2297 | + * @package GeoDirectory |
|
| 2298 | + * @global object $current_user Current user object. |
|
| 2299 | + * @param int $post_id The post ID. |
|
| 2300 | + */ |
|
| 2301 | + function geodir_add_to_favorite($post_id) |
|
| 2302 | + {
|
|
| 2303 | + |
|
| 2304 | + global $current_user; |
|
| 2305 | + |
|
| 2306 | + /** |
|
| 2307 | + * Filter to modify "Unfavorite" text |
|
| 2308 | + * |
|
| 2309 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2310 | + * |
|
| 2311 | + * @since 1.0.0 |
|
| 2312 | + * @package GeoDirectory |
|
| 2313 | + */ |
|
| 2314 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2315 | + |
|
| 2316 | + /** |
|
| 2317 | + * Filter to modify "Remove from Favorites" text |
|
| 2318 | + * |
|
| 2319 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2320 | + * |
|
| 2321 | + * @since 1.0.0 |
|
| 2322 | + * @package GeoDirectory |
|
| 2323 | + */ |
|
| 2324 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2325 | + |
|
| 2326 | + /** |
|
| 2327 | + * Filter to modify "fa fa-heart" icon |
|
| 2328 | + * |
|
| 2329 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2330 | + * |
|
| 2331 | + * @since 1.0.0 |
|
| 2332 | + * @package GeoDirectory |
|
| 2333 | + */ |
|
| 2334 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2335 | + |
|
| 2336 | + $site_id = ''; |
|
| 2337 | + if ( is_multisite() ) {
|
|
| 2338 | + $blog_id = get_current_blog_id(); |
|
| 2339 | + if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2340 | + } |
|
| 2341 | + |
|
| 2342 | + $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
|
| 2343 | + $user_meta_data = !empty($user_meta_data) && is_array($user_meta_data) ? $user_meta_data : array(); |
|
| 2344 | + |
|
| 2345 | + if (empty($user_meta_data) || (!empty($user_meta_data) && !in_array($post_id, $user_meta_data))) {
|
|
| 2346 | + $user_meta_data[] = $post_id; |
|
| 2347 | + } |
|
| 2348 | + |
|
| 2349 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post'.$site_id, $user_meta_data); |
|
| 2350 | + |
|
| 2351 | + /** |
|
| 2352 | + * Called before adding the post from favourites. |
|
| 2353 | + * |
|
| 2354 | + * @since 1.0.0 |
|
| 2355 | + * @package GeoDirectory |
|
| 2356 | + * @param int $post_id The post ID. |
|
| 2357 | + */ |
|
| 2358 | + do_action('geodir_before_add_from_favorite', $post_id);
|
|
| 2359 | + |
|
| 2360 | + echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2361 | + |
|
| 2362 | + /** |
|
| 2363 | + * Called after adding the post from favourites. |
|
| 2364 | + * |
|
| 2365 | + * @since 1.0.0 |
|
| 2366 | + * @package GeoDirectory |
|
| 2367 | + * @param int $post_id The post ID. |
|
| 2368 | + */ |
|
| 2369 | + do_action('geodir_after_add_from_favorite', $post_id);
|
|
| 2370 | 2370 | |
| 2371 | - } |
|
| 2371 | + } |
|
| 2372 | 2372 | } |
| 2373 | 2373 | |
| 2374 | 2374 | if (!function_exists('geodir_remove_from_favorite')) {
|
| 2375 | - /** |
|
| 2376 | - * This function would remove the favourited property earlier. |
|
| 2377 | - * |
|
| 2378 | - * @since 1.0.0 |
|
| 2379 | - * @package GeoDirectory |
|
| 2380 | - * @global object $current_user Current user object. |
|
| 2381 | - * @param int $post_id The post ID. |
|
| 2382 | - */ |
|
| 2383 | - function geodir_remove_from_favorite($post_id) |
|
| 2384 | - {
|
|
| 2385 | - global $current_user; |
|
| 2386 | - |
|
| 2387 | - /** |
|
| 2388 | - * Filter to modify "Add to Favorites" text |
|
| 2389 | - * |
|
| 2390 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2391 | - * |
|
| 2392 | - * @since 1.0.0 |
|
| 2393 | - * @package GeoDirectory |
|
| 2394 | - */ |
|
| 2395 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2396 | - |
|
| 2397 | - /** |
|
| 2398 | - * Filter to modify "Favourite" text |
|
| 2399 | - * |
|
| 2400 | - * You can use this filter to rename "Favourite" text to something else. |
|
| 2401 | - * |
|
| 2402 | - * @since 1.0.0 |
|
| 2403 | - * @package GeoDirectory |
|
| 2404 | - */ |
|
| 2405 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2406 | - |
|
| 2407 | - /** |
|
| 2408 | - * Filter to modify "fa fa-heart" icon |
|
| 2409 | - * |
|
| 2410 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2411 | - * |
|
| 2412 | - * @since 1.0.0 |
|
| 2413 | - * @package GeoDirectory |
|
| 2414 | - */ |
|
| 2415 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2416 | - |
|
| 2417 | - $site_id = ''; |
|
| 2418 | - if ( is_multisite() ) {
|
|
| 2419 | - $blog_id = get_current_blog_id(); |
|
| 2420 | - if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2421 | - } |
|
| 2422 | - |
|
| 2423 | - $user_meta_data = array(); |
|
| 2424 | - $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
|
| 2425 | - |
|
| 2426 | - if (!empty($user_meta_data)) {
|
|
| 2427 | - |
|
| 2428 | - if (($key = array_search($post_id, $user_meta_data)) !== false) {
|
|
| 2429 | - unset($user_meta_data[$key]); |
|
| 2430 | - } |
|
| 2375 | + /** |
|
| 2376 | + * This function would remove the favourited property earlier. |
|
| 2377 | + * |
|
| 2378 | + * @since 1.0.0 |
|
| 2379 | + * @package GeoDirectory |
|
| 2380 | + * @global object $current_user Current user object. |
|
| 2381 | + * @param int $post_id The post ID. |
|
| 2382 | + */ |
|
| 2383 | + function geodir_remove_from_favorite($post_id) |
|
| 2384 | + {
|
|
| 2385 | + global $current_user; |
|
| 2386 | + |
|
| 2387 | + /** |
|
| 2388 | + * Filter to modify "Add to Favorites" text |
|
| 2389 | + * |
|
| 2390 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2391 | + * |
|
| 2392 | + * @since 1.0.0 |
|
| 2393 | + * @package GeoDirectory |
|
| 2394 | + */ |
|
| 2395 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2396 | + |
|
| 2397 | + /** |
|
| 2398 | + * Filter to modify "Favourite" text |
|
| 2399 | + * |
|
| 2400 | + * You can use this filter to rename "Favourite" text to something else. |
|
| 2401 | + * |
|
| 2402 | + * @since 1.0.0 |
|
| 2403 | + * @package GeoDirectory |
|
| 2404 | + */ |
|
| 2405 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2406 | + |
|
| 2407 | + /** |
|
| 2408 | + * Filter to modify "fa fa-heart" icon |
|
| 2409 | + * |
|
| 2410 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2411 | + * |
|
| 2412 | + * @since 1.0.0 |
|
| 2413 | + * @package GeoDirectory |
|
| 2414 | + */ |
|
| 2415 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2416 | + |
|
| 2417 | + $site_id = ''; |
|
| 2418 | + if ( is_multisite() ) {
|
|
| 2419 | + $blog_id = get_current_blog_id(); |
|
| 2420 | + if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2421 | + } |
|
| 2422 | + |
|
| 2423 | + $user_meta_data = array(); |
|
| 2424 | + $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
|
| 2425 | + |
|
| 2426 | + if (!empty($user_meta_data)) {
|
|
| 2427 | + |
|
| 2428 | + if (($key = array_search($post_id, $user_meta_data)) !== false) {
|
|
| 2429 | + unset($user_meta_data[$key]); |
|
| 2430 | + } |
|
| 2431 | 2431 | |
| 2432 | - } |
|
| 2432 | + } |
|
| 2433 | 2433 | |
| 2434 | - update_user_meta($current_user->data->ID, 'gd_user_favourite_post'.$site_id, $user_meta_data); |
|
| 2434 | + update_user_meta($current_user->data->ID, 'gd_user_favourite_post'.$site_id, $user_meta_data); |
|
| 2435 | 2435 | |
| 2436 | - /** |
|
| 2437 | - * Called before removing the post from favourites. |
|
| 2438 | - * |
|
| 2439 | - * @since 1.0.0 |
|
| 2440 | - * @package GeoDirectory |
|
| 2441 | - * @param int $post_id The post ID. |
|
| 2442 | - */ |
|
| 2443 | - do_action('geodir_before_remove_from_favorite', $post_id);
|
|
| 2436 | + /** |
|
| 2437 | + * Called before removing the post from favourites. |
|
| 2438 | + * |
|
| 2439 | + * @since 1.0.0 |
|
| 2440 | + * @package GeoDirectory |
|
| 2441 | + * @param int $post_id The post ID. |
|
| 2442 | + */ |
|
| 2443 | + do_action('geodir_before_remove_from_favorite', $post_id);
|
|
| 2444 | 2444 | |
| 2445 | - echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2445 | + echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2446 | 2446 | |
| 2447 | - /** |
|
| 2448 | - * Called after removing the post from favourites. |
|
| 2449 | - * |
|
| 2450 | - * @since 1.0.0 |
|
| 2451 | - * @package GeoDirectory |
|
| 2452 | - * @param int $post_id The post ID. |
|
| 2453 | - */ |
|
| 2454 | - do_action('geodir_after_remove_from_favorite', $post_id);
|
|
| 2447 | + /** |
|
| 2448 | + * Called after removing the post from favourites. |
|
| 2449 | + * |
|
| 2450 | + * @since 1.0.0 |
|
| 2451 | + * @package GeoDirectory |
|
| 2452 | + * @param int $post_id The post ID. |
|
| 2453 | + */ |
|
| 2454 | + do_action('geodir_after_remove_from_favorite', $post_id);
|
|
| 2455 | 2455 | |
| 2456 | - } |
|
| 2456 | + } |
|
| 2457 | 2457 | } |
| 2458 | 2458 | |
| 2459 | 2459 | if (!function_exists('geodir_favourite_html')) {
|
| 2460 | - /** |
|
| 2461 | - * This function would display the html content for add to favorite or remove from favorite. |
|
| 2462 | - * |
|
| 2463 | - * @since 1.0.0 |
|
| 2464 | - * @package GeoDirectory |
|
| 2465 | - * @global object $current_user Current user object. |
|
| 2466 | - * @global object $post The current post object. |
|
| 2467 | - * @param int $user_id The user ID. |
|
| 2468 | - * @param int $post_id The post ID. |
|
| 2469 | - */ |
|
| 2470 | - function geodir_favourite_html($user_id, $post_id) |
|
| 2471 | - {
|
|
| 2472 | - |
|
| 2473 | - global $current_user, $post; |
|
| 2474 | - |
|
| 2475 | - /** |
|
| 2476 | - * Filter to modify "Add to Favorites" text |
|
| 2477 | - * |
|
| 2478 | - * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2479 | - * |
|
| 2480 | - * @since 1.0.0 |
|
| 2481 | - * @package GeoDirectory |
|
| 2482 | - */ |
|
| 2483 | - $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2484 | - |
|
| 2485 | - /** |
|
| 2486 | - * Filter to modify "Favourite" text |
|
| 2487 | - * |
|
| 2488 | - * You can use this filter to rename "Favourite" text to something else. |
|
| 2489 | - * |
|
| 2490 | - * @since 1.0.0 |
|
| 2491 | - * @package GeoDirectory |
|
| 2492 | - */ |
|
| 2493 | - $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2494 | - |
|
| 2495 | - /** |
|
| 2496 | - * Filter to modify "Unfavorite" text |
|
| 2497 | - * |
|
| 2498 | - * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2499 | - * |
|
| 2500 | - * @since 1.0.0 |
|
| 2501 | - * @package GeoDirectory |
|
| 2502 | - */ |
|
| 2503 | - $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2504 | - |
|
| 2505 | - /** |
|
| 2506 | - * Filter to modify "Remove from Favorites" text |
|
| 2507 | - * |
|
| 2508 | - * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2509 | - * |
|
| 2510 | - * @since 1.0.0 |
|
| 2511 | - * @package GeoDirectory |
|
| 2512 | - */ |
|
| 2513 | - $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2514 | - |
|
| 2515 | - /** |
|
| 2516 | - * Filter to modify "fa fa-heart" icon |
|
| 2517 | - * |
|
| 2518 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2519 | - * |
|
| 2520 | - * @since 1.0.0 |
|
| 2521 | - * @package GeoDirectory |
|
| 2522 | - */ |
|
| 2523 | - $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2524 | - |
|
| 2525 | - /** |
|
| 2526 | - * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
| 2527 | - * |
|
| 2528 | - * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2529 | - * |
|
| 2530 | - * @since 1.0.0 |
|
| 2531 | - * @package GeoDirectory |
|
| 2532 | - */ |
|
| 2533 | - $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
|
|
| 2534 | - |
|
| 2535 | - |
|
| 2536 | - $site_id = ''; |
|
| 2537 | - if ( is_multisite() ) {
|
|
| 2538 | - $blog_id = get_current_blog_id(); |
|
| 2539 | - if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2540 | - } |
|
| 2541 | - |
|
| 2542 | - $user_meta_data = ''; |
|
| 2543 | - if (isset($current_user->data->ID)) |
|
| 2544 | - $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
|
| 2545 | - |
|
| 2546 | - if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
|
| 2547 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2460 | + /** |
|
| 2461 | + * This function would display the html content for add to favorite or remove from favorite. |
|
| 2462 | + * |
|
| 2463 | + * @since 1.0.0 |
|
| 2464 | + * @package GeoDirectory |
|
| 2465 | + * @global object $current_user Current user object. |
|
| 2466 | + * @global object $post The current post object. |
|
| 2467 | + * @param int $user_id The user ID. |
|
| 2468 | + * @param int $post_id The post ID. |
|
| 2469 | + */ |
|
| 2470 | + function geodir_favourite_html($user_id, $post_id) |
|
| 2471 | + {
|
|
| 2472 | + |
|
| 2473 | + global $current_user, $post; |
|
| 2474 | + |
|
| 2475 | + /** |
|
| 2476 | + * Filter to modify "Add to Favorites" text |
|
| 2477 | + * |
|
| 2478 | + * You can use this filter to rename "Add to Favorites" text to something else. |
|
| 2479 | + * |
|
| 2480 | + * @since 1.0.0 |
|
| 2481 | + * @package GeoDirectory |
|
| 2482 | + */ |
|
| 2483 | + $add_favourite_text = apply_filters('geodir_add_favourite_text', ADD_FAVOURITE_TEXT);
|
|
| 2484 | + |
|
| 2485 | + /** |
|
| 2486 | + * Filter to modify "Favourite" text |
|
| 2487 | + * |
|
| 2488 | + * You can use this filter to rename "Favourite" text to something else. |
|
| 2489 | + * |
|
| 2490 | + * @since 1.0.0 |
|
| 2491 | + * @package GeoDirectory |
|
| 2492 | + */ |
|
| 2493 | + $favourite_text = apply_filters('geodir_favourite_text', FAVOURITE_TEXT);
|
|
| 2494 | + |
|
| 2495 | + /** |
|
| 2496 | + * Filter to modify "Unfavorite" text |
|
| 2497 | + * |
|
| 2498 | + * You can use this filter to rename "Unfavorite" text to something else. |
|
| 2499 | + * |
|
| 2500 | + * @since 1.0.0 |
|
| 2501 | + * @package GeoDirectory |
|
| 2502 | + */ |
|
| 2503 | + $remove_favourite_text = apply_filters('geodir_remove_favourite_text', REMOVE_FAVOURITE_TEXT);
|
|
| 2504 | + |
|
| 2505 | + /** |
|
| 2506 | + * Filter to modify "Remove from Favorites" text |
|
| 2507 | + * |
|
| 2508 | + * You can use this filter to rename "Remove from Favorites" text to something else. |
|
| 2509 | + * |
|
| 2510 | + * @since 1.0.0 |
|
| 2511 | + * @package GeoDirectory |
|
| 2512 | + */ |
|
| 2513 | + $unfavourite_text = apply_filters('geodir_unfavourite_text', UNFAVOURITE_TEXT);
|
|
| 2514 | + |
|
| 2515 | + /** |
|
| 2516 | + * Filter to modify "fa fa-heart" icon |
|
| 2517 | + * |
|
| 2518 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2519 | + * |
|
| 2520 | + * @since 1.0.0 |
|
| 2521 | + * @package GeoDirectory |
|
| 2522 | + */ |
|
| 2523 | + $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
|
| 2524 | + |
|
| 2525 | + /** |
|
| 2526 | + * Filter to modify "fa fa-heart" icon for "remove from favorites" link |
|
| 2527 | + * |
|
| 2528 | + * You can use this filter to change "fa fa-heart" icon to something else. |
|
| 2529 | + * |
|
| 2530 | + * @since 1.0.0 |
|
| 2531 | + * @package GeoDirectory |
|
| 2532 | + */ |
|
| 2533 | + $unfavourite_icon = apply_filters('geodir_unfavourite_icon', 'fa fa-heart');
|
|
| 2534 | + |
|
| 2535 | + |
|
| 2536 | + $site_id = ''; |
|
| 2537 | + if ( is_multisite() ) {
|
|
| 2538 | + $blog_id = get_current_blog_id(); |
|
| 2539 | + if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2540 | + } |
|
| 2541 | + |
|
| 2542 | + $user_meta_data = ''; |
|
| 2543 | + if (isset($current_user->data->ID)) |
|
| 2544 | + $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
|
| 2545 | + |
|
| 2546 | + if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
|
| 2547 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2548 | 2548 | class="geodir-removetofav-icon" href="javascript:void(0);" |
| 2549 | 2549 | onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');" |
| 2550 | 2550 | title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?> |
| 2551 | 2551 | </a> </span><?php |
| 2552 | 2552 | |
| 2553 | - } else {
|
|
| 2553 | + } else {
|
|
| 2554 | 2554 | |
| 2555 | - if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
|
| 2556 | - $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2557 | - } else |
|
| 2558 | - $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2555 | + if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
|
| 2556 | + $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2557 | + } else |
|
| 2558 | + $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2559 | 2559 | |
| 2560 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2560 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2561 | 2561 | href="javascript:void(0);" |
| 2562 | 2562 | onclick="<?php echo $script_text;?>" |
| 2563 | 2563 | title="<?php echo $add_favourite_text;?>"><i |
| 2564 | 2564 | class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span> |
| 2565 | 2565 | <?php } |
| 2566 | - } |
|
| 2566 | + } |
|
| 2567 | 2567 | } |
| 2568 | 2568 | |
| 2569 | 2569 | |
@@ -2580,54 +2580,54 @@ discard block |
||
| 2580 | 2580 | function geodir_get_cat_postcount($term = array()) |
| 2581 | 2581 | {
|
| 2582 | 2582 | |
| 2583 | - if (!empty($term)) {
|
|
| 2583 | + if (!empty($term)) {
|
|
| 2584 | 2584 | |
| 2585 | - global $wpdb, $plugin_prefix; |
|
| 2585 | + global $wpdb, $plugin_prefix; |
|
| 2586 | 2586 | |
| 2587 | - $where = ''; |
|
| 2588 | - $join = ''; |
|
| 2589 | - if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
|
|
| 2590 | - $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
| 2587 | + $where = ''; |
|
| 2588 | + $join = ''; |
|
| 2589 | + if (get_query_var('gd_country') != '' || get_query_var('gd_region') != '' || get_query_var('gd_city') != '') {
|
|
| 2590 | + $taxonomy_obj = get_taxonomy($term->taxonomy); |
|
| 2591 | 2591 | |
| 2592 | - $post_type = $taxonomy_obj->object_type[0]; |
|
| 2592 | + $post_type = $taxonomy_obj->object_type[0]; |
|
| 2593 | 2593 | |
| 2594 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2594 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2595 | 2595 | |
| 2596 | - /** |
|
| 2597 | - * Filter to modify the 'join' query |
|
| 2598 | - * |
|
| 2599 | - * @since 1.0.0 |
|
| 2600 | - * @package GeoDirectory |
|
| 2601 | - * @param object|array $term category / term object that need to be processed. |
|
| 2602 | - * @param string $join The join query. |
|
| 2603 | - */ |
|
| 2604 | - $join = apply_filters('geodir_cat_post_count_join', $join, $term);
|
|
| 2596 | + /** |
|
| 2597 | + * Filter to modify the 'join' query |
|
| 2598 | + * |
|
| 2599 | + * @since 1.0.0 |
|
| 2600 | + * @package GeoDirectory |
|
| 2601 | + * @param object|array $term category / term object that need to be processed. |
|
| 2602 | + * @param string $join The join query. |
|
| 2603 | + */ |
|
| 2604 | + $join = apply_filters('geodir_cat_post_count_join', $join, $term);
|
|
| 2605 | 2605 | |
| 2606 | - /** |
|
| 2607 | - * Filter to modify the 'where' query |
|
| 2608 | - * |
|
| 2609 | - * @since 1.0.0 |
|
| 2610 | - * @package GeoDirectory |
|
| 2611 | - * @param object|array $term category / term object that need to be processed. |
|
| 2612 | - * @param string $where The where query. |
|
| 2613 | - */ |
|
| 2614 | - $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
|
| 2606 | + /** |
|
| 2607 | + * Filter to modify the 'where' query |
|
| 2608 | + * |
|
| 2609 | + * @since 1.0.0 |
|
| 2610 | + * @package GeoDirectory |
|
| 2611 | + * @param object|array $term category / term object that need to be processed. |
|
| 2612 | + * @param string $where The where query. |
|
| 2613 | + */ |
|
| 2614 | + $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
|
| 2615 | 2615 | |
| 2616 | - $count_query = "SELECT count(post_id) FROM |
|
| 2616 | + $count_query = "SELECT count(post_id) FROM |
|
| 2617 | 2617 | " . $table . " as pd " . $join . " |
| 2618 | 2618 | WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
|
| 2619 | 2619 | |
| 2620 | - $cat_post_count = $wpdb->get_var($count_query); |
|
| 2621 | - if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
| 2622 | - $cat_post_count = 0; |
|
| 2620 | + $cat_post_count = $wpdb->get_var($count_query); |
|
| 2621 | + if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
|
| 2622 | + $cat_post_count = 0; |
|
| 2623 | 2623 | |
| 2624 | - return $cat_post_count; |
|
| 2624 | + return $cat_post_count; |
|
| 2625 | 2625 | |
| 2626 | - } else |
|
| 2626 | + } else |
|
| 2627 | 2627 | |
| 2628 | - return $term->count; |
|
| 2629 | - } |
|
| 2630 | - return false; |
|
| 2628 | + return $term->count; |
|
| 2629 | + } |
|
| 2630 | + return false; |
|
| 2631 | 2631 | |
| 2632 | 2632 | } |
| 2633 | 2633 | |
@@ -2640,17 +2640,17 @@ discard block |
||
| 2640 | 2640 | */ |
| 2641 | 2641 | function geodir_allow_post_type_frontend() |
| 2642 | 2642 | {
|
| 2643 | - $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2643 | + $geodir_allow_posttype_frontend = get_option('geodir_allow_posttype_frontend');
|
|
| 2644 | 2644 | |
| 2645 | - if (!is_admin() && isset($_REQUEST['listing_type']) |
|
| 2646 | - && !empty($geodir_allow_posttype_frontend) |
|
| 2647 | - && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
| 2648 | - ) {
|
|
| 2645 | + if (!is_admin() && isset($_REQUEST['listing_type']) |
|
| 2646 | + && !empty($geodir_allow_posttype_frontend) |
|
| 2647 | + && !in_array($_REQUEST['listing_type'], $geodir_allow_posttype_frontend) |
|
| 2648 | + ) {
|
|
| 2649 | 2649 | |
| 2650 | - wp_redirect(home_url()); |
|
| 2651 | - exit; |
|
| 2650 | + wp_redirect(home_url()); |
|
| 2651 | + exit; |
|
| 2652 | 2652 | |
| 2653 | - } |
|
| 2653 | + } |
|
| 2654 | 2654 | |
| 2655 | 2655 | } |
| 2656 | 2656 | |
@@ -2667,20 +2667,20 @@ discard block |
||
| 2667 | 2667 | */ |
| 2668 | 2668 | function geodir_excerpt_length($length) |
| 2669 | 2669 | {
|
| 2670 | - global $wp_query, $geodir_is_widget_listing; |
|
| 2670 | + global $wp_query, $geodir_is_widget_listing; |
|
| 2671 | 2671 | if ($geodir_is_widget_listing) {
|
| 2672 | 2672 | return $length; |
| 2673 | 2673 | } |
| 2674 | 2674 | |
| 2675 | - if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
|
|
| 2676 | - $length = get_option('geodir_desc_word_limit');
|
|
| 2677 | - elseif (get_query_var('excerpt_length'))
|
|
| 2678 | - $length = get_query_var('excerpt_length');
|
|
| 2675 | + if (isset($wp_query->query_vars['is_geodir_loop']) && $wp_query->query_vars['is_geodir_loop'] && get_option('geodir_desc_word_limit'))
|
|
| 2676 | + $length = get_option('geodir_desc_word_limit');
|
|
| 2677 | + elseif (get_query_var('excerpt_length'))
|
|
| 2678 | + $length = get_query_var('excerpt_length');
|
|
| 2679 | 2679 | |
| 2680 | - if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
|
|
| 2681 | - $length = get_option('geodir_author_desc_word_limit');
|
|
| 2680 | + if (geodir_is_page('author') && get_option('geodir_author_desc_word_limit'))
|
|
| 2681 | + $length = get_option('geodir_author_desc_word_limit');
|
|
| 2682 | 2682 | |
| 2683 | - return $length; |
|
| 2683 | + return $length; |
|
| 2684 | 2684 | } |
| 2685 | 2685 | |
| 2686 | 2686 | /** |
@@ -2695,21 +2695,21 @@ discard block |
||
| 2695 | 2695 | */ |
| 2696 | 2696 | function geodir_excerpt_more($more) |
| 2697 | 2697 | {
|
| 2698 | - global $post; |
|
| 2699 | - $all_postypes = geodir_get_posttypes(); |
|
| 2700 | - if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 2701 | - $out = ' <a class="excerpt-read-more" href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; |
|
| 2702 | - /** |
|
| 2703 | - * Filter excerpt read more text. |
|
| 2704 | - * |
|
| 2705 | - * @since 1.0.0 |
|
| 2706 | - */ |
|
| 2707 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); |
|
| 2708 | - $out .= '</a>'; |
|
| 2709 | - return $out; |
|
| 2710 | - } |
|
| 2698 | + global $post; |
|
| 2699 | + $all_postypes = geodir_get_posttypes(); |
|
| 2700 | + if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
|
| 2701 | + $out = ' <a class="excerpt-read-more" href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; |
|
| 2702 | + /** |
|
| 2703 | + * Filter excerpt read more text. |
|
| 2704 | + * |
|
| 2705 | + * @since 1.0.0 |
|
| 2706 | + */ |
|
| 2707 | + $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); |
|
| 2708 | + $out .= '</a>'; |
|
| 2709 | + return $out; |
|
| 2710 | + } |
|
| 2711 | 2711 | |
| 2712 | - return $more; |
|
| 2712 | + return $more; |
|
| 2713 | 2713 | } |
| 2714 | 2714 | |
| 2715 | 2715 | |
@@ -2726,63 +2726,63 @@ discard block |
||
| 2726 | 2726 | */ |
| 2727 | 2727 | function geodir_update_markers_oncatedit($term_id, $tt_id, $taxonomy) |
| 2728 | 2728 | {
|
| 2729 | - global $plugin_prefix, $wpdb; |
|
| 2729 | + global $plugin_prefix, $wpdb; |
|
| 2730 | 2730 | |
| 2731 | - $gd_taxonomies = geodir_get_taxonomies(); |
|
| 2731 | + $gd_taxonomies = geodir_get_taxonomies(); |
|
| 2732 | 2732 | |
| 2733 | - if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
|
| 2733 | + if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
|
| 2734 | 2734 | |
| 2735 | - $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
| 2736 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2735 | + $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
|
| 2736 | + $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2737 | 2737 | |
| 2738 | - $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
| 2739 | - $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2738 | + $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
|
| 2739 | + $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2740 | 2740 | |
| 2741 | - $posts = $wpdb->get_results( |
|
| 2742 | - $wpdb->prepare( |
|
| 2743 | - "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2744 | - array($term_id, $taxonomy) |
|
| 2745 | - ) |
|
| 2746 | - ); |
|
| 2741 | + $posts = $wpdb->get_results( |
|
| 2742 | + $wpdb->prepare( |
|
| 2743 | + "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2744 | + array($term_id, $taxonomy) |
|
| 2745 | + ) |
|
| 2746 | + ); |
|
| 2747 | 2747 | |
| 2748 | - if (!empty($posts)): |
|
| 2749 | - foreach ($posts as $post_obj) {
|
|
| 2748 | + if (!empty($posts)): |
|
| 2749 | + foreach ($posts as $post_obj) {
|
|
| 2750 | 2750 | |
| 2751 | - $lat = $post_obj->post_latitude; |
|
| 2752 | - $lng = $post_obj->post_longitude; |
|
| 2751 | + $lat = $post_obj->post_latitude; |
|
| 2752 | + $lng = $post_obj->post_longitude; |
|
| 2753 | 2753 | |
| 2754 | - $json = '{';
|
|
| 2755 | - $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2756 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2757 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 2758 | - $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2759 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 2760 | - $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2761 | - $json .= '}'; |
|
| 2754 | + $json = '{';
|
|
| 2755 | + $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2756 | + $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2757 | + $json .= '"long_pos": "' . $lng . '",'; |
|
| 2758 | + $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2759 | + $json .= '"icon":"' . $term_icon . '",'; |
|
| 2760 | + $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2761 | + $json .= '}'; |
|
| 2762 | 2762 | |
| 2763 | - if ($post_obj->default_category == $term_id) {
|
|
| 2763 | + if ($post_obj->default_category == $term_id) {
|
|
| 2764 | 2764 | |
| 2765 | - $wpdb->query( |
|
| 2766 | - $wpdb->prepare( |
|
| 2767 | - "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2768 | - array($json, $post_obj->post_id) |
|
| 2769 | - ) |
|
| 2770 | - ); |
|
| 2771 | - } |
|
| 2765 | + $wpdb->query( |
|
| 2766 | + $wpdb->prepare( |
|
| 2767 | + "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2768 | + array($json, $post_obj->post_id) |
|
| 2769 | + ) |
|
| 2770 | + ); |
|
| 2771 | + } |
|
| 2772 | 2772 | |
| 2773 | - $wpdb->query( |
|
| 2774 | - $wpdb->prepare( |
|
| 2775 | - "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2776 | - array($json, $post_obj->post_id, $term_id) |
|
| 2777 | - ) |
|
| 2778 | - ); |
|
| 2773 | + $wpdb->query( |
|
| 2774 | + $wpdb->prepare( |
|
| 2775 | + "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2776 | + array($json, $post_obj->post_id, $term_id) |
|
| 2777 | + ) |
|
| 2778 | + ); |
|
| 2779 | 2779 | |
| 2780 | - } |
|
| 2780 | + } |
|
| 2781 | 2781 | |
| 2782 | 2782 | |
| 2783 | - endif; |
|
| 2783 | + endif; |
|
| 2784 | 2784 | |
| 2785 | - } |
|
| 2785 | + } |
|
| 2786 | 2786 | |
| 2787 | 2787 | } |
| 2788 | 2788 | |
@@ -2796,14 +2796,14 @@ discard block |
||
| 2796 | 2796 | */ |
| 2797 | 2797 | function geodir_get_listing_author($listing_id = '') |
| 2798 | 2798 | {
|
| 2799 | - if ($listing_id == '') {
|
|
| 2800 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2801 | - $listing_id = $_REQUEST['pid']; |
|
| 2802 | - } |
|
| 2803 | - } |
|
| 2804 | - $listing = get_post(strip_tags($listing_id)); |
|
| 2805 | - $listing_author_id = $listing->post_author; |
|
| 2806 | - return $listing_author_id; |
|
| 2799 | + if ($listing_id == '') {
|
|
| 2800 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') {
|
|
| 2801 | + $listing_id = $_REQUEST['pid']; |
|
| 2802 | + } |
|
| 2803 | + } |
|
| 2804 | + $listing = get_post(strip_tags($listing_id)); |
|
| 2805 | + $listing_author_id = $listing->post_author; |
|
| 2806 | + return $listing_author_id; |
|
| 2807 | 2807 | } |
| 2808 | 2808 | |
| 2809 | 2809 | |
@@ -2818,11 +2818,11 @@ discard block |
||
| 2818 | 2818 | */ |
| 2819 | 2819 | function geodir_lisiting_belong_to_user($listing_id, $user_id) |
| 2820 | 2820 | {
|
| 2821 | - $listing_author_id = geodir_get_listing_author($listing_id); |
|
| 2822 | - if ($listing_author_id == $user_id) |
|
| 2823 | - return true; |
|
| 2824 | - else |
|
| 2825 | - return false; |
|
| 2821 | + $listing_author_id = geodir_get_listing_author($listing_id); |
|
| 2822 | + if ($listing_author_id == $user_id) |
|
| 2823 | + return true; |
|
| 2824 | + else |
|
| 2825 | + return false; |
|
| 2826 | 2826 | |
| 2827 | 2827 | } |
| 2828 | 2828 | |
@@ -2838,29 +2838,29 @@ discard block |
||
| 2838 | 2838 | */ |
| 2839 | 2839 | function geodir_listing_belong_to_current_user($listing_id = '', $exclude_admin = true) |
| 2840 | 2840 | {
|
| 2841 | - global $current_user; |
|
| 2842 | - if ($exclude_admin) {
|
|
| 2843 | - foreach ($current_user->caps as $key => $caps) {
|
|
| 2844 | - if (geodir_strtolower($key) == 'administrator') {
|
|
| 2845 | - return true; |
|
| 2846 | - break; |
|
| 2847 | - } |
|
| 2848 | - } |
|
| 2849 | - } |
|
| 2850 | - |
|
| 2851 | - $result = geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
| 2852 | - |
|
| 2853 | - /** |
|
| 2854 | - * Filter if the listing belongs to a user. |
|
| 2855 | - * |
|
| 2856 | - * @since 1.6.23 |
|
| 2857 | - * @param bool $result The result, true:false |
|
| 2858 | - * @param int $listing_id The post ID. |
|
| 2859 | - * @param int $current_user->ID The current user ID. |
|
| 2860 | - * @param bool $exclude_admin Do you want to exclude admin from the check?. Default true. |
|
| 2861 | - * return bool |
|
| 2862 | - */ |
|
| 2863 | - return apply_filters('geodir_listing_belong_to_current_user',$result,$listing_id,$current_user->ID,$exclude_admin);
|
|
| 2841 | + global $current_user; |
|
| 2842 | + if ($exclude_admin) {
|
|
| 2843 | + foreach ($current_user->caps as $key => $caps) {
|
|
| 2844 | + if (geodir_strtolower($key) == 'administrator') {
|
|
| 2845 | + return true; |
|
| 2846 | + break; |
|
| 2847 | + } |
|
| 2848 | + } |
|
| 2849 | + } |
|
| 2850 | + |
|
| 2851 | + $result = geodir_lisiting_belong_to_user($listing_id, $current_user->ID); |
|
| 2852 | + |
|
| 2853 | + /** |
|
| 2854 | + * Filter if the listing belongs to a user. |
|
| 2855 | + * |
|
| 2856 | + * @since 1.6.23 |
|
| 2857 | + * @param bool $result The result, true:false |
|
| 2858 | + * @param int $listing_id The post ID. |
|
| 2859 | + * @param int $current_user->ID The current user ID. |
|
| 2860 | + * @param bool $exclude_admin Do you want to exclude admin from the check?. Default true. |
|
| 2861 | + * return bool |
|
| 2862 | + */ |
|
| 2863 | + return apply_filters('geodir_listing_belong_to_current_user',$result,$listing_id,$current_user->ID,$exclude_admin);
|
|
| 2864 | 2864 | } |
| 2865 | 2865 | |
| 2866 | 2866 | |
@@ -2876,17 +2876,17 @@ discard block |
||
| 2876 | 2876 | function geodir_only_supportable_attachments_remove($file) |
| 2877 | 2877 | {
|
| 2878 | 2878 | |
| 2879 | - global $wpdb; |
|
| 2879 | + global $wpdb; |
|
| 2880 | 2880 | |
| 2881 | - $matches = array(); |
|
| 2881 | + $matches = array(); |
|
| 2882 | 2882 | |
| 2883 | - $pattern = '/-\d+x\d+\./'; |
|
| 2884 | - preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
| 2883 | + $pattern = '/-\d+x\d+\./'; |
|
| 2884 | + preg_match($pattern, $file, $matches, PREG_OFFSET_CAPTURE); |
|
| 2885 | 2885 | |
| 2886 | - if (empty($matches)) |
|
| 2887 | - return ''; |
|
| 2888 | - else |
|
| 2889 | - return $file; |
|
| 2886 | + if (empty($matches)) |
|
| 2887 | + return ''; |
|
| 2888 | + else |
|
| 2889 | + return $file; |
|
| 2890 | 2890 | |
| 2891 | 2891 | } |
| 2892 | 2892 | |
@@ -2903,78 +2903,78 @@ discard block |
||
| 2903 | 2903 | function geodir_set_wp_featured_image($post_id) |
| 2904 | 2904 | {
|
| 2905 | 2905 | |
| 2906 | - global $wpdb, $plugin_prefix; |
|
| 2907 | - $uploads = wp_upload_dir(); |
|
| 2906 | + global $wpdb, $plugin_prefix; |
|
| 2907 | + $uploads = wp_upload_dir(); |
|
| 2908 | 2908 | // print_r($uploads ) ; |
| 2909 | - $post_first_image = $wpdb->get_results( |
|
| 2910 | - $wpdb->prepare( |
|
| 2911 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2912 | - ) |
|
| 2913 | - ); |
|
| 2909 | + $post_first_image = $wpdb->get_results( |
|
| 2910 | + $wpdb->prepare( |
|
| 2911 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2912 | + ) |
|
| 2913 | + ); |
|
| 2914 | 2914 | |
| 2915 | - $old_attachment_name = ''; |
|
| 2916 | - $post_thumbnail_id = ''; |
|
| 2917 | - if (has_post_thumbnail($post_id)) {
|
|
| 2915 | + $old_attachment_name = ''; |
|
| 2916 | + $post_thumbnail_id = ''; |
|
| 2917 | + if (has_post_thumbnail($post_id)) {
|
|
| 2918 | 2918 | |
| 2919 | - if (has_post_thumbnail($post_id)) {
|
|
| 2919 | + if (has_post_thumbnail($post_id)) {
|
|
| 2920 | 2920 | |
| 2921 | - $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2921 | + $post_thumbnail_id = get_post_thumbnail_id($post_id); |
|
| 2922 | 2922 | |
| 2923 | - $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
| 2923 | + $old_attachment_name = basename(get_attached_file($post_thumbnail_id)); |
|
| 2924 | 2924 | |
| 2925 | - } |
|
| 2926 | - } |
|
| 2927 | - |
|
| 2928 | - if (!empty($post_first_image)) {
|
|
| 2925 | + } |
|
| 2926 | + } |
|
| 2929 | 2927 | |
| 2930 | - $post_type = get_post_type($post_id); |
|
| 2928 | + if (!empty($post_first_image)) {
|
|
| 2931 | 2929 | |
| 2932 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2930 | + $post_type = get_post_type($post_id); |
|
| 2933 | 2931 | |
| 2934 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2932 | + $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2935 | 2933 | |
| 2936 | - $new_attachment_name = basename($post_first_image[0]->file); |
|
| 2934 | + $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2937 | 2935 | |
| 2938 | - if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
|
|
| 2936 | + $new_attachment_name = basename($post_first_image[0]->file); |
|
| 2939 | 2937 | |
| 2940 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
|
|
| 2938 | + if (geodir_strtolower($new_attachment_name) != geodir_strtolower($old_attachment_name)) {
|
|
| 2941 | 2939 | |
| 2942 | - add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
|
|
| 2940 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) {
|
|
| 2943 | 2941 | |
| 2944 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2942 | + add_filter('wp_delete_file', 'geodir_only_supportable_attachments_remove');
|
|
| 2945 | 2943 | |
| 2946 | - } |
|
| 2947 | - $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2944 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2948 | 2945 | |
| 2949 | - $attachment = array( |
|
| 2950 | - 'post_mime_type' => $post_first_image[0]->mime_type, |
|
| 2951 | - 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2952 | - 'post_parent' => $post_id, |
|
| 2953 | - 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
|
| 2954 | - 'post_content' => '' |
|
| 2955 | - ); |
|
| 2946 | + } |
|
| 2947 | + $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2948 | + |
|
| 2949 | + $attachment = array( |
|
| 2950 | + 'post_mime_type' => $post_first_image[0]->mime_type, |
|
| 2951 | + 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2952 | + 'post_parent' => $post_id, |
|
| 2953 | + 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
|
| 2954 | + 'post_content' => '' |
|
| 2955 | + ); |
|
| 2956 | 2956 | |
| 2957 | 2957 | |
| 2958 | - $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 2958 | + $id = wp_insert_attachment($attachment, $filename, $post_id); |
|
| 2959 | 2959 | |
| 2960 | - if (!is_wp_error($id)) {
|
|
| 2960 | + if (!is_wp_error($id)) {
|
|
| 2961 | 2961 | |
| 2962 | - set_post_thumbnail($post_id, $id); |
|
| 2962 | + set_post_thumbnail($post_id, $id); |
|
| 2963 | 2963 | |
| 2964 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2965 | - wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 2964 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2965 | + wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
|
| 2966 | 2966 | |
| 2967 | - } |
|
| 2967 | + } |
|
| 2968 | 2968 | |
| 2969 | - } |
|
| 2969 | + } |
|
| 2970 | 2970 | |
| 2971 | - } else {
|
|
| 2972 | - //set_post_thumbnail($post_id,-1); |
|
| 2971 | + } else {
|
|
| 2972 | + //set_post_thumbnail($post_id,-1); |
|
| 2973 | 2973 | |
| 2974 | - if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
| 2975 | - wp_delete_attachment($post_thumbnail_id); |
|
| 2974 | + if (has_post_thumbnail($post_id) && $post_thumbnail_id != '' && (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'delete')) |
|
| 2975 | + wp_delete_attachment($post_thumbnail_id); |
|
| 2976 | 2976 | |
| 2977 | - } |
|
| 2977 | + } |
|
| 2978 | 2978 | } |
| 2979 | 2979 | |
| 2980 | 2980 | |
@@ -2989,53 +2989,53 @@ discard block |
||
| 2989 | 2989 | */ |
| 2990 | 2990 | function gd_copy_original_translation() |
| 2991 | 2991 | {
|
| 2992 | - if (geodir_is_wpml()) {
|
|
| 2993 | - global $wpdb, $table_prefix, $plugin_prefix; |
|
| 2994 | - $post_id = absint($_POST['post_id']); |
|
| 2995 | - $upload_dir = wp_upload_dir(); |
|
| 2996 | - $post_type = get_post_type($_POST['post_id']); |
|
| 2997 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2998 | - |
|
| 2999 | - $post_arr = $wpdb->get_results($wpdb->prepare( |
|
| 3000 | - "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 3001 | - array($post_id) |
|
| 3002 | - ) |
|
| 3003 | - , ARRAY_A); |
|
| 3004 | - |
|
| 3005 | - $arrImages = $wpdb->get_results( |
|
| 3006 | - $wpdb->prepare( |
|
| 3007 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 3008 | - array('%image%', $post_id)
|
|
| 3009 | - ) |
|
| 3010 | - ); |
|
| 3011 | - if ($arrImages) {
|
|
| 3012 | - $image_arr = array(); |
|
| 3013 | - foreach ($arrImages as $img) {
|
|
| 3014 | - $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 3015 | - } |
|
| 3016 | - $comma_separated = implode(",", $image_arr);
|
|
| 3017 | - $post_arr[0]['post_images'] = $comma_separated; |
|
| 3018 | - } |
|
| 3019 | - |
|
| 3020 | - |
|
| 3021 | - $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 3022 | - $cat_arr = array_filter(explode(",", $cats));
|
|
| 3023 | - $trans_cat = array(); |
|
| 3024 | - foreach ($cat_arr as $cat) {
|
|
| 3025 | - $trans_cat[] = geodir_wpml_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 3026 | - } |
|
| 3027 | - |
|
| 3028 | - |
|
| 3029 | - $post_arr[0]['categories'] = array_filter($trans_cat); |
|
| 2992 | + if (geodir_is_wpml()) {
|
|
| 2993 | + global $wpdb, $table_prefix, $plugin_prefix; |
|
| 2994 | + $post_id = absint($_POST['post_id']); |
|
| 2995 | + $upload_dir = wp_upload_dir(); |
|
| 2996 | + $post_type = get_post_type($_POST['post_id']); |
|
| 2997 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2998 | + |
|
| 2999 | + $post_arr = $wpdb->get_results($wpdb->prepare( |
|
| 3000 | + "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 3001 | + array($post_id) |
|
| 3002 | + ) |
|
| 3003 | + , ARRAY_A); |
|
| 3004 | + |
|
| 3005 | + $arrImages = $wpdb->get_results( |
|
| 3006 | + $wpdb->prepare( |
|
| 3007 | + "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 3008 | + array('%image%', $post_id)
|
|
| 3009 | + ) |
|
| 3010 | + ); |
|
| 3011 | + if ($arrImages) {
|
|
| 3012 | + $image_arr = array(); |
|
| 3013 | + foreach ($arrImages as $img) {
|
|
| 3014 | + $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 3015 | + } |
|
| 3016 | + $comma_separated = implode(",", $image_arr);
|
|
| 3017 | + $post_arr[0]['post_images'] = $comma_separated; |
|
| 3018 | + } |
|
| 3019 | + |
|
| 3020 | + |
|
| 3021 | + $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 3022 | + $cat_arr = array_filter(explode(",", $cats));
|
|
| 3023 | + $trans_cat = array(); |
|
| 3024 | + foreach ($cat_arr as $cat) {
|
|
| 3025 | + $trans_cat[] = geodir_wpml_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 3026 | + } |
|
| 3027 | + |
|
| 3028 | + |
|
| 3029 | + $post_arr[0]['categories'] = array_filter($trans_cat); |
|
| 3030 | 3030 | //print_r($image_arr); |
| 3031 | - //print_r($arrImages); |
|
| 3032 | - //echo $_REQUEST['lang']; |
|
| 3031 | + //print_r($arrImages); |
|
| 3032 | + //echo $_REQUEST['lang']; |
|
| 3033 | 3033 | //print_r($post_arr); |
| 3034 | 3034 | //print_r($trans_cat); |
| 3035 | - echo json_encode($post_arr[0]); |
|
| 3035 | + echo json_encode($post_arr[0]); |
|
| 3036 | 3036 | |
| 3037 | - } |
|
| 3038 | - die(); |
|
| 3037 | + } |
|
| 3038 | + die(); |
|
| 3039 | 3039 | } |
| 3040 | 3040 | |
| 3041 | 3041 | |
@@ -3055,54 +3055,54 @@ discard block |
||
| 3055 | 3055 | function geodir_get_custom_fields_type($listing_type = '') |
| 3056 | 3056 | {
|
| 3057 | 3057 | |
| 3058 | - global $wpdb; |
|
| 3058 | + global $wpdb; |
|
| 3059 | 3059 | |
| 3060 | - if ($listing_type == '') |
|
| 3061 | - $listing_type = 'gd_place'; |
|
| 3060 | + if ($listing_type == '') |
|
| 3061 | + $listing_type = 'gd_place'; |
|
| 3062 | 3062 | |
| 3063 | - $fields_info = array(); |
|
| 3063 | + $fields_info = array(); |
|
| 3064 | 3064 | |
| 3065 | - $get_data = $wpdb->get_results( |
|
| 3066 | - $wpdb->prepare( |
|
| 3067 | - "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 3068 | - array($listing_type) |
|
| 3069 | - ) |
|
| 3070 | - ); |
|
| 3065 | + $get_data = $wpdb->get_results( |
|
| 3066 | + $wpdb->prepare( |
|
| 3067 | + "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 3068 | + array($listing_type) |
|
| 3069 | + ) |
|
| 3070 | + ); |
|
| 3071 | 3071 | |
| 3072 | - if (!empty($get_data)) {
|
|
| 3072 | + if (!empty($get_data)) {
|
|
| 3073 | 3073 | |
| 3074 | - foreach ($get_data as $data) {
|
|
| 3074 | + foreach ($get_data as $data) {
|
|
| 3075 | 3075 | |
| 3076 | - if ($data->field_type == 'address') {
|
|
| 3076 | + if ($data->field_type == 'address') {
|
|
| 3077 | 3077 | |
| 3078 | - $extra_fields = unserialize($data->extra_fields); |
|
| 3078 | + $extra_fields = unserialize($data->extra_fields); |
|
| 3079 | 3079 | |
| 3080 | - $prefix = $data->htmlvar_name . '_'; |
|
| 3080 | + $prefix = $data->htmlvar_name . '_'; |
|
| 3081 | 3081 | |
| 3082 | - $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 3082 | + $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 3083 | 3083 | |
| 3084 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
| 3085 | - $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 3084 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
|
| 3085 | + $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 3086 | 3086 | |
| 3087 | - } else {
|
|
| 3087 | + } else {
|
|
| 3088 | 3088 | |
| 3089 | - $fields_info[$data->htmlvar_name] = $data->field_type; |
|
| 3089 | + $fields_info[$data->htmlvar_name] = $data->field_type; |
|
| 3090 | 3090 | |
| 3091 | - } |
|
| 3091 | + } |
|
| 3092 | 3092 | |
| 3093 | - } |
|
| 3093 | + } |
|
| 3094 | 3094 | |
| 3095 | - } |
|
| 3095 | + } |
|
| 3096 | 3096 | |
| 3097 | - /** |
|
| 3098 | - * Filter to modify custom fields info using listing post type. |
|
| 3099 | - * |
|
| 3100 | - * @since 1.0.0 |
|
| 3101 | - * @package GeoDirectory |
|
| 3102 | - * @return array $fields_info Custom fields info. |
|
| 3103 | - * @param string $listing_type The listing post type. |
|
| 3104 | - */ |
|
| 3105 | - return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
|
|
| 3097 | + /** |
|
| 3098 | + * Filter to modify custom fields info using listing post type. |
|
| 3099 | + * |
|
| 3100 | + * @since 1.0.0 |
|
| 3101 | + * @package GeoDirectory |
|
| 3102 | + * @return array $fields_info Custom fields info. |
|
| 3103 | + * @param string $listing_type The listing post type. |
|
| 3104 | + */ |
|
| 3105 | + return apply_filters('geodir_get_custom_fields_type', $fields_info, $listing_type);
|
|
| 3106 | 3106 | } |
| 3107 | 3107 | |
| 3108 | 3108 | |
@@ -3117,58 +3117,58 @@ discard block |
||
| 3117 | 3117 | */ |
| 3118 | 3118 | function geodir_function_post_updated($post_ID, $post_after, $post_before) |
| 3119 | 3119 | {
|
| 3120 | - $post_type = get_post_type($post_ID); |
|
| 3120 | + $post_type = get_post_type($post_ID); |
|
| 3121 | 3121 | |
| 3122 | - if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
|
|
| 3123 | - // send notification to client when post moves from draft to publish |
|
| 3124 | - if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft' || $post_before->post_status == 'pending')) {
|
|
| 3125 | - $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
| 3126 | - $post_author_data = get_userdata($post_author_id); |
|
| 3122 | + if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) {
|
|
| 3123 | + // send notification to client when post moves from draft to publish |
|
| 3124 | + if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft' || $post_before->post_status == 'pending')) {
|
|
| 3125 | + $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; |
|
| 3126 | + $post_author_data = get_userdata($post_author_id); |
|
| 3127 | 3127 | |
| 3128 | - $to_name = geodir_get_client_name($post_author_id); |
|
| 3128 | + $to_name = geodir_get_client_name($post_author_id); |
|
| 3129 | 3129 | |
| 3130 | - $from_email = geodir_get_site_email_id(); |
|
| 3131 | - $from_name = get_site_emailName(); |
|
| 3132 | - $to_email = $post_author_data->user_email; |
|
| 3130 | + $from_email = geodir_get_site_email_id(); |
|
| 3131 | + $from_name = get_site_emailName(); |
|
| 3132 | + $to_email = $post_author_data->user_email; |
|
| 3133 | 3133 | |
| 3134 | - if (!is_email($to_email) && !empty($post_author_data->user_email)) {
|
|
| 3135 | - $to_email = $post_author_data->user_email; |
|
| 3136 | - } |
|
| 3134 | + if (!is_email($to_email) && !empty($post_author_data->user_email)) {
|
|
| 3135 | + $to_email = $post_author_data->user_email; |
|
| 3136 | + } |
|
| 3137 | 3137 | |
| 3138 | - $message_type = 'listing_published'; |
|
| 3138 | + $message_type = 'listing_published'; |
|
| 3139 | 3139 | |
| 3140 | - if (get_option('geodir_post_published_email_subject') == '') {
|
|
| 3141 | - update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
|
|
| 3142 | - } |
|
| 3140 | + if (get_option('geodir_post_published_email_subject') == '') {
|
|
| 3141 | + update_option('geodir_post_published_email_subject', __('Listing Published Successfully', 'geodirectory'));
|
|
| 3142 | + } |
|
| 3143 | 3143 | |
| 3144 | - if (get_option('geodir_post_published_email_content') == '') {
|
|
| 3145 | - update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
|
|
| 3146 | - } |
|
| 3144 | + if (get_option('geodir_post_published_email_content') == '') {
|
|
| 3145 | + update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", 'geodirectory'));
|
|
| 3146 | + } |
|
| 3147 | 3147 | |
| 3148 | - /** |
|
| 3149 | - * Called before sending the email when listing gets published. |
|
| 3150 | - * |
|
| 3151 | - * @since 1.0.0 |
|
| 3152 | - * @package GeoDirectory |
|
| 3153 | - * @param object $post_after The post object after update. |
|
| 3154 | - * @param object $post_before The post object before update. |
|
| 3155 | - */ |
|
| 3156 | - do_action('geodir_before_listing_published_email', $post_after, $post_before);
|
|
| 3157 | - if (is_email($to_email)) {
|
|
| 3158 | - geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 3159 | - } |
|
| 3148 | + /** |
|
| 3149 | + * Called before sending the email when listing gets published. |
|
| 3150 | + * |
|
| 3151 | + * @since 1.0.0 |
|
| 3152 | + * @package GeoDirectory |
|
| 3153 | + * @param object $post_after The post object after update. |
|
| 3154 | + * @param object $post_before The post object before update. |
|
| 3155 | + */ |
|
| 3156 | + do_action('geodir_before_listing_published_email', $post_after, $post_before);
|
|
| 3157 | + if (is_email($to_email)) {
|
|
| 3158 | + geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); |
|
| 3159 | + } |
|
| 3160 | 3160 | |
| 3161 | - /** |
|
| 3162 | - * Called after sending the email when listing gets published. |
|
| 3163 | - * |
|
| 3164 | - * @since 1.0.0 |
|
| 3165 | - * @package GeoDirectory |
|
| 3166 | - * @param object $post_after The post object after update. |
|
| 3167 | - * @param object $post_before The post object before update. |
|
| 3168 | - */ |
|
| 3169 | - do_action('geodir_after_listing_published_email', $post_after, $post_before);
|
|
| 3170 | - } |
|
| 3171 | - } |
|
| 3161 | + /** |
|
| 3162 | + * Called after sending the email when listing gets published. |
|
| 3163 | + * |
|
| 3164 | + * @since 1.0.0 |
|
| 3165 | + * @package GeoDirectory |
|
| 3166 | + * @param object $post_after The post object after update. |
|
| 3167 | + * @param object $post_before The post object before update. |
|
| 3168 | + */ |
|
| 3169 | + do_action('geodir_after_listing_published_email', $post_after, $post_before);
|
|
| 3170 | + } |
|
| 3171 | + } |
|
| 3172 | 3172 | } |
| 3173 | 3173 | |
| 3174 | 3174 | add_action('wp_head', 'geodir_fb_like_thumbnail');
|
@@ -3183,46 +3183,46 @@ discard block |
||
| 3183 | 3183 | */ |
| 3184 | 3184 | function geodir_fb_like_thumbnail(){
|
| 3185 | 3185 | |
| 3186 | - $facebook_image = ''; |
|
| 3187 | - |
|
| 3188 | - if(is_single()){// single post
|
|
| 3189 | - global $post; |
|
| 3190 | - if(isset($post->featured_image) && $post->featured_image){
|
|
| 3191 | - $upload_dir = wp_upload_dir(); |
|
| 3192 | - $facebook_image = $upload_dir['baseurl'].$post->featured_image; |
|
| 3193 | - |
|
| 3194 | - } |
|
| 3195 | - }elseif(geodir_is_page('location')){// location page
|
|
| 3196 | - if (function_exists('geodir_get_location_seo')) {
|
|
| 3197 | - $seo = geodir_get_location_seo(); |
|
| 3198 | - if (isset($seo->seo_image) && $seo->seo_image) {
|
|
| 3199 | - $image = wp_get_attachment_image_src($seo->seo_image, 'full'); |
|
| 3200 | - $facebook_image = isset($image[0]) ? $image[0] : ''; |
|
| 3201 | - } |
|
| 3202 | - } |
|
| 3186 | + $facebook_image = ''; |
|
| 3187 | + |
|
| 3188 | + if(is_single()){// single post
|
|
| 3189 | + global $post; |
|
| 3190 | + if(isset($post->featured_image) && $post->featured_image){
|
|
| 3191 | + $upload_dir = wp_upload_dir(); |
|
| 3192 | + $facebook_image = $upload_dir['baseurl'].$post->featured_image; |
|
| 3193 | + |
|
| 3194 | + } |
|
| 3195 | + }elseif(geodir_is_page('location')){// location page
|
|
| 3196 | + if (function_exists('geodir_get_location_seo')) {
|
|
| 3197 | + $seo = geodir_get_location_seo(); |
|
| 3198 | + if (isset($seo->seo_image) && $seo->seo_image) {
|
|
| 3199 | + $image = wp_get_attachment_image_src($seo->seo_image, 'full'); |
|
| 3200 | + $facebook_image = isset($image[0]) ? $image[0] : ''; |
|
| 3201 | + } |
|
| 3202 | + } |
|
| 3203 | 3203 | |
| 3204 | - if(!$facebook_image){
|
|
| 3205 | - global $post; |
|
| 3204 | + if(!$facebook_image){
|
|
| 3205 | + global $post; |
|
| 3206 | 3206 | |
| 3207 | - if (has_post_thumbnail( $post->ID ) ){
|
|
| 3208 | - $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); |
|
| 3209 | - $facebook_image = isset($image[0]) ? $image[0] : ''; |
|
| 3210 | - } |
|
| 3211 | - } |
|
| 3212 | - } |
|
| 3207 | + if (has_post_thumbnail( $post->ID ) ){
|
|
| 3208 | + $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); |
|
| 3209 | + $facebook_image = isset($image[0]) ? $image[0] : ''; |
|
| 3210 | + } |
|
| 3211 | + } |
|
| 3212 | + } |
|
| 3213 | 3213 | |
| 3214 | 3214 | |
| 3215 | - /** |
|
| 3216 | - * Filter the facebook share image. |
|
| 3217 | - * |
|
| 3218 | - * @since 1.6.22 |
|
| 3219 | - * @param string $facebook_image The image URL or blank. |
|
| 3220 | - */ |
|
| 3221 | - $facebook_image = apply_filters('geodir_fb_share_image',$facebook_image);
|
|
| 3215 | + /** |
|
| 3216 | + * Filter the facebook share image. |
|
| 3217 | + * |
|
| 3218 | + * @since 1.6.22 |
|
| 3219 | + * @param string $facebook_image The image URL or blank. |
|
| 3220 | + */ |
|
| 3221 | + $facebook_image = apply_filters('geodir_fb_share_image',$facebook_image);
|
|
| 3222 | 3222 | |
| 3223 | - if($facebook_image){
|
|
| 3224 | - echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$facebook_image\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
| 3225 | - } |
|
| 3223 | + if($facebook_image){
|
|
| 3224 | + echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$facebook_image\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
|
| 3225 | + } |
|
| 3226 | 3226 | |
| 3227 | 3227 | |
| 3228 | 3228 | } |
@@ -3236,11 +3236,11 @@ discard block |
||
| 3236 | 3236 | * @since 1.6.22 |
| 3237 | 3237 | */ |
| 3238 | 3238 | function geodir_delete_map_cache(){
|
| 3239 | - $files = glob(realpath(dirname(__FILE__))."/map-functions/map-cache/*.json"); // get all file names |
|
| 3240 | - foreach($files as $file){ // iterate files
|
|
| 3241 | - if(is_file($file)) |
|
| 3242 | - unlink($file); // delete file |
|
| 3243 | - } |
|
| 3239 | + $files = glob(realpath(dirname(__FILE__))."/map-functions/map-cache/*.json"); // get all file names |
|
| 3240 | + foreach($files as $file){ // iterate files
|
|
| 3241 | + if(is_file($file)) |
|
| 3242 | + unlink($file); // delete file |
|
| 3243 | + } |
|
| 3244 | 3244 | } |
| 3245 | 3245 | |
| 3246 | 3246 | |
@@ -3253,23 +3253,23 @@ discard block |
||
| 3253 | 3253 | */ |
| 3254 | 3254 | function geodir_clear_map_cache_on_save($post_id, $post) {
|
| 3255 | 3255 | |
| 3256 | - if(!get_option('geodir_enable_map_cache')){
|
|
| 3257 | - return; |
|
| 3258 | - } |
|
| 3256 | + if(!get_option('geodir_enable_map_cache')){
|
|
| 3257 | + return; |
|
| 3258 | + } |
|
| 3259 | 3259 | |
| 3260 | - if ( isset( $post->post_type ) && ( $post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post' ) ) {
|
|
| 3261 | - return; |
|
| 3262 | - } |
|
| 3260 | + if ( isset( $post->post_type ) && ( $post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post' ) ) {
|
|
| 3261 | + return; |
|
| 3262 | + } |
|
| 3263 | 3263 | |
| 3264 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 3264 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 3265 | 3265 | |
| 3266 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
| 3267 | - return; |
|
| 3268 | - } |
|
| 3266 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
| 3267 | + return; |
|
| 3268 | + } |
|
| 3269 | 3269 | |
| 3270 | - if ( ! wp_is_post_revision( $post_id ) && isset( $post->post_type ) && in_array( $post->post_type, $geodir_posttypes ) ) {
|
|
| 3271 | - geodir_delete_map_cache(); |
|
| 3272 | - } |
|
| 3270 | + if ( ! wp_is_post_revision( $post_id ) && isset( $post->post_type ) && in_array( $post->post_type, $geodir_posttypes ) ) {
|
|
| 3271 | + geodir_delete_map_cache(); |
|
| 3272 | + } |
|
| 3273 | 3273 | |
| 3274 | 3274 | } |
| 3275 | 3275 | |
@@ -3284,19 +3284,19 @@ discard block |
||
| 3284 | 3284 | * @return array Filtered post data. |
| 3285 | 3285 | */ |
| 3286 | 3286 | function geodir_fix_pending_listing_post_name( $data, $postarr ) {
|
| 3287 | - // Dont' update post name for autosaves |
|
| 3288 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
| 3289 | - return $data; |
|
| 3290 | - } |
|
| 3287 | + // Dont' update post name for autosaves |
|
| 3288 | + if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
| 3289 | + return $data; |
|
| 3290 | + } |
|
| 3291 | 3291 | |
| 3292 | - if ( !empty( $data['post_name'] ) || empty( $data['post_status'] ) || empty( $data['post_type'] ) || empty( $data['post_title'] ) ) {
|
|
| 3293 | - return $data; |
|
| 3294 | - } |
|
| 3292 | + if ( !empty( $data['post_name'] ) || empty( $data['post_status'] ) || empty( $data['post_type'] ) || empty( $data['post_title'] ) ) {
|
|
| 3293 | + return $data; |
|
| 3294 | + } |
|
| 3295 | 3295 | |
| 3296 | - if ( ( 'draft' == $data['post_status'] || 'pending' == $data['post_status'] ) && in_array( $data['post_type'], geodir_get_posttypes() ) ) {
|
|
| 3297 | - $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'] ), ( !empty( $postarr['ID'] ) ? $postarr['ID'] : 0 ), '', $data['post_type'], $data['post_parent'] ); |
|
| 3298 | - } |
|
| 3296 | + if ( ( 'draft' == $data['post_status'] || 'pending' == $data['post_status'] ) && in_array( $data['post_type'], geodir_get_posttypes() ) ) {
|
|
| 3297 | + $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'] ), ( !empty( $postarr['ID'] ) ? $postarr['ID'] : 0 ), '', $data['post_type'], $data['post_parent'] ); |
|
| 3298 | + } |
|
| 3299 | 3299 | |
| 3300 | - return $data; |
|
| 3300 | + return $data; |
|
| 3301 | 3301 | } |
| 3302 | 3302 | add_filter( 'wp_insert_post_data', 'geodir_fix_pending_listing_post_name', 10, 2 ); |
| 3303 | 3303 | \ No newline at end of file |
@@ -26,11 +26,11 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | if (!isset($default_cat) || empty($default_cat)) {
|
| 28 | 28 | $default_cat = isset($post_cat_array[0]) ? $post_cat_array[0] : ''; |
| 29 | - }else{
|
|
| 30 | - if(!is_int($default_cat)){
|
|
| 29 | + } else {
|
|
| 30 | + if (!is_int($default_cat)) {
|
|
| 31 | 31 | $category = get_term_by('name', $default_cat, $taxonomy);
|
| 32 | - if(isset($category->term_id)){
|
|
| 33 | - $default_cat = $category->term_id; |
|
| 32 | + if (isset($category->term_id)) {
|
|
| 33 | + $default_cat = $category->term_id; |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | |
| 59 | 59 | if ($default_pos === false) {
|
| 60 | 60 | |
| 61 | - $change_cat_str = str_replace($default_cat . ',y:', $default_cat . ',y,d:', $change_cat_str); |
|
| 61 | + $change_cat_str = str_replace($default_cat.',y:', $default_cat.',y,d:', $change_cat_str); |
|
| 62 | 62 | |
| 63 | 63 | } |
| 64 | 64 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | |
| 146 | 146 | $gd_post = $post; |
| 147 | 147 | if (!empty($gd_post) && is_array($gd_post)) {
|
| 148 | - $gd_post = (object)$post; |
|
| 148 | + $gd_post = (object) $post; |
|
| 149 | 149 | |
| 150 | 150 | // Fix WPML duplicate. |
| 151 | 151 | if (geodir_is_wpml() && !empty($request_info['action']) && $request_info['action'] == 'editpost' && !empty($request_info['icl_trid']) && !isset($post['post_date'])) {
|
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $send_post_submit_mail = false; |
| 240 | 240 | |
| 241 | 241 | // unhook this function so it doesn't loop infinitely |
| 242 | - remove_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 242 | + remove_action('save_post', 'geodir_post_information_save', 10, 2);
|
|
| 243 | 243 | |
| 244 | 244 | if (isset($request_info['pid']) && $request_info['pid'] != '') {
|
| 245 | 245 | $post['ID'] = $request_info['pid']; |
@@ -263,13 +263,13 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | // re-hook this function |
| 266 | - add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 266 | + add_action('save_post', 'geodir_post_information_save', 10, 2);
|
|
| 267 | 267 | |
| 268 | 268 | $post_tags = ''; |
| 269 | 269 | if (!isset($request_info['post_tags'])) {
|
| 270 | 270 | |
| 271 | 271 | $post_type = $request_info['listing_type']; |
| 272 | - $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type . '_tags', array('fields' => 'names')));
|
|
| 272 | + $post_tags = implode(",", wp_get_object_terms($last_post_id, $post_type.'_tags', array('fields' => 'names')));
|
|
| 273 | 273 | |
| 274 | 274 | } |
| 275 | 275 | |
@@ -287,13 +287,13 @@ discard block |
||
| 287 | 287 | $payment_info = array(); |
| 288 | 288 | $package_info = array(); |
| 289 | 289 | |
| 290 | - $package_info = (array)geodir_post_package_info($package_info, $post); |
|
| 290 | + $package_info = (array) geodir_post_package_info($package_info, $post); |
|
| 291 | 291 | |
| 292 | 292 | $post_package_id = geodir_get_post_meta($last_post_id, 'package_id'); |
| 293 | 293 | |
| 294 | 294 | if (!empty($package_info) && !$post_package_id) {
|
| 295 | 295 | if (isset($package_info['days']) && $package_info['days'] != 0) {
|
| 296 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['days'] . " days"));
|
|
| 296 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['days']." days"));
|
|
| 297 | 297 | } else {
|
| 298 | 298 | $payment_info['expire_date'] = 'Never'; |
| 299 | 299 | } |
@@ -314,8 +314,8 @@ discard block |
||
| 314 | 314 | $extrafields = $val['extra_fields']; |
| 315 | 315 | |
| 316 | 316 | if (trim($type) == 'address') {
|
| 317 | - $prefix = $name . '_'; |
|
| 318 | - $address = $prefix . 'address'; |
|
| 317 | + $prefix = $name.'_'; |
|
| 318 | + $address = $prefix.'address'; |
|
| 319 | 319 | |
| 320 | 320 | if (isset($request_info[$address]) && $request_info[$address] != '') {
|
| 321 | 321 | $gd_post_info[$address] = wp_slash($request_info[$address]); |
@@ -325,59 +325,59 @@ discard block |
||
| 325 | 325 | $extrafields = unserialize($extrafields); |
| 326 | 326 | |
| 327 | 327 | |
| 328 | - if (!isset($request_info[$prefix . 'city']) || $request_info[$prefix . 'city'] == '') {
|
|
| 328 | + if (!isset($request_info[$prefix.'city']) || $request_info[$prefix.'city'] == '') {
|
|
| 329 | 329 | |
| 330 | 330 | $location_result = geodir_get_default_location(); |
| 331 | 331 | |
| 332 | - $gd_post_info[$prefix . 'city'] = $location_result->city; |
|
| 333 | - $gd_post_info[$prefix . 'region'] = $location_result->region; |
|
| 334 | - $gd_post_info[$prefix . 'country'] = $location_result->country; |
|
| 332 | + $gd_post_info[$prefix.'city'] = $location_result->city; |
|
| 333 | + $gd_post_info[$prefix.'region'] = $location_result->region; |
|
| 334 | + $gd_post_info[$prefix.'country'] = $location_result->country; |
|
| 335 | 335 | |
| 336 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 336 | + $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location |
|
| 337 | 337 | |
| 338 | 338 | } else {
|
| 339 | 339 | |
| 340 | - $gd_post_info[$prefix . 'city'] = $request_info[$prefix . 'city']; |
|
| 341 | - $gd_post_info[$prefix . 'region'] = $request_info[$prefix . 'region']; |
|
| 342 | - $gd_post_info[$prefix . 'country'] = $request_info[$prefix . 'country']; |
|
| 340 | + $gd_post_info[$prefix.'city'] = $request_info[$prefix.'city']; |
|
| 341 | + $gd_post_info[$prefix.'region'] = $request_info[$prefix.'region']; |
|
| 342 | + $gd_post_info[$prefix.'country'] = $request_info[$prefix.'country']; |
|
| 343 | 343 | |
| 344 | 344 | //----------set post locations when import dummy data------- |
| 345 | 345 | $location_result = geodir_get_default_location(); |
| 346 | 346 | |
| 347 | - $gd_post_info['post_locations'] = '[' . $location_result->city_slug . '],[' . $location_result->region_slug . '],[' . $location_result->country_slug . ']'; // set all overall post location |
|
| 347 | + $gd_post_info['post_locations'] = '['.$location_result->city_slug.'],['.$location_result->region_slug.'],['.$location_result->country_slug.']'; // set all overall post location |
|
| 348 | 348 | //----------------------------------------------------------------- |
| 349 | 349 | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | |
| 353 | - if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix . 'zip'])) {
|
|
| 354 | - $gd_post_info[$prefix . 'zip'] = $request_info[$prefix . 'zip']; |
|
| 353 | + if (isset($extrafields['show_zip']) && $extrafields['show_zip'] && isset($request_info[$prefix.'zip'])) {
|
|
| 354 | + $gd_post_info[$prefix.'zip'] = $request_info[$prefix.'zip']; |
|
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | |
| 358 | 358 | if (isset($extrafields['show_map']) && $extrafields['show_map']) {
|
| 359 | 359 | |
| 360 | - if (isset($request_info[$prefix . 'latitude']) && $request_info[$prefix . 'latitude'] != '') {
|
|
| 361 | - $gd_post_info[$prefix . 'latitude'] = $request_info[$prefix . 'latitude']; |
|
| 360 | + if (isset($request_info[$prefix.'latitude']) && $request_info[$prefix.'latitude'] != '') {
|
|
| 361 | + $gd_post_info[$prefix.'latitude'] = $request_info[$prefix.'latitude']; |
|
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - if (isset($request_info[$prefix . 'longitude']) && $request_info[$prefix . 'longitude'] != '') {
|
|
| 365 | - $gd_post_info[$prefix . 'longitude'] = $request_info[$prefix . 'longitude']; |
|
| 364 | + if (isset($request_info[$prefix.'longitude']) && $request_info[$prefix.'longitude'] != '') {
|
|
| 365 | + $gd_post_info[$prefix.'longitude'] = $request_info[$prefix.'longitude']; |
|
| 366 | 366 | } |
| 367 | 367 | |
| 368 | - if (isset($request_info[$prefix . 'mapview']) && $request_info[$prefix . 'mapview'] != '') {
|
|
| 369 | - $gd_post_info[$prefix . 'mapview'] = $request_info[$prefix . 'mapview']; |
|
| 368 | + if (isset($request_info[$prefix.'mapview']) && $request_info[$prefix.'mapview'] != '') {
|
|
| 369 | + $gd_post_info[$prefix.'mapview'] = $request_info[$prefix.'mapview']; |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | - if (isset($request_info[$prefix . 'mapzoom']) && $request_info[$prefix . 'mapzoom'] != '') {
|
|
| 373 | - $gd_post_info[$prefix . 'mapzoom'] = $request_info[$prefix . 'mapzoom']; |
|
| 372 | + if (isset($request_info[$prefix.'mapzoom']) && $request_info[$prefix.'mapzoom'] != '') {
|
|
| 373 | + $gd_post_info[$prefix.'mapzoom'] = $request_info[$prefix.'mapzoom']; |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | // show lat lng |
| 379 | - if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix . 'latlng'])) {
|
|
| 380 | - $gd_post_info[$prefix . 'latlng'] = $request_info[$prefix . 'latlng']; |
|
| 379 | + if (isset($extrafields['show_latlng']) && $extrafields['show_latlng'] && isset($request_info[$prefix.'latlng'])) {
|
|
| 380 | + $gd_post_info[$prefix.'latlng'] = $request_info[$prefix.'latlng']; |
|
| 381 | 381 | } |
| 382 | 382 | } |
| 383 | 383 | |
@@ -403,16 +403,16 @@ discard block |
||
| 403 | 403 | |
| 404 | 404 | // check if we need to change the format or not |
| 405 | 405 | $date_format_len = strlen(str_replace(' ', '', $date_format));
|
| 406 | - if($date_format_len>5){// if greater then 5 then it's the old style format.
|
|
| 406 | + if ($date_format_len > 5) {// if greater then 5 then it's the old style format.
|
|
| 407 | 407 | |
| 408 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format
|
|
| 409 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format
|
|
| 408 | + $search = array('dd', 'd', 'DD', 'mm', 'm', 'MM', 'yy'); //jQuery UI datepicker format
|
|
| 409 | + $replace = array('d', 'j', 'l', 'm', 'n', 'F', 'Y'); //PHP date format
|
|
| 410 | 410 | |
| 411 | 411 | $date_format = str_replace($search, $replace, $date_format); |
| 412 | 412 | |
| 413 | 413 | $post_htmlvar_value = $date_format == 'd/m/Y' ? str_replace('/', '-', $request_info[$name]) : $request_info[$name];
|
| 414 | 414 | |
| 415 | - }else{
|
|
| 415 | + } else {
|
|
| 416 | 416 | $post_htmlvar_value = $request_info[$name]; |
| 417 | 417 | } |
| 418 | 418 | |
@@ -426,7 +426,7 @@ discard block |
||
| 426 | 426 | if (isset($request_info[$name])) {
|
| 427 | 427 | $gd_post_info[$name] = $request_info[$name]; |
| 428 | 428 | } else {
|
| 429 | - if (isset($request_info['gd_field_' . $name])) {
|
|
| 429 | + if (isset($request_info['gd_field_'.$name])) {
|
|
| 430 | 430 | $gd_post_info[$name] = ''; /* fix de-select for multiselect */ |
| 431 | 431 | } |
| 432 | 432 | } |
@@ -486,7 +486,7 @@ discard block |
||
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | if (is_array($post_tags)) {
|
| 489 | - $taxonomy = $request_info['listing_type'] . '_tags'; |
|
| 489 | + $taxonomy = $request_info['listing_type'].'_tags'; |
|
| 490 | 490 | wp_set_object_terms($last_post_id, $post_tags, $taxonomy); |
| 491 | 491 | } |
| 492 | 492 | |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | $tmpimgArr = trim($request_info['post_images'], ","); |
| 499 | 499 | $tmpimgArr = explode(",", $tmpimgArr);
|
| 500 | 500 | geodir_save_post_images($last_post_id, $tmpimgArr, $dummy); |
| 501 | - } else{
|
|
| 501 | + } else {
|
|
| 502 | 502 | geodir_save_post_images($last_post_id, $request_info['post_images'], $dummy); |
| 503 | 503 | } |
| 504 | 504 | |
@@ -579,7 +579,7 @@ discard block |
||
| 579 | 579 | if (!in_array($post_type, $all_postypes)) |
| 580 | 580 | return false; |
| 581 | 581 | |
| 582 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 582 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 583 | 583 | |
| 584 | 584 | /** |
| 585 | 585 | * Apply Filter to change Post info |
@@ -589,7 +589,7 @@ discard block |
||
| 589 | 589 | * @since 1.0.0 |
| 590 | 590 | * @package GeoDirectory |
| 591 | 591 | */ |
| 592 | - $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM " . $wpdb->posts . " p," . $table . " pd
|
|
| 592 | + $query = apply_filters('geodir_post_info_query', $wpdb->prepare("SELECT p.*,pd.* FROM ".$wpdb->posts." p,".$table." pd
|
|
| 593 | 593 | WHERE p.ID = pd.post_id |
| 594 | 594 | AND pd.post_id = %d", $post_id)); |
| 595 | 595 | |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | |
| 653 | 653 | $post_type = get_post_type($post_id); |
| 654 | 654 | |
| 655 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 655 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 656 | 656 | |
| 657 | 657 | /** |
| 658 | 658 | * Filter to change Post info |
@@ -673,7 +673,7 @@ discard block |
||
| 673 | 673 | |
| 674 | 674 | $columns = $wpdb->get_col("show columns from $table");
|
| 675 | 675 | foreach ($postmeta as $mkey => $mval) {
|
| 676 | - if(in_array($mkey,$columns)) {
|
|
| 676 | + if (in_array($mkey, $columns)) {
|
|
| 677 | 677 | if (is_array($mval)) {
|
| 678 | 678 | $mval = implode(",", $mval);
|
| 679 | 679 | } |
@@ -702,12 +702,12 @@ discard block |
||
| 702 | 702 | */ |
| 703 | 703 | do_action('geodir_before_save_listinginfo', $postinfo_array, $post_id);
|
| 704 | 704 | |
| 705 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 705 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
|
|
| 706 | 706 | |
| 707 | 707 | $query_string_array[] = $post_id; |
| 708 | 708 | $wpdb->query( |
| 709 | 709 | $wpdb->prepare( |
| 710 | - "UPDATE " . $table . " SET " . $query_string_escaped . " where post_id =%d", |
|
| 710 | + "UPDATE ".$table." SET ".$query_string_escaped." where post_id =%d", |
|
| 711 | 711 | $query_string_array |
| 712 | 712 | ) |
| 713 | 713 | ); |
@@ -718,7 +718,7 @@ discard block |
||
| 718 | 718 | array_unshift($query_string_array, $post_id); |
| 719 | 719 | $wpdb->query( |
| 720 | 720 | $wpdb->prepare( |
| 721 | - "INSERT INTO " . $table . " SET post_id = %d," . $query_string_escaped, |
|
| 721 | + "INSERT INTO ".$table." SET post_id = %d,".$query_string_escaped, |
|
| 722 | 722 | $query_string_array |
| 723 | 723 | ) |
| 724 | 724 | ); |
@@ -764,7 +764,7 @@ discard block |
||
| 764 | 764 | |
| 765 | 765 | $post_type = get_post_type($post_id); |
| 766 | 766 | |
| 767 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 767 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 768 | 768 | |
| 769 | 769 | if ($postmeta != '' && geodir_column_exist($table, $postmeta) && $post_id) {
|
| 770 | 770 | |
@@ -772,11 +772,11 @@ discard block |
||
| 772 | 772 | $meta_value = implode(",", $meta_value);
|
| 773 | 773 | } |
| 774 | 774 | |
| 775 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 775 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
|
|
| 776 | 776 | |
| 777 | 777 | $wpdb->query( |
| 778 | 778 | $wpdb->prepare( |
| 779 | - "UPDATE " . $table . " SET " . $postmeta . " = '" . $meta_value . "' where post_id =%d", |
|
| 779 | + "UPDATE ".$table." SET ".$postmeta." = '".$meta_value."' where post_id =%d", |
|
| 780 | 780 | array($post_id) |
| 781 | 781 | ) |
| 782 | 782 | ); |
@@ -785,7 +785,7 @@ discard block |
||
| 785 | 785 | |
| 786 | 786 | $wpdb->query( |
| 787 | 787 | $wpdb->prepare( |
| 788 | - "INSERT INTO " . $table . " SET post_id = %d, " . $postmeta . " = '" . $meta_value . "'", |
|
| 788 | + "INSERT INTO ".$table." SET post_id = %d, ".$postmeta." = '".$meta_value."'", |
|
| 789 | 789 | array($post_id) |
| 790 | 790 | ) |
| 791 | 791 | ); |
@@ -818,14 +818,14 @@ discard block |
||
| 818 | 818 | |
| 819 | 819 | $post_type = get_post_type($post_id); |
| 820 | 820 | |
| 821 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 821 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 822 | 822 | |
| 823 | 823 | if (is_array($postmeta) && !empty($postmeta) && $post_id) {
|
| 824 | 824 | $post_meta_set_query = ''; |
| 825 | 825 | |
| 826 | 826 | foreach ($postmeta as $mkey) {
|
| 827 | 827 | if ($mval != '') |
| 828 | - $post_meta_set_query .= $mkey . " = '', "; |
|
| 828 | + $post_meta_set_query .= $mkey." = '', "; |
|
| 829 | 829 | } |
| 830 | 830 | |
| 831 | 831 | $post_meta_set_query = trim($post_meta_set_query, ", "); |
@@ -834,11 +834,11 @@ discard block |
||
| 834 | 834 | return false; |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 837 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
|
|
| 838 | 838 | |
| 839 | 839 | $wpdb->query( |
| 840 | 840 | $wpdb->prepare( |
| 841 | - "UPDATE " . $table . " SET " . $post_meta_set_query . " where post_id = %d", |
|
| 841 | + "UPDATE ".$table." SET ".$post_meta_set_query." where post_id = %d", |
|
| 842 | 842 | array($post_id) |
| 843 | 843 | ) |
| 844 | 844 | ); |
@@ -847,11 +847,11 @@ discard block |
||
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | } elseif ($postmeta != '' && $post_id) {
|
| 850 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $postmeta . "'") != '') {
|
|
| 850 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$postmeta."'") != '') {
|
|
| 851 | 851 | |
| 852 | 852 | $wpdb->query( |
| 853 | 853 | $wpdb->prepare( |
| 854 | - "UPDATE " . $table . " SET " . $postmeta . "= '' where post_id = %d", |
|
| 854 | + "UPDATE ".$table." SET ".$postmeta."= '' where post_id = %d", |
|
| 855 | 855 | array($post_id) |
| 856 | 856 | ) |
| 857 | 857 | ); |
@@ -893,10 +893,10 @@ discard block |
||
| 893 | 893 | if (!in_array($post_type, $all_postypes)) |
| 894 | 894 | return false; |
| 895 | 895 | |
| 896 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 896 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 897 | 897 | |
| 898 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $table . " WHERE field = '" . $meta_key . "'") != '') {
|
|
| 899 | - $meta_value = $wpdb->get_var($wpdb->prepare("SELECT " . $meta_key . " from " . $table . " where post_id = %d", array($post_id)));
|
|
| 898 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$table." WHERE field = '".$meta_key."'") != '') {
|
|
| 899 | + $meta_value = $wpdb->get_var($wpdb->prepare("SELECT ".$meta_key." from ".$table." where post_id = %d", array($post_id)));
|
|
| 900 | 900 | |
| 901 | 901 | if ($meta_value && $meta_value !== '') {
|
| 902 | 902 | $meta_value = maybe_serialize($meta_value); |
@@ -915,7 +915,7 @@ discard block |
||
| 915 | 915 | * @param string $meta_key The meta key to retrieve. |
| 916 | 916 | * @param bool $single Optional. Whether to return a single value. Default false. |
| 917 | 917 | */ |
| 918 | - return apply_filters( 'geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single ); |
|
| 918 | + return apply_filters('geodir_get_post_meta', $meta_value, $post_id, $meta_key, $single);
|
|
| 919 | 919 | } |
| 920 | 920 | } |
| 921 | 921 | |
@@ -941,13 +941,13 @@ discard block |
||
| 941 | 941 | |
| 942 | 942 | $post_type = get_post_type($post_id); |
| 943 | 943 | |
| 944 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 944 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 945 | 945 | |
| 946 | 946 | $post_images = geodir_get_images($post_id); |
| 947 | 947 | |
| 948 | 948 | $wpdb->query( |
| 949 | 949 | $wpdb->prepare( |
| 950 | - "UPDATE " . $table . " SET featured_image = '' where post_id =%d", |
|
| 950 | + "UPDATE ".$table." SET featured_image = '' where post_id =%d", |
|
| 951 | 951 | array($post_id) |
| 952 | 952 | ) |
| 953 | 953 | ); |
@@ -977,12 +977,12 @@ discard block |
||
| 977 | 977 | $file_path = ''; |
| 978 | 978 | /* --------- start ------- */ |
| 979 | 979 | |
| 980 | - $split_img_path = explode(str_replace(array('http://','https://'),'',$uploads['baseurl']), str_replace(array('http://','https://'),'',$post_image[$m]));
|
|
| 980 | + $split_img_path = explode(str_replace(array('http://', 'https://'), '', $uploads['baseurl']), str_replace(array('http://', 'https://'), '', $post_image[$m]));
|
|
| 981 | 981 | |
| 982 | 982 | $split_img_file_path = isset($split_img_path[1]) ? $split_img_path[1] : ''; |
| 983 | 983 | |
| 984 | 984 | |
| 985 | - if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 985 | + if (!$find_image = $wpdb->get_var($wpdb->prepare("SELECT ID FROM ".GEODIR_ATTACHMENT_TABLE." WHERE file=%s AND post_id = %d", array($split_img_file_path, $post_id)))) {
|
|
| 986 | 986 | |
| 987 | 987 | /* --------- end ------- */ |
| 988 | 988 | $curr_img_url = $post_image[$m]; |
@@ -1026,7 +1026,7 @@ discard block |
||
| 1026 | 1026 | // If the uploaded file is the right format |
| 1027 | 1027 | if (in_array($uploaded_file_type, $allowed_file_types)) {
|
| 1028 | 1028 | if (!function_exists('wp_handle_upload')) {
|
| 1029 | - require_once(ABSPATH . 'wp-admin/includes/file.php'); |
|
| 1029 | + require_once(ABSPATH.'wp-admin/includes/file.php'); |
|
| 1030 | 1030 | } |
| 1031 | 1031 | |
| 1032 | 1032 | if (!is_dir($geodir_uploadpath)) {
|
@@ -1034,41 +1034,41 @@ discard block |
||
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | 1036 | $external_img = false; |
| 1037 | - if (strpos( str_replace( array('http://','https://'),'',$curr_img_url ), str_replace(array('http://','https://'),'',$uploads['baseurl'] ) ) !== false) {
|
|
| 1037 | + if (strpos(str_replace(array('http://', 'https://'), '', $curr_img_url), str_replace(array('http://', 'https://'), '', $uploads['baseurl'])) !== false) {
|
|
| 1038 | 1038 | } else {
|
| 1039 | 1039 | $external_img = true; |
| 1040 | 1040 | } |
| 1041 | 1041 | |
| 1042 | 1042 | if ($dummy || $external_img) {
|
| 1043 | 1043 | $uploaded_file = array(); |
| 1044 | - $uploaded = (array)fetch_remote_file($curr_img_url); |
|
| 1044 | + $uploaded = (array) fetch_remote_file($curr_img_url); |
|
| 1045 | 1045 | |
| 1046 | 1046 | if (isset($uploaded['error']) && empty($uploaded['error'])) {
|
| 1047 | 1047 | $new_name = basename($uploaded['file']); |
| 1048 | 1048 | $uploaded_file = $uploaded; |
| 1049 | - }else{
|
|
| 1050 | - print_r($uploaded);exit; |
|
| 1049 | + } else {
|
|
| 1050 | + print_r($uploaded); exit; |
|
| 1051 | 1051 | } |
| 1052 | 1052 | $external_img = false; |
| 1053 | 1053 | } else {
|
| 1054 | - $new_name = $post_id . '_' . $file_name; |
|
| 1054 | + $new_name = $post_id.'_'.$file_name; |
|
| 1055 | 1055 | |
| 1056 | 1056 | if ($curr_img_dir == $sub_dir) {
|
| 1057 | - $img_path = $geodir_uploadpath . '/' . $filename; |
|
| 1058 | - $img_url = $geodir_uploadurl . '/' . $filename; |
|
| 1057 | + $img_path = $geodir_uploadpath.'/'.$filename; |
|
| 1058 | + $img_url = $geodir_uploadurl.'/'.$filename; |
|
| 1059 | 1059 | } else {
|
| 1060 | - $img_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1061 | - $img_url = $uploads['url'] . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1060 | + $img_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename; |
|
| 1061 | + $img_url = $uploads['url'].'/temp_'.$current_user->data->ID.'/'.$filename; |
|
| 1062 | 1062 | } |
| 1063 | 1063 | |
| 1064 | 1064 | $uploaded_file = ''; |
| 1065 | 1065 | |
| 1066 | 1066 | if (file_exists($img_path)) {
|
| 1067 | - $uploaded_file = copy($img_path, $geodir_uploadpath . '/' . $new_name); |
|
| 1067 | + $uploaded_file = copy($img_path, $geodir_uploadpath.'/'.$new_name); |
|
| 1068 | 1068 | $file_path = ''; |
| 1069 | - } else if (file_exists($uploads['basedir'] . $curr_img_dir . $filename)) {
|
|
| 1069 | + } else if (file_exists($uploads['basedir'].$curr_img_dir.$filename)) {
|
|
| 1070 | 1070 | $uploaded_file = true; |
| 1071 | - $file_path = $curr_img_dir . '/' . $filename; |
|
| 1071 | + $file_path = $curr_img_dir.'/'.$filename; |
|
| 1072 | 1072 | } |
| 1073 | 1073 | |
| 1074 | 1074 | if ($curr_img_dir != $geodir_uploaddir && file_exists($img_path)) |
@@ -1077,14 +1077,14 @@ discard block |
||
| 1077 | 1077 | |
| 1078 | 1078 | if (!empty($uploaded_file)) {
|
| 1079 | 1079 | if (!isset($file_path) || !$file_path) {
|
| 1080 | - $file_path = $sub_dir . '/' . $new_name; |
|
| 1080 | + $file_path = $sub_dir.'/'.$new_name; |
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$uploads['baseurl'] . $file_path);
|
|
| 1083 | + $postcurr_images[] = str_replace(array('http://', 'https://'), '', $uploads['baseurl'].$file_path);
|
|
| 1084 | 1084 | |
| 1085 | 1085 | if ($menu_order == 1) {
|
| 1086 | 1086 | |
| 1087 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1087 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($file_path, $post_id)));
|
|
| 1088 | 1088 | |
| 1089 | 1089 | } |
| 1090 | 1090 | |
@@ -1102,12 +1102,12 @@ discard block |
||
| 1102 | 1102 | |
| 1103 | 1103 | foreach ($attachment as $key => $val) {
|
| 1104 | 1104 | if ($val != '') |
| 1105 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 1105 | + $attachment_set .= $key." = '".$val."', "; |
|
| 1106 | 1106 | } |
| 1107 | 1107 | |
| 1108 | 1108 | $attachment_set = trim($attachment_set, ", "); |
| 1109 | 1109 | |
| 1110 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 1110 | + $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
|
|
| 1111 | 1111 | |
| 1112 | 1112 | $valid_file_ids[] = $wpdb->insert_id; |
| 1113 | 1113 | } |
@@ -1118,17 +1118,17 @@ discard block |
||
| 1118 | 1118 | } else {
|
| 1119 | 1119 | $valid_file_ids[] = $find_image; |
| 1120 | 1120 | |
| 1121 | - $postcurr_images[] = str_replace(array('http://','https://'),'',$post_image[$m]);
|
|
| 1121 | + $postcurr_images[] = str_replace(array('http://', 'https://'), '', $post_image[$m]);
|
|
| 1122 | 1122 | |
| 1123 | 1123 | $wpdb->query( |
| 1124 | 1124 | $wpdb->prepare( |
| 1125 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1125 | + "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET menu_order = %d where file =%s AND post_id =%d", |
|
| 1126 | 1126 | array($menu_order, $split_img_path[1], $post_id) |
| 1127 | 1127 | ) |
| 1128 | 1128 | ); |
| 1129 | 1129 | |
| 1130 | 1130 | if ($menu_order == 1) |
| 1131 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1131 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($split_img_path[1], $post_id)));
|
|
| 1132 | 1132 | |
| 1133 | 1133 | } |
| 1134 | 1134 | |
@@ -1152,9 +1152,9 @@ discard block |
||
| 1152 | 1152 | |
| 1153 | 1153 | foreach ($post_images as $img) {
|
| 1154 | 1154 | |
| 1155 | - if (!in_array(str_replace(array('http://','https://'),'',$img->src), $postcurr_images)) {
|
|
| 1155 | + if (!in_array(str_replace(array('http://', 'https://'), '', $img->src), $postcurr_images)) {
|
|
| 1156 | 1156 | |
| 1157 | - $invalid_files[] = (object)array('src' => $img->src);
|
|
| 1157 | + $invalid_files[] = (object) array('src' => $img->src);
|
|
| 1158 | 1158 | |
| 1159 | 1159 | } |
| 1160 | 1160 | |
@@ -1162,12 +1162,12 @@ discard block |
||
| 1162 | 1162 | |
| 1163 | 1163 | } |
| 1164 | 1164 | |
| 1165 | - $invalid_files = (object)$invalid_files; |
|
| 1165 | + $invalid_files = (object) $invalid_files; |
|
| 1166 | 1166 | } |
| 1167 | 1167 | |
| 1168 | 1168 | $remove_files[] = $post_id; |
| 1169 | 1169 | |
| 1170 | - $wpdb->query($wpdb->prepare("DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE " . $valid_files_condition . " post_id = %d", $remove_files));
|
|
| 1170 | + $wpdb->query($wpdb->prepare("DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE ".$valid_files_condition." post_id = %d", $remove_files));
|
|
| 1171 | 1171 | |
| 1172 | 1172 | if (!empty($invalid_files)) |
| 1173 | 1173 | geodir_remove_attachments($invalid_files); |
@@ -1207,7 +1207,7 @@ discard block |
||
| 1207 | 1207 | rmdir($dirPath); |
| 1208 | 1208 | } */ |
| 1209 | 1209 | |
| 1210 | - $dirname = $uploads_dir . '/temp_' . $current_user->ID; |
|
| 1210 | + $dirname = $uploads_dir.'/temp_'.$current_user->ID; |
|
| 1211 | 1211 | geodir_delete_directory($dirname); |
| 1212 | 1212 | } |
| 1213 | 1213 | |
@@ -1229,10 +1229,10 @@ discard block |
||
| 1229 | 1229 | return false; |
| 1230 | 1230 | while ($file = readdir($dir_handle)) {
|
| 1231 | 1231 | if ($file != "." && $file != "..") {
|
| 1232 | - if (!is_dir($dirname . "/" . $file)) |
|
| 1233 | - unlink($dirname . "/" . $file); |
|
| 1232 | + if (!is_dir($dirname."/".$file)) |
|
| 1233 | + unlink($dirname."/".$file); |
|
| 1234 | 1234 | else |
| 1235 | - geodir_delete_directory($dirname . '/' . $file); |
|
| 1235 | + geodir_delete_directory($dirname.'/'.$file); |
|
| 1236 | 1236 | } |
| 1237 | 1237 | } |
| 1238 | 1238 | closedir($dir_handle); |
@@ -1261,8 +1261,8 @@ discard block |
||
| 1261 | 1261 | foreach ($postcurr_images as $postimg) {
|
| 1262 | 1262 | $image_name_arr = explode('/', $postimg->src);
|
| 1263 | 1263 | $filename = end($image_name_arr); |
| 1264 | - if (file_exists($uploads_dir . '/' . $filename)) |
|
| 1265 | - unlink($uploads_dir . '/' . $filename); |
|
| 1264 | + if (file_exists($uploads_dir.'/'.$filename)) |
|
| 1265 | + unlink($uploads_dir.'/'.$filename); |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | } // endif |
@@ -1303,28 +1303,28 @@ discard block |
||
| 1303 | 1303 | } |
| 1304 | 1304 | |
| 1305 | 1305 | if (!in_array($post_type, geodir_get_posttypes())) {
|
| 1306 | - return false;// if not a GD CPT return; |
|
| 1306 | + return false; // if not a GD CPT return; |
|
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | 1309 | |
| 1310 | - $list_img_size = get_option('geodir_listing_img_size','default');
|
|
| 1310 | + $list_img_size = get_option('geodir_listing_img_size', 'default');
|
|
| 1311 | 1311 | |
| 1312 | - if( $size=='list-thumb' && $list_img_size != 'default' ){
|
|
| 1313 | - $fimg = get_the_post_thumbnail_url($post_id,$list_img_size); |
|
| 1314 | - if($fimg){
|
|
| 1312 | + if ($size == 'list-thumb' && $list_img_size != 'default') {
|
|
| 1313 | + $fimg = get_the_post_thumbnail_url($post_id, $list_img_size); |
|
| 1314 | + if ($fimg) {
|
|
| 1315 | 1315 | $uploads = wp_upload_dir(); |
| 1316 | 1316 | $uploads_baseurl = $uploads['baseurl']; |
| 1317 | - $file = str_replace($uploads_baseurl,'',$fimg); |
|
| 1317 | + $file = str_replace($uploads_baseurl, '', $fimg); |
|
| 1318 | 1318 | } |
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1321 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 1322 | 1322 | |
| 1323 | 1323 | if (!$file) {
|
| 1324 | 1324 | if (isset($post->featured_image)) {
|
| 1325 | 1325 | $file = $post->featured_image; |
| 1326 | 1326 | } else {
|
| 1327 | - $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM " . $table . " WHERE post_id = %d", array($post_id)));
|
|
| 1327 | + $file = $wpdb->get_var($wpdb->prepare("SELECT featured_image FROM ".$table." WHERE post_id = %d", array($post_id)));
|
|
| 1328 | 1328 | } |
| 1329 | 1329 | } |
| 1330 | 1330 | |
@@ -1343,9 +1343,9 @@ discard block |
||
| 1343 | 1343 | |
| 1344 | 1344 | $file_name = $file_info['basename']; |
| 1345 | 1345 | |
| 1346 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1346 | + $uploads_url = $uploads_baseurl.$sub_dir; |
|
| 1347 | 1347 | |
| 1348 | - $img_src = $uploads_url . '/' . $file_name; |
|
| 1348 | + $img_src = $uploads_url.'/'.$file_name; |
|
| 1349 | 1349 | |
| 1350 | 1350 | // jetpack CDN check |
| 1351 | 1351 | if (strpos($file, '.wp.com/') !== false) {
|
@@ -1361,8 +1361,8 @@ discard block |
||
| 1361 | 1361 | * @param string $uploads_url The server upload directory url. |
| 1362 | 1362 | * @param string $uploads_baseurl The uploads dir base url. |
| 1363 | 1363 | */ |
| 1364 | - $img_arr['src'] = apply_filters('geodir_get_featured_image_src',$img_src,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1365 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1364 | + $img_arr['src'] = apply_filters('geodir_get_featured_image_src', $img_src, $file_name, $uploads_url, $uploads_baseurl);
|
|
| 1365 | + $img_arr['path'] = $uploads_path.'/'.$file_name; |
|
| 1366 | 1366 | $width = 0; |
| 1367 | 1367 | $height = 0; |
| 1368 | 1368 | if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
@@ -1405,7 +1405,7 @@ discard block |
||
| 1405 | 1405 | $file_name = $file_info['basename']; |
| 1406 | 1406 | |
| 1407 | 1407 | $img_arr['src'] = $default_img; |
| 1408 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1408 | + $img_arr['path'] = $uploads_path.'/'.$file_name; |
|
| 1409 | 1409 | |
| 1410 | 1410 | $width = 0; |
| 1411 | 1411 | $height = 0; |
@@ -1422,7 +1422,7 @@ discard block |
||
| 1422 | 1422 | } |
| 1423 | 1423 | |
| 1424 | 1424 | if (!empty($img_arr)) |
| 1425 | - return (object)$img_arr;//return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1425 | + return (object) $img_arr; //return (object)array( 'src' => $file_url, 'path' => $file_path ); |
|
| 1426 | 1426 | else |
| 1427 | 1427 | return false; |
| 1428 | 1428 | } |
@@ -1485,7 +1485,7 @@ discard block |
||
| 1485 | 1485 | |
| 1486 | 1486 | $arrImages = $wpdb->get_results( |
| 1487 | 1487 | $wpdb->prepare( |
| 1488 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d" . $not_featured . " ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1488 | + "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d".$not_featured." ORDER BY menu_order ASC, ID DESC $limit_q ", |
|
| 1489 | 1489 | array('%image%', $post_id)
|
| 1490 | 1490 | ) |
| 1491 | 1491 | ); |
@@ -1511,7 +1511,7 @@ discard block |
||
| 1511 | 1511 | |
| 1512 | 1512 | $file_name = $file_info['basename']; |
| 1513 | 1513 | |
| 1514 | - $uploads_url = $uploads_baseurl . $sub_dir; |
|
| 1514 | + $uploads_url = $uploads_baseurl.$sub_dir; |
|
| 1515 | 1515 | /* |
| 1516 | 1516 | * Allows the filter of image src for such things as CDN change. |
| 1517 | 1517 | * |
@@ -1521,8 +1521,8 @@ discard block |
||
| 1521 | 1521 | * @param string $uploads_url The server upload directory url. |
| 1522 | 1522 | * @param string $uploads_baseurl The uploads dir base url. |
| 1523 | 1523 | */ |
| 1524 | - $img_arr['src'] = apply_filters('geodir_get_images_src',$uploads_url . '/' . $file_name,$file_name,$uploads_url,$uploads_baseurl);
|
|
| 1525 | - $img_arr['path'] = $uploads_path . '/' . $file_name; |
|
| 1524 | + $img_arr['src'] = apply_filters('geodir_get_images_src', $uploads_url.'/'.$file_name, $file_name, $uploads_url, $uploads_baseurl);
|
|
| 1525 | + $img_arr['path'] = $uploads_path.'/'.$file_name; |
|
| 1526 | 1526 | $width = 0; |
| 1527 | 1527 | $height = 0; |
| 1528 | 1528 | if (is_file($img_arr['path']) && file_exists($img_arr['path'])) {
|
@@ -1539,7 +1539,7 @@ discard block |
||
| 1539 | 1539 | $img_arr['content'] = $attechment->content; // add the description to the array |
| 1540 | 1540 | $img_arr['is_approved'] = isset($attechment->is_approved) ? $attechment->is_approved : ''; // used for user image moderation. For backward compatibility Default value is 1. |
| 1541 | 1541 | |
| 1542 | - $return_arr[] = (object)$img_arr; |
|
| 1542 | + $return_arr[] = (object) $img_arr; |
|
| 1543 | 1543 | |
| 1544 | 1544 | $counter++; |
| 1545 | 1545 | } |
@@ -1550,7 +1550,7 @@ discard block |
||
| 1550 | 1550 | * @since 1.6.20 |
| 1551 | 1551 | * @param array $return_arr The array of image objects. |
| 1552 | 1552 | */ |
| 1553 | - return apply_filters('geodir_get_images_arr',$return_arr);
|
|
| 1553 | + return apply_filters('geodir_get_images_arr', $return_arr);
|
|
| 1554 | 1554 | } else if ($no_images) {
|
| 1555 | 1555 | $default_img = ''; |
| 1556 | 1556 | $default_cat = geodir_get_post_meta($post_id, 'default_category', true); |
@@ -1589,7 +1589,7 @@ discard block |
||
| 1589 | 1589 | $img_arr['title'] = $file_info['filename']; // add the title to the array |
| 1590 | 1590 | $img_arr['content'] = $file_info['filename']; // add the description to the array |
| 1591 | 1591 | |
| 1592 | - $return_arr[] = (object)$img_arr; |
|
| 1592 | + $return_arr[] = (object) $img_arr; |
|
| 1593 | 1593 | |
| 1594 | 1594 | /** |
| 1595 | 1595 | * Filter the images array so things can be changed. |
@@ -1597,7 +1597,7 @@ discard block |
||
| 1597 | 1597 | * @since 1.6.20 |
| 1598 | 1598 | * @param array $return_arr The array of image objects. |
| 1599 | 1599 | */ |
| 1600 | - return apply_filters('geodir_get_images_arr',$return_arr);
|
|
| 1600 | + return apply_filters('geodir_get_images_arr', $return_arr);
|
|
| 1601 | 1601 | } else |
| 1602 | 1602 | return false; |
| 1603 | 1603 | } |
@@ -1622,8 +1622,8 @@ discard block |
||
| 1622 | 1622 | |
| 1623 | 1623 | $html = ''; |
| 1624 | 1624 | if (!empty($request)) {
|
| 1625 | - if (!is_object($request)){
|
|
| 1626 | - $request = (object)$request; |
|
| 1625 | + if (!is_object($request)) {
|
|
| 1626 | + $request = (object) $request; |
|
| 1627 | 1627 | } |
| 1628 | 1628 | |
| 1629 | 1629 | if (isset($request->src) && !isset($request->path)) {
|
@@ -1637,7 +1637,7 @@ discard block |
||
| 1637 | 1637 | $img_no_http = str_replace(array("http://", "https://"), "", $request->path);
|
| 1638 | 1638 | $upload_no_http = str_replace(array("http://", "https://"), "", $upload_dir['baseurl']);
|
| 1639 | 1639 | if (strpos($img_no_http, $upload_no_http) !== false) {
|
| 1640 | - $request->path = str_replace( $img_no_http,$upload_dir['basedir'], $request->path); |
|
| 1640 | + $request->path = str_replace($img_no_http, $upload_dir['basedir'], $request->path); |
|
| 1641 | 1641 | } |
| 1642 | 1642 | |
| 1643 | 1643 | $width = 0; |
@@ -1654,7 +1654,7 @@ discard block |
||
| 1654 | 1654 | $image->height = $height; |
| 1655 | 1655 | $image->title = isset($request->title) ? $request->title : ''; |
| 1656 | 1656 | |
| 1657 | - $max_size = (object)geodir_get_imagesize($size); |
|
| 1657 | + $max_size = (object) geodir_get_imagesize($size); |
|
| 1658 | 1658 | |
| 1659 | 1659 | if (!is_wp_error($max_size)) {
|
| 1660 | 1660 | if ($image->width) {
|
@@ -1666,13 +1666,13 @@ discard block |
||
| 1666 | 1666 | $width_per = 100; |
| 1667 | 1667 | } |
| 1668 | 1668 | |
| 1669 | - if (is_admin() && !isset($_REQUEST['geodir_ajax'])){
|
|
| 1670 | - $html = '<div class="geodir_thumbnail"><img style="max-height:' . $max_size->h . 'px;" alt="place image" src="' . $image->src . '" /></div>'; |
|
| 1669 | + if (is_admin() && !isset($_REQUEST['geodir_ajax'])) {
|
|
| 1670 | + $html = '<div class="geodir_thumbnail"><img style="max-height:'.$max_size->h.'px;" alt="place image" src="'.$image->src.'" /></div>'; |
|
| 1671 | 1671 | } else {
|
| 1672 | - if($size=='widget-thumb' || !get_option('geodir_lazy_load',1)){
|
|
| 1673 | - $html = '<div class="geodir_thumbnail" style="background-image:url(\'' . $image->src . '\');" title="'.$image->title.'" aria-label="'.$image->title.'" ></div>'; |
|
| 1674 | - }else{
|
|
| 1675 | - $html = '<div data-src="'.str_replace(' ','%20',$image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" title="'.$image->title.'" aria-label="'.$image->title.'"></div>';
|
|
| 1672 | + if ($size == 'widget-thumb' || !get_option('geodir_lazy_load', 1)) {
|
|
| 1673 | + $html = '<div class="geodir_thumbnail" style="background-image:url(\''.$image->src.'\');" title="'.$image->title.'" aria-label="'.$image->title.'" ></div>'; |
|
| 1674 | + } else {
|
|
| 1675 | + $html = '<div data-src="'.str_replace(' ', '%20', $image->src).'" class="geodir_thumbnail geodir_lazy_load_thumbnail" title="'.$image->title.'" aria-label="'.$image->title.'"></div>';
|
|
| 1676 | 1676 | } |
| 1677 | 1677 | |
| 1678 | 1678 | } |
@@ -1707,15 +1707,15 @@ discard block |
||
| 1707 | 1707 | |
| 1708 | 1708 | $post_type = get_post_type($post_id); |
| 1709 | 1709 | |
| 1710 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 1710 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 1711 | 1711 | |
| 1712 | 1712 | if (in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_id)) {
|
| 1713 | 1713 | |
| 1714 | - if ($taxonomy == $post_type . '_tags') {
|
|
| 1714 | + if ($taxonomy == $post_type.'_tags') {
|
|
| 1715 | 1715 | if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
| 1716 | 1716 | geodir_save_post_meta($post_id, 'post_tags', $terms); |
| 1717 | 1717 | } |
| 1718 | - } elseif ($taxonomy == $post_type . 'category') {
|
|
| 1718 | + } elseif ($taxonomy == $post_type.'category') {
|
|
| 1719 | 1719 | $srcharr = array('"', '\\');
|
| 1720 | 1720 | $replarr = array(""", '');
|
| 1721 | 1721 | |
@@ -1737,7 +1737,7 @@ discard block |
||
| 1737 | 1737 | |
| 1738 | 1738 | $wpdb->get_var( |
| 1739 | 1739 | $wpdb->prepare( |
| 1740 | - "DELETE from " . GEODIR_ICON_TABLE . " WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1740 | + "DELETE from ".GEODIR_ICON_TABLE." WHERE cat_id NOT IN ($format) AND post_id = %d ", |
|
| 1741 | 1741 | $cat_ids_array_del |
| 1742 | 1742 | ) |
| 1743 | 1743 | ); |
@@ -1745,7 +1745,7 @@ discard block |
||
| 1745 | 1745 | |
| 1746 | 1746 | $post_term = $wpdb->get_col( |
| 1747 | 1747 | $wpdb->prepare( |
| 1748 | - "SELECT term_id FROM " . $wpdb->term_taxonomy . " WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1748 | + "SELECT term_id FROM ".$wpdb->term_taxonomy." WHERE term_taxonomy_id IN($format) GROUP BY term_id", |
|
| 1749 | 1749 | $cat_ids_array |
| 1750 | 1750 | ) |
| 1751 | 1751 | ); |
@@ -1767,16 +1767,16 @@ discard block |
||
| 1767 | 1767 | $lat = geodir_get_post_meta($post_id, 'post_latitude', true); |
| 1768 | 1768 | $lng = geodir_get_post_meta($post_id, 'post_longitude', true); |
| 1769 | 1769 | |
| 1770 | - $timing = ' - ' . date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1771 | - $timing .= ' - ' . geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1770 | + $timing = ' - '.date('D M j, Y', strtotime(geodir_get_post_meta($post_id, 'st_date', true)));
|
|
| 1771 | + $timing .= ' - '.geodir_get_post_meta($post_id, 'st_time', true); |
|
| 1772 | 1772 | |
| 1773 | 1773 | $json = '{';
|
| 1774 | - $json .= '"id":"' . $post_id . '",'; |
|
| 1775 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 1776 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 1777 | - $json .= '"marker_id":"' . $post_id . '_' . $cat_id . '",'; |
|
| 1778 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 1779 | - $json .= '"group":"catgroup' . $cat_id . '"'; |
|
| 1774 | + $json .= '"id":"'.$post_id.'",'; |
|
| 1775 | + $json .= '"lat_pos": "'.$lat.'",'; |
|
| 1776 | + $json .= '"long_pos": "'.$lng.'",'; |
|
| 1777 | + $json .= '"marker_id":"'.$post_id.'_'.$cat_id.'",'; |
|
| 1778 | + $json .= '"icon":"'.$term_icon.'",'; |
|
| 1779 | + $json .= '"group":"catgroup'.$cat_id.'"'; |
|
| 1780 | 1780 | $json .= '}'; |
| 1781 | 1781 | |
| 1782 | 1782 | |
@@ -1784,9 +1784,9 @@ discard block |
||
| 1784 | 1784 | $post_marker_json = $json; |
| 1785 | 1785 | |
| 1786 | 1786 | |
| 1787 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . GEODIR_ICON_TABLE . " WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1787 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".GEODIR_ICON_TABLE." WHERE post_id = %d AND cat_id = %d", array($post_id, $cat_id)))) {
|
|
| 1788 | 1788 | |
| 1789 | - $json_query = $wpdb->prepare("UPDATE " . GEODIR_ICON_TABLE . " SET
|
|
| 1789 | + $json_query = $wpdb->prepare("UPDATE ".GEODIR_ICON_TABLE." SET
|
|
| 1790 | 1790 | post_title = %s, |
| 1791 | 1791 | json = %s |
| 1792 | 1792 | WHERE post_id = %d AND cat_id = %d ", |
@@ -1794,7 +1794,7 @@ discard block |
||
| 1794 | 1794 | |
| 1795 | 1795 | } else {
|
| 1796 | 1796 | |
| 1797 | - $json_query = $wpdb->prepare("INSERT INTO " . GEODIR_ICON_TABLE . " SET
|
|
| 1797 | + $json_query = $wpdb->prepare("INSERT INTO ".GEODIR_ICON_TABLE." SET
|
|
| 1798 | 1798 | post_id = %d, |
| 1799 | 1799 | post_title = %s, |
| 1800 | 1800 | cat_id = %d, |
@@ -1812,17 +1812,17 @@ discard block |
||
| 1812 | 1812 | if (!empty($post_term) && is_array($post_term)) {
|
| 1813 | 1813 | $categories = implode(',', $post_term);
|
| 1814 | 1814 | |
| 1815 | - if ($categories != '' && $categories != 0) $categories = ',' . $categories . ','; |
|
| 1815 | + if ($categories != '' && $categories != 0) $categories = ','.$categories.','; |
|
| 1816 | 1816 | |
| 1817 | 1817 | if (empty($post_marker_json)) |
| 1818 | 1818 | $post_marker_json = isset($json) ? $json : ''; |
| 1819 | 1819 | |
| 1820 | - if ($wpdb->get_var($wpdb->prepare("SELECT post_id from " . $table . " where post_id = %d", array($post_id)))) {
|
|
| 1820 | + if ($wpdb->get_var($wpdb->prepare("SELECT post_id from ".$table." where post_id = %d", array($post_id)))) {
|
|
| 1821 | 1821 | |
| 1822 | 1822 | $wpdb->query( |
| 1823 | 1823 | $wpdb->prepare( |
| 1824 | - "UPDATE " . $table . " SET |
|
| 1825 | - " . $taxonomy . " = %s, |
|
| 1824 | + "UPDATE ".$table." SET |
|
| 1825 | + " . $taxonomy." = %s, |
|
| 1826 | 1826 | marker_json = %s |
| 1827 | 1827 | where post_id = %d", |
| 1828 | 1828 | array($categories, $post_marker_json, $post_id) |
@@ -1843,7 +1843,7 @@ discard block |
||
| 1843 | 1843 | |
| 1844 | 1844 | $wpdb->query( |
| 1845 | 1845 | $wpdb->prepare( |
| 1846 | - "UPDATE " . $table . " SET |
|
| 1846 | + "UPDATE ".$table." SET |
|
| 1847 | 1847 | default_category = %s |
| 1848 | 1848 | where post_id = %d", |
| 1849 | 1849 | array($categories[0], $post_id) |
@@ -1868,9 +1868,9 @@ discard block |
||
| 1868 | 1868 | |
| 1869 | 1869 | $wpdb->query( |
| 1870 | 1870 | $wpdb->prepare( |
| 1871 | - "INSERT INTO " . $table . " SET |
|
| 1871 | + "INSERT INTO ".$table." SET |
|
| 1872 | 1872 | post_id = %d, |
| 1873 | - " . $taxonomy . " = %s, |
|
| 1873 | + " . $taxonomy." = %s, |
|
| 1874 | 1874 | marker_json = %s ", |
| 1875 | 1875 | |
| 1876 | 1876 | array($post_id, $categories, $post_marker_json) |
@@ -2002,7 +2002,7 @@ discard block |
||
| 2002 | 2002 | } ?>"><img alt="bubble image" style="max-height:50px;" |
| 2003 | 2003 | src="<?php echo $post_images[0]; ?>"/></a></div> |
| 2004 | 2004 | <?php |
| 2005 | - }else{
|
|
| 2005 | + } else {
|
|
| 2006 | 2006 | echo '<div class="geodir-bubble_image"></div>'; |
| 2007 | 2007 | } |
| 2008 | 2008 | } else {
|
@@ -2010,7 +2010,7 @@ discard block |
||
| 2010 | 2010 | ?> |
| 2011 | 2011 | <div class="geodir-bubble_image"><a href="<?php echo $plink; ?>"><?php echo $image; ?></a></div> |
| 2012 | 2012 | <?php |
| 2013 | - }else{
|
|
| 2013 | + } else {
|
|
| 2014 | 2014 | echo '<div class="geodir-bubble_image"></div>'; |
| 2015 | 2015 | } |
| 2016 | 2016 | } |
@@ -2040,7 +2040,7 @@ discard block |
||
| 2040 | 2040 | * @param object $postinfo_obj The posts info as an object. |
| 2041 | 2041 | * @param bool|string $post_preview True if currently in post preview page. Empty string if not. * |
| 2042 | 2042 | */ |
| 2043 | - do_action('geodir_infowindow_meta_after',$postinfo_obj,$post_preview );
|
|
| 2043 | + do_action('geodir_infowindow_meta_after', $postinfo_obj, $post_preview);
|
|
| 2044 | 2044 | ?> |
| 2045 | 2045 | </div> |
| 2046 | 2046 | <?php |
@@ -2050,9 +2050,9 @@ discard block |
||
| 2050 | 2050 | <div class="geodir-bubble-meta-fade"></div> |
| 2051 | 2051 | <div class="geodir-bubble-meta-bottom"> |
| 2052 | 2052 | <?php if ($rating_star != '') { ?>
|
| 2053 | - <span class="geodir-bubble-rating"><?php echo $rating_star;?></span> |
|
| 2053 | + <span class="geodir-bubble-rating"><?php echo $rating_star; ?></span> |
|
| 2054 | 2054 | <?php } ?> |
| 2055 | - <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID);?></span> |
|
| 2055 | + <span class="geodir-bubble-fav"><?php echo geodir_favourite_html($post_author, $ID); ?></span> |
|
| 2056 | 2056 | <span class="geodir-bubble-reviews"> |
| 2057 | 2057 | <a href="<?php echo get_comments_link($ID); ?>" class="geodir-pcomments"><i class="fa fa-comments"></i> <?php echo get_comments_number($ID); ?></a> |
| 2058 | 2058 | </span> |
@@ -2091,9 +2091,9 @@ discard block |
||
| 2091 | 2091 | function geodir_new_post_default_status() |
| 2092 | 2092 | {
|
| 2093 | 2093 | |
| 2094 | - $status = get_option( 'geodir_new_post_default_status' ); |
|
| 2094 | + $status = get_option('geodir_new_post_default_status');
|
|
| 2095 | 2095 | |
| 2096 | - if ( empty( $status ) ) {
|
|
| 2096 | + if (empty($status)) {
|
|
| 2097 | 2097 | $status = 'publish'; |
| 2098 | 2098 | } |
| 2099 | 2099 | |
@@ -2102,7 +2102,7 @@ discard block |
||
| 2102 | 2102 | * |
| 2103 | 2103 | * @since 1.6.23 |
| 2104 | 2104 | */ |
| 2105 | - return apply_filters( 'geodir_new_post_default_status', $status ); |
|
| 2105 | + return apply_filters('geodir_new_post_default_status', $status);
|
|
| 2106 | 2106 | |
| 2107 | 2107 | } |
| 2108 | 2108 | |
@@ -2121,11 +2121,11 @@ discard block |
||
| 2121 | 2121 | |
| 2122 | 2122 | $post_type = get_post_type($post_id); |
| 2123 | 2123 | |
| 2124 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2124 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2125 | 2125 | |
| 2126 | 2126 | $wpdb->query( |
| 2127 | 2127 | $wpdb->prepare( |
| 2128 | - "UPDATE " . $table . " SET post_status=%s WHERE post_id=%d", |
|
| 2128 | + "UPDATE ".$table." SET post_status=%s WHERE post_id=%d", |
|
| 2129 | 2129 | array($status, $post_id) |
| 2130 | 2130 | ) |
| 2131 | 2131 | ); |
@@ -2197,18 +2197,18 @@ discard block |
||
| 2197 | 2197 | |
| 2198 | 2198 | $post_type = get_post_type($post_id); |
| 2199 | 2199 | |
| 2200 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2200 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2201 | 2201 | |
| 2202 | 2202 | $wpdb->query( |
| 2203 | 2203 | $wpdb->prepare( |
| 2204 | - "UPDATE " . $table . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2204 | + "UPDATE ".$table." SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2205 | 2205 | array($updatingpost, $temppost) |
| 2206 | 2206 | ) |
| 2207 | 2207 | ); |
| 2208 | 2208 | |
| 2209 | 2209 | $wpdb->query( |
| 2210 | 2210 | $wpdb->prepare( |
| 2211 | - "UPDATE " . GEODIR_ICON_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2211 | + "UPDATE ".GEODIR_ICON_TABLE." SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2212 | 2212 | array($updatingpost, $temppost) |
| 2213 | 2213 | ) |
| 2214 | 2214 | ); |
@@ -2217,7 +2217,7 @@ discard block |
||
| 2217 | 2217 | |
| 2218 | 2218 | $wpdb->query( |
| 2219 | 2219 | $wpdb->prepare( |
| 2220 | - "UPDATE " . GEODIR_ATTACHMENT_TABLE . " SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2220 | + "UPDATE ".GEODIR_ATTACHMENT_TABLE." SET `post_id` = %d WHERE `post_id` = %d", |
|
| 2221 | 2221 | array($updatingpost, $temppost) |
| 2222 | 2222 | ) |
| 2223 | 2223 | ); |
@@ -2255,12 +2255,12 @@ discard block |
||
| 2255 | 2255 | if (!in_array($post_type, $all_postypes)) |
| 2256 | 2256 | return false; |
| 2257 | 2257 | |
| 2258 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2258 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2259 | 2259 | |
| 2260 | 2260 | /* Delete custom post meta*/ |
| 2261 | 2261 | $wpdb->query( |
| 2262 | 2262 | $wpdb->prepare( |
| 2263 | - "DELETE FROM " . $table . " WHERE `post_id` = %d", |
|
| 2263 | + "DELETE FROM ".$table." WHERE `post_id` = %d", |
|
| 2264 | 2264 | array($deleted_postid) |
| 2265 | 2265 | ) |
| 2266 | 2266 | ); |
@@ -2269,7 +2269,7 @@ discard block |
||
| 2269 | 2269 | |
| 2270 | 2270 | $wpdb->query( |
| 2271 | 2271 | $wpdb->prepare( |
| 2272 | - "DELETE FROM " . GEODIR_ICON_TABLE . " WHERE `post_id` = %d", |
|
| 2272 | + "DELETE FROM ".GEODIR_ICON_TABLE." WHERE `post_id` = %d", |
|
| 2273 | 2273 | array($deleted_postid) |
| 2274 | 2274 | ) |
| 2275 | 2275 | ); |
@@ -2279,7 +2279,7 @@ discard block |
||
| 2279 | 2279 | |
| 2280 | 2280 | $wpdb->query( |
| 2281 | 2281 | $wpdb->prepare( |
| 2282 | - "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE `post_id` = %d", |
|
| 2282 | + "DELETE FROM ".GEODIR_ATTACHMENT_TABLE." WHERE `post_id` = %d", |
|
| 2283 | 2283 | array($deleted_postid) |
| 2284 | 2284 | ) |
| 2285 | 2285 | ); |
@@ -2334,9 +2334,9 @@ discard block |
||
| 2334 | 2334 | $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
| 2335 | 2335 | |
| 2336 | 2336 | $site_id = ''; |
| 2337 | - if ( is_multisite() ) {
|
|
| 2337 | + if (is_multisite()) {
|
|
| 2338 | 2338 | $blog_id = get_current_blog_id(); |
| 2339 | - if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2339 | + if ($blog_id && $blog_id != '1') {$site_id = '_'.$blog_id; }
|
|
| 2340 | 2340 | } |
| 2341 | 2341 | |
| 2342 | 2342 | $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
@@ -2357,7 +2357,7 @@ discard block |
||
| 2357 | 2357 | */ |
| 2358 | 2358 | do_action('geodir_before_add_from_favorite', $post_id);
|
| 2359 | 2359 | |
| 2360 | - echo '<a href="javascript:void(0);" title="' . $remove_favourite_text . '" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'remove\');"><i class="'. $favourite_icon .'"></i> ' . $unfavourite_text . '</a>'; |
|
| 2360 | + echo '<a href="javascript:void(0);" title="'.$remove_favourite_text.'" class="geodir-removetofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'remove\');"><i class="'.$favourite_icon.'"></i> '.$unfavourite_text.'</a>'; |
|
| 2361 | 2361 | |
| 2362 | 2362 | /** |
| 2363 | 2363 | * Called after adding the post from favourites. |
@@ -2415,9 +2415,9 @@ discard block |
||
| 2415 | 2415 | $favourite_icon = apply_filters('geodir_favourite_icon', 'fa fa-heart');
|
| 2416 | 2416 | |
| 2417 | 2417 | $site_id = ''; |
| 2418 | - if ( is_multisite() ) {
|
|
| 2418 | + if (is_multisite()) {
|
|
| 2419 | 2419 | $blog_id = get_current_blog_id(); |
| 2420 | - if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2420 | + if ($blog_id && $blog_id != '1') {$site_id = '_'.$blog_id; }
|
|
| 2421 | 2421 | } |
| 2422 | 2422 | |
| 2423 | 2423 | $user_meta_data = array(); |
@@ -2442,7 +2442,7 @@ discard block |
||
| 2442 | 2442 | */ |
| 2443 | 2443 | do_action('geodir_before_remove_from_favorite', $post_id);
|
| 2444 | 2444 | |
| 2445 | - echo '<a href="javascript:void(0);" title="' . $add_favourite_text . '" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\'' . $post_id . '\',\'add\');"><i class="'. $favourite_icon .'"></i> ' . $favourite_text . '</a>'; |
|
| 2445 | + echo '<a href="javascript:void(0);" title="'.$add_favourite_text.'" class="geodir-addtofav-icon" onclick="javascript:addToFavourite(\''.$post_id.'\',\'add\');"><i class="'.$favourite_icon.'"></i> '.$favourite_text.'</a>'; |
|
| 2446 | 2446 | |
| 2447 | 2447 | /** |
| 2448 | 2448 | * Called after removing the post from favourites. |
@@ -2534,9 +2534,9 @@ discard block |
||
| 2534 | 2534 | |
| 2535 | 2535 | |
| 2536 | 2536 | $site_id = ''; |
| 2537 | - if ( is_multisite() ) {
|
|
| 2537 | + if (is_multisite()) {
|
|
| 2538 | 2538 | $blog_id = get_current_blog_id(); |
| 2539 | - if($blog_id && $blog_id!='1'){$site_id = '_' . $blog_id ;}
|
|
| 2539 | + if ($blog_id && $blog_id != '1') {$site_id = '_'.$blog_id; }
|
|
| 2540 | 2540 | } |
| 2541 | 2541 | |
| 2542 | 2542 | $user_meta_data = ''; |
@@ -2544,24 +2544,24 @@ discard block |
||
| 2544 | 2544 | $user_meta_data = geodir_get_user_favourites($current_user->data->ID); |
| 2545 | 2545 | |
| 2546 | 2546 | if (!empty($user_meta_data) && in_array($post_id, $user_meta_data)) {
|
| 2547 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>" ><a |
|
| 2547 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>" ><a |
|
| 2548 | 2548 | class="geodir-removetofav-icon" href="javascript:void(0);" |
| 2549 | - onclick="javascript:addToFavourite(<?php echo $post_id;?>,'remove');" |
|
| 2550 | - title="<?php echo $remove_favourite_text;?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text;?> |
|
| 2549 | + onclick="javascript:addToFavourite(<?php echo $post_id; ?>,'remove');" |
|
| 2550 | + title="<?php echo $remove_favourite_text; ?>"><i class="<?php echo $unfavourite_icon; ?>"></i> <?php echo $unfavourite_text; ?> |
|
| 2551 | 2551 | </a> </span><?php |
| 2552 | 2552 | |
| 2553 | 2553 | } else {
|
| 2554 | 2554 | |
| 2555 | 2555 | if (!isset($current_user->data->ID) || $current_user->data->ID == '') {
|
| 2556 | - $script_text = 'javascript:window.location.href=\'' . geodir_login_url() . '\''; |
|
| 2556 | + $script_text = 'javascript:window.location.href=\''.geodir_login_url().'\''; |
|
| 2557 | 2557 | } else |
| 2558 | - $script_text = 'javascript:addToFavourite(' . $post_id . ',\'add\')';
|
|
| 2558 | + $script_text = 'javascript:addToFavourite('.$post_id.',\'add\')';
|
|
| 2559 | 2559 | |
| 2560 | - ?><span class="geodir-addtofav favorite_property_<?php echo $post_id;?>"><a class="geodir-addtofav-icon" |
|
| 2560 | + ?><span class="geodir-addtofav favorite_property_<?php echo $post_id; ?>"><a class="geodir-addtofav-icon" |
|
| 2561 | 2561 | href="javascript:void(0);" |
| 2562 | - onclick="<?php echo $script_text;?>" |
|
| 2563 | - title="<?php echo $add_favourite_text;?>"><i |
|
| 2564 | - class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text;?></a></span> |
|
| 2562 | + onclick="<?php echo $script_text; ?>" |
|
| 2563 | + title="<?php echo $add_favourite_text; ?>"><i |
|
| 2564 | + class="<?php echo $favourite_icon; ?>"></i> <?php echo $favourite_text; ?></a></span> |
|
| 2565 | 2565 | <?php } |
| 2566 | 2566 | } |
| 2567 | 2567 | } |
@@ -2591,7 +2591,7 @@ discard block |
||
| 2591 | 2591 | |
| 2592 | 2592 | $post_type = $taxonomy_obj->object_type[0]; |
| 2593 | 2593 | |
| 2594 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2594 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2595 | 2595 | |
| 2596 | 2596 | /** |
| 2597 | 2597 | * Filter to modify the 'join' query |
@@ -2614,8 +2614,8 @@ discard block |
||
| 2614 | 2614 | $where = apply_filters('geodir_cat_post_count_where', $where, $term);
|
| 2615 | 2615 | |
| 2616 | 2616 | $count_query = "SELECT count(post_id) FROM |
| 2617 | - " . $table . " as pd " . $join . " |
|
| 2618 | - WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id . "'," . $term->taxonomy . ") " . $where;
|
|
| 2617 | + " . $table." as pd ".$join." |
|
| 2618 | + WHERE pd.post_status='publish' AND FIND_IN_SET('" . $term->term_id."',".$term->taxonomy.") ".$where;
|
|
| 2619 | 2619 | |
| 2620 | 2620 | $cat_post_count = $wpdb->get_var($count_query); |
| 2621 | 2621 | if (empty($cat_post_count) || is_wp_error($cat_post_count)) |
@@ -2698,13 +2698,13 @@ discard block |
||
| 2698 | 2698 | global $post; |
| 2699 | 2699 | $all_postypes = geodir_get_posttypes(); |
| 2700 | 2700 | if (is_array($all_postypes) && in_array($post->post_type, $all_postypes)) {
|
| 2701 | - $out = ' <a class="excerpt-read-more" href="' . get_permalink($post->ID) . '" title="' . get_the_title($post->ID) . '">'; |
|
| 2701 | + $out = ' <a class="excerpt-read-more" href="'.get_permalink($post->ID).'" title="'.get_the_title($post->ID).'">'; |
|
| 2702 | 2702 | /** |
| 2703 | 2703 | * Filter excerpt read more text. |
| 2704 | 2704 | * |
| 2705 | 2705 | * @since 1.0.0 |
| 2706 | 2706 | */ |
| 2707 | - $out .= apply_filters( 'geodir_max_excerpt_end', __( 'Read more [...]', 'geodirectory' ) ); |
|
| 2707 | + $out .= apply_filters('geodir_max_excerpt_end', __('Read more [...]', 'geodirectory'));
|
|
| 2708 | 2708 | $out .= '</a>'; |
| 2709 | 2709 | return $out; |
| 2710 | 2710 | } |
@@ -2733,14 +2733,14 @@ discard block |
||
| 2733 | 2733 | if (is_array($gd_taxonomies) && in_array($taxonomy, $gd_taxonomies)) {
|
| 2734 | 2734 | |
| 2735 | 2735 | $geodir_post_type = geodir_get_taxonomy_posttype($taxonomy); |
| 2736 | - $table = $plugin_prefix . $geodir_post_type . '_detail'; |
|
| 2736 | + $table = $plugin_prefix.$geodir_post_type.'_detail'; |
|
| 2737 | 2737 | |
| 2738 | 2738 | $path_parts = pathinfo($_REQUEST['ct_cat_icon']['src']); |
| 2739 | - $term_icon = $path_parts['dirname'] . '/cat_icon_' . $term_id . '.png'; |
|
| 2739 | + $term_icon = $path_parts['dirname'].'/cat_icon_'.$term_id.'.png'; |
|
| 2740 | 2740 | |
| 2741 | 2741 | $posts = $wpdb->get_results( |
| 2742 | 2742 | $wpdb->prepare( |
| 2743 | - "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM " . $table . " WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2743 | + "SELECT post_id,post_title,post_latitude,post_longitude,default_category FROM ".$table." WHERE FIND_IN_SET(%s,%1\$s ) ", |
|
| 2744 | 2744 | array($term_id, $taxonomy) |
| 2745 | 2745 | ) |
| 2746 | 2746 | ); |
@@ -2752,19 +2752,19 @@ discard block |
||
| 2752 | 2752 | $lng = $post_obj->post_longitude; |
| 2753 | 2753 | |
| 2754 | 2754 | $json = '{';
|
| 2755 | - $json .= '"id":"' . $post_obj->post_id . '",'; |
|
| 2756 | - $json .= '"lat_pos": "' . $lat . '",'; |
|
| 2757 | - $json .= '"long_pos": "' . $lng . '",'; |
|
| 2758 | - $json .= '"marker_id":"' . $post_obj->post_id . '_' . $term_id . '",'; |
|
| 2759 | - $json .= '"icon":"' . $term_icon . '",'; |
|
| 2760 | - $json .= '"group":"catgroup' . $term_id . '"'; |
|
| 2755 | + $json .= '"id":"'.$post_obj->post_id.'",'; |
|
| 2756 | + $json .= '"lat_pos": "'.$lat.'",'; |
|
| 2757 | + $json .= '"long_pos": "'.$lng.'",'; |
|
| 2758 | + $json .= '"marker_id":"'.$post_obj->post_id.'_'.$term_id.'",'; |
|
| 2759 | + $json .= '"icon":"'.$term_icon.'",'; |
|
| 2760 | + $json .= '"group":"catgroup'.$term_id.'"'; |
|
| 2761 | 2761 | $json .= '}'; |
| 2762 | 2762 | |
| 2763 | 2763 | if ($post_obj->default_category == $term_id) {
|
| 2764 | 2764 | |
| 2765 | 2765 | $wpdb->query( |
| 2766 | 2766 | $wpdb->prepare( |
| 2767 | - "UPDATE " . $table . " SET marker_json = %s where post_id = %d", |
|
| 2767 | + "UPDATE ".$table." SET marker_json = %s where post_id = %d", |
|
| 2768 | 2768 | array($json, $post_obj->post_id) |
| 2769 | 2769 | ) |
| 2770 | 2770 | ); |
@@ -2772,7 +2772,7 @@ discard block |
||
| 2772 | 2772 | |
| 2773 | 2773 | $wpdb->query( |
| 2774 | 2774 | $wpdb->prepare( |
| 2775 | - "UPDATE " . GEODIR_ICON_TABLE . " SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2775 | + "UPDATE ".GEODIR_ICON_TABLE." SET json = %s WHERE post_id = %d AND cat_id = %d", |
|
| 2776 | 2776 | array($json, $post_obj->post_id, $term_id) |
| 2777 | 2777 | ) |
| 2778 | 2778 | ); |
@@ -2860,7 +2860,7 @@ discard block |
||
| 2860 | 2860 | * @param bool $exclude_admin Do you want to exclude admin from the check?. Default true. |
| 2861 | 2861 | * return bool |
| 2862 | 2862 | */ |
| 2863 | - return apply_filters('geodir_listing_belong_to_current_user',$result,$listing_id,$current_user->ID,$exclude_admin);
|
|
| 2863 | + return apply_filters('geodir_listing_belong_to_current_user', $result, $listing_id, $current_user->ID, $exclude_admin);
|
|
| 2864 | 2864 | } |
| 2865 | 2865 | |
| 2866 | 2866 | |
@@ -2908,7 +2908,7 @@ discard block |
||
| 2908 | 2908 | // print_r($uploads ) ; |
| 2909 | 2909 | $post_first_image = $wpdb->get_results( |
| 2910 | 2910 | $wpdb->prepare( |
| 2911 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2911 | + "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE post_id = %d and menu_order = 1 ", array($post_id) |
|
| 2912 | 2912 | ) |
| 2913 | 2913 | ); |
| 2914 | 2914 | |
@@ -2929,9 +2929,9 @@ discard block |
||
| 2929 | 2929 | |
| 2930 | 2930 | $post_type = get_post_type($post_id); |
| 2931 | 2931 | |
| 2932 | - $table_name = $plugin_prefix . $post_type . '_detail'; |
|
| 2932 | + $table_name = $plugin_prefix.$post_type.'_detail'; |
|
| 2933 | 2933 | |
| 2934 | - $wpdb->query("UPDATE " . $table_name . " SET featured_image='" . $post_first_image[0]->file . "' WHERE post_id =" . $post_id);
|
|
| 2934 | + $wpdb->query("UPDATE ".$table_name." SET featured_image='".$post_first_image[0]->file."' WHERE post_id =".$post_id);
|
|
| 2935 | 2935 | |
| 2936 | 2936 | $new_attachment_name = basename($post_first_image[0]->file); |
| 2937 | 2937 | |
@@ -2944,11 +2944,11 @@ discard block |
||
| 2944 | 2944 | wp_delete_attachment($post_thumbnail_id); |
| 2945 | 2945 | |
| 2946 | 2946 | } |
| 2947 | - $filename = $uploads['basedir'] . $post_first_image[0]->file; |
|
| 2947 | + $filename = $uploads['basedir'].$post_first_image[0]->file; |
|
| 2948 | 2948 | |
| 2949 | 2949 | $attachment = array( |
| 2950 | 2950 | 'post_mime_type' => $post_first_image[0]->mime_type, |
| 2951 | - 'guid' => $uploads['baseurl'] . $post_first_image[0]->file, |
|
| 2951 | + 'guid' => $uploads['baseurl'].$post_first_image[0]->file, |
|
| 2952 | 2952 | 'post_parent' => $post_id, |
| 2953 | 2953 | 'post_title' => preg_replace('/\.[^.]+$/', '', $post_first_image[0]->title),
|
| 2954 | 2954 | 'post_content' => '' |
@@ -2961,7 +2961,7 @@ discard block |
||
| 2961 | 2961 | |
| 2962 | 2962 | set_post_thumbnail($post_id, $id); |
| 2963 | 2963 | |
| 2964 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
| 2964 | + require_once(ABSPATH.'wp-admin/includes/image.php'); |
|
| 2965 | 2965 | wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $filename)); |
| 2966 | 2966 | |
| 2967 | 2967 | } |
@@ -2994,35 +2994,35 @@ discard block |
||
| 2994 | 2994 | $post_id = absint($_POST['post_id']); |
| 2995 | 2995 | $upload_dir = wp_upload_dir(); |
| 2996 | 2996 | $post_type = get_post_type($_POST['post_id']); |
| 2997 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2997 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2998 | 2998 | |
| 2999 | 2999 | $post_arr = $wpdb->get_results($wpdb->prepare( |
| 3000 | - "SELECT * FROM $wpdb->posts p JOIN " . $table . " gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 3000 | + "SELECT * FROM $wpdb->posts p JOIN ".$table." gd ON gd.post_id=p.ID WHERE p.ID=%d LIMIT 1", |
|
| 3001 | 3001 | array($post_id) |
| 3002 | 3002 | ) |
| 3003 | 3003 | , ARRAY_A); |
| 3004 | 3004 | |
| 3005 | 3005 | $arrImages = $wpdb->get_results( |
| 3006 | 3006 | $wpdb->prepare( |
| 3007 | - "SELECT * FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 3007 | + "SELECT * FROM ".GEODIR_ATTACHMENT_TABLE." WHERE mime_type like %s AND post_id = %d ORDER BY menu_order ASC, ID DESC ", |
|
| 3008 | 3008 | array('%image%', $post_id)
|
| 3009 | 3009 | ) |
| 3010 | 3010 | ); |
| 3011 | 3011 | if ($arrImages) {
|
| 3012 | 3012 | $image_arr = array(); |
| 3013 | 3013 | foreach ($arrImages as $img) {
|
| 3014 | - $image_arr[] = $upload_dir['baseurl'] . $img->file; |
|
| 3014 | + $image_arr[] = $upload_dir['baseurl'].$img->file; |
|
| 3015 | 3015 | } |
| 3016 | 3016 | $comma_separated = implode(",", $image_arr);
|
| 3017 | 3017 | $post_arr[0]['post_images'] = $comma_separated; |
| 3018 | 3018 | } |
| 3019 | 3019 | |
| 3020 | 3020 | |
| 3021 | - $cats = $post_arr[0][$post_arr[0]['post_type'] . 'category']; |
|
| 3021 | + $cats = $post_arr[0][$post_arr[0]['post_type'].'category']; |
|
| 3022 | 3022 | $cat_arr = array_filter(explode(",", $cats));
|
| 3023 | 3023 | $trans_cat = array(); |
| 3024 | 3024 | foreach ($cat_arr as $cat) {
|
| 3025 | - $trans_cat[] = geodir_wpml_object_id($cat, $post_arr[0]['post_type'] . 'category', false); |
|
| 3025 | + $trans_cat[] = geodir_wpml_object_id($cat, $post_arr[0]['post_type'].'category', false); |
|
| 3026 | 3026 | } |
| 3027 | 3027 | |
| 3028 | 3028 | |
@@ -3064,7 +3064,7 @@ discard block |
||
| 3064 | 3064 | |
| 3065 | 3065 | $get_data = $wpdb->get_results( |
| 3066 | 3066 | $wpdb->prepare( |
| 3067 | - "SELECT htmlvar_name, field_type, extra_fields FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type=%s AND is_active='1'", |
|
| 3067 | + "SELECT htmlvar_name, field_type, extra_fields FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type=%s AND is_active='1'", |
|
| 3068 | 3068 | array($listing_type) |
| 3069 | 3069 | ) |
| 3070 | 3070 | ); |
@@ -3077,12 +3077,12 @@ discard block |
||
| 3077 | 3077 | |
| 3078 | 3078 | $extra_fields = unserialize($data->extra_fields); |
| 3079 | 3079 | |
| 3080 | - $prefix = $data->htmlvar_name . '_'; |
|
| 3080 | + $prefix = $data->htmlvar_name.'_'; |
|
| 3081 | 3081 | |
| 3082 | - $fields_info[$prefix . 'address'] = $data->field_type; |
|
| 3082 | + $fields_info[$prefix.'address'] = $data->field_type; |
|
| 3083 | 3083 | |
| 3084 | 3084 | if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) |
| 3085 | - $fields_info[$prefix . 'zip'] = $data->field_type; |
|
| 3085 | + $fields_info[$prefix.'zip'] = $data->field_type; |
|
| 3086 | 3086 | |
| 3087 | 3087 | } else {
|
| 3088 | 3088 | |
@@ -3181,18 +3181,18 @@ discard block |
||
| 3181 | 3181 | * @since 1.6.22 Added image from location page. |
| 3182 | 3182 | * @package GeoDirectory |
| 3183 | 3183 | */ |
| 3184 | -function geodir_fb_like_thumbnail(){
|
|
| 3184 | +function geodir_fb_like_thumbnail() {
|
|
| 3185 | 3185 | |
| 3186 | 3186 | $facebook_image = ''; |
| 3187 | 3187 | |
| 3188 | - if(is_single()){// single post
|
|
| 3188 | + if (is_single()) {// single post
|
|
| 3189 | 3189 | global $post; |
| 3190 | - if(isset($post->featured_image) && $post->featured_image){
|
|
| 3190 | + if (isset($post->featured_image) && $post->featured_image) {
|
|
| 3191 | 3191 | $upload_dir = wp_upload_dir(); |
| 3192 | 3192 | $facebook_image = $upload_dir['baseurl'].$post->featured_image; |
| 3193 | 3193 | |
| 3194 | 3194 | } |
| 3195 | - }elseif(geodir_is_page('location')){// location page
|
|
| 3195 | + }elseif (geodir_is_page('location')) {// location page
|
|
| 3196 | 3196 | if (function_exists('geodir_get_location_seo')) {
|
| 3197 | 3197 | $seo = geodir_get_location_seo(); |
| 3198 | 3198 | if (isset($seo->seo_image) && $seo->seo_image) {
|
@@ -3201,11 +3201,11 @@ discard block |
||
| 3201 | 3201 | } |
| 3202 | 3202 | } |
| 3203 | 3203 | |
| 3204 | - if(!$facebook_image){
|
|
| 3204 | + if (!$facebook_image) {
|
|
| 3205 | 3205 | global $post; |
| 3206 | 3206 | |
| 3207 | - if (has_post_thumbnail( $post->ID ) ){
|
|
| 3208 | - $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); |
|
| 3207 | + if (has_post_thumbnail($post->ID)) {
|
|
| 3208 | + $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'full'); |
|
| 3209 | 3209 | $facebook_image = isset($image[0]) ? $image[0] : ''; |
| 3210 | 3210 | } |
| 3211 | 3211 | } |
@@ -3218,16 +3218,16 @@ discard block |
||
| 3218 | 3218 | * @since 1.6.22 |
| 3219 | 3219 | * @param string $facebook_image The image URL or blank. |
| 3220 | 3220 | */ |
| 3221 | - $facebook_image = apply_filters('geodir_fb_share_image',$facebook_image);
|
|
| 3221 | + $facebook_image = apply_filters('geodir_fb_share_image', $facebook_image);
|
|
| 3222 | 3222 | |
| 3223 | - if($facebook_image){
|
|
| 3223 | + if ($facebook_image) {
|
|
| 3224 | 3224 | echo "\n\n<!-- GD Facebook Like Thumbnail -->\n<link rel=\"image_src\" href=\"$facebook_image\" />\n<!-- End GD Facebook Like Thumbnail -->\n\n"; |
| 3225 | 3225 | } |
| 3226 | 3226 | |
| 3227 | 3227 | |
| 3228 | 3228 | } |
| 3229 | 3229 | |
| 3230 | -add_action( 'save_post', 'geodir_clear_map_cache_on_save', 10,2 ); |
|
| 3230 | +add_action('save_post', 'geodir_clear_map_cache_on_save', 10, 2);
|
|
| 3231 | 3231 | |
| 3232 | 3232 | |
| 3233 | 3233 | /** |
@@ -3235,10 +3235,10 @@ discard block |
||
| 3235 | 3235 | * |
| 3236 | 3236 | * @since 1.6.22 |
| 3237 | 3237 | */ |
| 3238 | -function geodir_delete_map_cache(){
|
|
| 3238 | +function geodir_delete_map_cache() {
|
|
| 3239 | 3239 | $files = glob(realpath(dirname(__FILE__))."/map-functions/map-cache/*.json"); // get all file names |
| 3240 | - foreach($files as $file){ // iterate files
|
|
| 3241 | - if(is_file($file)) |
|
| 3240 | + foreach ($files as $file) { // iterate files
|
|
| 3241 | + if (is_file($file)) |
|
| 3242 | 3242 | unlink($file); // delete file |
| 3243 | 3243 | } |
| 3244 | 3244 | } |
@@ -3253,21 +3253,21 @@ discard block |
||
| 3253 | 3253 | */ |
| 3254 | 3254 | function geodir_clear_map_cache_on_save($post_id, $post) {
|
| 3255 | 3255 | |
| 3256 | - if(!get_option('geodir_enable_map_cache')){
|
|
| 3256 | + if (!get_option('geodir_enable_map_cache')) {
|
|
| 3257 | 3257 | return; |
| 3258 | 3258 | } |
| 3259 | 3259 | |
| 3260 | - if ( isset( $post->post_type ) && ( $post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post' ) ) {
|
|
| 3260 | + if (isset($post->post_type) && ($post->post_type == 'nav_menu_item' || $post->post_type == 'page' || $post->post_type == 'post')) {
|
|
| 3261 | 3261 | return; |
| 3262 | 3262 | } |
| 3263 | 3263 | |
| 3264 | 3264 | $geodir_posttypes = geodir_get_posttypes(); |
| 3265 | 3265 | |
| 3266 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
| 3266 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
|
| 3267 | 3267 | return; |
| 3268 | 3268 | } |
| 3269 | 3269 | |
| 3270 | - if ( ! wp_is_post_revision( $post_id ) && isset( $post->post_type ) && in_array( $post->post_type, $geodir_posttypes ) ) {
|
|
| 3270 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 3271 | 3271 | geodir_delete_map_cache(); |
| 3272 | 3272 | } |
| 3273 | 3273 | |
@@ -3283,20 +3283,20 @@ discard block |
||
| 3283 | 3283 | * @param array $postarr An array of sanitized, but otherwise unmodified post data. |
| 3284 | 3284 | * @return array Filtered post data. |
| 3285 | 3285 | */ |
| 3286 | -function geodir_fix_pending_listing_post_name( $data, $postarr ) {
|
|
| 3286 | +function geodir_fix_pending_listing_post_name($data, $postarr) {
|
|
| 3287 | 3287 | // Dont' update post name for autosaves |
| 3288 | - if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
|
|
| 3288 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
|
|
| 3289 | 3289 | return $data; |
| 3290 | 3290 | } |
| 3291 | 3291 | |
| 3292 | - if ( !empty( $data['post_name'] ) || empty( $data['post_status'] ) || empty( $data['post_type'] ) || empty( $data['post_title'] ) ) {
|
|
| 3292 | + if (!empty($data['post_name']) || empty($data['post_status']) || empty($data['post_type']) || empty($data['post_title'])) {
|
|
| 3293 | 3293 | return $data; |
| 3294 | 3294 | } |
| 3295 | 3295 | |
| 3296 | - if ( ( 'draft' == $data['post_status'] || 'pending' == $data['post_status'] ) && in_array( $data['post_type'], geodir_get_posttypes() ) ) {
|
|
| 3297 | - $data['post_name'] = wp_unique_post_slug( sanitize_title( $data['post_title'] ), ( !empty( $postarr['ID'] ) ? $postarr['ID'] : 0 ), '', $data['post_type'], $data['post_parent'] ); |
|
| 3296 | + if (('draft' == $data['post_status'] || 'pending' == $data['post_status']) && in_array($data['post_type'], geodir_get_posttypes())) {
|
|
| 3297 | + $data['post_name'] = wp_unique_post_slug(sanitize_title($data['post_title']), (!empty($postarr['ID']) ? $postarr['ID'] : 0), '', $data['post_type'], $data['post_parent']); |
|
| 3298 | 3298 | } |
| 3299 | 3299 | |
| 3300 | 3300 | return $data; |
| 3301 | 3301 | } |
| 3302 | -add_filter( 'wp_insert_post_data', 'geodir_fix_pending_listing_post_name', 10, 2 ); |
|
| 3303 | 3302 | \ No newline at end of file |
| 3303 | +add_filter('wp_insert_post_data', 'geodir_fix_pending_listing_post_name', 10, 2); |
|
| 3304 | 3304 | \ No newline at end of file |
@@ -13,133 +13,133 @@ discard block |
||
| 13 | 13 | * @package GeoDirectory |
| 14 | 14 | */ |
| 15 | 15 | function geodir_deactivation() {
|
| 16 | - // Update installed variable |
|
| 17 | - update_option("geodir_installed", 0);
|
|
| 16 | + // Update installed variable |
|
| 17 | + update_option("geodir_installed", 0);
|
|
| 18 | 18 | |
| 19 | - // Remove rewrite rules and then recreate rewrite rules. |
|
| 20 | - flush_rewrite_rules(); |
|
| 19 | + // Remove rewrite rules and then recreate rewrite rules. |
|
| 20 | + flush_rewrite_rules(); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | if (!function_exists('geodir_admin_styles')) {
|
| 24 | - /** |
|
| 25 | - * Enqueue Admin Styles. |
|
| 26 | - * |
|
| 27 | - * @since 1.0.0 |
|
| 28 | - * @package GeoDirectory |
|
| 29 | - */ |
|
| 30 | - function geodir_admin_styles() {
|
|
| 31 | - wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 32 | - wp_enqueue_style('geodirectory-admin-css');
|
|
| 24 | + /** |
|
| 25 | + * Enqueue Admin Styles. |
|
| 26 | + * |
|
| 27 | + * @since 1.0.0 |
|
| 28 | + * @package GeoDirectory |
|
| 29 | + */ |
|
| 30 | + function geodir_admin_styles() {
|
|
| 31 | + wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION);
|
|
| 32 | + wp_enqueue_style('geodirectory-admin-css');
|
|
| 33 | 33 | |
| 34 | - wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 35 | - wp_enqueue_style('geodirectory-frontend-style');
|
|
| 34 | + wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION);
|
|
| 35 | + wp_enqueue_style('geodirectory-frontend-style');
|
|
| 36 | 36 | |
| 37 | - wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 38 | - wp_enqueue_style('geodir-chosen-style');
|
|
| 37 | + wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION);
|
|
| 38 | + wp_enqueue_style('geodir-chosen-style');
|
|
| 39 | 39 | |
| 40 | - wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 41 | - wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 40 | + wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION);
|
|
| 41 | + wp_enqueue_style('geodirectory-jquery-ui-timepicker-css');
|
|
| 42 | 42 | |
| 43 | - wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 44 | - wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 43 | + wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION);
|
|
| 44 | + wp_enqueue_style('geodirectory-jquery-ui-css');
|
|
| 45 | 45 | |
| 46 | - wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 47 | - wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 46 | + wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION);
|
|
| 47 | + wp_enqueue_style('geodirectory-custom-fields-css');
|
|
| 48 | 48 | |
| 49 | - wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | - wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 49 | + wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION);
|
|
| 50 | + wp_enqueue_style('geodirectory-pluplodar-css');
|
|
| 51 | 51 | |
| 52 | - wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | - wp_enqueue_style('geodir-rating-style');
|
|
| 52 | + wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION);
|
|
| 53 | + wp_enqueue_style('geodir-rating-style');
|
|
| 54 | 54 | |
| 55 | - wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | - wp_enqueue_style('geodir-rtl-style');
|
|
| 57 | - } |
|
| 55 | + wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION);
|
|
| 56 | + wp_enqueue_style('geodir-rtl-style');
|
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | if (!function_exists('geodir_admin_styles_req')) {
|
| 61 | - /** |
|
| 62 | - * Loads stylesheets from CDN. |
|
| 63 | - * |
|
| 64 | - * @since 1.0.0 |
|
| 65 | - * @package GeoDirectory |
|
| 66 | - */ |
|
| 67 | - function geodir_admin_styles_req() |
|
| 68 | - {
|
|
| 61 | + /** |
|
| 62 | + * Loads stylesheets from CDN. |
|
| 63 | + * |
|
| 64 | + * @since 1.0.0 |
|
| 65 | + * @package GeoDirectory |
|
| 66 | + */ |
|
| 67 | + function geodir_admin_styles_req() |
|
| 68 | + {
|
|
| 69 | 69 | |
| 70 | - wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | - wp_enqueue_style('font-awesome');
|
|
| 70 | + wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 71 | + wp_enqueue_style('font-awesome');
|
|
| 72 | 72 | |
| 73 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 74 | - wp_enqueue_script('geodirectory-admin');
|
|
| 73 | + wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 74 | + wp_enqueue_script('geodirectory-admin');
|
|
| 75 | 75 | |
| 76 | - } |
|
| 76 | + } |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | if (!function_exists('geodir_admin_scripts')) {
|
| 80 | - /** |
|
| 81 | - * Enqueue Admin Scripts. |
|
| 82 | - * |
|
| 83 | - * @since 1.0.0 |
|
| 84 | - * @package GeoDirectory |
|
| 85 | - */ |
|
| 86 | - function geodir_admin_scripts() |
|
| 87 | - {
|
|
| 88 | - $geodir_map_name = geodir_map_name(); |
|
| 80 | + /** |
|
| 81 | + * Enqueue Admin Scripts. |
|
| 82 | + * |
|
| 83 | + * @since 1.0.0 |
|
| 84 | + * @package GeoDirectory |
|
| 85 | + */ |
|
| 86 | + function geodir_admin_scripts() |
|
| 87 | + {
|
|
| 88 | + $geodir_map_name = geodir_map_name(); |
|
| 89 | 89 | |
| 90 | - wp_enqueue_script('jquery');
|
|
| 90 | + wp_enqueue_script('jquery');
|
|
| 91 | 91 | |
| 92 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 92 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true);
|
|
| 93 | 93 | |
| 94 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 95 | - wp_enqueue_script('chosen');
|
|
| 94 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION);
|
|
| 95 | + wp_enqueue_script('chosen');
|
|
| 96 | 96 | |
| 97 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 98 | - wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 97 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION);
|
|
| 98 | + wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 99 | 99 | |
| 100 | - if (isset($_REQUEST['listing_type'])) {
|
|
| 101 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 102 | - } |
|
| 100 | + if (isset($_REQUEST['listing_type'])) {
|
|
| 101 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION);
|
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 105 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 104 | + wp_enqueue_script('geodirectory-custom-fields-script');
|
|
| 105 | + $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
| 106 | 106 | |
| 107 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 107 | + wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true);
|
|
| 108 | 108 | |
| 109 | - if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 110 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 111 | - $map_key = "&key=" . geodir_get_map_api_key(); |
|
| 112 | - /** This filter is documented in geodirectory_template_tags.php */ |
|
| 113 | - $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 114 | - wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
|
|
| 109 | + if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 110 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 111 | + $map_key = "&key=" . geodir_get_map_api_key(); |
|
| 112 | + /** This filter is documented in geodirectory_template_tags.php */ |
|
| 113 | + $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 114 | + wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
|
|
| 115 | 115 | |
| 116 | - // Overlapping Marker Spiderfier |
|
| 117 | - wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 118 | - wp_enqueue_script('geodirectory-g-overlappingmarker-script');
|
|
| 119 | - } |
|
| 116 | + // Overlapping Marker Spiderfier |
|
| 117 | + wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 118 | + wp_enqueue_script('geodirectory-g-overlappingmarker-script');
|
|
| 119 | + } |
|
| 120 | 120 | |
| 121 | - if ($geodir_map_name == 'osm') {
|
|
| 122 | - // Leaflet OpenStreetMap |
|
| 123 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 124 | - wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 121 | + if ($geodir_map_name == 'osm') {
|
|
| 122 | + // Leaflet OpenStreetMap |
|
| 123 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 124 | + wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 125 | 125 | |
| 126 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 127 | - wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 126 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 127 | + wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 128 | 128 | |
| 129 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 130 | - wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 129 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 130 | + wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 131 | 131 | |
| 132 | - // Overlapping Marker Spiderfier Leaflet |
|
| 133 | - wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 134 | - wp_enqueue_script('geodirectory-o-overlappingmarker-script');
|
|
| 135 | - } |
|
| 136 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 132 | + // Overlapping Marker Spiderfier Leaflet |
|
| 133 | + wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 134 | + wp_enqueue_script('geodirectory-o-overlappingmarker-script');
|
|
| 135 | + } |
|
| 136 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 137 | 137 | |
| 138 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 139 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 138 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 139 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 140 | 140 | |
| 141 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 142 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 141 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 142 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 143 | 143 | |
| 144 | 144 | // font awesome rating script |
| 145 | 145 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
@@ -150,166 +150,166 @@ discard block |
||
| 150 | 150 | wp_enqueue_script('geodir-jRating-js');
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 154 | - wp_enqueue_script('geodir-on-document-load');
|
|
| 155 | - |
|
| 156 | - |
|
| 157 | - // SCRIPT FOR UPLOAD |
|
| 158 | - wp_enqueue_script('plupload-all');
|
|
| 159 | - wp_enqueue_script('jquery-ui-sortable');
|
|
| 160 | - |
|
| 161 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 162 | - wp_enqueue_script('geodirectory-plupload-script');
|
|
| 163 | - |
|
| 164 | - // SCRIPT FOR UPLOAD END |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - // place js config array for plupload |
|
| 168 | - $plupload_init = array( |
|
| 169 | - 'runtimes' => 'html5,silverlight,html4', |
|
| 170 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 171 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 172 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 173 | - 'multiple_queues' => true, |
|
| 174 | - 'max_file_size' => geodir_max_upload_size(), |
|
| 175 | - 'url' => admin_url('admin-ajax.php'),
|
|
| 176 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 177 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 178 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 179 | - 'multipart' => true, |
|
| 180 | - 'urlstream_upload' => true, |
|
| 181 | - 'multi_selection' => false, // will be added per uploader |
|
| 182 | - // additional post data to send to our ajax hook |
|
| 183 | - 'multipart_params' => array( |
|
| 184 | - '_ajax_nonce' => "", // will be added per uploader |
|
| 185 | - 'action' => 'plupload_action', // the ajax action name |
|
| 186 | - 'imgid' => 0 // will be added per uploader |
|
| 187 | - ) |
|
| 188 | - ); |
|
| 189 | - $base_plupload_config = json_encode($plupload_init); |
|
| 190 | - |
|
| 191 | - |
|
| 192 | - $thumb_img_arr = array(); |
|
| 193 | - |
|
| 194 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 195 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 196 | - |
|
| 197 | - $totImg = ''; |
|
| 198 | - $image_limit = ''; |
|
| 199 | - if (!empty($thumb_img_arr)) {
|
|
| 200 | - $totImg = count($thumb_img_arr); |
|
| 201 | - } |
|
| 153 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 154 | + wp_enqueue_script('geodir-on-document-load');
|
|
| 155 | + |
|
| 156 | + |
|
| 157 | + // SCRIPT FOR UPLOAD |
|
| 158 | + wp_enqueue_script('plupload-all');
|
|
| 159 | + wp_enqueue_script('jquery-ui-sortable');
|
|
| 160 | + |
|
| 161 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 162 | + wp_enqueue_script('geodirectory-plupload-script');
|
|
| 163 | + |
|
| 164 | + // SCRIPT FOR UPLOAD END |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + // place js config array for plupload |
|
| 168 | + $plupload_init = array( |
|
| 169 | + 'runtimes' => 'html5,silverlight,html4', |
|
| 170 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 171 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 172 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 173 | + 'multiple_queues' => true, |
|
| 174 | + 'max_file_size' => geodir_max_upload_size(), |
|
| 175 | + 'url' => admin_url('admin-ajax.php'),
|
|
| 176 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 177 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 178 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 179 | + 'multipart' => true, |
|
| 180 | + 'urlstream_upload' => true, |
|
| 181 | + 'multi_selection' => false, // will be added per uploader |
|
| 182 | + // additional post data to send to our ajax hook |
|
| 183 | + 'multipart_params' => array( |
|
| 184 | + '_ajax_nonce' => "", // will be added per uploader |
|
| 185 | + 'action' => 'plupload_action', // the ajax action name |
|
| 186 | + 'imgid' => 0 // will be added per uploader |
|
| 187 | + ) |
|
| 188 | + ); |
|
| 189 | + $base_plupload_config = json_encode($plupload_init); |
|
| 190 | + |
|
| 191 | + |
|
| 192 | + $thumb_img_arr = array(); |
|
| 193 | + |
|
| 194 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 195 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 196 | + |
|
| 197 | + $totImg = ''; |
|
| 198 | + $image_limit = ''; |
|
| 199 | + if (!empty($thumb_img_arr)) {
|
|
| 200 | + $totImg = count($thumb_img_arr); |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 204 | - 'totalImg' => $totImg, |
|
| 205 | - 'image_limit' => $image_limit, |
|
| 206 | - 'upload_img_size' => geodir_max_upload_size()); |
|
| 203 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 204 | + 'totalImg' => $totImg, |
|
| 205 | + 'image_limit' => $image_limit, |
|
| 206 | + 'upload_img_size' => geodir_max_upload_size()); |
|
| 207 | 207 | |
| 208 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 208 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 209 | 209 | |
| 210 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 211 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 210 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 211 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 212 | 212 | |
| 213 | 213 | |
| 214 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 215 | - wp_enqueue_script('geodirectory-admin-script');
|
|
| 214 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 215 | + wp_enqueue_script('geodirectory-admin-script');
|
|
| 216 | 216 | |
| 217 | - wp_enqueue_style('farbtastic');
|
|
| 218 | - wp_enqueue_script('farbtastic');
|
|
| 217 | + wp_enqueue_style('farbtastic');
|
|
| 218 | + wp_enqueue_script('farbtastic');
|
|
| 219 | 219 | |
| 220 | - $screen = get_current_screen(); |
|
| 221 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 222 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 223 | - } |
|
| 220 | + $screen = get_current_screen(); |
|
| 221 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 222 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 223 | + } |
|
| 224 | 224 | |
| 225 | - $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
|
|
| 226 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 225 | + $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
|
|
| 226 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 227 | 227 | |
| 228 | - } |
|
| 228 | + } |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | if (!function_exists('geodir_admin_menu')) {
|
| 232 | - /** |
|
| 233 | - * Admin Menus |
|
| 234 | - * |
|
| 235 | - * Sets up the admin menus in wordpress. |
|
| 236 | - * |
|
| 237 | - * @since 1.0.0 |
|
| 238 | - * @package GeoDirectory |
|
| 239 | - * @global array $menu Menu array. |
|
| 240 | - * @global object $geodirectory GeoDirectory plugin object. |
|
| 241 | - */ |
|
| 242 | - function geodir_admin_menu() |
|
| 243 | - {
|
|
| 244 | - global $menu, $geodirectory; |
|
| 232 | + /** |
|
| 233 | + * Admin Menus |
|
| 234 | + * |
|
| 235 | + * Sets up the admin menus in wordpress. |
|
| 236 | + * |
|
| 237 | + * @since 1.0.0 |
|
| 238 | + * @package GeoDirectory |
|
| 239 | + * @global array $menu Menu array. |
|
| 240 | + * @global object $geodirectory GeoDirectory plugin object. |
|
| 241 | + */ |
|
| 242 | + function geodir_admin_menu() |
|
| 243 | + {
|
|
| 244 | + global $menu, $geodirectory; |
|
| 245 | 245 | |
| 246 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 246 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 247 | 247 | |
| 248 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 248 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 249 | 249 | |
| 250 | 250 | |
| 251 | - } |
|
| 251 | + } |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | if (!function_exists('geodir_admin_menu_order')) {
|
| 255 | - /** |
|
| 256 | - * Order admin menus. |
|
| 257 | - * |
|
| 258 | - * @since 1.0.0 |
|
| 259 | - * @package GeoDirectory |
|
| 260 | - * @param array $menu_order Menu order array. |
|
| 261 | - * @return array Modified menu order array. |
|
| 262 | - */ |
|
| 263 | - function geodir_admin_menu_order($menu_order) |
|
| 264 | - {
|
|
| 265 | - |
|
| 266 | - // Initialize our custom order array |
|
| 267 | - $geodir_menu_order = array(); |
|
| 268 | - |
|
| 269 | - // Get the index of our custom separator |
|
| 270 | - $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 271 | - |
|
| 272 | - // Get index of posttype menu |
|
| 273 | - $post_types = geodir_get_posttypes(); |
|
| 274 | - |
|
| 275 | - // Loop through menu order and do some rearranging |
|
| 276 | - foreach ($menu_order as $index => $item) : |
|
| 277 | - |
|
| 278 | - if ((('geodirectory') == $item)) :
|
|
| 279 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 280 | - if (!empty($post_types)) {
|
|
| 281 | - foreach ($post_types as $post_type) {
|
|
| 282 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 283 | - } |
|
| 284 | - } |
|
| 285 | - $geodir_menu_order[] = $item; |
|
| 255 | + /** |
|
| 256 | + * Order admin menus. |
|
| 257 | + * |
|
| 258 | + * @since 1.0.0 |
|
| 259 | + * @package GeoDirectory |
|
| 260 | + * @param array $menu_order Menu order array. |
|
| 261 | + * @return array Modified menu order array. |
|
| 262 | + */ |
|
| 263 | + function geodir_admin_menu_order($menu_order) |
|
| 264 | + {
|
|
| 286 | 265 | |
| 287 | - unset($menu_order[$geodir_separator]); |
|
| 288 | - //unset( $menu_order[$geodir_places] ); |
|
| 289 | - elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 290 | - $geodir_menu_order[] = $item; |
|
| 291 | - endif; |
|
| 266 | + // Initialize our custom order array |
|
| 267 | + $geodir_menu_order = array(); |
|
| 292 | 268 | |
| 293 | - endforeach; |
|
| 269 | + // Get the index of our custom separator |
|
| 270 | + $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 294 | 271 | |
| 295 | - // Return order |
|
| 296 | - return $geodir_menu_order; |
|
| 297 | - } |
|
| 272 | + // Get index of posttype menu |
|
| 273 | + $post_types = geodir_get_posttypes(); |
|
| 274 | + |
|
| 275 | + // Loop through menu order and do some rearranging |
|
| 276 | + foreach ($menu_order as $index => $item) : |
|
| 277 | + |
|
| 278 | + if ((('geodirectory') == $item)) :
|
|
| 279 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 280 | + if (!empty($post_types)) {
|
|
| 281 | + foreach ($post_types as $post_type) {
|
|
| 282 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 283 | + } |
|
| 284 | + } |
|
| 285 | + $geodir_menu_order[] = $item; |
|
| 286 | + |
|
| 287 | + unset($menu_order[$geodir_separator]); |
|
| 288 | + //unset( $menu_order[$geodir_places] ); |
|
| 289 | + elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 290 | + $geodir_menu_order[] = $item; |
|
| 291 | + endif; |
|
| 292 | + |
|
| 293 | + endforeach; |
|
| 294 | + |
|
| 295 | + // Return order |
|
| 296 | + return $geodir_menu_order; |
|
| 297 | + } |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | if (!function_exists('geodir_admin_custom_menu_order')) {
|
| 301 | - /** |
|
| 302 | - * Enables custom menu order. |
|
| 303 | - * |
|
| 304 | - * @since 1.0.0 |
|
| 305 | - * @package GeoDirectory |
|
| 306 | - * @return bool |
|
| 307 | - */ |
|
| 308 | - function geodir_admin_custom_menu_order() |
|
| 309 | - {
|
|
| 310 | - if (!current_user_can('manage_options')) return false;
|
|
| 311 | - return true; |
|
| 312 | - } |
|
| 301 | + /** |
|
| 302 | + * Enables custom menu order. |
|
| 303 | + * |
|
| 304 | + * @since 1.0.0 |
|
| 305 | + * @package GeoDirectory |
|
| 306 | + * @return bool |
|
| 307 | + */ |
|
| 308 | + function geodir_admin_custom_menu_order() |
|
| 309 | + {
|
|
| 310 | + if (!current_user_can('manage_options')) return false;
|
|
| 311 | + return true; |
|
| 312 | + } |
|
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | /** |
@@ -320,51 +320,51 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | function geodir_before_admin_panel() |
| 322 | 322 | {
|
| 323 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 324 | - echo '<div id="message" class="updated fade"> |
|
| 323 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 324 | + echo '<div id="message" class="updated fade"> |
|
| 325 | 325 | <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p>
|
| 326 | 326 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
| 327 | 327 | </div>'; |
| 328 | 328 | |
| 329 | - } |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 332 | - switch ($_REQUEST['msg']) {
|
|
| 333 | - case 'success': |
|
| 334 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 335 | - flush_rewrite_rules(false); |
|
| 331 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 332 | + switch ($_REQUEST['msg']) {
|
|
| 333 | + case 'success': |
|
| 334 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 335 | + flush_rewrite_rules(false); |
|
| 336 | 336 | |
| 337 | - break; |
|
| 337 | + break; |
|
| 338 | 338 | case 'fail': |
| 339 | 339 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 340 | 340 | |
| 341 | 341 | if ($gderr == 21) |
| 342 | - 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>';
|
|
| 342 | + 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>';
|
|
| 343 | 343 | else |
| 344 | 344 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
| 345 | - break; |
|
| 346 | - } |
|
| 347 | - } |
|
| 345 | + break; |
|
| 346 | + } |
|
| 347 | + } |
|
| 348 | 348 | |
| 349 | - $geodir_load_map = get_option('geodir_load_map');
|
|
| 350 | - $need_map_key = false; |
|
| 351 | - if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
|
|
| 352 | - $need_map_key = true; |
|
| 353 | - } |
|
| 349 | + $geodir_load_map = get_option('geodir_load_map');
|
|
| 350 | + $need_map_key = false; |
|
| 351 | + if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
|
|
| 352 | + $need_map_key = true; |
|
| 353 | + } |
|
| 354 | 354 | |
| 355 | - if (!geodir_get_map_api_key() && $need_map_key) {
|
|
| 356 | - echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 357 | - } |
|
| 355 | + if (!geodir_get_map_api_key() && $need_map_key) {
|
|
| 356 | + echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - if (!geodir_is_default_location_set()) {
|
|
| 360 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 359 | + if (!geodir_is_default_location_set()) {
|
|
| 360 | + echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>';
|
|
| 361 | 361 | |
| 362 | - } |
|
| 362 | + } |
|
| 363 | 363 | |
| 364 | - if (!function_exists('curl_init')) {
|
|
| 365 | - echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 364 | + if (!function_exists('curl_init')) {
|
|
| 365 | + echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>';
|
|
| 366 | 366 | |
| 367 | - } |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | 369 | |
| 370 | 370 | |
@@ -381,19 +381,19 @@ discard block |
||
| 381 | 381 | */ |
| 382 | 382 | function geodir_handle_option_form_submit($current_tab) |
| 383 | 383 | {
|
| 384 | - global $geodir_settings; |
|
| 385 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 386 | - /** |
|
| 387 | - * Contains settings array for current tab. |
|
| 388 | - * |
|
| 389 | - * @since 1.0.0 |
|
| 390 | - * @package GeoDirectory |
|
| 391 | - */ |
|
| 392 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 393 | - } |
|
| 394 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 395 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 396 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 384 | + global $geodir_settings; |
|
| 385 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 386 | + /** |
|
| 387 | + * Contains settings array for current tab. |
|
| 388 | + * |
|
| 389 | + * @since 1.0.0 |
|
| 390 | + * @package GeoDirectory |
|
| 391 | + */ |
|
| 392 | + include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 393 | + } |
|
| 394 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 395 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 396 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 397 | 397 | |
| 398 | 398 | /** |
| 399 | 399 | * Fires before updating geodirectory admin settings. |
@@ -405,38 +405,38 @@ discard block |
||
| 405 | 405 | */ |
| 406 | 406 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 407 | 407 | |
| 408 | - if (!empty($geodir_settings[$current_tab])) |
|
| 409 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 408 | + if (!empty($geodir_settings[$current_tab])) |
|
| 409 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 410 | 410 | |
| 411 | - /** |
|
| 412 | - * Called after GeoDirectory options settings are updated. |
|
| 413 | - * |
|
| 414 | - * @since 1.0.0 |
|
| 415 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 416 | - * @see 'geodir_before_update_options' |
|
| 417 | - */ |
|
| 418 | - do_action('geodir_update_options', $geodir_settings);
|
|
| 411 | + /** |
|
| 412 | + * Called after GeoDirectory options settings are updated. |
|
| 413 | + * |
|
| 414 | + * @since 1.0.0 |
|
| 415 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 416 | + * @see 'geodir_before_update_options' |
|
| 417 | + */ |
|
| 418 | + do_action('geodir_update_options', $geodir_settings);
|
|
| 419 | 419 | |
| 420 | - /** |
|
| 421 | - * Called after GeoDirectory options settings are updated. |
|
| 422 | - * |
|
| 423 | - * Provides tab specific settings. |
|
| 424 | - * |
|
| 425 | - * @since 1.0.0 |
|
| 426 | - * @param string $current_tab The current settings tab name. |
|
| 427 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 428 | - */ |
|
| 429 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 420 | + /** |
|
| 421 | + * Called after GeoDirectory options settings are updated. |
|
| 422 | + * |
|
| 423 | + * Provides tab specific settings. |
|
| 424 | + * |
|
| 425 | + * @since 1.0.0 |
|
| 426 | + * @param string $current_tab The current settings tab name. |
|
| 427 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 428 | + */ |
|
| 429 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 430 | 430 | |
| 431 | - flush_rewrite_rules(false); |
|
| 431 | + flush_rewrite_rules(false); |
|
| 432 | 432 | |
| 433 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 433 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 434 | 434 | |
| 435 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 435 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 436 | 436 | |
| 437 | - wp_redirect($redirect_url); |
|
| 438 | - exit(); |
|
| 439 | - endif; |
|
| 437 | + wp_redirect($redirect_url); |
|
| 438 | + exit(); |
|
| 439 | + endif; |
|
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | } |
@@ -454,144 +454,144 @@ discard block |
||
| 454 | 454 | * @return bool Returns true if saved. |
| 455 | 455 | */ |
| 456 | 456 | function geodir_update_options($options, $dummy = false) {
|
| 457 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 457 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 458 | 458 | |
| 459 | - foreach ($options as $value) {
|
|
| 460 | - if ($dummy && isset($value['std'])) |
|
| 461 | - $_POST[$value['id']] = $value['std']; |
|
| 459 | + foreach ($options as $value) {
|
|
| 460 | + if ($dummy && isset($value['std'])) |
|
| 461 | + $_POST[$value['id']] = $value['std']; |
|
| 462 | 462 | |
| 463 | 463 | |
| 464 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 464 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 465 | 465 | |
| 466 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 467 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 468 | - } else {
|
|
| 469 | - update_option($value['id'], 0); |
|
| 470 | - } |
|
| 466 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 467 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 468 | + } else {
|
|
| 469 | + update_option($value['id'], 0); |
|
| 470 | + } |
|
| 471 | 471 | |
| 472 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 472 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 473 | 473 | |
| 474 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 475 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 476 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 477 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 478 | - update_option($value['id'] . '_crop', 1); |
|
| 479 | - else : |
|
| 480 | - update_option($value['id'] . '_crop', 0); |
|
| 481 | - endif; |
|
| 482 | - } else {
|
|
| 483 | - update_option($value['id'] . '_width', $value['std']); |
|
| 484 | - update_option($value['id'] . '_height', $value['std']); |
|
| 485 | - update_option($value['id'] . '_crop', 1); |
|
| 486 | - } |
|
| 474 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 475 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 476 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 477 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 478 | + update_option($value['id'] . '_crop', 1); |
|
| 479 | + else : |
|
| 480 | + update_option($value['id'] . '_crop', 0); |
|
| 481 | + endif; |
|
| 482 | + } else {
|
|
| 483 | + update_option($value['id'] . '_width', $value['std']); |
|
| 484 | + update_option($value['id'] . '_height', $value['std']); |
|
| 485 | + update_option($value['id'] . '_crop', 1); |
|
| 486 | + } |
|
| 487 | 487 | |
| 488 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 489 | - $post_types = array(); |
|
| 490 | - $categories = array(); |
|
| 488 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 489 | + $post_types = array(); |
|
| 490 | + $categories = array(); |
|
| 491 | 491 | |
| 492 | - if (!empty($_POST['home_map_post_types'])) : |
|
| 493 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 494 | - $post_types[] = $post_type; |
|
| 495 | - endforeach; |
|
| 496 | - endif; |
|
| 492 | + if (!empty($_POST['home_map_post_types'])) : |
|
| 493 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 494 | + $post_types[] = $post_type; |
|
| 495 | + endforeach; |
|
| 496 | + endif; |
|
| 497 | 497 | |
| 498 | - update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 498 | + update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 499 | 499 | |
| 500 | - if (!empty($_POST['post_category'])) : |
|
| 501 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 502 | - $categories[$texonomy] = array(); |
|
| 503 | - foreach ($cat_arr as $category) : |
|
| 504 | - $categories[$texonomy][] = $category; |
|
| 505 | - endforeach; |
|
| 506 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 507 | - endforeach; |
|
| 508 | - endif; |
|
| 509 | - update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 510 | - update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 511 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 500 | + if (!empty($_POST['post_category'])) : |
|
| 501 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 502 | + $categories[$texonomy] = array(); |
|
| 503 | + foreach ($cat_arr as $category) : |
|
| 504 | + $categories[$texonomy][] = $category; |
|
| 505 | + endforeach; |
|
| 506 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 507 | + endforeach; |
|
| 508 | + endif; |
|
| 509 | + update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 510 | + update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 511 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 512 | 512 | |
| 513 | 513 | |
| 514 | - if (!empty($_POST['geodir_default_map_language'])): |
|
| 515 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 516 | - endif; |
|
| 514 | + if (!empty($_POST['geodir_default_map_language'])): |
|
| 515 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 516 | + endif; |
|
| 517 | 517 | |
| 518 | 518 | |
| 519 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 520 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 521 | - endif; |
|
| 519 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 520 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 521 | + endif; |
|
| 522 | 522 | |
| 523 | 523 | |
| 524 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 524 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 525 | 525 | |
| 526 | 526 | |
| 527 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 527 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 528 | 528 | |
| 529 | - if (get_option($value['id'])) {
|
|
| 530 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 531 | - $noimg_name = end($image_name_arr); |
|
| 532 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 533 | - if (file_exists($img_path)) |
|
| 534 | - unlink($img_path); |
|
| 535 | - } |
|
| 529 | + if (get_option($value['id'])) {
|
|
| 530 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 531 | + $noimg_name = end($image_name_arr); |
|
| 532 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 533 | + if (file_exists($img_path)) |
|
| 534 | + unlink($img_path); |
|
| 535 | + } |
|
| 536 | 536 | |
| 537 | - update_option($value['id'], ''); |
|
| 538 | - } |
|
| 537 | + update_option($value['id'], ''); |
|
| 538 | + } |
|
| 539 | 539 | |
| 540 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 541 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 542 | - |
|
| 543 | - if (!empty($filename)): |
|
| 544 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 545 | - $uplaods = array(); |
|
| 546 | - |
|
| 547 | - foreach ($uploadedfile as $key => $uplaod): |
|
| 548 | - if ($key == 'name'): |
|
| 549 | - $uplaods[$key] = $filename; |
|
| 550 | - else : |
|
| 551 | - $uplaods[$key] = $uplaod; |
|
| 552 | - endif; |
|
| 553 | - endforeach; |
|
| 554 | - |
|
| 555 | - $uploads = wp_upload_dir(); |
|
| 556 | - |
|
| 557 | - if (get_option($value['id'])) {
|
|
| 558 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 559 | - $noimg_name = end($image_name_arr); |
|
| 560 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 561 | - if (file_exists($img_path)) |
|
| 562 | - unlink($img_path); |
|
| 563 | - } |
|
| 540 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 541 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 542 | + |
|
| 543 | + if (!empty($filename)): |
|
| 544 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 545 | + $uplaods = array(); |
|
| 546 | + |
|
| 547 | + foreach ($uploadedfile as $key => $uplaod): |
|
| 548 | + if ($key == 'name'): |
|
| 549 | + $uplaods[$key] = $filename; |
|
| 550 | + else : |
|
| 551 | + $uplaods[$key] = $uplaod; |
|
| 552 | + endif; |
|
| 553 | + endforeach; |
|
| 554 | + |
|
| 555 | + $uploads = wp_upload_dir(); |
|
| 556 | + |
|
| 557 | + if (get_option($value['id'])) {
|
|
| 558 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 559 | + $noimg_name = end($image_name_arr); |
|
| 560 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 561 | + if (file_exists($img_path)) |
|
| 562 | + unlink($img_path); |
|
| 563 | + } |
|
| 564 | 564 | |
| 565 | - $upload_overrides = array('test_form' => false);
|
|
| 566 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 565 | + $upload_overrides = array('test_form' => false);
|
|
| 566 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 567 | 567 | |
| 568 | - update_option($value['id'], $movefile['url']); |
|
| 568 | + update_option($value['id'], $movefile['url']); |
|
| 569 | 569 | |
| 570 | - endif; |
|
| 570 | + endif; |
|
| 571 | 571 | |
| 572 | - if (!get_option($value['id']) && isset($value['value'])): |
|
| 573 | - update_option($value['id'], $value['value']); |
|
| 574 | - endif; |
|
| 572 | + if (!get_option($value['id']) && isset($value['value'])): |
|
| 573 | + update_option($value['id'], $value['value']); |
|
| 574 | + endif; |
|
| 575 | 575 | |
| 576 | 576 | |
| 577 | - else : |
|
| 578 | - // same menu setting per theme. |
|
| 579 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 580 | - $theme = wp_get_theme(); |
|
| 581 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 582 | - } |
|
| 577 | + else : |
|
| 578 | + // same menu setting per theme. |
|
| 579 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 580 | + $theme = wp_get_theme(); |
|
| 581 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 582 | + } |
|
| 583 | 583 | |
| 584 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 585 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 586 | - } else {
|
|
| 587 | - delete_option($value['id']); |
|
| 588 | - } |
|
| 584 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 585 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 586 | + } else {
|
|
| 587 | + delete_option($value['id']); |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - endif; |
|
| 591 | - } |
|
| 592 | - if ($dummy) |
|
| 593 | - $_POST = array(); |
|
| 594 | - return true; |
|
| 590 | + endif; |
|
| 591 | + } |
|
| 592 | + if ($dummy) |
|
| 593 | + $_POST = array(); |
|
| 594 | + return true; |
|
| 595 | 595 | |
| 596 | 596 | } |
| 597 | 597 | |
@@ -640,33 +640,33 @@ discard block |
||
| 640 | 640 | function places_custom_fields_tab($tabs) |
| 641 | 641 | {
|
| 642 | 642 | |
| 643 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 643 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 644 | 644 | |
| 645 | - if (!empty($geodir_post_types)) {
|
|
| 645 | + if (!empty($geodir_post_types)) {
|
|
| 646 | 646 | |
| 647 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 647 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 648 | 648 | |
| 649 | - $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
| 649 | + $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
| 650 | 650 | |
| 651 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 652 | - 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
|
|
| 653 | - 'subtabs' => array( |
|
| 654 | - array('subtab' => 'custom_fields',
|
|
| 655 | - 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 656 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 657 | - array('subtab' => 'sorting_options',
|
|
| 658 | - 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 659 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 660 | - ), |
|
| 661 | - 'tab_index' => 9, |
|
| 662 | - 'request' => array('listing_type' => $geodir_post_type)
|
|
| 663 | - ); |
|
| 651 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 652 | + 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
|
|
| 653 | + 'subtabs' => array( |
|
| 654 | + array('subtab' => 'custom_fields',
|
|
| 655 | + 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 656 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 657 | + array('subtab' => 'sorting_options',
|
|
| 658 | + 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 659 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 660 | + ), |
|
| 661 | + 'tab_index' => 9, |
|
| 662 | + 'request' => array('listing_type' => $geodir_post_type)
|
|
| 663 | + ); |
|
| 664 | 664 | |
| 665 | - endforeach; |
|
| 665 | + endforeach; |
|
| 666 | 666 | |
| 667 | - } |
|
| 667 | + } |
|
| 668 | 668 | |
| 669 | - return $tabs; |
|
| 669 | + return $tabs; |
|
| 670 | 670 | } |
| 671 | 671 | |
| 672 | 672 | |
@@ -682,9 +682,9 @@ discard block |
||
| 682 | 682 | */ |
| 683 | 683 | function geodir_tools_setting_tab($tabs) |
| 684 | 684 | {
|
| 685 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 686 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 687 | - return $tabs; |
|
| 685 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 686 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 687 | + return $tabs; |
|
| 688 | 688 | } |
| 689 | 689 | |
| 690 | 690 | /** |
@@ -699,8 +699,8 @@ discard block |
||
| 699 | 699 | */ |
| 700 | 700 | function geodir_compatibility_setting_tab($tabs) |
| 701 | 701 | {
|
| 702 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 703 | - return $tabs; |
|
| 702 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 703 | + return $tabs; |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | |
@@ -716,144 +716,144 @@ discard block |
||
| 716 | 716 | */ |
| 717 | 717 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 718 | 718 | {
|
| 719 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
|
|
| 720 | - return $tabs; |
|
| 719 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
|
|
| 720 | + return $tabs; |
|
| 721 | 721 | } |
| 722 | 722 | |
| 723 | 723 | |
| 724 | 724 | if (!function_exists('geodir_edit_post_columns')) {
|
| 725 | - /** |
|
| 726 | - * Modify admin post listing page columns. |
|
| 727 | - * |
|
| 728 | - * @since 1.0.0 |
|
| 729 | - * @package GeoDirectory |
|
| 730 | - * @param array $columns The column array. |
|
| 731 | - * @return array Altered column array. |
|
| 732 | - */ |
|
| 733 | - function geodir_edit_post_columns($columns) |
|
| 734 | - {
|
|
| 735 | - |
|
| 736 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 737 | - 'categorys' => __('Categories', 'geodirectory'));
|
|
| 738 | - |
|
| 739 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 740 | - {
|
|
| 741 | - $offset = 0; // should we prepend $array with $data? |
|
| 742 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 743 | - } |
|
| 725 | + /** |
|
| 726 | + * Modify admin post listing page columns. |
|
| 727 | + * |
|
| 728 | + * @since 1.0.0 |
|
| 729 | + * @package GeoDirectory |
|
| 730 | + * @param array $columns The column array. |
|
| 731 | + * @return array Altered column array. |
|
| 732 | + */ |
|
| 733 | + function geodir_edit_post_columns($columns) |
|
| 734 | + {
|
|
| 744 | 735 | |
| 745 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 736 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 737 | + 'categorys' => __('Categories', 'geodirectory'));
|
|
| 746 | 738 | |
| 747 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 739 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 740 | + {
|
|
| 741 | + $offset = 0; // should we prepend $array with $data? |
|
| 742 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 743 | + } |
|
| 748 | 744 | |
| 749 | - return $columns; |
|
| 750 | - } |
|
| 745 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 746 | + |
|
| 747 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 748 | + |
|
| 749 | + return $columns; |
|
| 750 | + } |
|
| 751 | 751 | } |
| 752 | 752 | |
| 753 | 753 | |
| 754 | 754 | if (!function_exists('geodir_manage_post_columns')) {
|
| 755 | - /** |
|
| 756 | - * Adds content to our custom post listing page columns. |
|
| 757 | - * |
|
| 758 | - * @since 1.0.0 |
|
| 759 | - * @package GeoDirectory |
|
| 760 | - * @global object $wpdb WordPress Database object. |
|
| 761 | - * @global object $post WordPress Post object. |
|
| 762 | - * @param string $column The column name. |
|
| 763 | - * @param int $post_id The post ID. |
|
| 764 | - */ |
|
| 765 | - function geodir_manage_post_columns($column, $post_id) |
|
| 766 | - {
|
|
| 767 | - global $post, $wpdb; |
|
| 768 | - |
|
| 769 | - switch ($column): |
|
| 770 | - /* If displaying the 'city' column. */ |
|
| 771 | - case 'location' : |
|
| 772 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 773 | - $location = geodir_get_location($location_id); |
|
| 774 | - /* If no city is found, output a default message. */ |
|
| 775 | - if (empty($location)) {
|
|
| 776 | - _e('Unknown', 'geodirectory');
|
|
| 777 | - } else {
|
|
| 778 | - /* If there is a city id, append 'city name' to the text string. */ |
|
| 779 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 780 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 781 | - } |
|
| 782 | - break; |
|
| 783 | - |
|
| 784 | - /* If displaying the 'expire' column. */ |
|
| 785 | - case 'expire' : |
|
| 786 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 787 | - $d1 = $expire_date; // get expire_date |
|
| 788 | - $d2 = date('Y-m-d'); // get current date
|
|
| 789 | - $state = __('days left', 'geodirectory');
|
|
| 790 | - $date_diff_text = ''; |
|
| 791 | - $expire_class = 'expire_left'; |
|
| 792 | - if ($expire_date != 'Never') {
|
|
| 793 | - if (strtotime($d1) < strtotime($d2)) {
|
|
| 794 | - $state = __('days overdue', 'geodirectory');
|
|
| 795 | - $expire_class = 'expire_over'; |
|
| 796 | - } |
|
| 797 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 798 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 799 | - } |
|
| 800 | - /* If no expire_date is found, output a default message. */ |
|
| 801 | - if (empty($expire_date)) |
|
| 802 | - echo __('Unknown', 'geodirectory');
|
|
| 803 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 804 | - else |
|
| 805 | - echo $expire_date . $date_diff_text; |
|
| 806 | - break; |
|
| 807 | - |
|
| 808 | - /* If displaying the 'categorys' column. */ |
|
| 809 | - case 'categorys' : |
|
| 810 | - |
|
| 811 | - /* Get the categorys for the post. */ |
|
| 812 | - |
|
| 813 | - |
|
| 814 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 815 | - |
|
| 816 | - /* If terms were found. */ |
|
| 817 | - if (!empty($terms)) {
|
|
| 818 | - $out = array(); |
|
| 819 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 820 | - foreach ($terms as $term) {
|
|
| 821 | - if (!strstr($term->taxonomy, 'tag')) {
|
|
| 822 | - $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 823 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 824 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 825 | - ); |
|
| 826 | - } |
|
| 827 | - } |
|
| 828 | - /* Join the terms, separating them with a comma. */ |
|
| 829 | - echo(join(', ', $out));
|
|
| 830 | - } /* If no terms were found, output a default message. */ |
|
| 831 | - else {
|
|
| 832 | - _e('No Categories', 'geodirectory');
|
|
| 833 | - } |
|
| 834 | - break; |
|
| 755 | + /** |
|
| 756 | + * Adds content to our custom post listing page columns. |
|
| 757 | + * |
|
| 758 | + * @since 1.0.0 |
|
| 759 | + * @package GeoDirectory |
|
| 760 | + * @global object $wpdb WordPress Database object. |
|
| 761 | + * @global object $post WordPress Post object. |
|
| 762 | + * @param string $column The column name. |
|
| 763 | + * @param int $post_id The post ID. |
|
| 764 | + */ |
|
| 765 | + function geodir_manage_post_columns($column, $post_id) |
|
| 766 | + {
|
|
| 767 | + global $post, $wpdb; |
|
| 768 | + |
|
| 769 | + switch ($column): |
|
| 770 | + /* If displaying the 'city' column. */ |
|
| 771 | + case 'location' : |
|
| 772 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 773 | + $location = geodir_get_location($location_id); |
|
| 774 | + /* If no city is found, output a default message. */ |
|
| 775 | + if (empty($location)) {
|
|
| 776 | + _e('Unknown', 'geodirectory');
|
|
| 777 | + } else {
|
|
| 778 | + /* If there is a city id, append 'city name' to the text string. */ |
|
| 779 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 780 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 781 | + } |
|
| 782 | + break; |
|
| 783 | + |
|
| 784 | + /* If displaying the 'expire' column. */ |
|
| 785 | + case 'expire' : |
|
| 786 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 787 | + $d1 = $expire_date; // get expire_date |
|
| 788 | + $d2 = date('Y-m-d'); // get current date
|
|
| 789 | + $state = __('days left', 'geodirectory');
|
|
| 790 | + $date_diff_text = ''; |
|
| 791 | + $expire_class = 'expire_left'; |
|
| 792 | + if ($expire_date != 'Never') {
|
|
| 793 | + if (strtotime($d1) < strtotime($d2)) {
|
|
| 794 | + $state = __('days overdue', 'geodirectory');
|
|
| 795 | + $expire_class = 'expire_over'; |
|
| 796 | + } |
|
| 797 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 798 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 799 | + } |
|
| 800 | + /* If no expire_date is found, output a default message. */ |
|
| 801 | + if (empty($expire_date)) |
|
| 802 | + echo __('Unknown', 'geodirectory');
|
|
| 803 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 804 | + else |
|
| 805 | + echo $expire_date . $date_diff_text; |
|
| 806 | + break; |
|
| 835 | 807 | |
| 836 | - endswitch; |
|
| 837 | - } |
|
| 808 | + /* If displaying the 'categorys' column. */ |
|
| 809 | + case 'categorys' : |
|
| 810 | + |
|
| 811 | + /* Get the categorys for the post. */ |
|
| 812 | + |
|
| 813 | + |
|
| 814 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 815 | + |
|
| 816 | + /* If terms were found. */ |
|
| 817 | + if (!empty($terms)) {
|
|
| 818 | + $out = array(); |
|
| 819 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 820 | + foreach ($terms as $term) {
|
|
| 821 | + if (!strstr($term->taxonomy, 'tag')) {
|
|
| 822 | + $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 823 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 824 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 825 | + ); |
|
| 826 | + } |
|
| 827 | + } |
|
| 828 | + /* Join the terms, separating them with a comma. */ |
|
| 829 | + echo(join(', ', $out));
|
|
| 830 | + } /* If no terms were found, output a default message. */ |
|
| 831 | + else {
|
|
| 832 | + _e('No Categories', 'geodirectory');
|
|
| 833 | + } |
|
| 834 | + break; |
|
| 835 | + |
|
| 836 | + endswitch; |
|
| 837 | + } |
|
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | |
| 841 | 841 | if (!function_exists('geodir_post_sortable_columns')) {
|
| 842 | - /** |
|
| 843 | - * Makes admin post listing page columns sortable. |
|
| 844 | - * |
|
| 845 | - * @since 1.0.0 |
|
| 846 | - * @package GeoDirectory |
|
| 847 | - * @param array $columns The column array. |
|
| 848 | - * @return array Altered column array. |
|
| 849 | - */ |
|
| 850 | - function geodir_post_sortable_columns($columns) |
|
| 851 | - {
|
|
| 852 | - |
|
| 853 | - $columns['expire'] = 'expire'; |
|
| 854 | - |
|
| 855 | - return $columns; |
|
| 856 | - } |
|
| 842 | + /** |
|
| 843 | + * Makes admin post listing page columns sortable. |
|
| 844 | + * |
|
| 845 | + * @since 1.0.0 |
|
| 846 | + * @package GeoDirectory |
|
| 847 | + * @param array $columns The column array. |
|
| 848 | + * @return array Altered column array. |
|
| 849 | + */ |
|
| 850 | + function geodir_post_sortable_columns($columns) |
|
| 851 | + {
|
|
| 852 | + |
|
| 853 | + $columns['expire'] = 'expire'; |
|
| 854 | + |
|
| 855 | + return $columns; |
|
| 856 | + } |
|
| 857 | 857 | } |
| 858 | 858 | |
| 859 | 859 | /** |
@@ -867,32 +867,32 @@ discard block |
||
| 867 | 867 | * @param int $post_id The post ID. |
| 868 | 868 | */ |
| 869 | 869 | function geodir_post_information_save($post_id, $post) {
|
| 870 | - global $wpdb, $current_user; |
|
| 870 | + global $wpdb, $current_user; |
|
| 871 | 871 | |
| 872 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 873 | - return; |
|
| 874 | - } |
|
| 872 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 873 | + return; |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 876 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 877 | 877 | |
| 878 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 879 | - return; |
|
| 878 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 879 | + return; |
|
| 880 | 880 | |
| 881 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 882 | - if (isset($_REQUEST['_status'])) |
|
| 883 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 881 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 882 | + if (isset($_REQUEST['_status'])) |
|
| 883 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 884 | 884 | |
| 885 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 886 | - return; |
|
| 885 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 886 | + return; |
|
| 887 | 887 | |
| 888 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 889 | - return; |
|
| 888 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 889 | + return; |
|
| 890 | 890 | |
| 891 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 892 | - return; |
|
| 891 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 892 | + return; |
|
| 893 | 893 | |
| 894 | - geodir_save_listing($_REQUEST); |
|
| 895 | - } |
|
| 894 | + geodir_save_listing($_REQUEST); |
|
| 895 | + } |
|
| 896 | 896 | } |
| 897 | 897 | |
| 898 | 898 | /** |
@@ -908,102 +908,102 @@ discard block |
||
| 908 | 908 | */ |
| 909 | 909 | function geodir_admin_fields($options) |
| 910 | 910 | {
|
| 911 | - global $geodirectory; |
|
| 912 | - |
|
| 913 | - $first_title = true; |
|
| 914 | - $tab_id = ''; |
|
| 915 | - $i = 0; |
|
| 916 | - foreach ($options as $value) : |
|
| 917 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 918 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 919 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 920 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 921 | - $desc = ''; |
|
| 922 | - switch ($value['type']) : |
|
| 923 | - case 'dummy_installer': |
|
| 924 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 925 | - geodir_autoinstall_admin_header($post_type); |
|
| 926 | - break; |
|
| 927 | - case 'title': |
|
| 928 | - |
|
| 929 | - if ($i == 0) {
|
|
| 930 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 931 | - echo '<div class="inner_content_tab_main">'; |
|
| 932 | - } |
|
| 911 | + global $geodirectory; |
|
| 912 | + |
|
| 913 | + $first_title = true; |
|
| 914 | + $tab_id = ''; |
|
| 915 | + $i = 0; |
|
| 916 | + foreach ($options as $value) : |
|
| 917 | + if (!isset($value['name'])) $value['name'] = ''; |
|
| 918 | + if (!isset($value['class'])) $value['class'] = ''; |
|
| 919 | + if (!isset($value['css'])) $value['css'] = ''; |
|
| 920 | + if (!isset($value['std'])) $value['std'] = ''; |
|
| 921 | + $desc = ''; |
|
| 922 | + switch ($value['type']) : |
|
| 923 | + case 'dummy_installer': |
|
| 924 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 925 | + geodir_autoinstall_admin_header($post_type); |
|
| 926 | + break; |
|
| 927 | + case 'title': |
|
| 928 | + |
|
| 929 | + if ($i == 0) {
|
|
| 930 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 931 | + echo '<div class="inner_content_tab_main">'; |
|
| 932 | + } |
|
| 933 | 933 | |
| 934 | - $i++; |
|
| 934 | + $i++; |
|
| 935 | 935 | |
| 936 | - if (isset($value['id']) && $value['id']) |
|
| 937 | - $tab_id = $value['id']; |
|
| 936 | + if (isset($value['id']) && $value['id']) |
|
| 937 | + $tab_id = $value['id']; |
|
| 938 | 938 | |
| 939 | - if (isset($value['desc']) && $value['desc']) |
|
| 940 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 939 | + if (isset($value['desc']) && $value['desc']) |
|
| 940 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 941 | 941 | |
| 942 | - if (isset($value['name']) && $value['name']) {
|
|
| 943 | - if ($first_title === true) {
|
|
| 944 | - $first_title = false; |
|
| 945 | - } else {
|
|
| 946 | - echo '</div>'; |
|
| 947 | - } |
|
| 948 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 942 | + if (isset($value['name']) && $value['name']) {
|
|
| 943 | + if ($first_title === true) {
|
|
| 944 | + $first_title = false; |
|
| 945 | + } else {
|
|
| 946 | + echo '</div>'; |
|
| 947 | + } |
|
| 948 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 949 | 949 | |
| 950 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 951 | - } |
|
| 950 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 951 | + } |
|
| 952 | 952 | |
| 953 | - /** |
|
| 954 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 955 | - * |
|
| 956 | - * The action is called dynamically geodir_settings_$value['id']. |
|
| 957 | - * |
|
| 958 | - * @since 1.0.0 |
|
| 959 | - */ |
|
| 960 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 961 | - break; |
|
| 962 | - |
|
| 963 | - case 'no_tabs': |
|
| 964 | - |
|
| 965 | - echo '<div class="inner_content_tab_main">'; |
|
| 966 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 967 | - |
|
| 968 | - break; |
|
| 969 | - |
|
| 970 | - case 'sectionstart': |
|
| 971 | - if (isset($value['desc']) && $value['desc']) |
|
| 972 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 973 | - if (isset($value['name']) && $value['name']) |
|
| 974 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 975 | - /** |
|
| 976 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 977 | - * |
|
| 978 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 979 | - * |
|
| 980 | - * @since 1.0.0 |
|
| 981 | - */ |
|
| 982 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 983 | - echo '<table class="form-table">' . "\n\n"; |
|
| 984 | - |
|
| 985 | - break; |
|
| 986 | - case 'sectionend': |
|
| 987 | - /** |
|
| 988 | - * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 989 | - * |
|
| 990 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 991 | - * |
|
| 992 | - * @since 1.0.0 |
|
| 993 | - */ |
|
| 994 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 995 | - echo '</table>'; |
|
| 996 | - /** |
|
| 997 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 998 | - * |
|
| 999 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1000 | - * |
|
| 1001 | - * @since 1.0.0 |
|
| 1002 | - */ |
|
| 1003 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1004 | - break; |
|
| 1005 | - case 'text': |
|
| 1006 | - ?> |
|
| 953 | + /** |
|
| 954 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 955 | + * |
|
| 956 | + * The action is called dynamically geodir_settings_$value['id']. |
|
| 957 | + * |
|
| 958 | + * @since 1.0.0 |
|
| 959 | + */ |
|
| 960 | + do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 961 | + break; |
|
| 962 | + |
|
| 963 | + case 'no_tabs': |
|
| 964 | + |
|
| 965 | + echo '<div class="inner_content_tab_main">'; |
|
| 966 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 967 | + |
|
| 968 | + break; |
|
| 969 | + |
|
| 970 | + case 'sectionstart': |
|
| 971 | + if (isset($value['desc']) && $value['desc']) |
|
| 972 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 973 | + if (isset($value['name']) && $value['name']) |
|
| 974 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 975 | + /** |
|
| 976 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 977 | + * |
|
| 978 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 979 | + * |
|
| 980 | + * @since 1.0.0 |
|
| 981 | + */ |
|
| 982 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 983 | + echo '<table class="form-table">' . "\n\n"; |
|
| 984 | + |
|
| 985 | + break; |
|
| 986 | + case 'sectionend': |
|
| 987 | + /** |
|
| 988 | + * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 989 | + * |
|
| 990 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 991 | + * |
|
| 992 | + * @since 1.0.0 |
|
| 993 | + */ |
|
| 994 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 995 | + echo '</table>'; |
|
| 996 | + /** |
|
| 997 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 998 | + * |
|
| 999 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 1000 | + * |
|
| 1001 | + * @since 1.0.0 |
|
| 1002 | + */ |
|
| 1003 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 1004 | + break; |
|
| 1005 | + case 'text': |
|
| 1006 | + ?> |
|
| 1007 | 1007 | <tr valign="top"> |
| 1008 | 1008 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1009 | 1009 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1012,15 +1012,15 @@ discard block |
||
| 1012 | 1012 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1013 | 1013 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1014 | 1014 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1015 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1016 | - } else {
|
|
| 1017 | - echo esc_attr($value['std']); |
|
| 1018 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1015 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1016 | + } else {
|
|
| 1017 | + echo esc_attr($value['std']); |
|
| 1018 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1019 | 1019 | </tr><?php |
| 1020 | - break; |
|
| 1020 | + break; |
|
| 1021 | 1021 | |
| 1022 | - case 'map-key': |
|
| 1023 | - ?> |
|
| 1022 | + case 'map-key': |
|
| 1023 | + ?> |
|
| 1024 | 1024 | <tr valign="top"> |
| 1025 | 1025 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1026 | 1026 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1029,17 +1029,17 @@ discard block |
||
| 1029 | 1029 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1030 | 1030 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1031 | 1031 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1032 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1033 | - } else {
|
|
| 1034 | - echo esc_attr($value['std']); |
|
| 1035 | - } ?>"/> |
|
| 1032 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1033 | + } else {
|
|
| 1034 | + echo esc_attr($value['std']); |
|
| 1035 | + } ?>"/> |
|
| 1036 | 1036 | <a href='https://console.developers.google.com/henhouse/?pb=["hh-1","maps_backend",null,[],"https://developers.google.com",null,["static_maps_backend","street_view_image_backend","maps_embed_backend","places_backend","geocoding_backend","directions_backend","distance_matrix_backend","geolocation","elevation_backend","timezone_backend","maps_backend"],null]&TB_iframe=true&width=600&height=400' class="thickbox button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )','geodirectory');?>" ><?php _e('Generate API Key','geodirectory');?></a>
|
| 1037 | 1037 | <span class="description"><?php echo $value['desc']; ?></span></td> |
| 1038 | 1038 | </tr><?php |
| 1039 | - break; |
|
| 1039 | + break; |
|
| 1040 | 1040 | |
| 1041 | - case 'password': |
|
| 1042 | - ?> |
|
| 1041 | + case 'password': |
|
| 1042 | + ?> |
|
| 1043 | 1043 | <tr valign="top"> |
| 1044 | 1044 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1045 | 1045 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1048,42 +1048,42 @@ discard block |
||
| 1048 | 1048 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1049 | 1049 | style="<?php echo esc_attr($value['css']); ?>" |
| 1050 | 1050 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1051 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1052 | - } else {
|
|
| 1053 | - echo esc_attr($value['std']); |
|
| 1054 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1051 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1052 | + } else {
|
|
| 1053 | + echo esc_attr($value['std']); |
|
| 1054 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1055 | 1055 | </tr><?php |
| 1056 | - break; |
|
| 1056 | + break; |
|
| 1057 | 1057 | |
| 1058 | - case 'html_content': |
|
| 1059 | - ?> |
|
| 1058 | + case 'html_content': |
|
| 1059 | + ?> |
|
| 1060 | 1060 | <tr valign="top"> |
| 1061 | 1061 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1062 | 1062 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
| 1063 | 1063 | </tr><?php |
| 1064 | - break; |
|
| 1064 | + break; |
|
| 1065 | 1065 | |
| 1066 | - case 'color' : |
|
| 1067 | - ?> |
|
| 1066 | + case 'color' : |
|
| 1067 | + ?> |
|
| 1068 | 1068 | <tr valign="top"> |
| 1069 | 1069 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1070 | 1070 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1071 | 1071 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 1072 | 1072 | style="<?php echo esc_attr($value['css']); ?>" |
| 1073 | 1073 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1074 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1075 | - } else {
|
|
| 1076 | - echo esc_attr($value['std']); |
|
| 1077 | - } ?>" class="colorpick"/> <span |
|
| 1074 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1075 | + } else {
|
|
| 1076 | + echo esc_attr($value['std']); |
|
| 1077 | + } ?>" class="colorpick"/> <span |
|
| 1078 | 1078 | class="description"><?php echo $value['desc']; ?></span> |
| 1079 | 1079 | |
| 1080 | 1080 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
| 1081 | 1081 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
| 1082 | 1082 | </td> |
| 1083 | 1083 | </tr><?php |
| 1084 | - break; |
|
| 1085 | - case 'image_width' : |
|
| 1086 | - ?> |
|
| 1084 | + break; |
|
| 1085 | + case 'image_width' : |
|
| 1086 | + ?> |
|
| 1087 | 1087 | <tr valign="top"> |
| 1088 | 1088 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1089 | 1089 | <td class="forminp"> |
@@ -1105,11 +1105,11 @@ discard block |
||
| 1105 | 1105 | |
| 1106 | 1106 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 1107 | 1107 | </tr><?php |
| 1108 | - break; |
|
| 1109 | - case 'select': |
|
| 1110 | - $option_value = get_option($value['id']); |
|
| 1111 | - $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1112 | - ?> |
|
| 1108 | + break; |
|
| 1109 | + case 'select': |
|
| 1110 | + $option_value = get_option($value['id']); |
|
| 1111 | + $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1112 | + ?> |
|
| 1113 | 1113 | <tr valign="top"> |
| 1114 | 1114 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1115 | 1115 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1118,33 +1118,33 @@ discard block |
||
| 1118 | 1118 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 1119 | 1119 | option-ajaxchosen="false"> |
| 1120 | 1120 | <?php |
| 1121 | - foreach ($value['options'] as $key => $val) {
|
|
| 1122 | - $geodir_select_value = ''; |
|
| 1123 | - if ($option_value != '') {
|
|
| 1124 | - if ($option_value != '' && $option_value == $key) |
|
| 1125 | - $geodir_select_value = ' selected="selected" '; |
|
| 1126 | - } else {
|
|
| 1127 | - if ($value['std'] == $key) |
|
| 1128 | - $geodir_select_value = ' selected="selected" '; |
|
| 1129 | - } |
|
| 1130 | - ?> |
|
| 1121 | + foreach ($value['options'] as $key => $val) {
|
|
| 1122 | + $geodir_select_value = ''; |
|
| 1123 | + if ($option_value != '') {
|
|
| 1124 | + if ($option_value != '' && $option_value == $key) |
|
| 1125 | + $geodir_select_value = ' selected="selected" '; |
|
| 1126 | + } else {
|
|
| 1127 | + if ($value['std'] == $key) |
|
| 1128 | + $geodir_select_value = ' selected="selected" '; |
|
| 1129 | + } |
|
| 1130 | + ?> |
|
| 1131 | 1131 | <option |
| 1132 | 1132 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo geodir_utf8_ucfirst($val) ?></option> |
| 1133 | 1133 | <?php |
| 1134 | - } |
|
| 1135 | - ?> |
|
| 1134 | + } |
|
| 1135 | + ?> |
|
| 1136 | 1136 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1137 | 1137 | </td> |
| 1138 | 1138 | </tr><?php |
| 1139 | - break; |
|
| 1139 | + break; |
|
| 1140 | 1140 | |
| 1141 | - case 'multiselect': |
|
| 1142 | - $option_values = get_option($value['id']); |
|
| 1143 | - if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1144 | - $option_values = $value['std']; |
|
| 1145 | - } |
|
| 1146 | - $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1147 | - ?> |
|
| 1141 | + case 'multiselect': |
|
| 1142 | + $option_values = get_option($value['id']); |
|
| 1143 | + if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1144 | + $option_values = $value['std']; |
|
| 1145 | + } |
|
| 1146 | + $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1147 | + ?> |
|
| 1148 | 1148 | <tr valign="top"> |
| 1149 | 1149 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1150 | 1150 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -1154,26 +1154,26 @@ discard block |
||
| 1154 | 1154 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
| 1155 | 1155 | option-ajaxchosen="false"> |
| 1156 | 1156 | <?php |
| 1157 | - foreach ($value['options'] as $key => $val) {
|
|
| 1158 | - if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1159 | - ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php |
|
| 1160 | - } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1161 | - ?></optgroup><?php |
|
| 1162 | - } else {
|
|
| 1163 | - ?> |
|
| 1157 | + foreach ($value['options'] as $key => $val) {
|
|
| 1158 | + if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1159 | + ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php |
|
| 1160 | + } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1161 | + ?></optgroup><?php |
|
| 1162 | + } else {
|
|
| 1163 | + ?> |
|
| 1164 | 1164 | <option value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>> |
| 1165 | 1165 | <?php echo geodir_utf8_ucfirst($val) ?> |
| 1166 | 1166 | </option> |
| 1167 | 1167 | <?php |
| 1168 | - } |
|
| 1169 | - } |
|
| 1170 | - ?> |
|
| 1168 | + } |
|
| 1169 | + } |
|
| 1170 | + ?> |
|
| 1171 | 1171 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1172 | 1172 | </td> |
| 1173 | 1173 | </tr><?php |
| 1174 | - break; |
|
| 1175 | - case 'file': |
|
| 1176 | - ?> |
|
| 1174 | + break; |
|
| 1175 | + case 'file': |
|
| 1176 | + ?> |
|
| 1177 | 1177 | <tr valign="top"> |
| 1178 | 1178 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1179 | 1179 | <td class="forminp"> |
@@ -1193,87 +1193,87 @@ discard block |
||
| 1193 | 1193 | <?php } ?> |
| 1194 | 1194 | </td> |
| 1195 | 1195 | </tr><?php |
| 1196 | - break; |
|
| 1197 | - case 'map_default_settings' : |
|
| 1198 | - ?> |
|
| 1196 | + break; |
|
| 1197 | + case 'map_default_settings' : |
|
| 1198 | + ?> |
|
| 1199 | 1199 | |
| 1200 | 1200 | <tr valign="top"> |
| 1201 | 1201 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
| 1202 | 1202 | <td width="60%"> |
| 1203 | 1203 | <select name="geodir_default_map_language" style="width:60%"> |
| 1204 | 1204 | <?php |
| 1205 | - $arr_map_langages = array( |
|
| 1206 | - 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1207 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1208 | - 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1209 | - 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1210 | - 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1211 | - 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1212 | - 'da' => __('DANISH', 'geodirectory'),
|
|
| 1213 | - 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1214 | - 'el' => __('GREEK', 'geodirectory'),
|
|
| 1215 | - 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1216 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1217 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1218 | - 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1219 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1220 | - 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1221 | - 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1222 | - 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1223 | - 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1224 | - 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1225 | - 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1226 | - 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1227 | - 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1228 | - 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1229 | - 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1230 | - 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1231 | - 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1232 | - 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1233 | - 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1234 | - 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1235 | - 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1236 | - 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1237 | - 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1238 | - 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1239 | - 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1240 | - 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1241 | - 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1242 | - 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1243 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1244 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1245 | - 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1246 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1247 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1248 | - 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1249 | - 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1250 | - 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1251 | - 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1252 | - 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1253 | - 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1254 | - 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1255 | - 'th' => __('THAI', 'geodirectory'),
|
|
| 1256 | - 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1257 | - 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1258 | - 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1259 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1260 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1261 | - ); |
|
| 1262 | - $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1263 | - if (empty($geodir_default_map_language)) |
|
| 1264 | - $geodir_default_map_language = 'en'; |
|
| 1265 | - foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1266 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1267 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 1268 | - else |
|
| 1269 | - $geodir_default_language_selected = ''; |
|
| 1270 | - |
|
| 1271 | - ?> |
|
| 1205 | + $arr_map_langages = array( |
|
| 1206 | + 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1207 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1208 | + 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1209 | + 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1210 | + 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1211 | + 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1212 | + 'da' => __('DANISH', 'geodirectory'),
|
|
| 1213 | + 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1214 | + 'el' => __('GREEK', 'geodirectory'),
|
|
| 1215 | + 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1216 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1217 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1218 | + 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1219 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1220 | + 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1221 | + 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1222 | + 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1223 | + 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1224 | + 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1225 | + 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1226 | + 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1227 | + 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1228 | + 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1229 | + 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1230 | + 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1231 | + 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1232 | + 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1233 | + 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1234 | + 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1235 | + 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1236 | + 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1237 | + 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1238 | + 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1239 | + 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1240 | + 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1241 | + 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1242 | + 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1243 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1244 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1245 | + 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1246 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1247 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1248 | + 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1249 | + 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1250 | + 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1251 | + 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1252 | + 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1253 | + 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1254 | + 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1255 | + 'th' => __('THAI', 'geodirectory'),
|
|
| 1256 | + 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1257 | + 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1258 | + 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1259 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1260 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1261 | + ); |
|
| 1262 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1263 | + if (empty($geodir_default_map_language)) |
|
| 1264 | + $geodir_default_map_language = 'en'; |
|
| 1265 | + foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1266 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1267 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 1268 | + else |
|
| 1269 | + $geodir_default_language_selected = ''; |
|
| 1270 | + |
|
| 1271 | + ?> |
|
| 1272 | 1272 | <option |
| 1273 | 1273 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
| 1274 | 1274 | |
| 1275 | 1275 | <?php } |
| 1276 | - ?> |
|
| 1276 | + ?> |
|
| 1277 | 1277 | </select> |
| 1278 | 1278 | </td> |
| 1279 | 1279 | </tr> |
@@ -1284,46 +1284,46 @@ discard block |
||
| 1284 | 1284 | <td width="60%"> |
| 1285 | 1285 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 1286 | 1286 | <?php |
| 1287 | - $post_types = geodir_get_posttypes('array');
|
|
| 1288 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1289 | - if (empty($geodir_default_map_search_pt)) |
|
| 1290 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 1291 | - if (is_array($post_types)) {
|
|
| 1292 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 1293 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1294 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 1295 | - else |
|
| 1296 | - $geodir_search_pt_selected = ''; |
|
| 1297 | - |
|
| 1298 | - ?> |
|
| 1287 | + $post_types = geodir_get_posttypes('array');
|
|
| 1288 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1289 | + if (empty($geodir_default_map_search_pt)) |
|
| 1290 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 1291 | + if (is_array($post_types)) {
|
|
| 1292 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 1293 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1294 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 1295 | + else |
|
| 1296 | + $geodir_search_pt_selected = ''; |
|
| 1297 | + |
|
| 1298 | + ?> |
|
| 1299 | 1299 | <option |
| 1300 | 1300 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo __($post_types_obj['labels']['singular_name'], 'geodirectory'); ?></option> |
| 1301 | 1301 | |
| 1302 | 1302 | <?php } |
| 1303 | 1303 | |
| 1304 | - } |
|
| 1304 | + } |
|
| 1305 | 1305 | |
| 1306 | - ?> |
|
| 1306 | + ?> |
|
| 1307 | 1307 | </select> |
| 1308 | 1308 | </td> |
| 1309 | 1309 | </tr> |
| 1310 | 1310 | |
| 1311 | 1311 | <?php |
| 1312 | - break; |
|
| 1312 | + break; |
|
| 1313 | 1313 | |
| 1314 | - case 'map': |
|
| 1315 | - ?> |
|
| 1314 | + case 'map': |
|
| 1315 | + ?> |
|
| 1316 | 1316 | <tr valign="top"> |
| 1317 | 1317 | <td class="forminp"> |
| 1318 | 1318 | <?php |
| 1319 | - global $post_cat, $cat_display; |
|
| 1320 | - $post_types = geodir_get_posttypes('object');
|
|
| 1321 | - $cat_display = 'checkbox'; |
|
| 1322 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1323 | - $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1324 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1325 | - $count = 1; |
|
| 1326 | - ?> |
|
| 1319 | + global $post_cat, $cat_display; |
|
| 1320 | + $post_types = geodir_get_posttypes('object');
|
|
| 1321 | + $cat_display = 'checkbox'; |
|
| 1322 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1323 | + $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1324 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1325 | + $count = 1; |
|
| 1326 | + ?> |
|
| 1327 | 1327 | <table width="70%" class="widefat"> |
| 1328 | 1328 | <thead> |
| 1329 | 1329 | <tr> |
@@ -1332,18 +1332,18 @@ discard block |
||
| 1332 | 1332 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
| 1333 | 1333 | </tr> |
| 1334 | 1334 | <?php |
| 1335 | - $gd_categs = $gd_cats; |
|
| 1336 | - foreach ($post_types as $key => $post_types_obj) : |
|
| 1337 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1338 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1339 | - if ($gd_cats_upgrade) {
|
|
| 1340 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1341 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1342 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1343 | - } |
|
| 1344 | - $post_cat = implode(',', $gd_cats);
|
|
| 1345 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1346 | - ?> |
|
| 1335 | + $gd_categs = $gd_cats; |
|
| 1336 | + foreach ($post_types as $key => $post_types_obj) : |
|
| 1337 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1338 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1339 | + if ($gd_cats_upgrade) {
|
|
| 1340 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1341 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1342 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1343 | + } |
|
| 1344 | + $post_cat = implode(',', $gd_cats);
|
|
| 1345 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1346 | + ?> |
|
| 1347 | 1347 | <tr> |
| 1348 | 1348 | <td valign="top" width="5%"><?php echo $count; ?></td> |
| 1349 | 1349 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -1364,19 +1364,19 @@ discard block |
||
| 1364 | 1364 | </td> |
| 1365 | 1365 | </tr> |
| 1366 | 1366 | <?php |
| 1367 | - break; |
|
| 1367 | + break; |
|
| 1368 | 1368 | |
| 1369 | - case 'checkbox' : |
|
| 1369 | + case 'checkbox' : |
|
| 1370 | 1370 | |
| 1371 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1372 | - ?> |
|
| 1371 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1372 | + ?> |
|
| 1373 | 1373 | <tr valign="top"> |
| 1374 | 1374 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1375 | 1375 | <td class="forminp"> |
| 1376 | 1376 | <?php |
| 1377 | - endif; |
|
| 1377 | + endif; |
|
| 1378 | 1378 | |
| 1379 | - ?> |
|
| 1379 | + ?> |
|
| 1380 | 1380 | <fieldset> |
| 1381 | 1381 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1382 | 1382 | <label for="<?php echo $value['id'] ?>"> |
@@ -1386,49 +1386,49 @@ discard block |
||
| 1386 | 1386 | </fieldset> |
| 1387 | 1387 | <?php |
| 1388 | 1388 | |
| 1389 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1390 | - ?> |
|
| 1389 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1390 | + ?> |
|
| 1391 | 1391 | </td> |
| 1392 | 1392 | </tr> |
| 1393 | 1393 | <?php |
| 1394 | - endif; |
|
| 1394 | + endif; |
|
| 1395 | 1395 | |
| 1396 | - break; |
|
| 1396 | + break; |
|
| 1397 | 1397 | |
| 1398 | - case 'radio' : |
|
| 1398 | + case 'radio' : |
|
| 1399 | 1399 | |
| 1400 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1401 | - ?> |
|
| 1400 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1401 | + ?> |
|
| 1402 | 1402 | <tr valign="top"> |
| 1403 | 1403 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1404 | 1404 | <td class="forminp"> |
| 1405 | 1405 | <?php |
| 1406 | - endif; |
|
| 1406 | + endif; |
|
| 1407 | 1407 | |
| 1408 | - ?> |
|
| 1408 | + ?> |
|
| 1409 | 1409 | <fieldset> |
| 1410 | 1410 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1411 | 1411 | <label for="<?php echo $value['id'];?>"> |
| 1412 | 1412 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 1413 | 1413 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 1414 | 1414 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 1415 | - echo 'checked="checked"'; |
|
| 1416 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1415 | + echo 'checked="checked"'; |
|
| 1416 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1417 | 1417 | <?php echo $value['desc']; ?></label><br> |
| 1418 | 1418 | </fieldset> |
| 1419 | 1419 | <?php |
| 1420 | 1420 | |
| 1421 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1422 | - ?> |
|
| 1421 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1422 | + ?> |
|
| 1423 | 1423 | </td> |
| 1424 | 1424 | </tr> |
| 1425 | 1425 | <?php |
| 1426 | - endif; |
|
| 1426 | + endif; |
|
| 1427 | 1427 | |
| 1428 | - break; |
|
| 1428 | + break; |
|
| 1429 | 1429 | |
| 1430 | - case 'textarea': |
|
| 1431 | - ?> |
|
| 1430 | + case 'textarea': |
|
| 1431 | + ?> |
|
| 1432 | 1432 | <tr valign="top"> |
| 1433 | 1433 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1434 | 1434 | <td class="forminp"> |
@@ -1441,30 +1441,30 @@ discard block |
||
| 1441 | 1441 | |
| 1442 | 1442 | </td> |
| 1443 | 1443 | </tr><?php |
| 1444 | - break; |
|
| 1444 | + break; |
|
| 1445 | 1445 | |
| 1446 | - case 'editor': |
|
| 1447 | - ?> |
|
| 1446 | + case 'editor': |
|
| 1447 | + ?> |
|
| 1448 | 1448 | <tr valign="top"> |
| 1449 | 1449 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1450 | 1450 | <td class="forminp"><?php |
| 1451 | - if (get_option($value['id'])) |
|
| 1452 | - $content = stripslashes(get_option($value['id'])); |
|
| 1453 | - else |
|
| 1454 | - $content = $value['std']; |
|
| 1451 | + if (get_option($value['id'])) |
|
| 1452 | + $content = stripslashes(get_option($value['id'])); |
|
| 1453 | + else |
|
| 1454 | + $content = $value['std']; |
|
| 1455 | 1455 | |
| 1456 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1456 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1457 | 1457 | |
| 1458 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1458 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1459 | 1459 | |
| 1460 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1460 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1461 | 1461 | |
| 1462 | 1462 | </td> |
| 1463 | 1463 | </tr><?php |
| 1464 | - break; |
|
| 1464 | + break; |
|
| 1465 | 1465 | |
| 1466 | - case 'single_select_page' : |
|
| 1467 | - // WPML |
|
| 1466 | + case 'single_select_page' : |
|
| 1467 | + // WPML |
|
| 1468 | 1468 | $switch_lang = false; |
| 1469 | 1469 | $disabled = ''; |
| 1470 | 1470 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
@@ -1482,18 +1482,18 @@ discard block |
||
| 1482 | 1482 | // |
| 1483 | 1483 | $page_setting = (int)get_option($value['id']); |
| 1484 | 1484 | |
| 1485 | - $args = array('name' => $value['id'],
|
|
| 1486 | - 'id' => $value['id'], |
|
| 1487 | - 'sort_column' => 'menu_order', |
|
| 1488 | - 'sort_order' => 'ASC', |
|
| 1489 | - 'show_option_none' => ' ', |
|
| 1490 | - 'class' => $value['class'], |
|
| 1491 | - 'echo' => false, |
|
| 1492 | - 'selected' => $page_setting); |
|
| 1485 | + $args = array('name' => $value['id'],
|
|
| 1486 | + 'id' => $value['id'], |
|
| 1487 | + 'sort_column' => 'menu_order', |
|
| 1488 | + 'sort_order' => 'ASC', |
|
| 1489 | + 'show_option_none' => ' ', |
|
| 1490 | + 'class' => $value['class'], |
|
| 1491 | + 'echo' => false, |
|
| 1492 | + 'selected' => $page_setting); |
|
| 1493 | 1493 | |
| 1494 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1494 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1495 | 1495 | |
| 1496 | - ?> |
|
| 1496 | + ?> |
|
| 1497 | 1497 | <tr valign="top" class="single_select_page"> |
| 1498 | 1498 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1499 | 1499 | <td class="forminp"> |
@@ -1504,17 +1504,17 @@ discard block |
||
| 1504 | 1504 | if ($switch_lang) {
|
| 1505 | 1505 | $sitepress->switch_lang($switch_lang, true); |
| 1506 | 1506 | } |
| 1507 | - break; |
|
| 1508 | - case 'single_select_country' : |
|
| 1509 | - $country_setting = (string)get_option($value['id']); |
|
| 1510 | - if (strstr($country_setting, ':')) : |
|
| 1511 | - $country = current(explode(':', $country_setting));
|
|
| 1512 | - $state = end(explode(':', $country_setting));
|
|
| 1513 | - else : |
|
| 1514 | - $country = $country_setting; |
|
| 1515 | - $state = '*'; |
|
| 1516 | - endif; |
|
| 1517 | - ?> |
|
| 1507 | + break; |
|
| 1508 | + case 'single_select_country' : |
|
| 1509 | + $country_setting = (string)get_option($value['id']); |
|
| 1510 | + if (strstr($country_setting, ':')) : |
|
| 1511 | + $country = current(explode(':', $country_setting));
|
|
| 1512 | + $state = end(explode(':', $country_setting));
|
|
| 1513 | + else : |
|
| 1514 | + $country = $country_setting; |
|
| 1515 | + $state = '*'; |
|
| 1516 | + endif; |
|
| 1517 | + ?> |
|
| 1518 | 1518 | <tr valign="top"> |
| 1519 | 1519 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
| 1520 | 1520 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1525,12 +1525,12 @@ discard block |
||
| 1525 | 1525 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1526 | 1526 | </td> |
| 1527 | 1527 | </tr><?php |
| 1528 | - break; |
|
| 1529 | - case 'multi_select_countries' : |
|
| 1530 | - $countries = $geodirectory->countries->countries; |
|
| 1531 | - asort($countries); |
|
| 1532 | - $selections = (array)get_option($value['id']); |
|
| 1533 | - ?> |
|
| 1528 | + break; |
|
| 1529 | + case 'multi_select_countries' : |
|
| 1530 | + $countries = $geodirectory->countries->countries; |
|
| 1531 | + asort($countries); |
|
| 1532 | + $selections = (array)get_option($value['id']); |
|
| 1533 | + ?> |
|
| 1534 | 1534 | <tr valign="top"> |
| 1535 | 1535 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1536 | 1536 | <td class="forminp"> |
@@ -1538,21 +1538,21 @@ discard block |
||
| 1538 | 1538 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 1539 | 1539 | title="Country" class="chosen_select"> |
| 1540 | 1540 | <?php |
| 1541 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 1542 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1543 | - endforeach; |
|
| 1544 | - ?> |
|
| 1541 | + if ($countries) foreach ($countries as $key => $val) : |
|
| 1542 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1543 | + endforeach; |
|
| 1544 | + ?> |
|
| 1545 | 1545 | </select> |
| 1546 | 1546 | </td> |
| 1547 | 1547 | </tr> |
| 1548 | 1548 | |
| 1549 | 1549 | <?php |
| 1550 | 1550 | |
| 1551 | - break; |
|
| 1551 | + break; |
|
| 1552 | 1552 | |
| 1553 | - case 'google_analytics' : |
|
| 1554 | - $selections = (array)get_option($value['id']); |
|
| 1555 | - ?> |
|
| 1553 | + case 'google_analytics' : |
|
| 1554 | + $selections = (array)get_option($value['id']); |
|
| 1555 | + ?> |
|
| 1556 | 1556 | <tr valign="top"> |
| 1557 | 1557 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1558 | 1558 | <td class="forminp"> |
@@ -1560,62 +1560,62 @@ discard block |
||
| 1560 | 1560 | |
| 1561 | 1561 | <?php |
| 1562 | 1562 | |
| 1563 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1564 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1565 | - $state = "&state=123";//any string |
|
| 1566 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1567 | - $response_type = "&response_type=code"; |
|
| 1568 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1569 | - $access_type = "&access_type=offline"; |
|
| 1570 | - $approval_prompt = "&approval_prompt=force"; |
|
| 1563 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1564 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1565 | + $state = "&state=123";//any string |
|
| 1566 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1567 | + $response_type = "&response_type=code"; |
|
| 1568 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1569 | + $access_type = "&access_type=offline"; |
|
| 1570 | + $approval_prompt = "&approval_prompt=force"; |
|
| 1571 | 1571 | |
| 1572 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1572 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1573 | 1573 | |
| 1574 | 1574 | |
| 1575 | - if (get_option('geodir_ga_auth_token')) {
|
|
| 1576 | - ?> |
|
| 1575 | + if (get_option('geodir_ga_auth_token')) {
|
|
| 1576 | + ?> |
|
| 1577 | 1577 | <span class="button-primary" |
| 1578 | 1578 | onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize');?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span>
|
| 1579 | 1579 | <span style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
|
| 1580 | 1580 | <?php |
| 1581 | - global $gd_ga_errors; |
|
| 1582 | - if(!empty($gd_ga_errors)){
|
|
| 1583 | - print_r($gd_ga_errors); |
|
| 1584 | - } |
|
| 1585 | - } else {
|
|
| 1586 | - ?> |
|
| 1581 | + global $gd_ga_errors; |
|
| 1582 | + if(!empty($gd_ga_errors)){
|
|
| 1583 | + print_r($gd_ga_errors); |
|
| 1584 | + } |
|
| 1585 | + } else {
|
|
| 1586 | + ?> |
|
| 1587 | 1587 | <span class="button-primary" |
| 1588 | 1588 | onclick="window.open('<?php echo geodir_ga_activation_url();?>', 'activate','width=700, height=600, menubar=0, status=0, location=0, toolbar=0')"><?php _e('Authorize', 'geodirectory');?></span>
|
| 1589 | 1589 | <?php |
| 1590 | - } |
|
| 1591 | - ?> |
|
| 1590 | + } |
|
| 1591 | + ?> |
|
| 1592 | 1592 | </td> |
| 1593 | 1593 | </tr> |
| 1594 | 1594 | |
| 1595 | 1595 | <?php |
| 1596 | 1596 | |
| 1597 | 1597 | |
| 1598 | - break; |
|
| 1598 | + break; |
|
| 1599 | 1599 | |
| 1600 | - case 'field_seperator' : |
|
| 1600 | + case 'field_seperator' : |
|
| 1601 | 1601 | |
| 1602 | - ?> |
|
| 1602 | + ?> |
|
| 1603 | 1603 | <tr valign="top"> |
| 1604 | 1604 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
| 1605 | 1605 | </tr> |
| 1606 | 1606 | <?php |
| 1607 | 1607 | |
| 1608 | - break; |
|
| 1608 | + break; |
|
| 1609 | 1609 | |
| 1610 | - endswitch; |
|
| 1610 | + endswitch; |
|
| 1611 | 1611 | |
| 1612 | - endforeach; |
|
| 1612 | + endforeach; |
|
| 1613 | 1613 | |
| 1614 | - if ($first_title === false) {
|
|
| 1615 | - echo "</div>"; |
|
| 1616 | - } |
|
| 1614 | + if ($first_title === false) {
|
|
| 1615 | + echo "</div>"; |
|
| 1616 | + } |
|
| 1617 | 1617 | |
| 1618 | - ?> |
|
| 1618 | + ?> |
|
| 1619 | 1619 | |
| 1620 | 1620 | <script type="text/javascript"> |
| 1621 | 1621 | |
@@ -1675,33 +1675,33 @@ discard block |
||
| 1675 | 1675 | */ |
| 1676 | 1676 | function geodir_post_info_setting() |
| 1677 | 1677 | {
|
| 1678 | - global $post, $post_id; |
|
| 1679 | - |
|
| 1680 | - $post_type = get_post_type(); |
|
| 1681 | - |
|
| 1682 | - $package_info = array(); |
|
| 1683 | - |
|
| 1684 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1685 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1686 | - echo '<div id="geodir_wrapper">'; |
|
| 1687 | - /** |
|
| 1688 | - * Called before the GD custom fields are output in the wp-admin area. |
|
| 1689 | - * |
|
| 1690 | - * @since 1.0.0 |
|
| 1691 | - * @see 'geodir_after_default_field_in_meta_box' |
|
| 1692 | - */ |
|
| 1693 | - do_action('geodir_before_default_field_in_meta_box');
|
|
| 1694 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 1695 | - // to display all fields in one information box |
|
| 1696 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 1697 | - /** |
|
| 1698 | - * Called after the GD custom fields are output in the wp-admin area. |
|
| 1699 | - * |
|
| 1700 | - * @since 1.0.0 |
|
| 1701 | - * @see 'geodir_before_default_field_in_meta_box' |
|
| 1702 | - */ |
|
| 1703 | - do_action('geodir_after_default_field_in_meta_box');
|
|
| 1704 | - echo '</div>'; |
|
| 1678 | + global $post, $post_id; |
|
| 1679 | + |
|
| 1680 | + $post_type = get_post_type(); |
|
| 1681 | + |
|
| 1682 | + $package_info = array(); |
|
| 1683 | + |
|
| 1684 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1685 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1686 | + echo '<div id="geodir_wrapper">'; |
|
| 1687 | + /** |
|
| 1688 | + * Called before the GD custom fields are output in the wp-admin area. |
|
| 1689 | + * |
|
| 1690 | + * @since 1.0.0 |
|
| 1691 | + * @see 'geodir_after_default_field_in_meta_box' |
|
| 1692 | + */ |
|
| 1693 | + do_action('geodir_before_default_field_in_meta_box');
|
|
| 1694 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 1695 | + // to display all fields in one information box |
|
| 1696 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 1697 | + /** |
|
| 1698 | + * Called after the GD custom fields are output in the wp-admin area. |
|
| 1699 | + * |
|
| 1700 | + * @since 1.0.0 |
|
| 1701 | + * @see 'geodir_before_default_field_in_meta_box' |
|
| 1702 | + */ |
|
| 1703 | + do_action('geodir_after_default_field_in_meta_box');
|
|
| 1704 | + echo '</div>'; |
|
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | /** |
@@ -1714,18 +1714,18 @@ discard block |
||
| 1714 | 1714 | */ |
| 1715 | 1715 | function geodir_post_addinfo_setting() |
| 1716 | 1716 | {
|
| 1717 | - global $post, $post_id; |
|
| 1717 | + global $post, $post_id; |
|
| 1718 | 1718 | |
| 1719 | - $post_type = get_post_type(); |
|
| 1719 | + $post_type = get_post_type(); |
|
| 1720 | 1720 | |
| 1721 | - $package_info = array(); |
|
| 1721 | + $package_info = array(); |
|
| 1722 | 1722 | |
| 1723 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1723 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1724 | 1724 | |
| 1725 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 1726 | - echo '<div id="geodir_wrapper">'; |
|
| 1727 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 1728 | - echo '</div>'; |
|
| 1725 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 1726 | + echo '<div id="geodir_wrapper">'; |
|
| 1727 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 1728 | + echo '</div>'; |
|
| 1729 | 1729 | |
| 1730 | 1730 | } |
| 1731 | 1731 | |
@@ -1739,60 +1739,60 @@ discard block |
||
| 1739 | 1739 | */ |
| 1740 | 1740 | function geodir_post_attachments() |
| 1741 | 1741 | {
|
| 1742 | - global $post, $post_id; |
|
| 1742 | + global $post, $post_id; |
|
| 1743 | 1743 | |
| 1744 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 1744 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 1745 | 1745 | |
| 1746 | - if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 1747 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 1748 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 1749 | - } |
|
| 1746 | + if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 1747 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 1748 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 1749 | + } |
|
| 1750 | 1750 | |
| 1751 | - $image_limit = 0; |
|
| 1751 | + $image_limit = 0; |
|
| 1752 | 1752 | |
| 1753 | - ?> |
|
| 1753 | + ?> |
|
| 1754 | 1754 | |
| 1755 | 1755 | |
| 1756 | 1756 | <h5 class="form_title"> |
| 1757 | 1757 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 1758 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 1759 | - } ?> |
|
| 1758 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 1759 | + } ?> |
|
| 1760 | 1760 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 1761 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 1762 | - } ?> |
|
| 1761 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 1762 | + } ?> |
|
| 1763 | 1763 | <?php if ($image_limit == 0) {
|
| 1764 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 1765 | - } ?> |
|
| 1764 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 1765 | + } ?> |
|
| 1766 | 1766 | </h5> |
| 1767 | 1767 | |
| 1768 | 1768 | |
| 1769 | 1769 | <?php |
| 1770 | 1770 | |
| 1771 | - $curImages = geodir_get_images($post_id); |
|
| 1772 | - $place_img_array = array(); |
|
| 1771 | + $curImages = geodir_get_images($post_id); |
|
| 1772 | + $place_img_array = array(); |
|
| 1773 | 1773 | |
| 1774 | - if (!empty($curImages)): |
|
| 1775 | - foreach ($curImages as $p_img): |
|
| 1776 | - $place_img_array[] = $p_img->src; |
|
| 1777 | - endforeach; |
|
| 1778 | - endif; |
|
| 1774 | + if (!empty($curImages)): |
|
| 1775 | + foreach ($curImages as $p_img): |
|
| 1776 | + $place_img_array[] = $p_img->src; |
|
| 1777 | + endforeach; |
|
| 1778 | + endif; |
|
| 1779 | 1779 | |
| 1780 | - if (!empty($place_img_array)) |
|
| 1781 | - $curImages = implode(',', $place_img_array);
|
|
| 1780 | + if (!empty($place_img_array)) |
|
| 1781 | + $curImages = implode(',', $place_img_array);
|
|
| 1782 | 1782 | |
| 1783 | 1783 | |
| 1784 | - // adjust values here |
|
| 1785 | - $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls |
|
| 1784 | + // adjust values here |
|
| 1785 | + $id = "post_images"; // this will be the name of form field. Image url(s) will be submitted in $_POST using this key. So if $id == �img1� then $_POST[�img1�] will have all the image urls |
|
| 1786 | 1786 | |
| 1787 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 1787 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 1788 | 1788 | |
| 1789 | - $multiple = true; // allow multiple files upload |
|
| 1789 | + $multiple = true; // allow multiple files upload |
|
| 1790 | 1790 | |
| 1791 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1791 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1792 | 1792 | |
| 1793 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1793 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1794 | 1794 | |
| 1795 | - ?> |
|
| 1795 | + ?> |
|
| 1796 | 1796 | |
| 1797 | 1797 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
| 1798 | 1798 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -1834,13 +1834,13 @@ discard block |
||
| 1834 | 1834 | */ |
| 1835 | 1835 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
| 1836 | 1836 | {
|
| 1837 | - $post_type = get_post_type($post_ID); |
|
| 1837 | + $post_type = get_post_type($post_ID); |
|
| 1838 | 1838 | |
| 1839 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1840 | - if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
|
|
| 1841 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 1842 | - } |
|
| 1843 | - } |
|
| 1839 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1840 | + if ($post_type != '' && in_array($post_type, geodir_get_posttypes()) && !wp_is_post_revision($post_ID) && !empty($post_after->post_title) && $post_after->post_title != $post_before->post_title) {
|
|
| 1841 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 1842 | + } |
|
| 1843 | + } |
|
| 1844 | 1844 | } |
| 1845 | 1845 | |
| 1846 | 1846 | /** |
@@ -1855,39 +1855,39 @@ discard block |
||
| 1855 | 1855 | */ |
| 1856 | 1856 | function geodir_notification_add_bcc_option($settings) |
| 1857 | 1857 | {
|
| 1858 | - if (!empty($settings)) {
|
|
| 1859 | - $new_settings = array(); |
|
| 1860 | - foreach ($settings as $setting) {
|
|
| 1861 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 1862 | - $geodir_bcc_listing_published_yes = array( |
|
| 1863 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 1864 | - 'desc' => __('Yes', 'geodirectory'),
|
|
| 1865 | - 'id' => 'geodir_bcc_listing_published', |
|
| 1866 | - 'std' => 'yes', |
|
| 1867 | - 'type' => 'radio', |
|
| 1868 | - 'value' => '1', |
|
| 1869 | - 'radiogroup' => 'start' |
|
| 1870 | - ); |
|
| 1871 | - |
|
| 1872 | - $geodir_bcc_listing_published_no = array( |
|
| 1873 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 1874 | - 'desc' => __('No', 'geodirectory'),
|
|
| 1875 | - 'id' => 'geodir_bcc_listing_published', |
|
| 1876 | - 'std' => 'yes', |
|
| 1877 | - 'type' => 'radio', |
|
| 1878 | - 'value' => '0', |
|
| 1879 | - 'radiogroup' => 'end' |
|
| 1880 | - ); |
|
| 1881 | - |
|
| 1882 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 1883 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 1884 | - } |
|
| 1885 | - $new_settings[] = $setting; |
|
| 1886 | - } |
|
| 1887 | - $settings = $new_settings; |
|
| 1888 | - } |
|
| 1858 | + if (!empty($settings)) {
|
|
| 1859 | + $new_settings = array(); |
|
| 1860 | + foreach ($settings as $setting) {
|
|
| 1861 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 1862 | + $geodir_bcc_listing_published_yes = array( |
|
| 1863 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 1864 | + 'desc' => __('Yes', 'geodirectory'),
|
|
| 1865 | + 'id' => 'geodir_bcc_listing_published', |
|
| 1866 | + 'std' => 'yes', |
|
| 1867 | + 'type' => 'radio', |
|
| 1868 | + 'value' => '1', |
|
| 1869 | + 'radiogroup' => 'start' |
|
| 1870 | + ); |
|
| 1871 | + |
|
| 1872 | + $geodir_bcc_listing_published_no = array( |
|
| 1873 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 1874 | + 'desc' => __('No', 'geodirectory'),
|
|
| 1875 | + 'id' => 'geodir_bcc_listing_published', |
|
| 1876 | + 'std' => 'yes', |
|
| 1877 | + 'type' => 'radio', |
|
| 1878 | + 'value' => '0', |
|
| 1879 | + 'radiogroup' => 'end' |
|
| 1880 | + ); |
|
| 1881 | + |
|
| 1882 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 1883 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 1884 | + } |
|
| 1885 | + $new_settings[] = $setting; |
|
| 1886 | + } |
|
| 1887 | + $settings = $new_settings; |
|
| 1888 | + } |
|
| 1889 | 1889 | |
| 1890 | - return $settings; |
|
| 1890 | + return $settings; |
|
| 1891 | 1891 | } |
| 1892 | 1892 | |
| 1893 | 1893 | |
@@ -1902,19 +1902,19 @@ discard block |
||
| 1902 | 1902 | */ |
| 1903 | 1903 | function get_gd_theme_compat_callback() |
| 1904 | 1904 | {
|
| 1905 | - global $wpdb; |
|
| 1906 | - $themes = get_option('gd_theme_compats');
|
|
| 1907 | - |
|
| 1908 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 1909 | - if (isset($_POST['export'])) {
|
|
| 1910 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 1911 | - } else {
|
|
| 1912 | - echo json_encode($themes[$_POST['theme']]); |
|
| 1913 | - } |
|
| 1905 | + global $wpdb; |
|
| 1906 | + $themes = get_option('gd_theme_compats');
|
|
| 1914 | 1907 | |
| 1915 | - } |
|
| 1908 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 1909 | + if (isset($_POST['export'])) {
|
|
| 1910 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 1911 | + } else {
|
|
| 1912 | + echo json_encode($themes[$_POST['theme']]); |
|
| 1913 | + } |
|
| 1914 | + |
|
| 1915 | + } |
|
| 1916 | 1916 | |
| 1917 | - die(); |
|
| 1917 | + die(); |
|
| 1918 | 1918 | } |
| 1919 | 1919 | |
| 1920 | 1920 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
|
@@ -1928,20 +1928,20 @@ discard block |
||
| 1928 | 1928 | */ |
| 1929 | 1929 | function get_gd_theme_compat_import_callback() |
| 1930 | 1930 | {
|
| 1931 | - global $wpdb; |
|
| 1932 | - $themes = get_option('gd_theme_compats');
|
|
| 1933 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 1934 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 1935 | - if (!empty($json) && is_array($json)) {
|
|
| 1936 | - $key = sanitize_text_field(key($json)); |
|
| 1937 | - $themes[$key] = $json[$key]; |
|
| 1938 | - update_option('gd_theme_compats', $themes);
|
|
| 1939 | - echo $key; |
|
| 1940 | - die(); |
|
| 1941 | - } |
|
| 1942 | - } |
|
| 1943 | - echo '0'; |
|
| 1944 | - die(); |
|
| 1931 | + global $wpdb; |
|
| 1932 | + $themes = get_option('gd_theme_compats');
|
|
| 1933 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 1934 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 1935 | + if (!empty($json) && is_array($json)) {
|
|
| 1936 | + $key = sanitize_text_field(key($json)); |
|
| 1937 | + $themes[$key] = $json[$key]; |
|
| 1938 | + update_option('gd_theme_compats', $themes);
|
|
| 1939 | + echo $key; |
|
| 1940 | + die(); |
|
| 1941 | + } |
|
| 1942 | + } |
|
| 1943 | + echo '0'; |
|
| 1944 | + die(); |
|
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | |
@@ -1954,39 +1954,39 @@ discard block |
||
| 1954 | 1954 | */ |
| 1955 | 1955 | function gd_set_theme_compat() |
| 1956 | 1956 | {
|
| 1957 | - global $wpdb; |
|
| 1958 | - $theme = wp_get_theme(); |
|
| 1957 | + global $wpdb; |
|
| 1958 | + $theme = wp_get_theme(); |
|
| 1959 | 1959 | |
| 1960 | - if ($theme->parent()) {
|
|
| 1961 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 1962 | - } else {
|
|
| 1963 | - $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 1964 | - } |
|
| 1960 | + if ($theme->parent()) {
|
|
| 1961 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 1962 | + } else {
|
|
| 1963 | + $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 1964 | + } |
|
| 1965 | 1965 | |
| 1966 | - $theme_compats = get_option('gd_theme_compats');
|
|
| 1967 | - $current_compat = get_option('gd_theme_compat');
|
|
| 1968 | - $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 1966 | + $theme_compats = get_option('gd_theme_compats');
|
|
| 1967 | + $current_compat = get_option('gd_theme_compat');
|
|
| 1968 | + $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 1969 | 1969 | |
| 1970 | - if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
|
|
| 1971 | - return; |
|
| 1972 | - }// if already running correct compat then bail |
|
| 1970 | + if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
|
|
| 1971 | + return; |
|
| 1972 | + }// if already running correct compat then bail |
|
| 1973 | 1973 | |
| 1974 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 1975 | - update_option('gd_theme_compat', $theme_name);
|
|
| 1976 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 1974 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 1975 | + update_option('gd_theme_compat', $theme_name);
|
|
| 1976 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 1977 | 1977 | |
| 1978 | - // if there are default options to set then set them |
|
| 1979 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 1978 | + // if there are default options to set then set them |
|
| 1979 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 1980 | 1980 | |
| 1981 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 1982 | - update_option($key, $val); |
|
| 1983 | - } |
|
| 1984 | - } |
|
| 1981 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 1982 | + update_option($key, $val); |
|
| 1983 | + } |
|
| 1984 | + } |
|
| 1985 | 1985 | |
| 1986 | - } else {
|
|
| 1987 | - update_option('gd_theme_compat', '');
|
|
| 1988 | - update_option('theme_compatibility_setting', '');
|
|
| 1989 | - } |
|
| 1986 | + } else {
|
|
| 1987 | + update_option('gd_theme_compat', '');
|
|
| 1988 | + update_option('theme_compatibility_setting', '');
|
|
| 1989 | + } |
|
| 1990 | 1990 | |
| 1991 | 1991 | |
| 1992 | 1992 | } |
@@ -2001,9 +2001,9 @@ discard block |
||
| 2001 | 2001 | */ |
| 2002 | 2002 | function gd_check_avada_compat() |
| 2003 | 2003 | {
|
| 2004 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 2005 | - add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 2006 | - } |
|
| 2004 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 2005 | + add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 2006 | + } |
|
| 2007 | 2007 | } |
| 2008 | 2008 | |
| 2009 | 2009 | |
@@ -2016,22 +2016,22 @@ discard block |
||
| 2016 | 2016 | function gd_avada_compat_warning() |
| 2017 | 2017 | {
|
| 2018 | 2018 | |
| 2019 | - /* |
|
| 2019 | + /* |
|
| 2020 | 2020 | $msg_type = error |
| 2021 | 2021 | $msg_type = updated fade |
| 2022 | 2022 | $msg_type = update-nag |
| 2023 | 2023 | */ |
| 2024 | 2024 | |
| 2025 | - $plugin = 'avada-nag'; |
|
| 2026 | - $timestamp = 'avada-nag1234'; |
|
| 2027 | - $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
|
|
| 2028 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2029 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2030 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2031 | - echo "<p>$message</p>"; |
|
| 2032 | - echo "</div>"; |
|
| 2025 | + $plugin = 'avada-nag'; |
|
| 2026 | + $timestamp = 'avada-nag1234'; |
|
| 2027 | + $message = __('Welcome to GeoDirectory, please have a look <a href="https://docs.wpgeodirectory.com/category/getting-started/" target="_blank">here</a> to get started. :)', 'geodirectory');
|
|
| 2028 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2029 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2030 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2031 | + echo "<p>$message</p>"; |
|
| 2032 | + echo "</div>"; |
|
| 2033 | 2033 | |
| 2034 | - ?> |
|
| 2034 | + ?> |
|
| 2035 | 2035 | <script> |
| 2036 | 2036 | function gdRemoveANotification($plugin, $timestamp) {
|
| 2037 | 2037 | |
@@ -2099,10 +2099,10 @@ discard block |
||
| 2099 | 2099 | */ |
| 2100 | 2100 | function geodir_avada_remove_notification() |
| 2101 | 2101 | {
|
| 2102 | - update_option('avada_nag', TRUE);
|
|
| 2102 | + update_option('avada_nag', TRUE);
|
|
| 2103 | 2103 | |
| 2104 | - // Always die in functions echoing ajax content |
|
| 2105 | - die(); |
|
| 2104 | + // Always die in functions echoing ajax content |
|
| 2105 | + die(); |
|
| 2106 | 2106 | } |
| 2107 | 2107 | |
| 2108 | 2108 | |
@@ -2124,11 +2124,11 @@ discard block |
||
| 2124 | 2124 | global $post, $typenow, $current_screen; |
| 2125 | 2125 | |
| 2126 | 2126 | $post_type = NULL; |
| 2127 | - if (isset($_REQUEST['post_type'])) |
|
| 2127 | + if (isset($_REQUEST['post_type'])) |
|
| 2128 | 2128 | $post_type = sanitize_key($_REQUEST['post_type']); |
| 2129 | - elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2129 | + elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2130 | 2130 | $post_type = get_post_type($_REQUEST['post']); |
| 2131 | - elseif ($post && isset($post->post_type)) |
|
| 2131 | + elseif ($post && isset($post->post_type)) |
|
| 2132 | 2132 | $post_type = $post->post_type; |
| 2133 | 2133 | elseif ($typenow) |
| 2134 | 2134 | $post_type = $typenow; |
@@ -2162,7 +2162,7 @@ discard block |
||
| 2162 | 2162 | // Don't allow same slug url for listing and location |
| 2163 | 2163 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 2164 | 2164 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
| 2165 | - wp_redirect($redirect_url); |
|
| 2165 | + wp_redirect($redirect_url); |
|
| 2166 | 2166 | exit; |
| 2167 | 2167 | } |
| 2168 | 2168 | |
@@ -2192,10 +2192,10 @@ discard block |
||
| 2192 | 2192 | * @package GeoDirectory |
| 2193 | 2193 | */ |
| 2194 | 2194 | function geodir_hide_admin_preview_button() {
|
| 2195 | - global $post_type; |
|
| 2196 | - $post_types = geodir_get_posttypes(); |
|
| 2197 | - if(in_array($post_type, $post_types)) |
|
| 2198 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2195 | + global $post_type; |
|
| 2196 | + $post_types = geodir_get_posttypes(); |
|
| 2197 | + if(in_array($post_type, $post_types)) |
|
| 2198 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2199 | 2199 | } |
| 2200 | 2200 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 2201 | 2201 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -2210,7 +2210,7 @@ discard block |
||
| 2210 | 2210 | */ |
| 2211 | 2211 | function geodir_import_export_tab( $tabs ) {
|
| 2212 | 2212 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
| 2213 | - return $tabs; |
|
| 2213 | + return $tabs; |
|
| 2214 | 2214 | } |
| 2215 | 2215 | |
| 2216 | 2216 | /** |
@@ -2225,26 +2225,26 @@ discard block |
||
| 2225 | 2225 | function geodir_import_export_page() {
|
| 2226 | 2226 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
| 2227 | 2227 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
| 2228 | - /** |
|
| 2229 | - * Filter sample category data csv file url. |
|
| 2230 | - * |
|
| 2231 | - * @since 1.0.0 |
|
| 2232 | - * @package GeoDirectory |
|
| 2233 | - * |
|
| 2234 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2235 | - */ |
|
| 2228 | + /** |
|
| 2229 | + * Filter sample category data csv file url. |
|
| 2230 | + * |
|
| 2231 | + * @since 1.0.0 |
|
| 2232 | + * @package GeoDirectory |
|
| 2233 | + * |
|
| 2234 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2235 | + */ |
|
| 2236 | 2236 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
| 2237 | 2237 | |
| 2238 | 2238 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
| 2239 | - /** |
|
| 2240 | - * Filter sample post data csv file url. |
|
| 2241 | - * |
|
| 2242 | - * @since 1.0.0 |
|
| 2243 | - * @package GeoDirectory |
|
| 2244 | - * |
|
| 2245 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2246 | - */ |
|
| 2247 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2239 | + /** |
|
| 2240 | + * Filter sample post data csv file url. |
|
| 2241 | + * |
|
| 2242 | + * @since 1.0.0 |
|
| 2243 | + * @package GeoDirectory |
|
| 2244 | + * |
|
| 2245 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2246 | + */ |
|
| 2247 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2248 | 2248 | |
| 2249 | 2249 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
| 2250 | 2250 | |
@@ -2267,14 +2267,14 @@ discard block |
||
| 2267 | 2267 | $gd_chunksize_options[100000] = 100000; |
| 2268 | 2268 | |
| 2269 | 2269 | /** |
| 2270 | - * Filter max entries per export csv file. |
|
| 2271 | - * |
|
| 2272 | - * @since 1.5.6 |
|
| 2273 | - * @package GeoDirectory |
|
| 2274 | - * |
|
| 2275 | - * @param string $gd_chunksize_options Entries options. |
|
| 2276 | - */ |
|
| 2277 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2270 | + * Filter max entries per export csv file. |
|
| 2271 | + * |
|
| 2272 | + * @since 1.5.6 |
|
| 2273 | + * @package GeoDirectory |
|
| 2274 | + * |
|
| 2275 | + * @param string $gd_chunksize_options Entries options. |
|
| 2276 | + */ |
|
| 2277 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2278 | 2278 | |
| 2279 | 2279 | $gd_chunksize_option = ''; |
| 2280 | 2280 | foreach ($gd_chunksize_options as $value => $title) {
|
@@ -2291,12 +2291,12 @@ discard block |
||
| 2291 | 2291 | <div class="gd-content-heading"> |
| 2292 | 2292 | |
| 2293 | 2293 | <?php |
| 2294 | - ini_set('max_execution_time', 999999);
|
|
| 2295 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2296 | - ini_restore('max_execution_time');
|
|
| 2294 | + ini_set('max_execution_time', 999999);
|
|
| 2295 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2296 | + ini_restore('max_execution_time');
|
|
| 2297 | 2297 | |
| 2298 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2299 | - ?> |
|
| 2298 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2299 | + ?> |
|
| 2300 | 2300 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 2301 | 2301 | <div class="meta-box-sortables ui-sortable"> |
| 2302 | 2302 | <div class="postbox"> |
@@ -2471,7 +2471,7 @@ discard block |
||
| 2471 | 2471 | * Called just after the sample CSV download link. |
| 2472 | 2472 | * |
| 2473 | 2473 | * @since 1.0.0 |
| 2474 | - * @package GeoDirectory |
|
| 2474 | + * @package GeoDirectory |
|
| 2475 | 2475 | */ |
| 2476 | 2476 | do_action('geodir_sample_cats_csv_download_link');
|
| 2477 | 2477 | ?> |
@@ -2556,11 +2556,11 @@ discard block |
||
| 2556 | 2556 | * |
| 2557 | 2557 | * Called after the last setting on the GD > Import & Export page. |
| 2558 | 2558 | * @since 1.4.6 |
| 2559 | - * @package GeoDirectory |
|
| 2559 | + * @package GeoDirectory |
|
| 2560 | 2560 | * |
| 2561 | 2561 | * @param array $gd_posttypes GD post types. |
| 2562 | - * @param array $gd_chunksize_options File chunk size options. |
|
| 2563 | - * @param string $nonce Wordpress security token for GD import & export. |
|
| 2562 | + * @param array $gd_chunksize_options File chunk size options. |
|
| 2563 | + * @param string $nonce Wordpress security token for GD import & export. |
|
| 2564 | 2564 | */ |
| 2565 | 2565 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
| 2566 | 2566 | ?> |
@@ -3247,44 +3247,44 @@ discard block |
||
| 3247 | 3247 | function geodir_init_filesystem() |
| 3248 | 3248 | {
|
| 3249 | 3249 | |
| 3250 | - if(!function_exists('get_filesystem_method')){
|
|
| 3251 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3252 | - } |
|
| 3253 | - $access_type = get_filesystem_method(); |
|
| 3254 | - if ($access_type === 'direct') {
|
|
| 3255 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3256 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3257 | - |
|
| 3258 | - /* initialize the API */ |
|
| 3259 | - if (!WP_Filesystem($creds)) {
|
|
| 3260 | - /* any problems and we exit */ |
|
| 3261 | - //return '@@@3'; |
|
| 3262 | - return false; |
|
| 3263 | - } |
|
| 3250 | + if(!function_exists('get_filesystem_method')){
|
|
| 3251 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3252 | + } |
|
| 3253 | + $access_type = get_filesystem_method(); |
|
| 3254 | + if ($access_type === 'direct') {
|
|
| 3255 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3256 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3257 | + |
|
| 3258 | + /* initialize the API */ |
|
| 3259 | + if (!WP_Filesystem($creds)) {
|
|
| 3260 | + /* any problems and we exit */ |
|
| 3261 | + //return '@@@3'; |
|
| 3262 | + return false; |
|
| 3263 | + } |
|
| 3264 | 3264 | |
| 3265 | - global $wp_filesystem; |
|
| 3266 | - return $wp_filesystem; |
|
| 3267 | - /* do our file manipulations below */ |
|
| 3268 | - } elseif (defined('FTP_USER')) {
|
|
| 3269 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3265 | + global $wp_filesystem; |
|
| 3266 | + return $wp_filesystem; |
|
| 3267 | + /* do our file manipulations below */ |
|
| 3268 | + } elseif (defined('FTP_USER')) {
|
|
| 3269 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3270 | + |
|
| 3271 | + /* initialize the API */ |
|
| 3272 | + if (!WP_Filesystem($creds)) {
|
|
| 3273 | + /* any problems and we exit */ |
|
| 3274 | + //return '@@@33'; |
|
| 3275 | + return false; |
|
| 3276 | + } |
|
| 3270 | 3277 | |
| 3271 | - /* initialize the API */ |
|
| 3272 | - if (!WP_Filesystem($creds)) {
|
|
| 3273 | - /* any problems and we exit */ |
|
| 3274 | - //return '@@@33'; |
|
| 3275 | - return false; |
|
| 3276 | - } |
|
| 3278 | + global $wp_filesystem; |
|
| 3279 | + //return '@@@1'; |
|
| 3280 | + return $wp_filesystem; |
|
| 3277 | 3281 | |
| 3278 | - global $wp_filesystem; |
|
| 3279 | - //return '@@@1'; |
|
| 3280 | - return $wp_filesystem; |
|
| 3281 | - |
|
| 3282 | - } else {
|
|
| 3283 | - //return '@@@2'; |
|
| 3284 | - /* don't have direct write access. Prompt user with our notice */ |
|
| 3285 | - add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3286 | - return false; |
|
| 3287 | - } |
|
| 3282 | + } else {
|
|
| 3283 | + //return '@@@2'; |
|
| 3284 | + /* don't have direct write access. Prompt user with our notice */ |
|
| 3285 | + add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3286 | + return false; |
|
| 3287 | + } |
|
| 3288 | 3288 | |
| 3289 | 3289 | } |
| 3290 | 3290 | |
@@ -3302,10 +3302,10 @@ discard block |
||
| 3302 | 3302 | */ |
| 3303 | 3303 | function geodir_filesystem_notice() |
| 3304 | 3304 | { if ( defined( 'DOING_AJAX' ) ){return;}
|
| 3305 | - $access_type = get_filesystem_method(); |
|
| 3306 | - if ($access_type === 'direct') {
|
|
| 3307 | - } elseif (!defined('FTP_USER')) {
|
|
| 3308 | - ?> |
|
| 3305 | + $access_type = get_filesystem_method(); |
|
| 3306 | + if ($access_type === 'direct') {
|
|
| 3307 | + } elseif (!defined('FTP_USER')) {
|
|
| 3308 | + ?> |
|
| 3309 | 3309 | <div class="error"> |
| 3310 | 3310 | <p><?php _e('GeoDirectory does not have access to your filesystem, thing like import/export will not work. Please define your details in wp-config.php as explained here', 'geodirectory'); ?>
|
| 3311 | 3311 | <a target="_blank" href="http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants">http://codex.wordpress.org/Editing_wp-config.php#WordPress_Upgrade_Constants</a> |
@@ -3333,1280 +3333,1280 @@ discard block |
||
| 3333 | 3333 | * @return string Json data. |
| 3334 | 3334 | */ |
| 3335 | 3335 | function geodir_ajax_import_export() {
|
| 3336 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3336 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3337 | 3337 | |
| 3338 | - error_reporting(0); |
|
| 3338 | + error_reporting(0); |
|
| 3339 | 3339 | |
| 3340 | - $xstart = microtime(true); |
|
| 3340 | + $xstart = microtime(true); |
|
| 3341 | 3341 | |
| 3342 | - // try to set higher limits for import |
|
| 3343 | - $max_input_time = ini_get('max_input_time');
|
|
| 3344 | - $max_execution_time = ini_get('max_execution_time');
|
|
| 3345 | - $memory_limit= ini_get('memory_limit');
|
|
| 3342 | + // try to set higher limits for import |
|
| 3343 | + $max_input_time = ini_get('max_input_time');
|
|
| 3344 | + $max_execution_time = ini_get('max_execution_time');
|
|
| 3345 | + $memory_limit= ini_get('memory_limit');
|
|
| 3346 | 3346 | |
| 3347 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 3348 | - ini_set('max_input_time', 3000);
|
|
| 3349 | - } |
|
| 3347 | + if(!$max_input_time || $max_input_time<3000){
|
|
| 3348 | + ini_set('max_input_time', 3000);
|
|
| 3349 | + } |
|
| 3350 | 3350 | |
| 3351 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3352 | - ini_set('max_execution_time', 3000);
|
|
| 3353 | - } |
|
| 3351 | + if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3352 | + ini_set('max_execution_time', 3000);
|
|
| 3353 | + } |
|
| 3354 | 3354 | |
| 3355 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3356 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 3357 | - ini_set('memory_limit', '256M');
|
|
| 3358 | - } |
|
| 3359 | - } |
|
| 3355 | + if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3356 | + if(str_replace('M','',$memory_limit)<256){
|
|
| 3357 | + ini_set('memory_limit', '256M');
|
|
| 3358 | + } |
|
| 3359 | + } |
|
| 3360 | 3360 | |
| 3361 | - $json = array(); |
|
| 3361 | + $json = array(); |
|
| 3362 | 3362 | |
| 3363 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3364 | - wp_send_json( $json ); |
|
| 3365 | - } |
|
| 3363 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3364 | + wp_send_json( $json ); |
|
| 3365 | + } |
|
| 3366 | 3366 | |
| 3367 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3368 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3369 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3367 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3368 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3369 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3370 | 3370 | |
| 3371 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3372 | - wp_send_json( $json ); |
|
| 3373 | - } |
|
| 3371 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3372 | + wp_send_json( $json ); |
|
| 3373 | + } |
|
| 3374 | 3374 | |
| 3375 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3376 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3377 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3378 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3375 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3376 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3377 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3378 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3379 | 3379 | |
| 3380 | - $wp_filesystem = geodir_init_filesystem(); |
|
| 3381 | - if (!$wp_filesystem) {
|
|
| 3382 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3383 | - wp_send_json( $json ); |
|
| 3384 | - } |
|
| 3380 | + $wp_filesystem = geodir_init_filesystem(); |
|
| 3381 | + if (!$wp_filesystem) {
|
|
| 3382 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3383 | + wp_send_json( $json ); |
|
| 3384 | + } |
|
| 3385 | 3385 | |
| 3386 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3387 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3388 | - wp_send_json( $json ); |
|
| 3389 | - } |
|
| 3386 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3387 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3388 | + wp_send_json( $json ); |
|
| 3389 | + } |
|
| 3390 | 3390 | |
| 3391 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 3392 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3393 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3394 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3395 | - wp_send_json( $json ); |
|
| 3396 | - } |
|
| 3397 | - } |
|
| 3391 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 3392 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3393 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3394 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3395 | + wp_send_json( $json ); |
|
| 3396 | + } |
|
| 3397 | + } |
|
| 3398 | 3398 | |
| 3399 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3400 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3401 | - |
|
| 3402 | - switch ( $task ) {
|
|
| 3403 | - case 'export_posts': {
|
|
| 3404 | - // WPML |
|
| 3405 | - $is_wpml = geodir_is_wpml(); |
|
| 3406 | - if ($is_wpml) {
|
|
| 3407 | - global $sitepress; |
|
| 3408 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3399 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3400 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3401 | + |
|
| 3402 | + switch ( $task ) {
|
|
| 3403 | + case 'export_posts': {
|
|
| 3404 | + // WPML |
|
| 3405 | + $is_wpml = geodir_is_wpml(); |
|
| 3406 | + if ($is_wpml) {
|
|
| 3407 | + global $sitepress; |
|
| 3408 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3409 | 3409 | |
| 3410 | - $sitepress->switch_lang('all', true);
|
|
| 3411 | - } |
|
| 3412 | - // WPML |
|
| 3413 | - if ( $post_type == 'gd_event' ) {
|
|
| 3414 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3415 | - } |
|
| 3416 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 3410 | + $sitepress->switch_lang('all', true);
|
|
| 3411 | + } |
|
| 3412 | + // WPML |
|
| 3413 | + if ( $post_type == 'gd_event' ) {
|
|
| 3414 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3415 | + } |
|
| 3416 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 3417 | 3417 | |
| 3418 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3419 | - if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
|
|
| 3420 | - $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
| 3421 | - } |
|
| 3422 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3423 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3424 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3425 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3426 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3418 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3419 | + if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
|
|
| 3420 | + $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
| 3421 | + } |
|
| 3422 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3423 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3424 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3425 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3426 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3427 | 3427 | |
| 3428 | - $chunk_file_paths = array(); |
|
| 3428 | + $chunk_file_paths = array(); |
|
| 3429 | 3429 | |
| 3430 | - if ( isset( $_REQUEST['_c'] ) ) {
|
|
| 3431 | - $json['total'] = $posts_count; |
|
| 3432 | - // WPML |
|
| 3433 | - if ($is_wpml) {
|
|
| 3434 | - $sitepress->switch_lang($active_lang, true); |
|
| 3435 | - } |
|
| 3436 | - // WPML |
|
| 3437 | - wp_send_json( $json ); |
|
| 3438 | - gd_die(); |
|
| 3439 | - } else if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3440 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3441 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3442 | - $percentage = min( $percentage, 100 ); |
|
| 3430 | + if ( isset( $_REQUEST['_c'] ) ) {
|
|
| 3431 | + $json['total'] = $posts_count; |
|
| 3432 | + // WPML |
|
| 3433 | + if ($is_wpml) {
|
|
| 3434 | + $sitepress->switch_lang($active_lang, true); |
|
| 3435 | + } |
|
| 3436 | + // WPML |
|
| 3437 | + wp_send_json( $json ); |
|
| 3438 | + gd_die(); |
|
| 3439 | + } else if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3440 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3441 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3442 | + $percentage = min( $percentage, 100 ); |
|
| 3443 | 3443 | |
| 3444 | - $json['percentage'] = $percentage; |
|
| 3445 | - // WPML |
|
| 3446 | - if ($is_wpml) {
|
|
| 3447 | - $sitepress->switch_lang($active_lang, true); |
|
| 3448 | - } |
|
| 3449 | - // WPML |
|
| 3450 | - wp_send_json( $json ); |
|
| 3451 | - gd_die(); |
|
| 3452 | - } else {
|
|
| 3453 | - if ( !$posts_count > 0 ) {
|
|
| 3454 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3455 | - } else {
|
|
| 3456 | - $total_posts = $posts_count; |
|
| 3457 | - if ($chunk_per_page > $total_posts) {
|
|
| 3458 | - $chunk_per_page = $total_posts; |
|
| 3459 | - } |
|
| 3460 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3444 | + $json['percentage'] = $percentage; |
|
| 3445 | + // WPML |
|
| 3446 | + if ($is_wpml) {
|
|
| 3447 | + $sitepress->switch_lang($active_lang, true); |
|
| 3448 | + } |
|
| 3449 | + // WPML |
|
| 3450 | + wp_send_json( $json ); |
|
| 3451 | + gd_die(); |
|
| 3452 | + } else {
|
|
| 3453 | + if ( !$posts_count > 0 ) {
|
|
| 3454 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3455 | + } else {
|
|
| 3456 | + $total_posts = $posts_count; |
|
| 3457 | + if ($chunk_per_page > $total_posts) {
|
|
| 3458 | + $chunk_per_page = $total_posts; |
|
| 3459 | + } |
|
| 3460 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3461 | 3461 | |
| 3462 | - $j = $chunk_page_no; |
|
| 3463 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3462 | + $j = $chunk_page_no; |
|
| 3463 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3464 | 3464 | |
| 3465 | - $per_page = 500; |
|
| 3466 | - if ($per_page > $chunk_per_page) {
|
|
| 3467 | - $per_page = $chunk_per_page; |
|
| 3468 | - } |
|
| 3469 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3465 | + $per_page = 500; |
|
| 3466 | + if ($per_page > $chunk_per_page) {
|
|
| 3467 | + $per_page = $chunk_per_page; |
|
| 3468 | + } |
|
| 3469 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3470 | 3470 | |
| 3471 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3472 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3471 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3472 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3473 | 3473 | |
| 3474 | - $clear = $i == 0 ? true : false; |
|
| 3475 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3476 | - } |
|
| 3474 | + $clear = $i == 0 ? true : false; |
|
| 3475 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3476 | + } |
|
| 3477 | 3477 | |
| 3478 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3479 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3480 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3481 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3482 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3478 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3479 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3480 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3481 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3482 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3483 | 3483 | |
| 3484 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3485 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3486 | - } |
|
| 3484 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3485 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3486 | + } |
|
| 3487 | 3487 | |
| 3488 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3489 | - $json['total'] = $posts_count; |
|
| 3490 | - $json['files'] = $chunk_file_paths; |
|
| 3491 | - } else {
|
|
| 3492 | - if ($j > 1) {
|
|
| 3493 | - $json['total'] = $posts_count; |
|
| 3494 | - $json['files'] = array(); |
|
| 3495 | - } else {
|
|
| 3496 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3497 | - } |
|
| 3498 | - } |
|
| 3499 | - } |
|
| 3500 | - // WPML |
|
| 3501 | - if ($is_wpml) {
|
|
| 3502 | - $sitepress->switch_lang($active_lang, true); |
|
| 3503 | - } |
|
| 3504 | - // WPML |
|
| 3505 | - wp_send_json( $json ); |
|
| 3506 | - } |
|
| 3507 | - } |
|
| 3508 | - break; |
|
| 3509 | - case 'export_cats': {
|
|
| 3510 | - // WPML |
|
| 3511 | - $is_wpml = geodir_is_wpml(); |
|
| 3512 | - if ($is_wpml) {
|
|
| 3513 | - global $sitepress; |
|
| 3514 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3488 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3489 | + $json['total'] = $posts_count; |
|
| 3490 | + $json['files'] = $chunk_file_paths; |
|
| 3491 | + } else {
|
|
| 3492 | + if ($j > 1) {
|
|
| 3493 | + $json['total'] = $posts_count; |
|
| 3494 | + $json['files'] = array(); |
|
| 3495 | + } else {
|
|
| 3496 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3497 | + } |
|
| 3498 | + } |
|
| 3499 | + } |
|
| 3500 | + // WPML |
|
| 3501 | + if ($is_wpml) {
|
|
| 3502 | + $sitepress->switch_lang($active_lang, true); |
|
| 3503 | + } |
|
| 3504 | + // WPML |
|
| 3505 | + wp_send_json( $json ); |
|
| 3506 | + } |
|
| 3507 | + } |
|
| 3508 | + break; |
|
| 3509 | + case 'export_cats': {
|
|
| 3510 | + // WPML |
|
| 3511 | + $is_wpml = geodir_is_wpml(); |
|
| 3512 | + if ($is_wpml) {
|
|
| 3513 | + global $sitepress; |
|
| 3514 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3515 | 3515 | |
| 3516 | - $sitepress->switch_lang('all', true);
|
|
| 3517 | - } |
|
| 3518 | - // WPML |
|
| 3519 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3516 | + $sitepress->switch_lang('all', true);
|
|
| 3517 | + } |
|
| 3518 | + // WPML |
|
| 3519 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3520 | 3520 | |
| 3521 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3522 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3523 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3524 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3525 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3521 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3522 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3523 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3524 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3525 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3526 | 3526 | |
| 3527 | - $chunk_file_paths = array(); |
|
| 3527 | + $chunk_file_paths = array(); |
|
| 3528 | 3528 | |
| 3529 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3530 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3531 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3532 | - $percentage = min( $percentage, 100 ); |
|
| 3529 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3530 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3531 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3532 | + $percentage = min( $percentage, 100 ); |
|
| 3533 | 3533 | |
| 3534 | - $json['percentage'] = $percentage; |
|
| 3535 | - // WPML |
|
| 3536 | - if ($is_wpml) {
|
|
| 3537 | - $sitepress->switch_lang($active_lang, true); |
|
| 3538 | - } |
|
| 3539 | - // WPML |
|
| 3540 | - wp_send_json( $json ); |
|
| 3541 | - } else {
|
|
| 3542 | - if ( !$terms_count > 0 ) {
|
|
| 3543 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3544 | - } else {
|
|
| 3545 | - $total_terms = $terms_count; |
|
| 3546 | - if ($chunk_per_page > $terms_count) {
|
|
| 3547 | - $chunk_per_page = $terms_count; |
|
| 3548 | - } |
|
| 3549 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3534 | + $json['percentage'] = $percentage; |
|
| 3535 | + // WPML |
|
| 3536 | + if ($is_wpml) {
|
|
| 3537 | + $sitepress->switch_lang($active_lang, true); |
|
| 3538 | + } |
|
| 3539 | + // WPML |
|
| 3540 | + wp_send_json( $json ); |
|
| 3541 | + } else {
|
|
| 3542 | + if ( !$terms_count > 0 ) {
|
|
| 3543 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3544 | + } else {
|
|
| 3545 | + $total_terms = $terms_count; |
|
| 3546 | + if ($chunk_per_page > $terms_count) {
|
|
| 3547 | + $chunk_per_page = $terms_count; |
|
| 3548 | + } |
|
| 3549 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3550 | 3550 | |
| 3551 | - $j = $chunk_page_no; |
|
| 3552 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3551 | + $j = $chunk_page_no; |
|
| 3552 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3553 | 3553 | |
| 3554 | - $per_page = 500; |
|
| 3555 | - if ($per_page > $chunk_per_page) {
|
|
| 3556 | - $per_page = $chunk_per_page; |
|
| 3557 | - } |
|
| 3558 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3554 | + $per_page = 500; |
|
| 3555 | + if ($per_page > $chunk_per_page) {
|
|
| 3556 | + $per_page = $chunk_per_page; |
|
| 3557 | + } |
|
| 3558 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3559 | 3559 | |
| 3560 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3561 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3560 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3561 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3562 | 3562 | |
| 3563 | - $clear = $i == 0 ? true : false; |
|
| 3564 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3565 | - } |
|
| 3563 | + $clear = $i == 0 ? true : false; |
|
| 3564 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3565 | + } |
|
| 3566 | 3566 | |
| 3567 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3568 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3569 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3570 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3571 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3567 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3568 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3569 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3570 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3571 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3572 | 3572 | |
| 3573 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3574 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3575 | - } |
|
| 3573 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3574 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3575 | + } |
|
| 3576 | 3576 | |
| 3577 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3578 | - $json['total'] = $terms_count; |
|
| 3579 | - $json['files'] = $chunk_file_paths; |
|
| 3580 | - } else {
|
|
| 3581 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3582 | - } |
|
| 3583 | - } |
|
| 3584 | - // WPML |
|
| 3585 | - if ($is_wpml) {
|
|
| 3586 | - $sitepress->switch_lang($active_lang, true); |
|
| 3587 | - } |
|
| 3588 | - // WPML |
|
| 3589 | - wp_send_json( $json ); |
|
| 3590 | - } |
|
| 3591 | - } |
|
| 3592 | - break; |
|
| 3593 | - case 'export_locations': {
|
|
| 3594 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3595 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3596 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3597 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3598 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3577 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3578 | + $json['total'] = $terms_count; |
|
| 3579 | + $json['files'] = $chunk_file_paths; |
|
| 3580 | + } else {
|
|
| 3581 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3582 | + } |
|
| 3583 | + } |
|
| 3584 | + // WPML |
|
| 3585 | + if ($is_wpml) {
|
|
| 3586 | + $sitepress->switch_lang($active_lang, true); |
|
| 3587 | + } |
|
| 3588 | + // WPML |
|
| 3589 | + wp_send_json( $json ); |
|
| 3590 | + } |
|
| 3591 | + } |
|
| 3592 | + break; |
|
| 3593 | + case 'export_locations': {
|
|
| 3594 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3595 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3596 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3597 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3598 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3599 | 3599 | |
| 3600 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3600 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3601 | 3601 | |
| 3602 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3603 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3604 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3605 | - $percentage = min( $percentage, 100 ); |
|
| 3602 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3603 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3604 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3605 | + $percentage = min( $percentage, 100 ); |
|
| 3606 | 3606 | |
| 3607 | - $json['percentage'] = $percentage; |
|
| 3608 | - wp_send_json( $json ); |
|
| 3609 | - } else {
|
|
| 3610 | - $chunk_file_paths = array(); |
|
| 3607 | + $json['percentage'] = $percentage; |
|
| 3608 | + wp_send_json( $json ); |
|
| 3609 | + } else {
|
|
| 3610 | + $chunk_file_paths = array(); |
|
| 3611 | 3611 | |
| 3612 | - if ( !$items_count > 0 ) {
|
|
| 3613 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3614 | - } else {
|
|
| 3615 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3616 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3612 | + if ( !$items_count > 0 ) {
|
|
| 3613 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3614 | + } else {
|
|
| 3615 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3616 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3617 | 3617 | |
| 3618 | - $j = $chunk_page_no; |
|
| 3619 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3618 | + $j = $chunk_page_no; |
|
| 3619 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3620 | 3620 | |
| 3621 | - $per_page = 500; |
|
| 3622 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3623 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3621 | + $per_page = 500; |
|
| 3622 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3623 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3624 | 3624 | |
| 3625 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3626 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3625 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3626 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3627 | 3627 | |
| 3628 | - $clear = $i == 0 ? true : false; |
|
| 3629 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3630 | - } |
|
| 3628 | + $clear = $i == 0 ? true : false; |
|
| 3629 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3630 | + } |
|
| 3631 | 3631 | |
| 3632 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3633 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3634 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3635 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3636 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3632 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3633 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3634 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3635 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3636 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3637 | 3637 | |
| 3638 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3639 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3640 | - } |
|
| 3638 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3639 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3640 | + } |
|
| 3641 | 3641 | |
| 3642 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3643 | - $json['total'] = $items_count; |
|
| 3644 | - $json['files'] = $chunk_file_paths; |
|
| 3645 | - } else {
|
|
| 3646 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3647 | - } |
|
| 3648 | - } |
|
| 3649 | - wp_send_json( $json ); |
|
| 3650 | - } |
|
| 3651 | - } |
|
| 3652 | - break; |
|
| 3653 | - case 'export_hoods': {
|
|
| 3654 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3655 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3656 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3657 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3658 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3642 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3643 | + $json['total'] = $items_count; |
|
| 3644 | + $json['files'] = $chunk_file_paths; |
|
| 3645 | + } else {
|
|
| 3646 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3647 | + } |
|
| 3648 | + } |
|
| 3649 | + wp_send_json( $json ); |
|
| 3650 | + } |
|
| 3651 | + } |
|
| 3652 | + break; |
|
| 3653 | + case 'export_hoods': {
|
|
| 3654 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3655 | + $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3656 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3657 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3658 | + $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3659 | 3659 | |
| 3660 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3660 | + $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3661 | 3661 | |
| 3662 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3663 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3664 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3665 | - $percentage = min( $percentage, 100 ); |
|
| 3662 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3663 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3664 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3665 | + $percentage = min( $percentage, 100 ); |
|
| 3666 | 3666 | |
| 3667 | - $json['percentage'] = $percentage; |
|
| 3668 | - wp_send_json( $json ); |
|
| 3669 | - } else {
|
|
| 3670 | - $chunk_file_paths = array(); |
|
| 3667 | + $json['percentage'] = $percentage; |
|
| 3668 | + wp_send_json( $json ); |
|
| 3669 | + } else {
|
|
| 3670 | + $chunk_file_paths = array(); |
|
| 3671 | 3671 | |
| 3672 | - if ( !$items_count > 0 ) {
|
|
| 3673 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3674 | - } else {
|
|
| 3675 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3676 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3672 | + if ( !$items_count > 0 ) {
|
|
| 3673 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3674 | + } else {
|
|
| 3675 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3676 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3677 | 3677 | |
| 3678 | - $j = $chunk_page_no; |
|
| 3679 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3678 | + $j = $chunk_page_no; |
|
| 3679 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3680 | 3680 | |
| 3681 | - $per_page = 500; |
|
| 3682 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3683 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3681 | + $per_page = 500; |
|
| 3682 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3683 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3684 | 3684 | |
| 3685 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3686 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3685 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3686 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3687 | 3687 | |
| 3688 | - $clear = $i == 0 ? true : false; |
|
| 3689 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3690 | - } |
|
| 3688 | + $clear = $i == 0 ? true : false; |
|
| 3689 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3690 | + } |
|
| 3691 | 3691 | |
| 3692 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3693 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3694 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3695 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3696 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3692 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3693 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3694 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3695 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3696 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3697 | 3697 | |
| 3698 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3699 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3700 | - } |
|
| 3698 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3699 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3700 | + } |
|
| 3701 | 3701 | |
| 3702 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3703 | - $json['total'] = $items_count; |
|
| 3704 | - $json['files'] = $chunk_file_paths; |
|
| 3705 | - } else {
|
|
| 3706 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3707 | - } |
|
| 3708 | - } |
|
| 3709 | - wp_send_json( $json ); |
|
| 3710 | - } |
|
| 3711 | - } |
|
| 3712 | - break; |
|
| 3713 | - case 'prepare_import': |
|
| 3714 | - case 'import_cat': |
|
| 3715 | - case 'import_post': |
|
| 3716 | - case 'import_loc': |
|
| 3717 | - case 'import_hood': {
|
|
| 3718 | - // WPML |
|
| 3719 | - $is_wpml = geodir_is_wpml(); |
|
| 3720 | - if ($is_wpml) {
|
|
| 3721 | - global $sitepress; |
|
| 3722 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3723 | - } |
|
| 3724 | - // WPML |
|
| 3702 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3703 | + $json['total'] = $items_count; |
|
| 3704 | + $json['files'] = $chunk_file_paths; |
|
| 3705 | + } else {
|
|
| 3706 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3707 | + } |
|
| 3708 | + } |
|
| 3709 | + wp_send_json( $json ); |
|
| 3710 | + } |
|
| 3711 | + } |
|
| 3712 | + break; |
|
| 3713 | + case 'prepare_import': |
|
| 3714 | + case 'import_cat': |
|
| 3715 | + case 'import_post': |
|
| 3716 | + case 'import_loc': |
|
| 3717 | + case 'import_hood': {
|
|
| 3718 | + // WPML |
|
| 3719 | + $is_wpml = geodir_is_wpml(); |
|
| 3720 | + if ($is_wpml) {
|
|
| 3721 | + global $sitepress; |
|
| 3722 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3723 | + } |
|
| 3724 | + // WPML |
|
| 3725 | 3725 | |
| 3726 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 3726 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 3727 | 3727 | |
| 3728 | - $uploads = wp_upload_dir(); |
|
| 3729 | - $uploads_dir = $uploads['path']; |
|
| 3730 | - $uploads_subdir = $uploads['subdir']; |
|
| 3728 | + $uploads = wp_upload_dir(); |
|
| 3729 | + $uploads_dir = $uploads['path']; |
|
| 3730 | + $uploads_subdir = $uploads['subdir']; |
|
| 3731 | 3731 | |
| 3732 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3733 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3732 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3733 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3734 | 3734 | |
| 3735 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 3736 | - $csv_filename = end( $csv_file_arr ); |
|
| 3737 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3735 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 3736 | + $csv_filename = end( $csv_file_arr ); |
|
| 3737 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3738 | 3738 | |
| 3739 | - $json['file'] = $csv_file; |
|
| 3740 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3741 | - $file = array(); |
|
| 3739 | + $json['file'] = $csv_file; |
|
| 3740 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3741 | + $file = array(); |
|
| 3742 | 3742 | |
| 3743 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3744 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3743 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3744 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3745 | 3745 | |
| 3746 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 3747 | - $json['error'] = NULL; |
|
| 3748 | - |
|
| 3749 | - $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
| 3750 | - setlocale(LC_ALL, 'en_US.UTF-8'); |
|
| 3751 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 3752 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 3753 | - if ( !empty( $data ) ) {
|
|
| 3754 | - $file[] = $data; |
|
| 3755 | - } |
|
| 3756 | - } |
|
| 3757 | - fclose($handle); |
|
| 3758 | - } |
|
| 3759 | - setlocale(LC_ALL, $lc_all); |
|
| 3746 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 3747 | + $json['error'] = NULL; |
|
| 3748 | + |
|
| 3749 | + $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
| 3750 | + setlocale(LC_ALL, 'en_US.UTF-8'); |
|
| 3751 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 3752 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 3753 | + if ( !empty( $data ) ) {
|
|
| 3754 | + $file[] = $data; |
|
| 3755 | + } |
|
| 3756 | + } |
|
| 3757 | + fclose($handle); |
|
| 3758 | + } |
|
| 3759 | + setlocale(LC_ALL, $lc_all); |
|
| 3760 | 3760 | |
| 3761 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 3761 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 3762 | 3762 | |
| 3763 | - if (!$json['rows'] > 0) {
|
|
| 3764 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 3765 | - } |
|
| 3766 | - } else {
|
|
| 3767 | - wp_send_json( $json ); |
|
| 3768 | - } |
|
| 3769 | - } else {
|
|
| 3770 | - wp_send_json( $json ); |
|
| 3771 | - } |
|
| 3763 | + if (!$json['rows'] > 0) {
|
|
| 3764 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 3765 | + } |
|
| 3766 | + } else {
|
|
| 3767 | + wp_send_json( $json ); |
|
| 3768 | + } |
|
| 3769 | + } else {
|
|
| 3770 | + wp_send_json( $json ); |
|
| 3771 | + } |
|
| 3772 | 3772 | |
| 3773 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 3774 | - wp_send_json( $json ); |
|
| 3775 | - } |
|
| 3773 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 3774 | + wp_send_json( $json ); |
|
| 3775 | + } |
|
| 3776 | 3776 | |
| 3777 | - $total = $json['rows']; |
|
| 3778 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 3779 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 3777 | + $total = $json['rows']; |
|
| 3778 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 3779 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 3780 | 3780 | |
| 3781 | - $count = $limit; |
|
| 3781 | + $count = $limit; |
|
| 3782 | 3782 | |
| 3783 | - if ($count < $total) {
|
|
| 3784 | - $count = $processed + $count; |
|
| 3785 | - if ($count > $total) {
|
|
| 3786 | - $count = $total; |
|
| 3787 | - } |
|
| 3788 | - } else {
|
|
| 3789 | - $count = $total; |
|
| 3790 | - } |
|
| 3783 | + if ($count < $total) {
|
|
| 3784 | + $count = $processed + $count; |
|
| 3785 | + if ($count > $total) {
|
|
| 3786 | + $count = $total; |
|
| 3787 | + } |
|
| 3788 | + } else {
|
|
| 3789 | + $count = $total; |
|
| 3790 | + } |
|
| 3791 | 3791 | |
| 3792 | - $created = 0; |
|
| 3793 | - $updated = 0; |
|
| 3794 | - $skipped = 0; |
|
| 3795 | - $invalid = 0; |
|
| 3796 | - $invalid_addr = 0; |
|
| 3797 | - $images = 0; |
|
| 3792 | + $created = 0; |
|
| 3793 | + $updated = 0; |
|
| 3794 | + $skipped = 0; |
|
| 3795 | + $invalid = 0; |
|
| 3796 | + $invalid_addr = 0; |
|
| 3797 | + $images = 0; |
|
| 3798 | 3798 | |
| 3799 | - $gd_post_info = array(); |
|
| 3800 | - $countpost = 0; |
|
| 3799 | + $gd_post_info = array(); |
|
| 3800 | + $countpost = 0; |
|
| 3801 | 3801 | |
| 3802 | - $post_types = geodir_get_posttypes(); |
|
| 3802 | + $post_types = geodir_get_posttypes(); |
|
| 3803 | 3803 | |
| 3804 | - if ( $task == 'import_cat' ) {
|
|
| 3805 | - if (!empty($file)) {
|
|
| 3806 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 3804 | + if ( $task == 'import_cat' ) {
|
|
| 3805 | + if (!empty($file)) {
|
|
| 3806 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 3807 | 3807 | |
| 3808 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 3809 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 3810 | - wp_send_json( $json ); |
|
| 3811 | - exit; |
|
| 3812 | - } |
|
| 3808 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 3809 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 3810 | + wp_send_json( $json ); |
|
| 3811 | + exit; |
|
| 3812 | + } |
|
| 3813 | 3813 | |
| 3814 | - $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 3814 | + $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 3815 | 3815 | |
| 3816 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 3817 | - $index = $processed + $i; |
|
| 3816 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 3817 | + $index = $processed + $i; |
|
| 3818 | 3818 | |
| 3819 | - if (isset($file[$index])) {
|
|
| 3820 | - $row = $file[$index]; |
|
| 3821 | - $row = array_map( 'trim', $row ); |
|
| 3822 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 3819 | + if (isset($file[$index])) {
|
|
| 3820 | + $row = $file[$index]; |
|
| 3821 | + $row = array_map( 'trim', $row ); |
|
| 3822 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 3823 | 3823 | |
| 3824 | - $cat_id = ''; |
|
| 3825 | - $cat_name = ''; |
|
| 3826 | - $cat_slug = ''; |
|
| 3827 | - $cat_posttype = ''; |
|
| 3828 | - $cat_parent = ''; |
|
| 3829 | - $cat_description = ''; |
|
| 3830 | - $cat_schema = ''; |
|
| 3831 | - $cat_top_description = ''; |
|
| 3832 | - $cat_image = ''; |
|
| 3833 | - $cat_icon = ''; |
|
| 3834 | - $cat_language = ''; |
|
| 3835 | - $cat_id_original = ''; |
|
| 3824 | + $cat_id = ''; |
|
| 3825 | + $cat_name = ''; |
|
| 3826 | + $cat_slug = ''; |
|
| 3827 | + $cat_posttype = ''; |
|
| 3828 | + $cat_parent = ''; |
|
| 3829 | + $cat_description = ''; |
|
| 3830 | + $cat_schema = ''; |
|
| 3831 | + $cat_top_description = ''; |
|
| 3832 | + $cat_image = ''; |
|
| 3833 | + $cat_icon = ''; |
|
| 3834 | + $cat_language = ''; |
|
| 3835 | + $cat_id_original = ''; |
|
| 3836 | 3836 | |
| 3837 | - $c = 0; |
|
| 3838 | - foreach ($columns as $column ) {
|
|
| 3839 | - if ( $column == 'cat_id' ) {
|
|
| 3840 | - $cat_id = (int)$row[$c]; |
|
| 3841 | - } else if ( $column == 'cat_name' ) {
|
|
| 3842 | - $cat_name = $row[$c]; |
|
| 3843 | - } else if ( $column == 'cat_slug' ) {
|
|
| 3844 | - $cat_slug = $row[$c]; |
|
| 3845 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 3846 | - $cat_posttype = $row[$c]; |
|
| 3847 | - } else if ( $column == 'cat_parent' ) {
|
|
| 3848 | - $cat_parent = trim($row[$c]); |
|
| 3849 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 3850 | - $cat_schema = $row[$c]; |
|
| 3851 | - } else if ( $column == 'cat_description' ) {
|
|
| 3852 | - $cat_description = $row[$c]; |
|
| 3853 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 3854 | - $cat_top_description = $row[$c]; |
|
| 3855 | - } else if ( $column == 'cat_image' ) {
|
|
| 3856 | - $cat_image = $row[$c]; |
|
| 3857 | - } else if ( $column == 'cat_icon' ) {
|
|
| 3858 | - $cat_icon = $row[$c]; |
|
| 3859 | - } |
|
| 3860 | - // WPML |
|
| 3861 | - if ( $is_wpml ) {
|
|
| 3862 | - if ( $column == 'cat_language' ) {
|
|
| 3863 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 3864 | - } else if ( $column == 'cat_id_original' ) {
|
|
| 3865 | - $cat_id_original = (int)$row[$c]; |
|
| 3866 | - } |
|
| 3867 | - } |
|
| 3868 | - // WPML |
|
| 3869 | - $c++; |
|
| 3870 | - } |
|
| 3837 | + $c = 0; |
|
| 3838 | + foreach ($columns as $column ) {
|
|
| 3839 | + if ( $column == 'cat_id' ) {
|
|
| 3840 | + $cat_id = (int)$row[$c]; |
|
| 3841 | + } else if ( $column == 'cat_name' ) {
|
|
| 3842 | + $cat_name = $row[$c]; |
|
| 3843 | + } else if ( $column == 'cat_slug' ) {
|
|
| 3844 | + $cat_slug = $row[$c]; |
|
| 3845 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 3846 | + $cat_posttype = $row[$c]; |
|
| 3847 | + } else if ( $column == 'cat_parent' ) {
|
|
| 3848 | + $cat_parent = trim($row[$c]); |
|
| 3849 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 3850 | + $cat_schema = $row[$c]; |
|
| 3851 | + } else if ( $column == 'cat_description' ) {
|
|
| 3852 | + $cat_description = $row[$c]; |
|
| 3853 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 3854 | + $cat_top_description = $row[$c]; |
|
| 3855 | + } else if ( $column == 'cat_image' ) {
|
|
| 3856 | + $cat_image = $row[$c]; |
|
| 3857 | + } else if ( $column == 'cat_icon' ) {
|
|
| 3858 | + $cat_icon = $row[$c]; |
|
| 3859 | + } |
|
| 3860 | + // WPML |
|
| 3861 | + if ( $is_wpml ) {
|
|
| 3862 | + if ( $column == 'cat_language' ) {
|
|
| 3863 | + $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 3864 | + } else if ( $column == 'cat_id_original' ) {
|
|
| 3865 | + $cat_id_original = (int)$row[$c]; |
|
| 3866 | + } |
|
| 3867 | + } |
|
| 3868 | + // WPML |
|
| 3869 | + $c++; |
|
| 3870 | + } |
|
| 3871 | 3871 | |
| 3872 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 3873 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 3872 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 3873 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 3874 | 3874 | |
| 3875 | - $invalid++; |
|
| 3876 | - continue; |
|
| 3877 | - } |
|
| 3875 | + $invalid++; |
|
| 3876 | + continue; |
|
| 3877 | + } |
|
| 3878 | 3878 | |
| 3879 | - // WPML |
|
| 3880 | - if ($is_wpml && $cat_language != '') {
|
|
| 3881 | - $sitepress->switch_lang($cat_language, true); |
|
| 3882 | - } |
|
| 3883 | - // WPML |
|
| 3879 | + // WPML |
|
| 3880 | + if ($is_wpml && $cat_language != '') {
|
|
| 3881 | + $sitepress->switch_lang($cat_language, true); |
|
| 3882 | + } |
|
| 3883 | + // WPML |
|
| 3884 | 3884 | |
| 3885 | - $term_data = array(); |
|
| 3886 | - $term_data['name'] = $cat_name; |
|
| 3887 | - $term_data['slug'] = $cat_slug; |
|
| 3888 | - $term_data['description'] = $cat_description; |
|
| 3889 | - $term_data['cat_schema'] = $cat_schema; |
|
| 3890 | - $term_data['top_description'] = $cat_top_description; |
|
| 3891 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 3892 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 3885 | + $term_data = array(); |
|
| 3886 | + $term_data['name'] = $cat_name; |
|
| 3887 | + $term_data['slug'] = $cat_slug; |
|
| 3888 | + $term_data['description'] = $cat_description; |
|
| 3889 | + $term_data['cat_schema'] = $cat_schema; |
|
| 3890 | + $term_data['top_description'] = $cat_top_description; |
|
| 3891 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 3892 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 3893 | 3893 | |
| 3894 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 3894 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 3895 | 3895 | |
| 3896 | - $taxonomy = $cat_posttype . 'category'; |
|
| 3896 | + $taxonomy = $cat_posttype . 'category'; |
|
| 3897 | 3897 | |
| 3898 | - $term_data['taxonomy'] = $taxonomy; |
|
| 3898 | + $term_data['taxonomy'] = $taxonomy; |
|
| 3899 | 3899 | |
| 3900 | - $term_parent_id = 0; |
|
| 3901 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 3902 | - $term_parent = ''; |
|
| 3900 | + $term_parent_id = 0; |
|
| 3901 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 3902 | + $term_parent = ''; |
|
| 3903 | 3903 | |
| 3904 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 3905 | - // |
|
| 3906 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 3907 | - // |
|
| 3908 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 3909 | - // |
|
| 3910 | - } else {
|
|
| 3911 | - $term_parent_data = array(); |
|
| 3912 | - $term_parent_data['name'] = $cat_parent; |
|
| 3913 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 3914 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 3904 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 3905 | + // |
|
| 3906 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 3907 | + // |
|
| 3908 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 3909 | + // |
|
| 3910 | + } else {
|
|
| 3911 | + $term_parent_data = array(); |
|
| 3912 | + $term_parent_data['name'] = $cat_parent; |
|
| 3913 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 3914 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 3915 | 3915 | |
| 3916 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 3917 | - } |
|
| 3916 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 3917 | + } |
|
| 3918 | 3918 | |
| 3919 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 3920 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 3921 | - } |
|
| 3922 | - } |
|
| 3923 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 3919 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 3920 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 3921 | + } |
|
| 3922 | + } |
|
| 3923 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 3924 | 3924 | |
| 3925 | - $term_id = NULL; |
|
| 3926 | - if ( $import_choice == 'update' ) {
|
|
| 3927 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3928 | - $term_data['term_id'] = $term['term_id']; |
|
| 3925 | + $term_id = NULL; |
|
| 3926 | + if ( $import_choice == 'update' ) {
|
|
| 3927 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3928 | + $term_data['term_id'] = $term['term_id']; |
|
| 3929 | 3929 | |
| 3930 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3931 | - $updated++; |
|
| 3932 | - } else {
|
|
| 3933 | - $invalid++; |
|
| 3934 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3935 | - } |
|
| 3936 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3937 | - $term_data['term_id'] = $term['term_id']; |
|
| 3930 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3931 | + $updated++; |
|
| 3932 | + } else {
|
|
| 3933 | + $invalid++; |
|
| 3934 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3935 | + } |
|
| 3936 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3937 | + $term_data['term_id'] = $term['term_id']; |
|
| 3938 | 3938 | |
| 3939 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3940 | - $updated++; |
|
| 3941 | - } else {
|
|
| 3942 | - $invalid++; |
|
| 3943 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3944 | - } |
|
| 3945 | - } else {
|
|
| 3946 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3947 | - $created++; |
|
| 3948 | - } else {
|
|
| 3949 | - $invalid++; |
|
| 3950 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3951 | - } |
|
| 3952 | - } |
|
| 3953 | - } else if ( $import_choice == 'skip' ) {
|
|
| 3954 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3955 | - $skipped++; |
|
| 3956 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3957 | - $skipped++; |
|
| 3958 | - } else {
|
|
| 3959 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3960 | - $created++; |
|
| 3961 | - } else {
|
|
| 3962 | - $invalid++; |
|
| 3963 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3964 | - } |
|
| 3965 | - } |
|
| 3966 | - } else {
|
|
| 3967 | - $invalid++; |
|
| 3968 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3969 | - } |
|
| 3939 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3940 | + $updated++; |
|
| 3941 | + } else {
|
|
| 3942 | + $invalid++; |
|
| 3943 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3944 | + } |
|
| 3945 | + } else {
|
|
| 3946 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3947 | + $created++; |
|
| 3948 | + } else {
|
|
| 3949 | + $invalid++; |
|
| 3950 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3951 | + } |
|
| 3952 | + } |
|
| 3953 | + } else if ( $import_choice == 'skip' ) {
|
|
| 3954 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3955 | + $skipped++; |
|
| 3956 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3957 | + $skipped++; |
|
| 3958 | + } else {
|
|
| 3959 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3960 | + $created++; |
|
| 3961 | + } else {
|
|
| 3962 | + $invalid++; |
|
| 3963 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be updated due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3964 | + } |
|
| 3965 | + } |
|
| 3966 | + } else {
|
|
| 3967 | + $invalid++; |
|
| 3968 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to invalid data (check & remove if any invalid characters used in data)', 'geodirectory' ) ); |
|
| 3969 | + } |
|
| 3970 | 3970 | |
| 3971 | - if ( $term_id ) {
|
|
| 3972 | - // WPML |
|
| 3973 | - if ($is_wpml && geodir_wpml_is_taxonomy_translated($taxonomy) && $cat_id_original > 0 && $cat_language != '') {
|
|
| 3974 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
| 3975 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 3976 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 3977 | - |
|
| 3978 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 3971 | + if ( $term_id ) {
|
|
| 3972 | + // WPML |
|
| 3973 | + if ($is_wpml && geodir_wpml_is_taxonomy_translated($taxonomy) && $cat_id_original > 0 && $cat_language != '') {
|
|
| 3974 | + $wpml_element_type = 'tax_' . $taxonomy; |
|
| 3975 | + $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 3976 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 3977 | + |
|
| 3978 | + $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 3979 | 3979 | |
| 3980 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 3981 | - } |
|
| 3982 | - // WPML |
|
| 3980 | + $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 3981 | + } |
|
| 3982 | + // WPML |
|
| 3983 | 3983 | |
| 3984 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 3985 | - geodir_update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 3986 | - } |
|
| 3984 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 3985 | + geodir_update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 3986 | + } |
|
| 3987 | 3987 | |
| 3988 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 3989 | - geodir_update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 3990 | - } |
|
| 3988 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 3989 | + geodir_update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 3990 | + } |
|
| 3991 | 3991 | |
| 3992 | - $attachment = false; |
|
| 3993 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 3994 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 3995 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 3992 | + $attachment = false; |
|
| 3993 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 3994 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 3995 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 3996 | 3996 | |
| 3997 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 3998 | - $attachment = true; |
|
| 3999 | - geodir_update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4000 | - } |
|
| 4001 | - } |
|
| 3997 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 3998 | + $attachment = true; |
|
| 3999 | + geodir_update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 4000 | + } |
|
| 4001 | + } |
|
| 4002 | 4002 | |
| 4003 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4004 | - $cat_icon = geodir_get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4005 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4006 | - |
|
| 4007 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4008 | - $attachment = true; |
|
| 4009 | - geodir_update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4010 | - } |
|
| 4011 | - } |
|
| 4003 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 4004 | + $cat_icon = geodir_get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 4005 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 4006 | + |
|
| 4007 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 4008 | + $attachment = true; |
|
| 4009 | + geodir_update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4010 | + } |
|
| 4011 | + } |
|
| 4012 | 4012 | |
| 4013 | - if ( $attachment ) {
|
|
| 4014 | - $images++; |
|
| 4015 | - } |
|
| 4016 | - } |
|
| 4013 | + if ( $attachment ) {
|
|
| 4014 | + $images++; |
|
| 4015 | + } |
|
| 4016 | + } |
|
| 4017 | 4017 | |
| 4018 | - // WPML |
|
| 4019 | - if ($is_wpml && $cat_language != '') {
|
|
| 4020 | - $sitepress->switch_lang($active_lang, true); |
|
| 4021 | - } |
|
| 4022 | - // WPML |
|
| 4023 | - } |
|
| 4024 | - } |
|
| 4025 | - } |
|
| 4018 | + // WPML |
|
| 4019 | + if ($is_wpml && $cat_language != '') {
|
|
| 4020 | + $sitepress->switch_lang($active_lang, true); |
|
| 4021 | + } |
|
| 4022 | + // WPML |
|
| 4023 | + } |
|
| 4024 | + } |
|
| 4025 | + } |
|
| 4026 | 4026 | |
| 4027 | - $json = array(); |
|
| 4028 | - $json['processed'] = $limit; |
|
| 4029 | - $json['created'] = $created; |
|
| 4030 | - $json['updated'] = $updated; |
|
| 4031 | - $json['skipped'] = $skipped; |
|
| 4032 | - $json['invalid'] = $invalid; |
|
| 4033 | - $json['images'] = $images; |
|
| 4027 | + $json = array(); |
|
| 4028 | + $json['processed'] = $limit; |
|
| 4029 | + $json['created'] = $created; |
|
| 4030 | + $json['updated'] = $updated; |
|
| 4031 | + $json['skipped'] = $skipped; |
|
| 4032 | + $json['invalid'] = $invalid; |
|
| 4033 | + $json['images'] = $images; |
|
| 4034 | 4034 | |
| 4035 | - wp_send_json( $json ); |
|
| 4036 | - exit; |
|
| 4037 | - } else if ( $task == 'import_post' ) {
|
|
| 4038 | - $xtimings['###1'] = microtime(true)-$xstart; |
|
| 4039 | - //run some stuff to make the import quicker |
|
| 4040 | - wp_defer_term_counting( true ); |
|
| 4041 | - wp_defer_comment_counting( true ); |
|
| 4042 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4035 | + wp_send_json( $json ); |
|
| 4036 | + exit; |
|
| 4037 | + } else if ( $task == 'import_post' ) {
|
|
| 4038 | + $xtimings['###1'] = microtime(true)-$xstart; |
|
| 4039 | + //run some stuff to make the import quicker |
|
| 4040 | + wp_defer_term_counting( true ); |
|
| 4041 | + wp_defer_comment_counting( true ); |
|
| 4042 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4043 | 4043 | // |
| 4044 | 4044 | // remove_all_actions('publish_post');
|
| 4045 | 4045 | // remove_all_actions('transition_post_status');
|
| 4046 | 4046 | // remove_all_actions('publish_future_post');
|
| 4047 | 4047 | |
| 4048 | - if (!empty($file)) {
|
|
| 4049 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 4050 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4051 | - $default_status = 'publish'; |
|
| 4052 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4048 | + if (!empty($file)) {
|
|
| 4049 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 4050 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4051 | + $default_status = 'publish'; |
|
| 4052 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4053 | 4053 | |
| 4054 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4054 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4055 | 4055 | |
| 4056 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4057 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4058 | - wp_send_json( $json ); |
|
| 4059 | - exit; |
|
| 4060 | - } |
|
| 4061 | - $xtimings['###2'] = microtime(true)-$xstart; |
|
| 4062 | - $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4063 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4064 | - $processed_actual = 0; |
|
| 4065 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4066 | - $index = $processed + $i; |
|
| 4067 | - $gd_post = array(); |
|
| 4056 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4057 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4058 | + wp_send_json( $json ); |
|
| 4059 | + exit; |
|
| 4060 | + } |
|
| 4061 | + $xtimings['###2'] = microtime(true)-$xstart; |
|
| 4062 | + $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4063 | + $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4064 | + $processed_actual = 0; |
|
| 4065 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4066 | + $index = $processed + $i; |
|
| 4067 | + $gd_post = array(); |
|
| 4068 | 4068 | |
| 4069 | - if (isset($file[$index])) {
|
|
| 4070 | - $processed_actual++; |
|
| 4071 | - $row = $file[$index]; |
|
| 4072 | - $row = array_map( 'trim', $row ); |
|
| 4073 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4074 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 4069 | + if (isset($file[$index])) {
|
|
| 4070 | + $processed_actual++; |
|
| 4071 | + $row = $file[$index]; |
|
| 4072 | + $row = array_map( 'trim', $row ); |
|
| 4073 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4074 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 4075 | 4075 | |
| 4076 | - $post_id = ''; |
|
| 4077 | - $post_title = ''; |
|
| 4078 | - $post_date = ''; |
|
| 4079 | - $post_author = ''; |
|
| 4080 | - $post_content = ''; |
|
| 4081 | - $post_category_arr = array(); |
|
| 4082 | - $default_category = ''; |
|
| 4083 | - $post_tags = array(); |
|
| 4084 | - $post_type = ''; |
|
| 4085 | - $post_status = ''; |
|
| 4086 | - $is_featured = 0; |
|
| 4087 | - $geodir_video = ''; |
|
| 4088 | - $post_address = ''; |
|
| 4089 | - $post_city = ''; |
|
| 4090 | - $post_region = ''; |
|
| 4091 | - $post_country = ''; |
|
| 4092 | - $post_zip = ''; |
|
| 4093 | - $post_latitude = ''; |
|
| 4094 | - $post_longitude = ''; |
|
| 4095 | - $post_neighbourhood = ''; |
|
| 4096 | - $neighbourhood_latitude = ''; |
|
| 4097 | - $neighbourhood_longitude = ''; |
|
| 4098 | - $geodir_timing = ''; |
|
| 4099 | - $geodir_contact = ''; |
|
| 4100 | - $geodir_email = ''; |
|
| 4101 | - $geodir_website = ''; |
|
| 4102 | - $geodir_twitter = ''; |
|
| 4103 | - $geodir_facebook = ''; |
|
| 4104 | - $geodir_twitter = ''; |
|
| 4105 | - $geodir_link_business = null; |
|
| 4106 | - $post_images = array(); |
|
| 4076 | + $post_id = ''; |
|
| 4077 | + $post_title = ''; |
|
| 4078 | + $post_date = ''; |
|
| 4079 | + $post_author = ''; |
|
| 4080 | + $post_content = ''; |
|
| 4081 | + $post_category_arr = array(); |
|
| 4082 | + $default_category = ''; |
|
| 4083 | + $post_tags = array(); |
|
| 4084 | + $post_type = ''; |
|
| 4085 | + $post_status = ''; |
|
| 4086 | + $is_featured = 0; |
|
| 4087 | + $geodir_video = ''; |
|
| 4088 | + $post_address = ''; |
|
| 4089 | + $post_city = ''; |
|
| 4090 | + $post_region = ''; |
|
| 4091 | + $post_country = ''; |
|
| 4092 | + $post_zip = ''; |
|
| 4093 | + $post_latitude = ''; |
|
| 4094 | + $post_longitude = ''; |
|
| 4095 | + $post_neighbourhood = ''; |
|
| 4096 | + $neighbourhood_latitude = ''; |
|
| 4097 | + $neighbourhood_longitude = ''; |
|
| 4098 | + $geodir_timing = ''; |
|
| 4099 | + $geodir_contact = ''; |
|
| 4100 | + $geodir_email = ''; |
|
| 4101 | + $geodir_website = ''; |
|
| 4102 | + $geodir_twitter = ''; |
|
| 4103 | + $geodir_facebook = ''; |
|
| 4104 | + $geodir_twitter = ''; |
|
| 4105 | + $geodir_link_business = null; |
|
| 4106 | + $post_images = array(); |
|
| 4107 | 4107 | |
| 4108 | - $expire_date = 'Never'; |
|
| 4108 | + $expire_date = 'Never'; |
|
| 4109 | 4109 | |
| 4110 | - $language = ''; |
|
| 4111 | - $original_post_id = ''; |
|
| 4110 | + $language = ''; |
|
| 4111 | + $original_post_id = ''; |
|
| 4112 | 4112 | |
| 4113 | - $c = 0; |
|
| 4114 | - foreach ($columns as $column ) {
|
|
| 4115 | - $gd_post[$column] = $row[$c]; |
|
| 4113 | + $c = 0; |
|
| 4114 | + foreach ($columns as $column ) {
|
|
| 4115 | + $gd_post[$column] = $row[$c]; |
|
| 4116 | 4116 | |
| 4117 | - if ( $column == 'post_id' ) {
|
|
| 4118 | - $post_id = $row[$c]; |
|
| 4119 | - } else if ( $column == 'post_title' ) {
|
|
| 4120 | - $post_title = sanitize_text_field($row[$c]); |
|
| 4121 | - } else if ( $column == 'post_author' ) {
|
|
| 4122 | - $post_author = $row[$c]; |
|
| 4123 | - } else if ( $column == 'post_date' ) {
|
|
| 4124 | - $post_date = $row[$c]; |
|
| 4125 | - } else if ( $column == 'post_content' ) {
|
|
| 4126 | - $post_content = $row[$c]; |
|
| 4127 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4128 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 4129 | - } else if ( $column == 'default_category' ) {
|
|
| 4130 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4131 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4132 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4133 | - } else if ( $column == 'post_type' ) {
|
|
| 4134 | - $post_type = $row[$c]; |
|
| 4135 | - } else if ( $column == 'post_status' ) {
|
|
| 4136 | - $post_status = sanitize_key( $row[$c] ); |
|
| 4137 | - } else if ( $column == 'is_featured' ) {
|
|
| 4138 | - $is_featured = (int)$row[$c]; |
|
| 4139 | - } else if ( $column == 'geodir_video' ) {
|
|
| 4140 | - $geodir_video = $row[$c]; |
|
| 4141 | - } else if ( $column == 'post_address' ) {
|
|
| 4142 | - $post_address = sanitize_text_field($row[$c]); |
|
| 4143 | - } else if ( $column == 'post_city' ) {
|
|
| 4144 | - $post_city = sanitize_text_field($row[$c]); |
|
| 4145 | - } else if ( $column == 'post_region' ) {
|
|
| 4146 | - $post_region = sanitize_text_field($row[$c]); |
|
| 4147 | - } else if ( $column == 'post_country' ) {
|
|
| 4148 | - $post_country = sanitize_text_field($row[$c]); |
|
| 4149 | - } else if ( $column == 'post_zip' ) {
|
|
| 4150 | - $post_zip = sanitize_text_field($row[$c]); |
|
| 4151 | - } else if ( $column == 'post_latitude' ) {
|
|
| 4152 | - $post_latitude = sanitize_text_field($row[$c]); |
|
| 4153 | - } else if ( $column == 'post_longitude' ) {
|
|
| 4154 | - $post_longitude = sanitize_text_field($row[$c]); |
|
| 4155 | - } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4156 | - $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4157 | - unset($gd_post[$column]); |
|
| 4158 | - } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4159 | - $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4160 | - } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4161 | - $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4162 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 4163 | - $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4164 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 4165 | - $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4166 | - } else if ( $column == 'geodir_email' ) {
|
|
| 4167 | - $geodir_email = sanitize_email($row[$c]); |
|
| 4168 | - } else if ( $column == 'geodir_website' ) {
|
|
| 4169 | - $geodir_website = sanitize_text_field($row[$c]); |
|
| 4170 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 4171 | - $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4172 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 4173 | - $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4174 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4175 | - $post_images[] = $row[$c]; |
|
| 4176 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4177 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4178 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4179 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4180 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4181 | - } else if ( strpos( $column, 'linked_' ) === 0 ) {
|
|
| 4182 | - $geodir_link_business = (int)$row[$c]; |
|
| 4183 | - } |
|
| 4184 | - // WPML |
|
| 4185 | - if ($is_wpml) {
|
|
| 4186 | - if ($column == 'language') {
|
|
| 4187 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 4188 | - } else if ($column == 'original_post_id') {
|
|
| 4189 | - $original_post_id = (int)$row[$c]; |
|
| 4190 | - } |
|
| 4191 | - } |
|
| 4192 | - // WPML |
|
| 4193 | - $c++; |
|
| 4194 | - } |
|
| 4195 | - // listing claimed or not |
|
| 4196 | - if ($is_claim_active && isset($gd_post['claimed'])) {
|
|
| 4197 | - $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
| 4198 | - } |
|
| 4117 | + if ( $column == 'post_id' ) {
|
|
| 4118 | + $post_id = $row[$c]; |
|
| 4119 | + } else if ( $column == 'post_title' ) {
|
|
| 4120 | + $post_title = sanitize_text_field($row[$c]); |
|
| 4121 | + } else if ( $column == 'post_author' ) {
|
|
| 4122 | + $post_author = $row[$c]; |
|
| 4123 | + } else if ( $column == 'post_date' ) {
|
|
| 4124 | + $post_date = $row[$c]; |
|
| 4125 | + } else if ( $column == 'post_content' ) {
|
|
| 4126 | + $post_content = $row[$c]; |
|
| 4127 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4128 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 4129 | + } else if ( $column == 'default_category' ) {
|
|
| 4130 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4131 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4132 | + $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4133 | + } else if ( $column == 'post_type' ) {
|
|
| 4134 | + $post_type = $row[$c]; |
|
| 4135 | + } else if ( $column == 'post_status' ) {
|
|
| 4136 | + $post_status = sanitize_key( $row[$c] ); |
|
| 4137 | + } else if ( $column == 'is_featured' ) {
|
|
| 4138 | + $is_featured = (int)$row[$c]; |
|
| 4139 | + } else if ( $column == 'geodir_video' ) {
|
|
| 4140 | + $geodir_video = $row[$c]; |
|
| 4141 | + } else if ( $column == 'post_address' ) {
|
|
| 4142 | + $post_address = sanitize_text_field($row[$c]); |
|
| 4143 | + } else if ( $column == 'post_city' ) {
|
|
| 4144 | + $post_city = sanitize_text_field($row[$c]); |
|
| 4145 | + } else if ( $column == 'post_region' ) {
|
|
| 4146 | + $post_region = sanitize_text_field($row[$c]); |
|
| 4147 | + } else if ( $column == 'post_country' ) {
|
|
| 4148 | + $post_country = sanitize_text_field($row[$c]); |
|
| 4149 | + } else if ( $column == 'post_zip' ) {
|
|
| 4150 | + $post_zip = sanitize_text_field($row[$c]); |
|
| 4151 | + } else if ( $column == 'post_latitude' ) {
|
|
| 4152 | + $post_latitude = sanitize_text_field($row[$c]); |
|
| 4153 | + } else if ( $column == 'post_longitude' ) {
|
|
| 4154 | + $post_longitude = sanitize_text_field($row[$c]); |
|
| 4155 | + } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4156 | + $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4157 | + unset($gd_post[$column]); |
|
| 4158 | + } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4159 | + $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4160 | + } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4161 | + $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4162 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 4163 | + $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4164 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 4165 | + $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4166 | + } else if ( $column == 'geodir_email' ) {
|
|
| 4167 | + $geodir_email = sanitize_email($row[$c]); |
|
| 4168 | + } else if ( $column == 'geodir_website' ) {
|
|
| 4169 | + $geodir_website = sanitize_text_field($row[$c]); |
|
| 4170 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 4171 | + $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4172 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 4173 | + $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4174 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4175 | + $post_images[] = $row[$c]; |
|
| 4176 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4177 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4178 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4179 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4180 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4181 | + } else if ( strpos( $column, 'linked_' ) === 0 ) {
|
|
| 4182 | + $geodir_link_business = (int)$row[$c]; |
|
| 4183 | + } |
|
| 4184 | + // WPML |
|
| 4185 | + if ($is_wpml) {
|
|
| 4186 | + if ($column == 'language') {
|
|
| 4187 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 4188 | + } else if ($column == 'original_post_id') {
|
|
| 4189 | + $original_post_id = (int)$row[$c]; |
|
| 4190 | + } |
|
| 4191 | + } |
|
| 4192 | + // WPML |
|
| 4193 | + $c++; |
|
| 4194 | + } |
|
| 4195 | + // listing claimed or not |
|
| 4196 | + if ($is_claim_active && isset($gd_post['claimed'])) {
|
|
| 4197 | + $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
| 4198 | + } |
|
| 4199 | 4199 | |
| 4200 | - // WPML |
|
| 4201 | - if ($is_wpml && $language != '') {
|
|
| 4202 | - $sitepress->switch_lang($language, true); |
|
| 4203 | - } |
|
| 4204 | - // WPML |
|
| 4200 | + // WPML |
|
| 4201 | + if ($is_wpml && $language != '') {
|
|
| 4202 | + $sitepress->switch_lang($language, true); |
|
| 4203 | + } |
|
| 4204 | + // WPML |
|
| 4205 | 4205 | |
| 4206 | - $gd_post['IMAGE'] = $post_images; |
|
| 4206 | + $gd_post['IMAGE'] = $post_images; |
|
| 4207 | 4207 | |
| 4208 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4209 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4208 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4209 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4210 | 4210 | |
| 4211 | - $valid = true; |
|
| 4211 | + $valid = true; |
|
| 4212 | 4212 | |
| 4213 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4214 | - $invalid++; |
|
| 4215 | - $valid = false; |
|
| 4216 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4217 | - } |
|
| 4218 | - $xtimings['###3'] = microtime(true)-$xstart; |
|
| 4219 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4220 | - if ( $location_allowed ) {
|
|
| 4221 | - $location_result = geodir_get_default_location(); |
|
| 4222 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4223 | - $invalid_addr++; |
|
| 4224 | - $valid = false; |
|
| 4225 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4226 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4227 | - 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 ) ) ) {
|
|
| 4228 | - $invalid_addr++; |
|
| 4229 | - $valid = false; |
|
| 4230 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4231 | - } else {
|
|
| 4232 | - if (!$location_manager) {
|
|
| 4233 | - $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. |
|
| 4234 | - } |
|
| 4235 | - } |
|
| 4236 | - } |
|
| 4237 | - } |
|
| 4238 | - $xtimings['###4'] = microtime(true)-$xstart; |
|
| 4239 | - if ( !$valid ) {
|
|
| 4240 | - continue; |
|
| 4241 | - } |
|
| 4213 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4214 | + $invalid++; |
|
| 4215 | + $valid = false; |
|
| 4216 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4217 | + } |
|
| 4218 | + $xtimings['###3'] = microtime(true)-$xstart; |
|
| 4219 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4220 | + if ( $location_allowed ) {
|
|
| 4221 | + $location_result = geodir_get_default_location(); |
|
| 4222 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4223 | + $invalid_addr++; |
|
| 4224 | + $valid = false; |
|
| 4225 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4226 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4227 | + 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 ) ) ) {
|
|
| 4228 | + $invalid_addr++; |
|
| 4229 | + $valid = false; |
|
| 4230 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank/invalid address(city, region, country, latitude, longitude).', 'geodirectory' ) ); |
|
| 4231 | + } else {
|
|
| 4232 | + if (!$location_manager) {
|
|
| 4233 | + $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. |
|
| 4234 | + } |
|
| 4235 | + } |
|
| 4236 | + } |
|
| 4237 | + } |
|
| 4238 | + $xtimings['###4'] = microtime(true)-$xstart; |
|
| 4239 | + if ( !$valid ) {
|
|
| 4240 | + continue; |
|
| 4241 | + } |
|
| 4242 | 4242 | |
| 4243 | - $cat_taxonomy = $post_type . 'category'; |
|
| 4244 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 4243 | + $cat_taxonomy = $post_type . 'category'; |
|
| 4244 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 4245 | 4245 | |
| 4246 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4247 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4248 | - } |
|
| 4246 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4247 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4248 | + } |
|
| 4249 | 4249 | |
| 4250 | - $post_category = array(); |
|
| 4251 | - $default_category_id = NULL; |
|
| 4252 | - if ( !empty( $post_category_arr ) ) {
|
|
| 4253 | - foreach ( $post_category_arr as $value ) {
|
|
| 4254 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4250 | + $post_category = array(); |
|
| 4251 | + $default_category_id = NULL; |
|
| 4252 | + if ( !empty( $post_category_arr ) ) {
|
|
| 4253 | + foreach ( $post_category_arr as $value ) {
|
|
| 4254 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4255 | 4255 | |
| 4256 | - if ( $category_name != '' ) {
|
|
| 4257 | - $term_category = array(); |
|
| 4256 | + if ( $category_name != '' ) {
|
|
| 4257 | + $term_category = array(); |
|
| 4258 | 4258 | |
| 4259 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4260 | - $term_category = $term; |
|
| 4261 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4262 | - $term_category = $term; |
|
| 4263 | - } else {
|
|
| 4264 | - $term_data = array(); |
|
| 4265 | - $term_data['name'] = $category_name; |
|
| 4266 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4259 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4260 | + $term_category = $term; |
|
| 4261 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4262 | + $term_category = $term; |
|
| 4263 | + } else {
|
|
| 4264 | + $term_data = array(); |
|
| 4265 | + $term_data['name'] = $category_name; |
|
| 4266 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4267 | 4267 | |
| 4268 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4269 | - if ( $term_id ) {
|
|
| 4270 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4271 | - } |
|
| 4272 | - } |
|
| 4268 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4269 | + if ( $term_id ) {
|
|
| 4270 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4271 | + } |
|
| 4272 | + } |
|
| 4273 | 4273 | |
| 4274 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4275 | - $post_category[] = intval($term_category->term_id); |
|
| 4274 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4275 | + $post_category[] = intval($term_category->term_id); |
|
| 4276 | 4276 | |
| 4277 | - if ($category_name == $default_category) {
|
|
| 4278 | - $default_category_id = intval($term_category->term_id); |
|
| 4279 | - } |
|
| 4280 | - } |
|
| 4281 | - } |
|
| 4282 | - } |
|
| 4283 | - } |
|
| 4284 | - $xtimings['###5'] = microtime(true)-$xstart; |
|
| 4285 | - $save_post = array(); |
|
| 4286 | - $save_post['post_title'] = $post_title; |
|
| 4287 | - if (!empty($post_date)) {
|
|
| 4288 | - $post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format. |
|
| 4277 | + if ($category_name == $default_category) {
|
|
| 4278 | + $default_category_id = intval($term_category->term_id); |
|
| 4279 | + } |
|
| 4280 | + } |
|
| 4281 | + } |
|
| 4282 | + } |
|
| 4283 | + } |
|
| 4284 | + $xtimings['###5'] = microtime(true)-$xstart; |
|
| 4285 | + $save_post = array(); |
|
| 4286 | + $save_post['post_title'] = $post_title; |
|
| 4287 | + if (!empty($post_date)) {
|
|
| 4288 | + $post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format. |
|
| 4289 | 4289 | |
| 4290 | - $save_post['post_date'] = $post_date; |
|
| 4291 | - $save_post['post_date_gmt'] = get_gmt_from_date( $post_date ); |
|
| 4292 | - } |
|
| 4293 | - $save_post['post_content'] = $post_content; |
|
| 4294 | - $save_post['post_type'] = $post_type; |
|
| 4295 | - $save_post['post_author'] = $post_author; |
|
| 4296 | - $save_post['post_status'] = $post_status; |
|
| 4297 | - $save_post['post_category'] = $post_category; |
|
| 4298 | - $save_post['post_tags'] = $post_tags; |
|
| 4299 | - |
|
| 4300 | - $saved_post_id = NULL; |
|
| 4301 | - if ( $import_choice == 'update' ) {
|
|
| 4302 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4290 | + $save_post['post_date'] = $post_date; |
|
| 4291 | + $save_post['post_date_gmt'] = get_gmt_from_date( $post_date ); |
|
| 4292 | + } |
|
| 4293 | + $save_post['post_content'] = $post_content; |
|
| 4294 | + $save_post['post_type'] = $post_type; |
|
| 4295 | + $save_post['post_author'] = $post_author; |
|
| 4296 | + $save_post['post_status'] = $post_status; |
|
| 4297 | + $save_post['post_category'] = $post_category; |
|
| 4298 | + $save_post['post_tags'] = $post_tags; |
|
| 4299 | + |
|
| 4300 | + $saved_post_id = NULL; |
|
| 4301 | + if ( $import_choice == 'update' ) {
|
|
| 4302 | + $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4303 | 4303 | |
| 4304 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4305 | - $save_post['ID'] = $post_id; |
|
| 4304 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4305 | + $save_post['ID'] = $post_id; |
|
| 4306 | 4306 | |
| 4307 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4308 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4309 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4310 | - $saved_post_id = 0; |
|
| 4311 | - } else {
|
|
| 4312 | - $saved_post_id = $post_id; |
|
| 4313 | - $updated++; |
|
| 4314 | - } |
|
| 4315 | - } |
|
| 4316 | - } else {
|
|
| 4317 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4318 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4319 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4320 | - $saved_post_id = 0; |
|
| 4321 | - } else {
|
|
| 4322 | - $created++; |
|
| 4323 | - } |
|
| 4324 | - } |
|
| 4325 | - } |
|
| 4307 | + if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4308 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4309 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4310 | + $saved_post_id = 0; |
|
| 4311 | + } else {
|
|
| 4312 | + $saved_post_id = $post_id; |
|
| 4313 | + $updated++; |
|
| 4314 | + } |
|
| 4315 | + } |
|
| 4316 | + } else {
|
|
| 4317 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4318 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4319 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4320 | + $saved_post_id = 0; |
|
| 4321 | + } else {
|
|
| 4322 | + $created++; |
|
| 4323 | + } |
|
| 4324 | + } |
|
| 4325 | + } |
|
| 4326 | 4326 | |
| 4327 | - if ( !$saved_post_id > 0 ) {
|
|
| 4328 | - $invalid++; |
|
| 4329 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4330 | - } |
|
| 4331 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4332 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4333 | - $skipped++; |
|
| 4334 | - } else {
|
|
| 4335 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4336 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4337 | - $invalid++; |
|
| 4327 | + if ( !$saved_post_id > 0 ) {
|
|
| 4328 | + $invalid++; |
|
| 4329 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4330 | + } |
|
| 4331 | + } else if ( $import_choice == 'skip' ) {
|
|
| 4332 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4333 | + $skipped++; |
|
| 4334 | + } else {
|
|
| 4335 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4336 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4337 | + $invalid++; |
|
| 4338 | 4338 | |
| 4339 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4340 | - $saved_post_id = 0; |
|
| 4341 | - } else {
|
|
| 4342 | - $created++; |
|
| 4343 | - } |
|
| 4344 | - } else {
|
|
| 4345 | - $invalid++; |
|
| 4339 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4340 | + $saved_post_id = 0; |
|
| 4341 | + } else {
|
|
| 4342 | + $created++; |
|
| 4343 | + } |
|
| 4344 | + } else {
|
|
| 4345 | + $invalid++; |
|
| 4346 | 4346 | |
| 4347 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4348 | - } |
|
| 4349 | - } |
|
| 4350 | - } else {
|
|
| 4351 | - $invalid++; |
|
| 4347 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4348 | + } |
|
| 4349 | + } |
|
| 4350 | + } else {
|
|
| 4351 | + $invalid++; |
|
| 4352 | 4352 | |
| 4353 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4354 | - } |
|
| 4355 | - $xtimings['###6'] = microtime(true)-$xstart; |
|
| 4356 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 4357 | - // WPML |
|
| 4358 | - if ($is_wpml && geodir_wpml_is_post_type_translated($post_type) && $original_post_id > 0 && $language != '') {
|
|
| 4359 | - $wpml_post_type = 'post_' . $post_type; |
|
| 4360 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4361 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4362 | - |
|
| 4363 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4353 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4354 | + } |
|
| 4355 | + $xtimings['###6'] = microtime(true)-$xstart; |
|
| 4356 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 4357 | + // WPML |
|
| 4358 | + if ($is_wpml && geodir_wpml_is_post_type_translated($post_type) && $original_post_id > 0 && $language != '') {
|
|
| 4359 | + $wpml_post_type = 'post_' . $post_type; |
|
| 4360 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4361 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4362 | + |
|
| 4363 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4364 | 4364 | |
| 4365 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4366 | - } |
|
| 4367 | - // WPML |
|
| 4368 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4365 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4366 | + } |
|
| 4367 | + // WPML |
|
| 4368 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4369 | 4369 | |
| 4370 | - $gd_post['post_id'] = $saved_post_id; |
|
| 4371 | - $gd_post['ID'] = $saved_post_id; |
|
| 4372 | - $gd_post['post_tags'] = $post_tags; |
|
| 4373 | - $gd_post['post_title'] = $post_title; |
|
| 4374 | - $gd_post['post_status'] = $post_status; |
|
| 4375 | - $gd_post['submit_time'] = time(); |
|
| 4376 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4370 | + $gd_post['post_id'] = $saved_post_id; |
|
| 4371 | + $gd_post['ID'] = $saved_post_id; |
|
| 4372 | + $gd_post['post_tags'] = $post_tags; |
|
| 4373 | + $gd_post['post_title'] = $post_title; |
|
| 4374 | + $gd_post['post_status'] = $post_status; |
|
| 4375 | + $gd_post['submit_time'] = time(); |
|
| 4376 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4377 | 4377 | |
| 4378 | - // post location |
|
| 4379 | - $post_location_id = 0; |
|
| 4380 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4381 | - $gd_post['post_neighbourhood'] = ''; |
|
| 4378 | + // post location |
|
| 4379 | + $post_location_id = 0; |
|
| 4380 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4381 | + $gd_post['post_neighbourhood'] = ''; |
|
| 4382 | 4382 | |
| 4383 | - $post_location_info = array( |
|
| 4384 | - 'city' => $post_city, |
|
| 4385 | - 'region' => $post_region, |
|
| 4386 | - 'country' => $post_country, |
|
| 4387 | - 'geo_lat' => $post_latitude, |
|
| 4388 | - 'geo_lng' => $post_longitude |
|
| 4389 | - ); |
|
| 4390 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4391 | - $post_location_id = $location_id; |
|
| 4392 | - } |
|
| 4383 | + $post_location_info = array( |
|
| 4384 | + 'city' => $post_city, |
|
| 4385 | + 'region' => $post_region, |
|
| 4386 | + 'country' => $post_country, |
|
| 4387 | + 'geo_lat' => $post_latitude, |
|
| 4388 | + 'geo_lng' => $post_longitude |
|
| 4389 | + ); |
|
| 4390 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4391 | + $post_location_id = $location_id; |
|
| 4392 | + } |
|
| 4393 | 4393 | |
| 4394 | - if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4395 | - $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4394 | + if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4395 | + $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4396 | 4396 | |
| 4397 | - $hood_data = array(); |
|
| 4398 | - $hood_data['hood_location_id'] = $post_location_id; |
|
| 4399 | - $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4397 | + $hood_data = array(); |
|
| 4398 | + $hood_data['hood_location_id'] = $post_location_id; |
|
| 4399 | + $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4400 | 4400 | |
| 4401 | - if (!empty($neighbourhood_info)) {
|
|
| 4402 | - $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4403 | - $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4401 | + if (!empty($neighbourhood_info)) {
|
|
| 4402 | + $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4403 | + $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4404 | 4404 | |
| 4405 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4406 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4407 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4408 | - } |
|
| 4409 | - } |
|
| 4405 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4406 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4407 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4408 | + } |
|
| 4409 | + } |
|
| 4410 | 4410 | |
| 4411 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4412 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4413 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4414 | - } |
|
| 4411 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4412 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4413 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4414 | + } |
|
| 4415 | 4415 | |
| 4416 | - $hood_data['hood_latitude'] = $post_latitude; |
|
| 4417 | - $hood_data['hood_longitude'] = $post_longitude; |
|
| 4418 | - |
|
| 4419 | - $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4420 | - if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4421 | - $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4422 | - } |
|
| 4423 | - } |
|
| 4424 | - } |
|
| 4425 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 4416 | + $hood_data['hood_latitude'] = $post_latitude; |
|
| 4417 | + $hood_data['hood_longitude'] = $post_longitude; |
|
| 4418 | + |
|
| 4419 | + $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4420 | + if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4421 | + $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4422 | + } |
|
| 4423 | + } |
|
| 4424 | + } |
|
| 4425 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 4426 | 4426 | |
| 4427 | - if ($geodir_link_business !== null) {
|
|
| 4428 | - $gd_post['geodir_link_business'] = $geodir_link_business > 0 ? $geodir_link_business : ''; |
|
| 4429 | - } |
|
| 4427 | + if ($geodir_link_business !== null) {
|
|
| 4428 | + $gd_post['geodir_link_business'] = $geodir_link_business > 0 ? $geodir_link_business : ''; |
|
| 4429 | + } |
|
| 4430 | 4430 | |
| 4431 | - // post package info |
|
| 4432 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4433 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4434 | - $package_id = $gd_post_info->package_id; |
|
| 4435 | - } |
|
| 4431 | + // post package info |
|
| 4432 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4433 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4434 | + $package_id = $gd_post_info->package_id; |
|
| 4435 | + } |
|
| 4436 | 4436 | |
| 4437 | - $package_info = array(); |
|
| 4438 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4439 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4437 | + $package_info = array(); |
|
| 4438 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4439 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4440 | 4440 | |
| 4441 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4442 | - $package_info = array(); |
|
| 4443 | - } |
|
| 4444 | - } |
|
| 4441 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4442 | + $package_info = array(); |
|
| 4443 | + } |
|
| 4444 | + } |
|
| 4445 | 4445 | |
| 4446 | - if (empty($package_info)) {
|
|
| 4447 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4448 | - } |
|
| 4446 | + if (empty($package_info)) {
|
|
| 4447 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4448 | + } |
|
| 4449 | 4449 | |
| 4450 | - if (!empty($package_info)) {
|
|
| 4451 | - $package_id = $package_info['pid']; |
|
| 4450 | + if (!empty($package_info)) {
|
|
| 4451 | + $package_id = $package_info['pid']; |
|
| 4452 | 4452 | |
| 4453 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4454 | - $gd_post['expire_date'] = $expire_date; |
|
| 4455 | - } else {
|
|
| 4456 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4457 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4458 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4459 | - } else {
|
|
| 4460 | - $gd_post['expire_date'] = 'Never'; |
|
| 4461 | - } |
|
| 4462 | - } |
|
| 4453 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4454 | + $gd_post['expire_date'] = $expire_date; |
|
| 4455 | + } else {
|
|
| 4456 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4457 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4458 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4459 | + } else {
|
|
| 4460 | + $gd_post['expire_date'] = 'Never'; |
|
| 4461 | + } |
|
| 4462 | + } |
|
| 4463 | 4463 | |
| 4464 | - $gd_post['package_id'] = $package_id; |
|
| 4465 | - } |
|
| 4464 | + $gd_post['package_id'] = $package_id; |
|
| 4465 | + } |
|
| 4466 | 4466 | |
| 4467 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4467 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4468 | 4468 | |
| 4469 | - if ($post_type == 'gd_event') {
|
|
| 4470 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4471 | - } |
|
| 4469 | + if ($post_type == 'gd_event') {
|
|
| 4470 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4471 | + } |
|
| 4472 | 4472 | |
| 4473 | - if (isset($gd_post['post_id'])) {
|
|
| 4474 | - unset($gd_post['post_id']); |
|
| 4475 | - } |
|
| 4473 | + if (isset($gd_post['post_id'])) {
|
|
| 4474 | + unset($gd_post['post_id']); |
|
| 4475 | + } |
|
| 4476 | 4476 | |
| 4477 | - // Export franchise fields |
|
| 4478 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4479 | - if ($is_franchise_active) {
|
|
| 4480 | - if ( isset( $gd_post['gd_is_franchise'] ) && empty( $gd_post['franchise'] ) ) {
|
|
| 4481 | - if ( absint( $gd_post['gd_is_franchise'] ) != 0 ) {
|
|
| 4482 | - $gd_franchise_lock = array(); |
|
| 4477 | + // Export franchise fields |
|
| 4478 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4479 | + if ($is_franchise_active) {
|
|
| 4480 | + if ( isset( $gd_post['gd_is_franchise'] ) && empty( $gd_post['franchise'] ) ) {
|
|
| 4481 | + if ( absint( $gd_post['gd_is_franchise'] ) != 0 ) {
|
|
| 4482 | + $gd_franchise_lock = array(); |
|
| 4483 | 4483 | |
| 4484 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4485 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4486 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4487 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4488 | - } |
|
| 4484 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4485 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4486 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4487 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4488 | + } |
|
| 4489 | 4489 | |
| 4490 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4491 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4492 | - } else {
|
|
| 4493 | - if ( function_exists( 'geodir_franchise_remove_franchise' ) ) {
|
|
| 4494 | - geodir_franchise_remove_franchise( $saved_post_id ); |
|
| 4495 | - } |
|
| 4496 | - } |
|
| 4497 | - } else {
|
|
| 4498 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4499 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4500 | - } |
|
| 4501 | - } |
|
| 4502 | - } |
|
| 4490 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4491 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4492 | + } else {
|
|
| 4493 | + if ( function_exists( 'geodir_franchise_remove_franchise' ) ) {
|
|
| 4494 | + geodir_franchise_remove_franchise( $saved_post_id ); |
|
| 4495 | + } |
|
| 4496 | + } |
|
| 4497 | + } else {
|
|
| 4498 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4499 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4500 | + } |
|
| 4501 | + } |
|
| 4502 | + } |
|
| 4503 | 4503 | |
| 4504 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4505 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4506 | - if ($default_category_id) {
|
|
| 4507 | - $save_post['post_default_category'] = $default_category_id; |
|
| 4508 | - $gd_post['default_category'] = $default_category_id; |
|
| 4509 | - } |
|
| 4510 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4511 | - } |
|
| 4512 | - $xtimings['###7'] = microtime(true)-$xstart; |
|
| 4513 | - // Save post info |
|
| 4514 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4515 | - $xtimings['###8'] = microtime(true)-$xstart; |
|
| 4516 | - // post taxonomies |
|
| 4517 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4518 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4504 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4505 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4506 | + if ($default_category_id) {
|
|
| 4507 | + $save_post['post_default_category'] = $default_category_id; |
|
| 4508 | + $gd_post['default_category'] = $default_category_id; |
|
| 4509 | + } |
|
| 4510 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4511 | + } |
|
| 4512 | + $xtimings['###7'] = microtime(true)-$xstart; |
|
| 4513 | + // Save post info |
|
| 4514 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4515 | + $xtimings['###8'] = microtime(true)-$xstart; |
|
| 4516 | + // post taxonomies |
|
| 4517 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4518 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4519 | 4519 | |
| 4520 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4521 | - if ($default_category_id) {
|
|
| 4522 | - $post_default_category = $default_category_id; |
|
| 4523 | - } |
|
| 4524 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4525 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4526 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4520 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4521 | + if ($default_category_id) {
|
|
| 4522 | + $post_default_category = $default_category_id; |
|
| 4523 | + } |
|
| 4524 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4525 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4526 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4527 | 4527 | |
| 4528 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 4529 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4530 | - } |
|
| 4528 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 4529 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4530 | + } |
|
| 4531 | 4531 | |
| 4532 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4532 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4533 | 4533 | |
| 4534 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4535 | - } |
|
| 4536 | - $xtimings['###8.1'] = microtime(true)-$xstart; |
|
| 4537 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4538 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4539 | - } |
|
| 4540 | - $xtimings['###9'] = microtime(true)-$xstart; |
|
| 4541 | - // Post images |
|
| 4542 | - if ( !empty( $post_images ) ) {
|
|
| 4543 | - $post_images = array_unique($post_images); |
|
| 4534 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4535 | + } |
|
| 4536 | + $xtimings['###8.1'] = microtime(true)-$xstart; |
|
| 4537 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4538 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4539 | + } |
|
| 4540 | + $xtimings['###9'] = microtime(true)-$xstart; |
|
| 4541 | + // Post images |
|
| 4542 | + if ( !empty( $post_images ) ) {
|
|
| 4543 | + $post_images = array_unique($post_images); |
|
| 4544 | 4544 | |
| 4545 | - $old_post_images_arr = array(); |
|
| 4546 | - $saved_post_images_arr = array(); |
|
| 4545 | + $old_post_images_arr = array(); |
|
| 4546 | + $saved_post_images_arr = array(); |
|
| 4547 | 4547 | |
| 4548 | - $order = 1; |
|
| 4548 | + $order = 1; |
|
| 4549 | 4549 | |
| 4550 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4551 | - $xtimings['###9.1'] = microtime(true)-$xstart; |
|
| 4552 | - if (!empty($old_post_images)) {
|
|
| 4553 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 4554 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4555 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 4556 | - } |
|
| 4557 | - } |
|
| 4558 | - } |
|
| 4550 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4551 | + $xtimings['###9.1'] = microtime(true)-$xstart; |
|
| 4552 | + if (!empty($old_post_images)) {
|
|
| 4553 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 4554 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4555 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 4556 | + } |
|
| 4557 | + } |
|
| 4558 | + } |
|
| 4559 | 4559 | |
| 4560 | - foreach ( $post_images as $post_image ) {
|
|
| 4561 | - $image_name = basename( $post_image ); |
|
| 4562 | - $saved_post_images_arr[] = $image_name; |
|
| 4560 | + foreach ( $post_images as $post_image ) {
|
|
| 4561 | + $image_name = basename( $post_image ); |
|
| 4562 | + $saved_post_images_arr[] = $image_name; |
|
| 4563 | 4563 | |
| 4564 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4565 | - continue; // Skip if image already exists. |
|
| 4566 | - } |
|
| 4564 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4565 | + continue; // Skip if image already exists. |
|
| 4566 | + } |
|
| 4567 | 4567 | |
| 4568 | - $image_name_parts = explode( '.', $image_name ); |
|
| 4569 | - array_pop( $image_name_parts ); |
|
| 4570 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4571 | - $xtimings['###9.2'] = microtime(true)-$xstart; |
|
| 4572 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4573 | - $xtimings['###9.3'] = microtime(true)-$xstart; |
|
| 4574 | - if ( !empty( $arr_file_type ) ) {
|
|
| 4575 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 4568 | + $image_name_parts = explode( '.', $image_name ); |
|
| 4569 | + array_pop( $image_name_parts ); |
|
| 4570 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4571 | + $xtimings['###9.2'] = microtime(true)-$xstart; |
|
| 4572 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4573 | + $xtimings['###9.3'] = microtime(true)-$xstart; |
|
| 4574 | + if ( !empty( $arr_file_type ) ) {
|
|
| 4575 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 4576 | 4576 | |
| 4577 | - $attachment = array(); |
|
| 4578 | - $attachment['post_id'] = $saved_post_id; |
|
| 4579 | - $attachment['title'] = $proper_image_name; |
|
| 4580 | - $attachment['content'] = ''; |
|
| 4581 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4582 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 4583 | - $attachment['menu_order'] = $order; |
|
| 4584 | - $attachment['is_featured'] = 0; |
|
| 4585 | - |
|
| 4586 | - $attachment_set = ''; |
|
| 4587 | - foreach ( $attachment as $key => $val ) {
|
|
| 4588 | - if ( $val != '' ) {
|
|
| 4589 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4590 | - } |
|
| 4591 | - } |
|
| 4592 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 4577 | + $attachment = array(); |
|
| 4578 | + $attachment['post_id'] = $saved_post_id; |
|
| 4579 | + $attachment['title'] = $proper_image_name; |
|
| 4580 | + $attachment['content'] = ''; |
|
| 4581 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4582 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 4583 | + $attachment['menu_order'] = $order; |
|
| 4584 | + $attachment['is_featured'] = 0; |
|
| 4585 | + |
|
| 4586 | + $attachment_set = ''; |
|
| 4587 | + foreach ( $attachment as $key => $val ) {
|
|
| 4588 | + if ( $val != '' ) {
|
|
| 4589 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4590 | + } |
|
| 4591 | + } |
|
| 4592 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 4593 | 4593 | |
| 4594 | - // Add new attachment |
|
| 4595 | - $xtimings['###9.4'] = microtime(true)-$xstart; |
|
| 4596 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4597 | - $xtimings['###9.5'] = microtime(true)-$xstart; |
|
| 4598 | - $order++; |
|
| 4599 | - } |
|
| 4600 | - } |
|
| 4601 | - |
|
| 4602 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4603 | - // Remove previous attachment |
|
| 4604 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4605 | - $xtimings['###9.6'] = microtime(true)-$xstart; |
|
| 4606 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4607 | - geodir_set_wp_featured_image($saved_post_id); |
|
| 4608 | - $xtimings['###9.7'] = microtime(true)-$xstart; |
|
| 4609 | - /* |
|
| 4594 | + // Add new attachment |
|
| 4595 | + $xtimings['###9.4'] = microtime(true)-$xstart; |
|
| 4596 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4597 | + $xtimings['###9.5'] = microtime(true)-$xstart; |
|
| 4598 | + $order++; |
|
| 4599 | + } |
|
| 4600 | + } |
|
| 4601 | + |
|
| 4602 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4603 | + // Remove previous attachment |
|
| 4604 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4605 | + $xtimings['###9.6'] = microtime(true)-$xstart; |
|
| 4606 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4607 | + geodir_set_wp_featured_image($saved_post_id); |
|
| 4608 | + $xtimings['###9.7'] = microtime(true)-$xstart; |
|
| 4609 | + /* |
|
| 4610 | 4610 | $menu_order = 1; |
| 4611 | 4611 | |
| 4612 | 4612 | foreach ( $saved_post_images_arr as $img_name ) {
|
@@ -4619,288 +4619,288 @@ discard block |
||
| 4619 | 4619 | } |
| 4620 | 4620 | $menu_order++; |
| 4621 | 4621 | }*/ |
| 4622 | - } |
|
| 4622 | + } |
|
| 4623 | 4623 | |
| 4624 | - if ( $order > 1 ) {
|
|
| 4625 | - $images++; |
|
| 4626 | - } |
|
| 4627 | - } |
|
| 4628 | - $xtimings['###10'] = microtime(true)-$xstart; |
|
| 4629 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4630 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4631 | - $xtimings['###11'] = microtime(true)-$xstart; |
|
| 4632 | - if (isset($is_featured)) {
|
|
| 4633 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4634 | - } |
|
| 4635 | - if (isset($gd_post['alive_days'])) {
|
|
| 4636 | - geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
| 4637 | - } |
|
| 4638 | - if (isset($gd_post['expire_date'])) {
|
|
| 4639 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4640 | - } |
|
| 4641 | - $xtimings['###12'] = microtime(true)-$xstart; |
|
| 4642 | - } |
|
| 4624 | + if ( $order > 1 ) {
|
|
| 4625 | + $images++; |
|
| 4626 | + } |
|
| 4627 | + } |
|
| 4628 | + $xtimings['###10'] = microtime(true)-$xstart; |
|
| 4629 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4630 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4631 | + $xtimings['###11'] = microtime(true)-$xstart; |
|
| 4632 | + if (isset($is_featured)) {
|
|
| 4633 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4634 | + } |
|
| 4635 | + if (isset($gd_post['alive_days'])) {
|
|
| 4636 | + geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
| 4637 | + } |
|
| 4638 | + if (isset($gd_post['expire_date'])) {
|
|
| 4639 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4640 | + } |
|
| 4641 | + $xtimings['###12'] = microtime(true)-$xstart; |
|
| 4642 | + } |
|
| 4643 | 4643 | |
| 4644 | - // WPML |
|
| 4645 | - if ($is_wpml && $language != '') {
|
|
| 4646 | - $sitepress->switch_lang($active_lang, true); |
|
| 4647 | - } |
|
| 4648 | - // WPML |
|
| 4649 | - } |
|
| 4650 | - } |
|
| 4651 | - } |
|
| 4644 | + // WPML |
|
| 4645 | + if ($is_wpml && $language != '') {
|
|
| 4646 | + $sitepress->switch_lang($active_lang, true); |
|
| 4647 | + } |
|
| 4648 | + // WPML |
|
| 4649 | + } |
|
| 4650 | + } |
|
| 4651 | + } |
|
| 4652 | 4652 | |
| 4653 | - //undo some stuff to make the import quicker |
|
| 4654 | - wp_defer_term_counting( false ); |
|
| 4655 | - wp_defer_comment_counting( false ); |
|
| 4656 | - $wpdb->query( 'COMMIT;' ); |
|
| 4657 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4658 | - $xtimings['###13'] = microtime(true)-$xstart; |
|
| 4659 | - $json = array(); |
|
| 4660 | - $json['processed'] = $processed_actual; |
|
| 4661 | - $json['created'] = $created; |
|
| 4662 | - $json['updated'] = $updated; |
|
| 4663 | - $json['skipped'] = $skipped; |
|
| 4664 | - $json['invalid'] = $invalid; |
|
| 4665 | - $json['invalid_addr'] = $invalid_addr; |
|
| 4666 | - $json['images'] = $images; |
|
| 4667 | - $json['timing'] = microtime(true)-$xstart; |
|
| 4668 | - $json['timings'] = $xtimings; |
|
| 4653 | + //undo some stuff to make the import quicker |
|
| 4654 | + wp_defer_term_counting( false ); |
|
| 4655 | + wp_defer_comment_counting( false ); |
|
| 4656 | + $wpdb->query( 'COMMIT;' ); |
|
| 4657 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4658 | + $xtimings['###13'] = microtime(true)-$xstart; |
|
| 4659 | + $json = array(); |
|
| 4660 | + $json['processed'] = $processed_actual; |
|
| 4661 | + $json['created'] = $created; |
|
| 4662 | + $json['updated'] = $updated; |
|
| 4663 | + $json['skipped'] = $skipped; |
|
| 4664 | + $json['invalid'] = $invalid; |
|
| 4665 | + $json['invalid_addr'] = $invalid_addr; |
|
| 4666 | + $json['images'] = $images; |
|
| 4667 | + $json['timing'] = microtime(true)-$xstart; |
|
| 4668 | + $json['timings'] = $xtimings; |
|
| 4669 | 4669 | |
| 4670 | 4670 | |
| 4671 | - wp_send_json( $json ); |
|
| 4672 | - exit; |
|
| 4673 | - } else if ( $task == 'import_loc' ) {
|
|
| 4674 | - global $gd_post_types; |
|
| 4675 | - $gd_post_types = $post_types; |
|
| 4671 | + wp_send_json( $json ); |
|
| 4672 | + exit; |
|
| 4673 | + } else if ( $task == 'import_loc' ) {
|
|
| 4674 | + global $gd_post_types; |
|
| 4675 | + $gd_post_types = $post_types; |
|
| 4676 | 4676 | |
| 4677 | - if (!empty($file)) {
|
|
| 4678 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4677 | + if (!empty($file)) {
|
|
| 4678 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4679 | 4679 | |
| 4680 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4681 | - $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory');
|
|
| 4682 | - wp_send_json( $json ); |
|
| 4683 | - } |
|
| 4680 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4681 | + $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory');
|
|
| 4682 | + wp_send_json( $json ); |
|
| 4683 | + } |
|
| 4684 | 4684 | |
| 4685 | - $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4686 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4687 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4688 | - $index = $processed + $i; |
|
| 4685 | + $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4686 | + $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4687 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4688 | + $index = $processed + $i; |
|
| 4689 | 4689 | |
| 4690 | - if (isset($file[$index])) {
|
|
| 4691 | - $row = $file[$index]; |
|
| 4692 | - $row = array_map( 'trim', $row ); |
|
| 4693 | - $data = array(); |
|
| 4690 | + if (isset($file[$index])) {
|
|
| 4691 | + $row = $file[$index]; |
|
| 4692 | + $row = array_map( 'trim', $row ); |
|
| 4693 | + $data = array(); |
|
| 4694 | 4694 | |
| 4695 | - foreach ($columns as $c => $column ) {
|
|
| 4696 | - if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
|
|
| 4697 | - $data[$column] = $row[$c]; |
|
| 4698 | - } |
|
| 4699 | - } |
|
| 4695 | + foreach ($columns as $c => $column ) {
|
|
| 4696 | + if (in_array($column, array('location_id', 'latitude', 'longitude', 'city', 'city_slug', 'region', 'country', 'city_meta_title', 'city_meta_desc', 'city_desc', 'region_meta_title', 'region_meta_desc', 'region_desc', 'country_meta_title', 'country_meta_desc', 'country_desc'))) {
|
|
| 4697 | + $data[$column] = $row[$c]; |
|
| 4698 | + } |
|
| 4699 | + } |
|
| 4700 | 4700 | |
| 4701 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4702 | - $invalid++; |
|
| 4703 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4704 | - continue; |
|
| 4705 | - } |
|
| 4701 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4702 | + $invalid++; |
|
| 4703 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4704 | + continue; |
|
| 4705 | + } |
|
| 4706 | 4706 | |
| 4707 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4707 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4708 | 4708 | |
| 4709 | - if ( $import_choice == 'update' ) {
|
|
| 4710 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4711 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4712 | - $updated++; |
|
| 4713 | - } else {
|
|
| 4714 | - $invalid++; |
|
| 4715 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4716 | - } |
|
| 4717 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4718 | - $data['location_id'] = (int)$location->location_id; |
|
| 4709 | + if ( $import_choice == 'update' ) {
|
|
| 4710 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4711 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4712 | + $updated++; |
|
| 4713 | + } else {
|
|
| 4714 | + $invalid++; |
|
| 4715 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4716 | + } |
|
| 4717 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4718 | + $data['location_id'] = (int)$location->location_id; |
|
| 4719 | 4719 | |
| 4720 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4721 | - $data['location_id'] = (int)$location->location_id; |
|
| 4722 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4723 | - $data['location_id'] = (int)$location->location_id; |
|
| 4724 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4725 | - $data['location_id'] = (int)$location->location_id; |
|
| 4726 | - } |
|
| 4720 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4721 | + $data['location_id'] = (int)$location->location_id; |
|
| 4722 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4723 | + $data['location_id'] = (int)$location->location_id; |
|
| 4724 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4725 | + $data['location_id'] = (int)$location->location_id; |
|
| 4726 | + } |
|
| 4727 | 4727 | |
| 4728 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4729 | - $updated++; |
|
| 4730 | - } else {
|
|
| 4731 | - $invalid++; |
|
| 4732 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4733 | - } |
|
| 4734 | - } else {
|
|
| 4735 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4736 | - $created++; |
|
| 4737 | - } else {
|
|
| 4738 | - $invalid++; |
|
| 4739 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4740 | - } |
|
| 4741 | - } |
|
| 4742 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4743 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4744 | - $skipped++; |
|
| 4745 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4746 | - $skipped++; |
|
| 4747 | - } else {
|
|
| 4748 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4749 | - $created++; |
|
| 4750 | - } else {
|
|
| 4751 | - $invalid++; |
|
| 4752 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4753 | - } |
|
| 4754 | - } |
|
| 4755 | - } else {
|
|
| 4756 | - $invalid++; |
|
| 4757 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4758 | - } |
|
| 4759 | - } |
|
| 4760 | - } |
|
| 4761 | - } |
|
| 4728 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4729 | + $updated++; |
|
| 4730 | + } else {
|
|
| 4731 | + $invalid++; |
|
| 4732 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4733 | + } |
|
| 4734 | + } else {
|
|
| 4735 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4736 | + $created++; |
|
| 4737 | + } else {
|
|
| 4738 | + $invalid++; |
|
| 4739 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4740 | + } |
|
| 4741 | + } |
|
| 4742 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4743 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4744 | + $skipped++; |
|
| 4745 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4746 | + $skipped++; |
|
| 4747 | + } else {
|
|
| 4748 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4749 | + $created++; |
|
| 4750 | + } else {
|
|
| 4751 | + $invalid++; |
|
| 4752 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4753 | + } |
|
| 4754 | + } |
|
| 4755 | + } else {
|
|
| 4756 | + $invalid++; |
|
| 4757 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4758 | + } |
|
| 4759 | + } |
|
| 4760 | + } |
|
| 4761 | + } |
|
| 4762 | 4762 | |
| 4763 | - $json = array(); |
|
| 4764 | - $json['processed'] = $limit; |
|
| 4765 | - $json['created'] = $created; |
|
| 4766 | - $json['updated'] = $updated; |
|
| 4767 | - $json['skipped'] = $skipped; |
|
| 4768 | - $json['invalid'] = $invalid; |
|
| 4769 | - $json['images'] = $images; |
|
| 4763 | + $json = array(); |
|
| 4764 | + $json['processed'] = $limit; |
|
| 4765 | + $json['created'] = $created; |
|
| 4766 | + $json['updated'] = $updated; |
|
| 4767 | + $json['skipped'] = $skipped; |
|
| 4768 | + $json['invalid'] = $invalid; |
|
| 4769 | + $json['images'] = $images; |
|
| 4770 | 4770 | |
| 4771 | - wp_send_json( $json ); |
|
| 4772 | - } else if ( $task == 'import_hood' ) {
|
|
| 4773 | - if (!empty($file)) {
|
|
| 4774 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4771 | + wp_send_json( $json ); |
|
| 4772 | + } else if ( $task == 'import_hood' ) {
|
|
| 4773 | + if (!empty($file)) {
|
|
| 4774 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4775 | 4775 | |
| 4776 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4777 | - $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory');
|
|
| 4778 | - wp_send_json( $json ); |
|
| 4779 | - } |
|
| 4776 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4777 | + $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory');
|
|
| 4778 | + wp_send_json( $json ); |
|
| 4779 | + } |
|
| 4780 | 4780 | |
| 4781 | - $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4782 | - $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ); |
|
| 4783 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4784 | - $index = $processed + $i; |
|
| 4781 | + $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4782 | + $gd_error_hood = __( 'Could not be saved due to invalid neighbourhood data(name, latitude, longitude) or invalid location data(either location_id or city/region/country is empty)', 'geodirectory' ); |
|
| 4783 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4784 | + $index = $processed + $i; |
|
| 4785 | 4785 | |
| 4786 | - if (isset($file[$index])) {
|
|
| 4787 | - $row = $file[$index]; |
|
| 4788 | - $row = array_map( 'trim', $row ); |
|
| 4789 | - $data = array(); |
|
| 4786 | + if (isset($file[$index])) {
|
|
| 4787 | + $row = $file[$index]; |
|
| 4788 | + $row = array_map( 'trim', $row ); |
|
| 4789 | + $data = array(); |
|
| 4790 | 4790 | |
| 4791 | - foreach ($columns as $c => $column) {
|
|
| 4792 | - if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 4793 | - $data[$column] = sanitize_text_field($row[$c]); |
|
| 4794 | - } |
|
| 4795 | - } |
|
| 4791 | + foreach ($columns as $c => $column) {
|
|
| 4792 | + if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 4793 | + $data[$column] = sanitize_text_field($row[$c]); |
|
| 4794 | + } |
|
| 4795 | + } |
|
| 4796 | 4796 | |
| 4797 | - if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4798 | - $invalid++; |
|
| 4799 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4800 | - continue; |
|
| 4801 | - } |
|
| 4797 | + if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4798 | + $invalid++; |
|
| 4799 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4800 | + continue; |
|
| 4801 | + } |
|
| 4802 | 4802 | |
| 4803 | - $location_info = array(); |
|
| 4804 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 4805 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 4806 | - } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 4807 | - $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 4808 | - } |
|
| 4803 | + $location_info = array(); |
|
| 4804 | + if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 4805 | + $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 4806 | + } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 4807 | + $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 4808 | + } |
|
| 4809 | 4809 | |
| 4810 | - if (empty($location_info)) {
|
|
| 4811 | - $invalid++; |
|
| 4812 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4813 | - continue; |
|
| 4814 | - } |
|
| 4810 | + if (empty($location_info)) {
|
|
| 4811 | + $invalid++; |
|
| 4812 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4813 | + continue; |
|
| 4814 | + } |
|
| 4815 | 4815 | |
| 4816 | - $location_id = $location_info->location_id; |
|
| 4816 | + $location_id = $location_info->location_id; |
|
| 4817 | 4817 | |
| 4818 | - $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 4818 | + $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 4819 | 4819 | |
| 4820 | - $hood_data = array(); |
|
| 4821 | - $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 4822 | - $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 4823 | - $hood_data['hood_latitude'] = $data['latitude']; |
|
| 4824 | - $hood_data['hood_longitude'] = $data['longitude']; |
|
| 4825 | - $hood_data['hood_location_id'] = $location_id; |
|
| 4820 | + $hood_data = array(); |
|
| 4821 | + $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 4822 | + $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 4823 | + $hood_data['hood_latitude'] = $data['latitude']; |
|
| 4824 | + $hood_data['hood_longitude'] = $data['longitude']; |
|
| 4825 | + $hood_data['hood_location_id'] = $location_id; |
|
| 4826 | 4826 | |
| 4827 | - if ( $import_choice == 'update' ) {
|
|
| 4828 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4829 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 4827 | + if ( $import_choice == 'update' ) {
|
|
| 4828 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4829 | + $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 4830 | 4830 | |
| 4831 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4832 | - $updated++; |
|
| 4833 | - } else {
|
|
| 4834 | - $invalid++; |
|
| 4835 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4836 | - } |
|
| 4837 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4838 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 4831 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4832 | + $updated++; |
|
| 4833 | + } else {
|
|
| 4834 | + $invalid++; |
|
| 4835 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4836 | + } |
|
| 4837 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4838 | + $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 4839 | 4839 | |
| 4840 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4841 | - $updated++; |
|
| 4842 | - } else {
|
|
| 4843 | - $invalid++; |
|
| 4844 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4845 | - } |
|
| 4846 | - } else {
|
|
| 4847 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4848 | - $created++; |
|
| 4849 | - } else {
|
|
| 4850 | - $invalid++; |
|
| 4851 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4852 | - } |
|
| 4853 | - } |
|
| 4854 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4855 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4856 | - $skipped++; |
|
| 4857 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4858 | - $skipped++; |
|
| 4859 | - } else {
|
|
| 4840 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4841 | + $updated++; |
|
| 4842 | + } else {
|
|
| 4843 | + $invalid++; |
|
| 4844 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4845 | + } |
|
| 4846 | + } else {
|
|
| 4847 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4848 | + $created++; |
|
| 4849 | + } else {
|
|
| 4850 | + $invalid++; |
|
| 4851 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4852 | + } |
|
| 4853 | + } |
|
| 4854 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4855 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4856 | + $skipped++; |
|
| 4857 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4858 | + $skipped++; |
|
| 4859 | + } else {
|
|
| 4860 | 4860 | |
| 4861 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4862 | - $created++; |
|
| 4863 | - } else {
|
|
| 4864 | - $invalid++; |
|
| 4865 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4866 | - } |
|
| 4867 | - } |
|
| 4868 | - } else {
|
|
| 4869 | - $invalid++; |
|
| 4870 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4871 | - } |
|
| 4872 | - } |
|
| 4873 | - } |
|
| 4874 | - } |
|
| 4861 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4862 | + $created++; |
|
| 4863 | + } else {
|
|
| 4864 | + $invalid++; |
|
| 4865 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4866 | + } |
|
| 4867 | + } |
|
| 4868 | + } else {
|
|
| 4869 | + $invalid++; |
|
| 4870 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4871 | + } |
|
| 4872 | + } |
|
| 4873 | + } |
|
| 4874 | + } |
|
| 4875 | 4875 | |
| 4876 | - $json = array(); |
|
| 4877 | - $json['processed'] = $limit; |
|
| 4878 | - $json['created'] = $created; |
|
| 4879 | - $json['updated'] = $updated; |
|
| 4880 | - $json['skipped'] = $skipped; |
|
| 4881 | - $json['invalid'] = $invalid; |
|
| 4882 | - $json['images'] = $images; |
|
| 4876 | + $json = array(); |
|
| 4877 | + $json['processed'] = $limit; |
|
| 4878 | + $json['created'] = $created; |
|
| 4879 | + $json['updated'] = $updated; |
|
| 4880 | + $json['skipped'] = $skipped; |
|
| 4881 | + $json['invalid'] = $invalid; |
|
| 4882 | + $json['images'] = $images; |
|
| 4883 | 4883 | |
| 4884 | - wp_send_json( $json ); |
|
| 4885 | - } |
|
| 4886 | - } |
|
| 4887 | - break; |
|
| 4888 | - case 'import_finish':{
|
|
| 4889 | - /** |
|
| 4890 | - * Run an action when an import finishes. |
|
| 4891 | - * |
|
| 4892 | - * This action can be used to fire functions after an import ends. |
|
| 4893 | - * |
|
| 4894 | - * @since 1.5.3 |
|
| 4895 | - * @package GeoDirectory |
|
| 4896 | - */ |
|
| 4897 | - do_action('geodir_import_finished');
|
|
| 4898 | - } |
|
| 4899 | - break; |
|
| 4884 | + wp_send_json( $json ); |
|
| 4885 | + } |
|
| 4886 | + } |
|
| 4887 | + break; |
|
| 4888 | + case 'import_finish':{
|
|
| 4889 | + /** |
|
| 4890 | + * Run an action when an import finishes. |
|
| 4891 | + * |
|
| 4892 | + * This action can be used to fire functions after an import ends. |
|
| 4893 | + * |
|
| 4894 | + * @since 1.5.3 |
|
| 4895 | + * @package GeoDirectory |
|
| 4896 | + */ |
|
| 4897 | + do_action('geodir_import_finished');
|
|
| 4898 | + } |
|
| 4899 | + break; |
|
| 4900 | 4900 | |
| 4901 | - } |
|
| 4902 | - echo '0'; |
|
| 4903 | - gd_die(); |
|
| 4901 | + } |
|
| 4902 | + echo '0'; |
|
| 4903 | + gd_die(); |
|
| 4904 | 4904 | } |
| 4905 | 4905 | |
| 4906 | 4906 | /** |
@@ -4944,12 +4944,12 @@ discard block |
||
| 4944 | 4944 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
| 4945 | 4945 | } |
| 4946 | 4946 | |
| 4947 | - if( !empty( $term ) ) {
|
|
| 4947 | + if( !empty( $term ) ) {
|
|
| 4948 | 4948 | $result = wp_insert_term( $term, $taxonomy, $args ); |
| 4949 | - if( !is_wp_error( $result ) ) {
|
|
| 4950 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4951 | - } |
|
| 4952 | - } |
|
| 4949 | + if( !is_wp_error( $result ) ) {
|
|
| 4950 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4951 | + } |
|
| 4952 | + } |
|
| 4953 | 4953 | |
| 4954 | 4954 | return false; |
| 4955 | 4955 | } |
@@ -4995,16 +4995,16 @@ discard block |
||
| 4995 | 4995 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 4996 | 4996 | |
| 4997 | 4997 | if( !is_wp_error( $result ) ) {
|
| 4998 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4999 | - } |
|
| 4998 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4999 | + } |
|
| 5000 | 5000 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
| 5001 | 5001 | $term_data['term_id'] = $term_info['term_id']; |
| 5002 | 5002 | |
| 5003 | 5003 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 5004 | 5004 | |
| 5005 | 5005 | if( !is_wp_error( $result ) ) {
|
| 5006 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5007 | - } |
|
| 5006 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 5007 | + } |
|
| 5008 | 5008 | } else {
|
| 5009 | 5009 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
| 5010 | 5010 | } |
@@ -5026,47 +5026,47 @@ discard block |
||
| 5026 | 5026 | * @return int Posts count. |
| 5027 | 5027 | */ |
| 5028 | 5028 | function geodir_get_posts_count( $post_type ) {
|
| 5029 | - global $wpdb, $plugin_prefix; |
|
| 5029 | + global $wpdb, $plugin_prefix; |
|
| 5030 | 5030 | |
| 5031 | - if ( !post_type_exists( $post_type ) ) {
|
|
| 5032 | - return 0; |
|
| 5033 | - } |
|
| 5031 | + if ( !post_type_exists( $post_type ) ) {
|
|
| 5032 | + return 0; |
|
| 5033 | + } |
|
| 5034 | 5034 | |
| 5035 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5035 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5036 | 5036 | |
| 5037 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5038 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5039 | - $where_statuses = ''; |
|
| 5040 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5041 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5042 | - } |
|
| 5037 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5038 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5039 | + $where_statuses = ''; |
|
| 5040 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5041 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5042 | + } |
|
| 5043 | 5043 | |
| 5044 | - /** |
|
| 5045 | - * Filter the SQL where clause part to filter posts count in import/export. |
|
| 5046 | - * |
|
| 5047 | - * @since 1.6.4 |
|
| 5048 | - * @package GeoDirectory |
|
| 5049 | - * |
|
| 5050 | - * @param string $where SQL where clause part. |
|
| 5051 | - */ |
|
| 5052 | - $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
| 5053 | - |
|
| 5054 | - $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
|
|
| 5055 | - |
|
| 5056 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5044 | + /** |
|
| 5045 | + * Filter the SQL where clause part to filter posts count in import/export. |
|
| 5046 | + * |
|
| 5047 | + * @since 1.6.4 |
|
| 5048 | + * @package GeoDirectory |
|
| 5049 | + * |
|
| 5050 | + * @param string $where SQL where clause part. |
|
| 5051 | + */ |
|
| 5052 | + $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
| 5053 | + |
|
| 5054 | + $query = $wpdb->prepare( "SELECT COUNT({$wpdb->posts}.ID) FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses, $post_type );
|
|
| 5055 | + |
|
| 5056 | + $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5057 | 5057 | |
| 5058 | - /** |
|
| 5059 | - * Modify returned post counts for the current post type. |
|
| 5060 | - * |
|
| 5061 | - * @since 1.4.6 |
|
| 5062 | - * @package GeoDirectory |
|
| 5063 | - * |
|
| 5064 | - * @param int $posts_count Post counts. |
|
| 5065 | - * @param string $post_type Post type. |
|
| 5066 | - */ |
|
| 5067 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5068 | - |
|
| 5069 | - return $posts_count; |
|
| 5058 | + /** |
|
| 5059 | + * Modify returned post counts for the current post type. |
|
| 5060 | + * |
|
| 5061 | + * @since 1.4.6 |
|
| 5062 | + * @package GeoDirectory |
|
| 5063 | + * |
|
| 5064 | + * @param int $posts_count Post counts. |
|
| 5065 | + * @param string $post_type Post type. |
|
| 5066 | + */ |
|
| 5067 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5068 | + |
|
| 5069 | + return $posts_count; |
|
| 5070 | 5070 | } |
| 5071 | 5071 | |
| 5072 | 5072 | /** |
@@ -5134,7 +5134,7 @@ discard block |
||
| 5134 | 5134 | } |
| 5135 | 5135 | $csv_row[] = 'post_status'; |
| 5136 | 5136 | $csv_row[] = 'is_featured'; |
| 5137 | - // Export claim listing field |
|
| 5137 | + // Export claim listing field |
|
| 5138 | 5138 | if ($is_claim_active) {
|
| 5139 | 5139 | $csv_row[] = 'claimed'; |
| 5140 | 5140 | } |
@@ -5143,7 +5143,7 @@ discard block |
||
| 5143 | 5143 | $csv_row[] = 'alive_days'; |
| 5144 | 5144 | $csv_row[] = 'expire_date'; |
| 5145 | 5145 | } |
| 5146 | - $csv_row[] = 'post_date'; |
|
| 5146 | + $csv_row[] = 'post_date'; |
|
| 5147 | 5147 | $csv_row[] = 'post_address'; |
| 5148 | 5148 | $csv_row[] = 'post_city'; |
| 5149 | 5149 | $csv_row[] = 'post_region'; |
@@ -5151,11 +5151,11 @@ discard block |
||
| 5151 | 5151 | $csv_row[] = 'post_zip'; |
| 5152 | 5152 | $csv_row[] = 'post_latitude'; |
| 5153 | 5153 | $csv_row[] = 'post_longitude'; |
| 5154 | - if ($neighbourhood_active) {
|
|
| 5155 | - $csv_row[] = 'post_neighbourhood'; |
|
| 5156 | - $csv_row[] = 'neighbourhood_latitude'; |
|
| 5157 | - $csv_row[] = 'neighbourhood_longitude'; |
|
| 5158 | - } |
|
| 5154 | + if ($neighbourhood_active) {
|
|
| 5155 | + $csv_row[] = 'post_neighbourhood'; |
|
| 5156 | + $csv_row[] = 'neighbourhood_latitude'; |
|
| 5157 | + $csv_row[] = 'neighbourhood_longitude'; |
|
| 5158 | + } |
|
| 5159 | 5159 | $csv_row[] = 'geodir_timing'; |
| 5160 | 5160 | $csv_row[] = 'geodir_contact'; |
| 5161 | 5161 | $csv_row[] = 'geodir_email'; |
@@ -5190,21 +5190,21 @@ discard block |
||
| 5190 | 5190 | $csv_row[] = 'franchise'; |
| 5191 | 5191 | } |
| 5192 | 5192 | |
| 5193 | - /** |
|
| 5194 | - * Filter columns field names of gd export listings csv. |
|
| 5195 | - * |
|
| 5196 | - * @since 1.6.5 |
|
| 5197 | - * @package GeoDirectory |
|
| 5198 | - * |
|
| 5199 | - * @param array $csv_row Column names being exported in csv. |
|
| 5200 | - * @param string $post_type The post type. |
|
| 5201 | - */ |
|
| 5202 | - $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
|
|
| 5193 | + /** |
|
| 5194 | + * Filter columns field names of gd export listings csv. |
|
| 5195 | + * |
|
| 5196 | + * @since 1.6.5 |
|
| 5197 | + * @package GeoDirectory |
|
| 5198 | + * |
|
| 5199 | + * @param array $csv_row Column names being exported in csv. |
|
| 5200 | + * @param string $post_type The post type. |
|
| 5201 | + */ |
|
| 5202 | + $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
|
|
| 5203 | 5203 | |
| 5204 | 5204 | $csv_rows[] = $csv_row; |
| 5205 | 5205 | |
| 5206 | 5206 | $images_count = 5; |
| 5207 | - $xx=0; |
|
| 5207 | + $xx=0; |
|
| 5208 | 5208 | foreach ( $posts as $post ) {$xx++;
|
| 5209 | 5209 | $post_id = $post['ID']; |
| 5210 | 5210 | |
@@ -5335,15 +5335,15 @@ discard block |
||
| 5335 | 5335 | } |
| 5336 | 5336 | $csv_row[] = $post_info['post_status']; // post_status |
| 5337 | 5337 | $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
| 5338 | - if ($is_claim_active) {
|
|
| 5339 | - $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
| 5340 | - } |
|
| 5338 | + if ($is_claim_active) {
|
|
| 5339 | + $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
| 5340 | + } |
|
| 5341 | 5341 | if ($is_payment_plugin) {
|
| 5342 | 5342 | $csv_row[] = (int)$post_info['package_id']; // package_id |
| 5343 | 5343 | $csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days |
| 5344 | 5344 | $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
|
| 5345 | 5345 | } |
| 5346 | - $csv_row[] = $post_info['post_date']; // post_date |
|
| 5346 | + $csv_row[] = $post_info['post_date']; // post_date |
|
| 5347 | 5347 | $csv_row[] = stripslashes($post_info['post_address']); // post_address |
| 5348 | 5348 | $csv_row[] = stripslashes($post_info['post_city']); // post_city |
| 5349 | 5349 | $csv_row[] = stripslashes($post_info['post_region']); // post_region |
@@ -5351,21 +5351,21 @@ discard block |
||
| 5351 | 5351 | $csv_row[] = stripslashes($post_info['post_zip']); // post_zip |
| 5352 | 5352 | $csv_row[] = $post_info['post_latitude']; // post_latitude |
| 5353 | 5353 | $csv_row[] = $post_info['post_longitude']; // post_longitude |
| 5354 | - if ($neighbourhood_active) {
|
|
| 5355 | - $post_neighbourhood = ''; |
|
| 5356 | - $neighbourhood_latitude = ''; |
|
| 5357 | - $neighbourhood_longitude = ''; |
|
| 5358 | - if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5359 | - if (!empty($hood_info)) {
|
|
| 5360 | - $post_neighbourhood = $hood_info->hood_name; |
|
| 5361 | - $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5362 | - $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5363 | - } |
|
| 5364 | - } |
|
| 5365 | - $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
| 5366 | - $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5367 | - $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5368 | - } |
|
| 5354 | + if ($neighbourhood_active) {
|
|
| 5355 | + $post_neighbourhood = ''; |
|
| 5356 | + $neighbourhood_latitude = ''; |
|
| 5357 | + $neighbourhood_longitude = ''; |
|
| 5358 | + if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5359 | + if (!empty($hood_info)) {
|
|
| 5360 | + $post_neighbourhood = $hood_info->hood_name; |
|
| 5361 | + $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5362 | + $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5363 | + } |
|
| 5364 | + } |
|
| 5365 | + $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
| 5366 | + $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5367 | + $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5368 | + } |
|
| 5369 | 5369 | $csv_row[] = stripslashes($post_info['geodir_timing']); // geodir_timing |
| 5370 | 5370 | $csv_row[] = stripslashes($post_info['geodir_contact']); // geodir_contact |
| 5371 | 5371 | $csv_row[] = stripslashes($post_info['geodir_email']); // geodir_email |
@@ -5408,16 +5408,16 @@ discard block |
||
| 5408 | 5408 | $csv_row[] = (int)$franchise; // franchise id |
| 5409 | 5409 | } |
| 5410 | 5410 | |
| 5411 | - /** |
|
| 5412 | - * Filter columns values of gd export listings csv file |
|
| 5413 | - * |
|
| 5414 | - * @since 1.6.5 |
|
| 5415 | - * @package GeoDirectory |
|
| 5416 | - * |
|
| 5417 | - * @param array $csv_row Field values being exported in csv. |
|
| 5418 | - * @param array $post_info The post info. |
|
| 5419 | - */ |
|
| 5420 | - $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
|
|
| 5411 | + /** |
|
| 5412 | + * Filter columns values of gd export listings csv file |
|
| 5413 | + * |
|
| 5414 | + * @since 1.6.5 |
|
| 5415 | + * @package GeoDirectory |
|
| 5416 | + * |
|
| 5417 | + * @param array $csv_row Field values being exported in csv. |
|
| 5418 | + * @param array $post_info The post info. |
|
| 5419 | + */ |
|
| 5420 | + $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
|
|
| 5421 | 5421 | |
| 5422 | 5422 | for ( $c = 0; $c < $images_count; $c++ ) {
|
| 5423 | 5423 | $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
@@ -5450,64 +5450,64 @@ discard block |
||
| 5450 | 5450 | * @return array Array of posts data. |
| 5451 | 5451 | */ |
| 5452 | 5452 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 5453 | - global $wpdb, $plugin_prefix; |
|
| 5453 | + global $wpdb, $plugin_prefix; |
|
| 5454 | 5454 | |
| 5455 | - if ( ! post_type_exists( $post_type ) ) |
|
| 5456 | - return new stdClass; |
|
| 5455 | + if ( ! post_type_exists( $post_type ) ) |
|
| 5456 | + return new stdClass; |
|
| 5457 | 5457 | |
| 5458 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5458 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5459 | 5459 | |
| 5460 | - $limit = ''; |
|
| 5461 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5462 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 5460 | + $limit = ''; |
|
| 5461 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5462 | + $offset = ( $page_no - 1 ) * $per_page; |
|
| 5463 | 5463 | |
| 5464 | - if ( $offset > 0 ) {
|
|
| 5465 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5466 | - } else {
|
|
| 5467 | - $limit = " LIMIT " . $per_page; |
|
| 5468 | - } |
|
| 5469 | - } |
|
| 5464 | + if ( $offset > 0 ) {
|
|
| 5465 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5466 | + } else {
|
|
| 5467 | + $limit = " LIMIT " . $per_page; |
|
| 5468 | + } |
|
| 5469 | + } |
|
| 5470 | 5470 | |
| 5471 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5472 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5473 | - $where_statuses = ''; |
|
| 5474 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5475 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5476 | - } |
|
| 5471 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5472 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5473 | + $where_statuses = ''; |
|
| 5474 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5475 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5476 | + } |
|
| 5477 | 5477 | |
| 5478 | - /** |
|
| 5479 | - * Filter the SQL where clause part to filter posts in import/export. |
|
| 5480 | - * |
|
| 5481 | - * @since 1.6.4 |
|
| 5482 | - * @package GeoDirectory |
|
| 5483 | - * |
|
| 5484 | - * @param string $where SQL where clause part. |
|
| 5485 | - */ |
|
| 5486 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5487 | - |
|
| 5488 | - $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
|
|
| 5489 | - /** |
|
| 5490 | - * Modify returned posts SQL query for the current post type. |
|
| 5491 | - * |
|
| 5492 | - * @since 1.4.6 |
|
| 5493 | - * @package GeoDirectory |
|
| 5494 | - * |
|
| 5495 | - * @param int $query The SQL query. |
|
| 5496 | - * @param string $post_type Post type. |
|
| 5497 | - */ |
|
| 5498 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5499 | - $results = (array)$wpdb->get_results( $query, ARRAY_A ); |
|
| 5500 | - |
|
| 5501 | - /** |
|
| 5502 | - * Modify returned post results for the current post type. |
|
| 5503 | - * |
|
| 5504 | - * @since 1.4.6 |
|
| 5505 | - * @package GeoDirectory |
|
| 5506 | - * |
|
| 5507 | - * @param object $results An object containing all post ids. |
|
| 5508 | - * @param string $post_type Post type. |
|
| 5509 | - */ |
|
| 5510 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5478 | + /** |
|
| 5479 | + * Filter the SQL where clause part to filter posts in import/export. |
|
| 5480 | + * |
|
| 5481 | + * @since 1.6.4 |
|
| 5482 | + * @package GeoDirectory |
|
| 5483 | + * |
|
| 5484 | + * @param string $where SQL where clause part. |
|
| 5485 | + */ |
|
| 5486 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5487 | + |
|
| 5488 | + $query = $wpdb->prepare( "SELECT {$wpdb->posts}.ID FROM {$wpdb->posts} INNER JOIN {$table} ON {$table}.post_id = {$wpdb->posts}.ID WHERE {$wpdb->posts}.post_type = %s " . $where_statuses . " ORDER BY {$wpdb->posts}.ID ASC" . $limit, $post_type );
|
|
| 5489 | + /** |
|
| 5490 | + * Modify returned posts SQL query for the current post type. |
|
| 5491 | + * |
|
| 5492 | + * @since 1.4.6 |
|
| 5493 | + * @package GeoDirectory |
|
| 5494 | + * |
|
| 5495 | + * @param int $query The SQL query. |
|
| 5496 | + * @param string $post_type Post type. |
|
| 5497 | + */ |
|
| 5498 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5499 | + $results = (array)$wpdb->get_results( $query, ARRAY_A ); |
|
| 5500 | + |
|
| 5501 | + /** |
|
| 5502 | + * Modify returned post results for the current post type. |
|
| 5503 | + * |
|
| 5504 | + * @since 1.4.6 |
|
| 5505 | + * @package GeoDirectory |
|
| 5506 | + * |
|
| 5507 | + * @param object $results An object containing all post ids. |
|
| 5508 | + * @param string $post_type Post type. |
|
| 5509 | + */ |
|
| 5510 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5511 | 5511 | } |
| 5512 | 5512 | |
| 5513 | 5513 | /** |
@@ -5526,26 +5526,26 @@ discard block |
||
| 5526 | 5526 | * @return string The SQL query. |
| 5527 | 5527 | */ |
| 5528 | 5528 | function geodir_imex_get_events_query( $query, $post_type ) {
|
| 5529 | - if ( $post_type == 'gd_event' ) {
|
|
| 5530 | - global $wpdb, $plugin_prefix; |
|
| 5529 | + if ( $post_type == 'gd_event' ) {
|
|
| 5530 | + global $wpdb, $plugin_prefix; |
|
| 5531 | 5531 | |
| 5532 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5533 | - $schedule_table = EVENT_SCHEDULE; |
|
| 5532 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5533 | + $schedule_table = EVENT_SCHEDULE; |
|
| 5534 | 5534 | |
| 5535 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5536 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5537 | - $where_statuses = ''; |
|
| 5538 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5539 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5540 | - } |
|
| 5535 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5536 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5537 | + $where_statuses = ''; |
|
| 5538 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5539 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5540 | + } |
|
| 5541 | 5541 | |
| 5542 | - /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
| 5543 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5542 | + /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
| 5543 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5544 | 5544 | |
| 5545 | - $query = $wpdb->prepare( "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 " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
|
|
| 5546 | - } |
|
| 5545 | + $query = $wpdb->prepare( "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 " . $where_statuses . " GROUP BY {$table}.post_id ORDER BY {$wpdb->posts}.ID ASC, {$schedule_table}.schedule_id ASC", $post_type );
|
|
| 5546 | + } |
|
| 5547 | 5547 | |
| 5548 | - return $query; |
|
| 5548 | + return $query; |
|
| 5549 | 5549 | } |
| 5550 | 5550 | |
| 5551 | 5551 | /** |
@@ -5567,36 +5567,36 @@ discard block |
||
| 5567 | 5567 | * @return int Total terms count. |
| 5568 | 5568 | */ |
| 5569 | 5569 | function geodir_get_terms_count( $post_type ) {
|
| 5570 | - $args = array( 'hide_empty' => 0 ); |
|
| 5570 | + $args = array( 'hide_empty' => 0 ); |
|
| 5571 | 5571 | |
| 5572 | - remove_all_filters( 'get_terms' ); |
|
| 5572 | + remove_all_filters( 'get_terms' ); |
|
| 5573 | 5573 | |
| 5574 | - $taxonomy = $post_type . 'category'; |
|
| 5574 | + $taxonomy = $post_type . 'category'; |
|
| 5575 | 5575 | |
| 5576 | - // WPML |
|
| 5577 | - $is_wpml = geodir_is_wpml(); |
|
| 5578 | - $active_lang = 'all'; |
|
| 5579 | - if ( $is_wpml ) {
|
|
| 5580 | - global $sitepress; |
|
| 5581 | - $active_lang = $sitepress->get_current_language(); |
|
| 5576 | + // WPML |
|
| 5577 | + $is_wpml = geodir_is_wpml(); |
|
| 5578 | + $active_lang = 'all'; |
|
| 5579 | + if ( $is_wpml ) {
|
|
| 5580 | + global $sitepress; |
|
| 5581 | + $active_lang = $sitepress->get_current_language(); |
|
| 5582 | 5582 | |
| 5583 | - if ( $active_lang != 'all' ) {
|
|
| 5584 | - $sitepress->switch_lang( 'all', true ); |
|
| 5585 | - } |
|
| 5586 | - } |
|
| 5587 | - // WPML |
|
| 5583 | + if ( $active_lang != 'all' ) {
|
|
| 5584 | + $sitepress->switch_lang( 'all', true ); |
|
| 5585 | + } |
|
| 5586 | + } |
|
| 5587 | + // WPML |
|
| 5588 | 5588 | |
| 5589 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5589 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5590 | 5590 | |
| 5591 | - // WPML |
|
| 5592 | - if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5593 | - global $sitepress; |
|
| 5594 | - $sitepress->switch_lang( $active_lang, true ); |
|
| 5595 | - } |
|
| 5596 | - // WPML |
|
| 5597 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5591 | + // WPML |
|
| 5592 | + if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5593 | + global $sitepress; |
|
| 5594 | + $sitepress->switch_lang( $active_lang, true ); |
|
| 5595 | + } |
|
| 5596 | + // WPML |
|
| 5597 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5598 | 5598 | |
| 5599 | - return $count_terms; |
|
| 5599 | + return $count_terms; |
|
| 5600 | 5600 | } |
| 5601 | 5601 | |
| 5602 | 5602 | /** |
@@ -5635,11 +5635,11 @@ discard block |
||
| 5635 | 5635 | $csv_row[] = 'cat_posttype'; |
| 5636 | 5636 | $csv_row[] = 'cat_parent'; |
| 5637 | 5637 | $csv_row[] = 'cat_schema'; |
| 5638 | - // WPML |
|
| 5638 | + // WPML |
|
| 5639 | 5639 | $is_wpml = geodir_wpml_is_taxonomy_translated( $taxonomy ); |
| 5640 | 5640 | if ($is_wpml) {
|
| 5641 | 5641 | $csv_row[] = 'cat_language'; |
| 5642 | - $csv_row[] = 'cat_id_original'; |
|
| 5642 | + $csv_row[] = 'cat_id_original'; |
|
| 5643 | 5643 | } |
| 5644 | 5644 | // WPML |
| 5645 | 5645 | $csv_row[] = 'cat_description'; |
@@ -5669,10 +5669,10 @@ discard block |
||
| 5669 | 5669 | $csv_row[] = $post_type; |
| 5670 | 5670 | $csv_row[] = $cat_parent; |
| 5671 | 5671 | $csv_row[] = geodir_get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
| 5672 | - // WPML |
|
| 5672 | + // WPML |
|
| 5673 | 5673 | if ($is_wpml) {
|
| 5674 | 5674 | $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
| 5675 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5675 | + $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5676 | 5676 | } |
| 5677 | 5677 | // WPML |
| 5678 | 5678 | $csv_row[] = $term->description; |
@@ -6090,43 +6090,43 @@ discard block |
||
| 6090 | 6090 | * @param string $status Post status. |
| 6091 | 6091 | */ |
| 6092 | 6092 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
|
| 6093 | - global $wpdb, $current_user; |
|
| 6094 | - |
|
| 6095 | - $option_value = get_option($option); |
|
| 6096 | - |
|
| 6097 | - if ($option_value > 0) : |
|
| 6098 | - if (get_post($option_value)) : |
|
| 6099 | - // Page exists |
|
| 6100 | - return; |
|
| 6101 | - endif; |
|
| 6102 | - endif; |
|
| 6103 | - |
|
| 6104 | - $page_found = $wpdb->get_var( |
|
| 6105 | - $wpdb->prepare( |
|
| 6106 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6107 | - array($slug) |
|
| 6108 | - ) |
|
| 6109 | - ); |
|
| 6110 | - |
|
| 6111 | - if ($page_found) : |
|
| 6112 | - // Page exists |
|
| 6113 | - if (!$option_value) update_option($option, $page_found); |
|
| 6114 | - return; |
|
| 6115 | - endif; |
|
| 6116 | - |
|
| 6117 | - $page_data = array( |
|
| 6118 | - 'post_status' => $status, |
|
| 6119 | - 'post_type' => 'page', |
|
| 6120 | - 'post_author' => $current_user->ID, |
|
| 6121 | - 'post_name' => $slug, |
|
| 6122 | - 'post_title' => $page_title, |
|
| 6123 | - 'post_content' => $page_content, |
|
| 6124 | - 'post_parent' => $post_parent, |
|
| 6125 | - 'comment_status' => 'closed' |
|
| 6126 | - ); |
|
| 6127 | - $page_id = wp_insert_post($page_data); |
|
| 6128 | - |
|
| 6129 | - add_option($option, $page_id); |
|
| 6093 | + global $wpdb, $current_user; |
|
| 6094 | + |
|
| 6095 | + $option_value = get_option($option); |
|
| 6096 | + |
|
| 6097 | + if ($option_value > 0) : |
|
| 6098 | + if (get_post($option_value)) : |
|
| 6099 | + // Page exists |
|
| 6100 | + return; |
|
| 6101 | + endif; |
|
| 6102 | + endif; |
|
| 6103 | + |
|
| 6104 | + $page_found = $wpdb->get_var( |
|
| 6105 | + $wpdb->prepare( |
|
| 6106 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6107 | + array($slug) |
|
| 6108 | + ) |
|
| 6109 | + ); |
|
| 6110 | + |
|
| 6111 | + if ($page_found) : |
|
| 6112 | + // Page exists |
|
| 6113 | + if (!$option_value) update_option($option, $page_found); |
|
| 6114 | + return; |
|
| 6115 | + endif; |
|
| 6116 | + |
|
| 6117 | + $page_data = array( |
|
| 6118 | + 'post_status' => $status, |
|
| 6119 | + 'post_type' => 'page', |
|
| 6120 | + 'post_author' => $current_user->ID, |
|
| 6121 | + 'post_name' => $slug, |
|
| 6122 | + 'post_title' => $page_title, |
|
| 6123 | + 'post_content' => $page_content, |
|
| 6124 | + 'post_parent' => $post_parent, |
|
| 6125 | + 'comment_status' => 'closed' |
|
| 6126 | + ); |
|
| 6127 | + $page_id = wp_insert_post($page_data); |
|
| 6128 | + |
|
| 6129 | + add_option($option, $page_id); |
|
| 6130 | 6130 | |
| 6131 | 6131 | } |
| 6132 | 6132 | |
@@ -6157,9 +6157,9 @@ discard block |
||
| 6157 | 6157 | * @package GeoDirectory |
| 6158 | 6158 | */ |
| 6159 | 6159 | function geodir_admin_upgrade_notice() {
|
| 6160 | - $class = "error"; |
|
| 6161 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6162 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6160 | + $class = "error"; |
|
| 6161 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6162 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6163 | 6163 | } |
| 6164 | 6164 | |
| 6165 | 6165 | /** |
@@ -6172,18 +6172,18 @@ discard block |
||
| 6172 | 6172 | */ |
| 6173 | 6173 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
| 6174 | 6174 | {
|
| 6175 | - // readme contents |
|
| 6176 | - $args = array( |
|
| 6177 | - 'timeout' => 15, |
|
| 6178 | - 'redirection' => 5 |
|
| 6179 | - ); |
|
| 6180 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6181 | - $data = wp_remote_get( $url, $args ); |
|
| 6175 | + // readme contents |
|
| 6176 | + $args = array( |
|
| 6177 | + 'timeout' => 15, |
|
| 6178 | + 'redirection' => 5 |
|
| 6179 | + ); |
|
| 6180 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6181 | + $data = wp_remote_get( $url, $args ); |
|
| 6182 | 6182 | |
| 6183 | - if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6183 | + if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6184 | 6184 | |
| 6185 | - geodir_in_plugin_update_message($data['body']); |
|
| 6186 | - } |
|
| 6185 | + geodir_in_plugin_update_message($data['body']); |
|
| 6186 | + } |
|
| 6187 | 6187 | } |
| 6188 | 6188 | |
| 6189 | 6189 | |
@@ -6191,28 +6191,28 @@ discard block |
||
| 6191 | 6191 | * @param string $content http response body |
| 6192 | 6192 | */ |
| 6193 | 6193 | function geodir_in_plugin_update_message($content) {
|
| 6194 | - // Output Upgrade Notice |
|
| 6195 | - $matches = null; |
|
| 6196 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6197 | - $upgrade_notice = ''; |
|
| 6198 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6199 | - if(empty($matches)){return;}
|
|
| 6200 | - |
|
| 6201 | - $version = trim( $matches[1] ); |
|
| 6202 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6203 | - |
|
| 6204 | - |
|
| 6205 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6206 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6207 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6208 | - foreach ( $notices as $index => $line ) {
|
|
| 6209 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6210 | - } |
|
| 6211 | - $upgrade_notice .= '</div> '; |
|
| 6212 | - } |
|
| 6213 | - } |
|
| 6214 | - } |
|
| 6215 | - echo $upgrade_notice; |
|
| 6194 | + // Output Upgrade Notice |
|
| 6195 | + $matches = null; |
|
| 6196 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6197 | + $upgrade_notice = ''; |
|
| 6198 | + if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6199 | + if(empty($matches)){return;}
|
|
| 6200 | + |
|
| 6201 | + $version = trim( $matches[1] ); |
|
| 6202 | + if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6203 | + |
|
| 6204 | + |
|
| 6205 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6206 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6207 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6208 | + foreach ( $notices as $index => $line ) {
|
|
| 6209 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6210 | + } |
|
| 6211 | + $upgrade_notice .= '</div> '; |
|
| 6212 | + } |
|
| 6213 | + } |
|
| 6214 | + } |
|
| 6215 | + echo $upgrade_notice; |
|
| 6216 | 6216 | } |
| 6217 | 6217 | |
| 6218 | 6218 | /** |
@@ -6245,19 +6245,19 @@ discard block |
||
| 6245 | 6245 | * @param array Listing statuses to be skipped. |
| 6246 | 6246 | */ |
| 6247 | 6247 | function geodir_imex_export_skip_statuses() {
|
| 6248 | - $statuses = array( 'trash', 'auto-draft' ); |
|
| 6248 | + $statuses = array( 'trash', 'auto-draft' ); |
|
| 6249 | 6249 | |
| 6250 | - /** |
|
| 6251 | - * Filter the statuses to skip during GD export listings. |
|
| 6252 | - * |
|
| 6253 | - * @since 1.6.0 |
|
| 6254 | - * @package GeoDirectory |
|
| 6255 | - * |
|
| 6256 | - * @param array $statuses Listing statuses to be skipped. |
|
| 6257 | - */ |
|
| 6258 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6250 | + /** |
|
| 6251 | + * Filter the statuses to skip during GD export listings. |
|
| 6252 | + * |
|
| 6253 | + * @since 1.6.0 |
|
| 6254 | + * @package GeoDirectory |
|
| 6255 | + * |
|
| 6256 | + * @param array $statuses Listing statuses to be skipped. |
|
| 6257 | + */ |
|
| 6258 | + $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6259 | 6259 | |
| 6260 | - return $statuses; |
|
| 6260 | + return $statuses; |
|
| 6261 | 6261 | } |
| 6262 | 6262 | |
| 6263 | 6263 | /** |
@@ -6273,42 +6273,42 @@ discard block |
||
| 6273 | 6273 | * @global string $typenow Current post type. |
| 6274 | 6274 | */ |
| 6275 | 6275 | function geodir_admin_dequeue_scripts() {
|
| 6276 | - global $typenow; |
|
| 6276 | + global $typenow; |
|
| 6277 | 6277 | |
| 6278 | - // EDD |
|
| 6279 | - if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6280 | - wp_dequeue_script('jquery-chosen');
|
|
| 6281 | - } |
|
| 6278 | + // EDD |
|
| 6279 | + if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6280 | + wp_dequeue_script('jquery-chosen');
|
|
| 6281 | + } |
|
| 6282 | 6282 | |
| 6283 | - // Ultimate Addons for Visual Composer |
|
| 6284 | - if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6285 | - wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6286 | - } |
|
| 6283 | + // Ultimate Addons for Visual Composer |
|
| 6284 | + if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6285 | + wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6286 | + } |
|
| 6287 | 6287 | |
| 6288 | - // VC editor conflicts |
|
| 6289 | - if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
|
|
| 6290 | - wp_dequeue_script('dfd_vc_damin_scripts');
|
|
| 6291 | - } |
|
| 6288 | + // VC editor conflicts |
|
| 6289 | + if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
|
|
| 6290 | + wp_dequeue_script('dfd_vc_damin_scripts');
|
|
| 6291 | + } |
|
| 6292 | 6292 | |
| 6293 | - // Ultimate chosen |
|
| 6294 | - if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
|
|
| 6295 | - wp_dequeue_script('ultimate-chosen-script');
|
|
| 6296 | - } |
|
| 6293 | + // Ultimate chosen |
|
| 6294 | + if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
|
|
| 6295 | + wp_dequeue_script('ultimate-chosen-script');
|
|
| 6296 | + } |
|
| 6297 | 6297 | |
| 6298 | - // Crum composer choosen |
|
| 6299 | - if (wp_script_is('crum-composer-choosen', 'enqueued')) {
|
|
| 6300 | - wp_dequeue_script('crum-composer-choosen');
|
|
| 6301 | - } |
|
| 6298 | + // Crum composer choosen |
|
| 6299 | + if (wp_script_is('crum-composer-choosen', 'enqueued')) {
|
|
| 6300 | + wp_dequeue_script('crum-composer-choosen');
|
|
| 6301 | + } |
|
| 6302 | 6302 | |
| 6303 | - // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
| 6304 | - if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
|
|
| 6305 | - wp_dequeue_script('fusion_builder_chosen_js');
|
|
| 6306 | - } |
|
| 6303 | + // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
| 6304 | + if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
|
|
| 6305 | + wp_dequeue_script('fusion_builder_chosen_js');
|
|
| 6306 | + } |
|
| 6307 | 6307 | |
| 6308 | - // Fix conflicts timepicker & setting date value. |
|
| 6309 | - if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
|
|
| 6310 | - wp_dequeue_script('acf-timepicker');
|
|
| 6311 | - } |
|
| 6308 | + // Fix conflicts timepicker & setting date value. |
|
| 6309 | + if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) {
|
|
| 6310 | + wp_dequeue_script('acf-timepicker');
|
|
| 6311 | + } |
|
| 6312 | 6312 | } |
| 6313 | 6313 | |
| 6314 | 6314 | /** |
@@ -6324,48 +6324,48 @@ discard block |
||
| 6324 | 6324 | * @return string SQL where clause part. |
| 6325 | 6325 | */ |
| 6326 | 6326 | function geodir_imex_get_filter_where($where = '', $post_type = '') {
|
| 6327 | - global $wpdb; |
|
| 6327 | + global $wpdb; |
|
| 6328 | 6328 | |
| 6329 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 6329 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 6330 | 6330 | |
| 6331 | - if ( !empty( $filters ) ) {
|
|
| 6332 | - foreach ( $filters as $field => $value ) {
|
|
| 6333 | - switch ($field) {
|
|
| 6334 | - case 'start_date': |
|
| 6335 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
| 6336 | - break; |
|
| 6337 | - case 'end_date': |
|
| 6338 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
| 6339 | - break; |
|
| 6340 | - } |
|
| 6341 | - } |
|
| 6342 | - } |
|
| 6331 | + if ( !empty( $filters ) ) {
|
|
| 6332 | + foreach ( $filters as $field => $value ) {
|
|
| 6333 | + switch ($field) {
|
|
| 6334 | + case 'start_date': |
|
| 6335 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
| 6336 | + break; |
|
| 6337 | + case 'end_date': |
|
| 6338 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
| 6339 | + break; |
|
| 6340 | + } |
|
| 6341 | + } |
|
| 6342 | + } |
|
| 6343 | 6343 | |
| 6344 | - return $where; |
|
| 6344 | + return $where; |
|
| 6345 | 6345 | } |
| 6346 | 6346 | add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2);
|
| 6347 | 6347 | add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2);
|
| 6348 | 6348 | |
| 6349 | 6349 | |
| 6350 | 6350 | function geodir_fix_for_primer_theme(){
|
| 6351 | - if(!defined( 'PRIMER_VERSION' )){return;}
|
|
| 6352 | - global $pagenow; |
|
| 6351 | + if(!defined( 'PRIMER_VERSION' )){return;}
|
|
| 6352 | + global $pagenow; |
|
| 6353 | 6353 | |
| 6354 | - if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){
|
|
| 6354 | + if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){
|
|
| 6355 | 6355 | |
| 6356 | - $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
| 6356 | + $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
| 6357 | 6357 | |
| 6358 | - $post_types = geodir_get_posttypes(); |
|
| 6359 | - if ($post_type && in_array($post_type, $post_types) ) {
|
|
| 6360 | - global $primer_customizer_layouts; |
|
| 6361 | - remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
| 6362 | - } |
|
| 6363 | - } |
|
| 6358 | + $post_types = geodir_get_posttypes(); |
|
| 6359 | + if ($post_type && in_array($post_type, $post_types) ) {
|
|
| 6360 | + global $primer_customizer_layouts; |
|
| 6361 | + remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
| 6362 | + } |
|
| 6363 | + } |
|
| 6364 | 6364 | |
| 6365 | 6365 | } |
| 6366 | 6366 | |
| 6367 | 6367 | if(is_admin()){
|
| 6368 | - add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);
|
|
| 6368 | + add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);
|
|
| 6369 | 6369 | } |
| 6370 | 6370 | |
| 6371 | 6371 | |
@@ -6498,96 +6498,96 @@ discard block |
||
| 6498 | 6498 | |
| 6499 | 6499 | function geodir_ga_activation_url() {
|
| 6500 | 6500 | |
| 6501 | - return add_query_arg( array( |
|
| 6502 | - 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
|
|
| 6503 | - 'scope' => GEODIR_GA_SCOPE, |
|
| 6504 | - 'response_type' => 'code', |
|
| 6505 | - 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
| 6506 | - 'client_id' => GEODIR_GA_CLIENTID, |
|
| 6507 | - ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
| 6501 | + return add_query_arg( array( |
|
| 6502 | + 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
|
|
| 6503 | + 'scope' => GEODIR_GA_SCOPE, |
|
| 6504 | + 'response_type' => 'code', |
|
| 6505 | + 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
| 6506 | + 'client_id' => GEODIR_GA_CLIENTID, |
|
| 6507 | + ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
| 6508 | 6508 | |
| 6509 | - return $url; |
|
| 6509 | + return $url; |
|
| 6510 | 6510 | } |
| 6511 | 6511 | |
| 6512 | 6512 | function geodir_gd_accounts(){
|
| 6513 | - $accounts = array(); |
|
| 6514 | - $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
| 6515 | - if($useAuth){
|
|
| 6516 | - try {
|
|
| 6517 | - $accounts = geodir_ga_get_analytics_accounts(); |
|
| 6518 | - } catch (Exception $e) {
|
|
| 6519 | - geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
| 6520 | - } |
|
| 6513 | + $accounts = array(); |
|
| 6514 | + $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
| 6515 | + if($useAuth){
|
|
| 6516 | + try {
|
|
| 6517 | + $accounts = geodir_ga_get_analytics_accounts(); |
|
| 6518 | + } catch (Exception $e) {
|
|
| 6519 | + geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
| 6520 | + } |
|
| 6521 | 6521 | |
| 6522 | - if(is_array($accounts)){
|
|
| 6523 | - $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
|
|
| 6524 | - }elseif(get_option('geodir_ga_account_id')){
|
|
| 6525 | - $accounts = array(); |
|
| 6526 | - $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
|
|
| 6527 | - } |
|
| 6528 | - } |
|
| 6529 | - return $accounts; |
|
| 6522 | + if(is_array($accounts)){
|
|
| 6523 | + $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
|
|
| 6524 | + }elseif(get_option('geodir_ga_account_id')){
|
|
| 6525 | + $accounts = array(); |
|
| 6526 | + $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
|
|
| 6527 | + } |
|
| 6528 | + } |
|
| 6529 | + return $accounts; |
|
| 6530 | 6530 | } |
| 6531 | 6531 | |
| 6532 | 6532 | function geodir_ga_get_analytics_accounts() |
| 6533 | 6533 | {
|
| 6534 | - global $gd_ga_errors; |
|
| 6535 | - $accounts = array(); |
|
| 6534 | + global $gd_ga_errors; |
|
| 6535 | + $accounts = array(); |
|
| 6536 | 6536 | |
| 6537 | - if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
|
|
| 6537 | + if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
|
|
| 6538 | 6538 | |
| 6539 | 6539 | |
| 6540 | - if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
|
|
| 6541 | - return get_option('geodir_gd_uids');
|
|
| 6542 | - } |
|
| 6540 | + if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
|
|
| 6541 | + return get_option('geodir_gd_uids');
|
|
| 6542 | + } |
|
| 6543 | 6543 | |
| 6544 | - # Create a new Gdata call |
|
| 6545 | - if ( trim(get_option('geodir_ga_auth_code')) != '' )
|
|
| 6546 | - $stats = new GDGoogleAnalyticsStats(); |
|
| 6547 | - else |
|
| 6548 | - return false; |
|
| 6544 | + # Create a new Gdata call |
|
| 6545 | + if ( trim(get_option('geodir_ga_auth_code')) != '' )
|
|
| 6546 | + $stats = new GDGoogleAnalyticsStats(); |
|
| 6547 | + else |
|
| 6548 | + return false; |
|
| 6549 | 6549 | |
| 6550 | - # Check if Google sucessfully logged in |
|
| 6551 | - if ( ! $stats->checkLogin() ) |
|
| 6552 | - return false; |
|
| 6550 | + # Check if Google sucessfully logged in |
|
| 6551 | + if ( ! $stats->checkLogin() ) |
|
| 6552 | + return false; |
|
| 6553 | 6553 | |
| 6554 | - # Get a list of accounts |
|
| 6555 | - try {
|
|
| 6556 | - $accounts = $stats->getAllProfiles(); |
|
| 6557 | - } catch (Exception $e) {
|
|
| 6558 | - $gd_ga_errors[] = $e->getMessage(); |
|
| 6559 | - return false; |
|
| 6560 | - } |
|
| 6554 | + # Get a list of accounts |
|
| 6555 | + try {
|
|
| 6556 | + $accounts = $stats->getAllProfiles(); |
|
| 6557 | + } catch (Exception $e) {
|
|
| 6558 | + $gd_ga_errors[] = $e->getMessage(); |
|
| 6559 | + return false; |
|
| 6560 | + } |
|
| 6561 | 6561 | |
| 6562 | 6562 | |
| 6563 | - natcasesort ($accounts); |
|
| 6563 | + natcasesort ($accounts); |
|
| 6564 | 6564 | |
| 6565 | - # Return the account array if there are accounts |
|
| 6566 | - if ( count($accounts) > 0 ){
|
|
| 6567 | - update_option('geodir_gd_uids',$accounts);
|
|
| 6568 | - return $accounts; |
|
| 6569 | - } |
|
| 6570 | - else |
|
| 6571 | - return false; |
|
| 6565 | + # Return the account array if there are accounts |
|
| 6566 | + if ( count($accounts) > 0 ){
|
|
| 6567 | + update_option('geodir_gd_uids',$accounts);
|
|
| 6568 | + return $accounts; |
|
| 6569 | + } |
|
| 6570 | + else |
|
| 6571 | + return false; |
|
| 6572 | 6572 | } |
| 6573 | 6573 | |
| 6574 | 6574 | add_action( 'wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize' ); |
| 6575 | 6575 | function geodir_ga_deauthorize(){
|
| 6576 | 6576 | |
| 6577 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
|
|
| 6577 | + if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
|
|
| 6578 | 6578 | |
| 6579 | - die( 'Security check' ); |
|
| 6579 | + die( 'Security check' ); |
|
| 6580 | 6580 | |
| 6581 | - } else {
|
|
| 6582 | - update_option('geodir_ga_auth_token','');
|
|
| 6583 | - update_option('geodir_ga_auth_code','');
|
|
| 6584 | - update_option('geodir_gd_uids','');
|
|
| 6581 | + } else {
|
|
| 6582 | + update_option('geodir_ga_auth_token','');
|
|
| 6583 | + update_option('geodir_ga_auth_code','');
|
|
| 6584 | + update_option('geodir_gd_uids','');
|
|
| 6585 | 6585 | |
| 6586 | 6586 | |
| 6587 | - echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
|
|
| 6588 | - } |
|
| 6587 | + echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
|
|
| 6588 | + } |
|
| 6589 | 6589 | |
| 6590 | - die(); |
|
| 6590 | + die(); |
|
| 6591 | 6591 | } |
| 6592 | 6592 | |
| 6593 | 6593 | |
@@ -6598,14 +6598,14 @@ discard block |
||
| 6598 | 6598 | * @package GeoDirectory |
| 6599 | 6599 | */ |
| 6600 | 6600 | function geodir_post_type_setting_fun() {
|
| 6601 | - $post_type_arr = array(); |
|
| 6601 | + $post_type_arr = array(); |
|
| 6602 | 6602 | |
| 6603 | - $post_types = geodir_get_posttypes('object');
|
|
| 6603 | + $post_types = geodir_get_posttypes('object');
|
|
| 6604 | 6604 | |
| 6605 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 6606 | - $post_type_arr[$key] = $post_types_obj->labels->singular_name; |
|
| 6607 | - } |
|
| 6608 | - return $post_type_arr; |
|
| 6605 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 6606 | + $post_type_arr[$key] = $post_types_obj->labels->singular_name; |
|
| 6607 | + } |
|
| 6608 | + return $post_type_arr; |
|
| 6609 | 6609 | } |
| 6610 | 6610 | |
| 6611 | 6611 | /** |
@@ -6616,35 +6616,35 @@ discard block |
||
| 6616 | 6616 | */ |
| 6617 | 6617 | function geodir_listing_image_size_arr(){
|
| 6618 | 6618 | |
| 6619 | - global $_wp_additional_image_sizes; |
|
| 6620 | - |
|
| 6621 | - $sizes = array(); |
|
| 6622 | - |
|
| 6623 | - foreach ( get_intermediate_image_sizes() as $_size ) {
|
|
| 6624 | - if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) {
|
|
| 6625 | - $sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" );
|
|
| 6626 | - $sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" );
|
|
| 6627 | - $sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" );
|
|
| 6628 | - } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
|
|
| 6629 | - $sizes[ $_size ] = array( |
|
| 6630 | - 'width' => $_wp_additional_image_sizes[ $_size ]['width'], |
|
| 6631 | - 'height' => $_wp_additional_image_sizes[ $_size ]['height'], |
|
| 6632 | - 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], |
|
| 6633 | - ); |
|
| 6634 | - } |
|
| 6635 | - } |
|
| 6619 | + global $_wp_additional_image_sizes; |
|
| 6620 | + |
|
| 6621 | + $sizes = array(); |
|
| 6622 | + |
|
| 6623 | + foreach ( get_intermediate_image_sizes() as $_size ) {
|
|
| 6624 | + if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) {
|
|
| 6625 | + $sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" );
|
|
| 6626 | + $sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" );
|
|
| 6627 | + $sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" );
|
|
| 6628 | + } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
|
|
| 6629 | + $sizes[ $_size ] = array( |
|
| 6630 | + 'width' => $_wp_additional_image_sizes[ $_size ]['width'], |
|
| 6631 | + 'height' => $_wp_additional_image_sizes[ $_size ]['height'], |
|
| 6632 | + 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], |
|
| 6633 | + ); |
|
| 6634 | + } |
|
| 6635 | + } |
|
| 6636 | 6636 | |
| 6637 | 6637 | |
| 6638 | 6638 | |
| 6639 | - $options = array(); |
|
| 6639 | + $options = array(); |
|
| 6640 | 6640 | |
| 6641 | - $options['default'] = __('GD Default', 'geodirectory');
|
|
| 6641 | + $options['default'] = __('GD Default', 'geodirectory');
|
|
| 6642 | 6642 | |
| 6643 | - if(!empty($sizes)){
|
|
| 6644 | - foreach($sizes as $key=>$val){
|
|
| 6645 | - $options[$key] = $key. ' ( '.$val['width'].' x '.$val['height']. ' )'; |
|
| 6646 | - } |
|
| 6647 | - } |
|
| 6643 | + if(!empty($sizes)){
|
|
| 6644 | + foreach($sizes as $key=>$val){
|
|
| 6645 | + $options[$key] = $key. ' ( '.$val['width'].' x '.$val['height']. ' )'; |
|
| 6646 | + } |
|
| 6647 | + } |
|
| 6648 | 6648 | |
| 6649 | - return $options; |
|
| 6649 | + return $options; |
|
| 6650 | 6650 | } |
| 6651 | 6651 | \ No newline at end of file |
@@ -36,175 +36,175 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function geodir_templates_scripts() |
| 38 | 38 | {
|
| 39 | - $is_detail_page = false; |
|
| 40 | - $geodir_map_name = geodir_map_name(); |
|
| 39 | + $is_detail_page = false; |
|
| 40 | + $geodir_map_name = geodir_map_name(); |
|
| 41 | 41 | |
| 42 | - if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
|
|
| 43 | - $is_detail_page = true; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - wp_enqueue_script('jquery');
|
|
| 47 | - |
|
| 48 | - wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 49 | - wp_enqueue_script('geodirectory-script');
|
|
| 50 | - |
|
| 51 | - $geodir_vars_data = array( |
|
| 52 | - 'siteurl' => get_option('siteurl'),
|
|
| 53 | - 'geodir_plugin_url' => geodir_plugin_url(), |
|
| 54 | - 'geodir_lazy_load' => get_option('geodir_lazy_load',1),
|
|
| 55 | - 'geodir_ajax_url' => geodir_get_ajax_url(), |
|
| 56 | - 'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
|
|
| 57 | - 'is_rtl' => is_rtl() ? 1 : 0 // fix rtl issue |
|
| 58 | - ); |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Filter the `geodir_var` data array that outputs the wp_localize_script() translations and variables. |
|
| 62 | - * |
|
| 63 | - * This is used by addons to add JS translatable variables. |
|
| 64 | - * |
|
| 65 | - * @since 1.4.4 |
|
| 66 | - * @param array $geodir_vars_data {
|
|
| 67 | - * geodir var data used by addons to add JS translatable variables. |
|
| 68 | - * |
|
| 69 | - * @type string $siteurl Site url. |
|
| 70 | - * @type string $geodir_plugin_url Geodirectory core plugin url. |
|
| 71 | - * @type string $geodir_ajax_url Geodirectory plugin ajax url. |
|
| 72 | - * @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?. |
|
| 73 | - * @type int $is_rtl Checks if current locale is RTL. |
|
| 74 | - * |
|
| 75 | - * } |
|
| 76 | - */ |
|
| 77 | - $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
|
|
| 78 | - |
|
| 79 | - wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
|
|
| 80 | - |
|
| 81 | - wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 82 | - if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
|
|
| 83 | - |
|
| 84 | - wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 85 | - wp_enqueue_script('geodirectory-lightbox-jquery');
|
|
| 42 | + if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) {
|
|
| 43 | + $is_detail_page = true; |
|
| 44 | + } |
|
| 86 | 45 | |
| 87 | - wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 88 | - if ($is_detail_page) {
|
|
| 89 | - wp_enqueue_script('geodirectory-jquery-simplemodal');
|
|
| 90 | - } |
|
| 46 | + wp_enqueue_script('jquery');
|
|
| 47 | + |
|
| 48 | + wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 49 | + wp_enqueue_script('geodirectory-script');
|
|
| 50 | + |
|
| 51 | + $geodir_vars_data = array( |
|
| 52 | + 'siteurl' => get_option('siteurl'),
|
|
| 53 | + 'geodir_plugin_url' => geodir_plugin_url(), |
|
| 54 | + 'geodir_lazy_load' => get_option('geodir_lazy_load',1),
|
|
| 55 | + 'geodir_ajax_url' => geodir_get_ajax_url(), |
|
| 56 | + 'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'),
|
|
| 57 | + 'is_rtl' => is_rtl() ? 1 : 0 // fix rtl issue |
|
| 58 | + ); |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Filter the `geodir_var` data array that outputs the wp_localize_script() translations and variables. |
|
| 62 | + * |
|
| 63 | + * This is used by addons to add JS translatable variables. |
|
| 64 | + * |
|
| 65 | + * @since 1.4.4 |
|
| 66 | + * @param array $geodir_vars_data {
|
|
| 67 | + * geodir var data used by addons to add JS translatable variables. |
|
| 68 | + * |
|
| 69 | + * @type string $siteurl Site url. |
|
| 70 | + * @type string $geodir_plugin_url Geodirectory core plugin url. |
|
| 71 | + * @type string $geodir_ajax_url Geodirectory plugin ajax url. |
|
| 72 | + * @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?. |
|
| 73 | + * @type int $is_rtl Checks if current locale is RTL. |
|
| 74 | + * |
|
| 75 | + * } |
|
| 76 | + */ |
|
| 77 | + $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data);
|
|
| 78 | + |
|
| 79 | + wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data);
|
|
| 80 | + |
|
| 81 | + wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 82 | + if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');}
|
|
| 83 | + |
|
| 84 | + wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 85 | + wp_enqueue_script('geodirectory-lightbox-jquery');
|
|
| 86 | + |
|
| 87 | + wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 88 | + if ($is_detail_page) {
|
|
| 89 | + wp_enqueue_script('geodirectory-jquery-simplemodal');
|
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 93 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 94 | - $map_key = "&key=" . geodir_get_map_api_key(); |
|
| 95 | - /** |
|
| 96 | - * Filter the variables that are added to the end of the google maps script call. |
|
| 97 | - * |
|
| 98 | - * This i used to change things like google maps language etc. |
|
| 99 | - * |
|
| 100 | - * @since 1.0.0 |
|
| 101 | - * @param string $var The string to filter, default is empty string. |
|
| 102 | - */ |
|
| 103 | - $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 104 | - wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
|
|
| 92 | + if (in_array($geodir_map_name, array('auto', 'google'))) {
|
|
| 93 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
| 94 | + $map_key = "&key=" . geodir_get_map_api_key(); |
|
| 95 | + /** |
|
| 96 | + * Filter the variables that are added to the end of the google maps script call. |
|
| 97 | + * |
|
| 98 | + * This i used to change things like google maps language etc. |
|
| 99 | + * |
|
| 100 | + * @since 1.0.0 |
|
| 101 | + * @param string $var The string to filter, default is empty string. |
|
| 102 | + */ |
|
| 103 | + $map_extra = apply_filters('geodir_googlemap_script_extra', '');
|
|
| 104 | + wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL);
|
|
| 105 | 105 | |
| 106 | - // Overlapping Marker Spiderfier |
|
| 107 | - wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 108 | - wp_enqueue_script('geodirectory-g-overlappingmarker-script');
|
|
| 109 | - } |
|
| 106 | + // Overlapping Marker Spiderfier |
|
| 107 | + wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 108 | + wp_enqueue_script('geodirectory-g-overlappingmarker-script');
|
|
| 109 | + } |
|
| 110 | 110 | |
| 111 | - if ($geodir_map_name == 'osm') {
|
|
| 112 | - // Leaflet OpenStreetMap |
|
| 113 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 114 | - wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 111 | + if ($geodir_map_name == 'osm') {
|
|
| 112 | + // Leaflet OpenStreetMap |
|
| 113 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 114 | + wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 115 | 115 | |
| 116 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | - wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 116 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 117 | + wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 118 | 118 | |
| 119 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 120 | - wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 119 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 120 | + wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 121 | 121 | |
| 122 | - if ($is_detail_page) {
|
|
| 123 | - wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
|
|
| 124 | - wp_enqueue_style('geodirectory-leaflet-routing-style');
|
|
| 122 | + if ($is_detail_page) {
|
|
| 123 | + wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION);
|
|
| 124 | + wp_enqueue_style('geodirectory-leaflet-routing-style');
|
|
| 125 | 125 | |
| 126 | - wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 127 | - wp_enqueue_script('geodirectory-leaflet-routing-script');
|
|
| 128 | - } |
|
| 126 | + wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 127 | + wp_enqueue_script('geodirectory-leaflet-routing-script');
|
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - // Overlapping Marker Spiderfier Leaflet |
|
| 131 | - wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 132 | - wp_enqueue_script('geodirectory-o-overlappingmarker-script');
|
|
| 133 | - } |
|
| 134 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 130 | + // Overlapping Marker Spiderfier Leaflet |
|
| 131 | + wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 132 | + wp_enqueue_script('geodirectory-o-overlappingmarker-script');
|
|
| 133 | + } |
|
| 134 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 135 | 135 | |
| 136 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 137 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 138 | - |
|
| 139 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 140 | - wp_enqueue_script('chosen');
|
|
| 141 | - |
|
| 142 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 143 | - wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 144 | - |
|
| 145 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
|
|
| 146 | - |
|
| 147 | - if (is_page() && geodir_is_page('add-listing')) {
|
|
| 148 | - // SCRIPT FOR UPLOAD |
|
| 149 | - wp_enqueue_script('plupload-all');
|
|
| 150 | - wp_enqueue_script('jquery-ui-sortable');
|
|
| 151 | - |
|
| 152 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
|
|
| 153 | - wp_enqueue_script('geodirectory-plupload-script');
|
|
| 154 | - // SCRIPT FOR UPLOAD END |
|
| 155 | - |
|
| 156 | - // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls |
|
| 157 | - if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 158 | - $ajax_url = admin_url('admin-ajax.php');
|
|
| 159 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 160 | - $ajax_url = admin_url('admin-ajax.php');
|
|
| 161 | - } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 162 | - $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
|
|
| 163 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 164 | - $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
|
|
| 165 | - } else {
|
|
| 166 | - $ajax_url = admin_url('admin-ajax.php');
|
|
| 167 | - } |
|
| 136 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true);
|
|
| 137 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 138 | + |
|
| 139 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 140 | + wp_enqueue_script('chosen');
|
|
| 141 | + |
|
| 142 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 143 | + wp_enqueue_script('geodirectory-choose-ajax');
|
|
| 144 | + |
|
| 145 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true);
|
|
| 146 | + |
|
| 147 | + if (is_page() && geodir_is_page('add-listing')) {
|
|
| 148 | + // SCRIPT FOR UPLOAD |
|
| 149 | + wp_enqueue_script('plupload-all');
|
|
| 150 | + wp_enqueue_script('jquery-ui-sortable');
|
|
| 151 | + |
|
| 152 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true);
|
|
| 153 | + wp_enqueue_script('geodirectory-plupload-script');
|
|
| 154 | + // SCRIPT FOR UPLOAD END |
|
| 155 | + |
|
| 156 | + // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls |
|
| 157 | + if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 158 | + $ajax_url = admin_url('admin-ajax.php');
|
|
| 159 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 160 | + $ajax_url = admin_url('admin-ajax.php');
|
|
| 161 | + } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) {
|
|
| 162 | + $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php'));
|
|
| 163 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) {
|
|
| 164 | + $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php'));
|
|
| 165 | + } else {
|
|
| 166 | + $ajax_url = admin_url('admin-ajax.php');
|
|
| 167 | + } |
|
| 168 | 168 | |
| 169 | - // place js config array for plupload |
|
| 170 | - $plupload_init = array( |
|
| 171 | - 'runtimes' => 'html5,silverlight,browserplus,gears,html4', |
|
| 172 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 173 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 174 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 175 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 176 | - 'multiple_queues' => true, |
|
| 177 | - 'max_file_size' => geodir_max_upload_size(), |
|
| 178 | - 'url' => $ajax_url, |
|
| 179 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 180 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 181 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 182 | - 'multipart' => true, |
|
| 183 | - 'urlstream_upload' => true, |
|
| 184 | - 'multi_selection' => false, // will be added per uploader |
|
| 185 | - // additional post data to send to our ajax hook |
|
| 186 | - 'multipart_params' => array( |
|
| 187 | - '_ajax_nonce' => "", // will be added per uploader |
|
| 188 | - 'action' => 'plupload_action', // the ajax action name |
|
| 189 | - 'imgid' => 0 // will be added per uploader |
|
| 190 | - ) |
|
| 191 | - ); |
|
| 192 | - $base_plupload_config = json_encode($plupload_init); |
|
| 193 | - |
|
| 194 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 195 | - 'upload_img_size' => geodir_max_upload_size()); |
|
| 196 | - |
|
| 197 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 198 | - |
|
| 199 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
|
|
| 200 | - } // End if for add place page |
|
| 201 | - |
|
| 202 | - wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
|
| 203 | - if ($is_detail_page) {
|
|
| 169 | + // place js config array for plupload |
|
| 170 | + $plupload_init = array( |
|
| 171 | + 'runtimes' => 'html5,silverlight,browserplus,gears,html4', |
|
| 172 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 173 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 174 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 175 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 176 | + 'multiple_queues' => true, |
|
| 177 | + 'max_file_size' => geodir_max_upload_size(), |
|
| 178 | + 'url' => $ajax_url, |
|
| 179 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 180 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 181 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 182 | + 'multipart' => true, |
|
| 183 | + 'urlstream_upload' => true, |
|
| 184 | + 'multi_selection' => false, // will be added per uploader |
|
| 185 | + // additional post data to send to our ajax hook |
|
| 186 | + 'multipart_params' => array( |
|
| 187 | + '_ajax_nonce' => "", // will be added per uploader |
|
| 188 | + 'action' => 'plupload_action', // the ajax action name |
|
| 189 | + 'imgid' => 0 // will be added per uploader |
|
| 190 | + ) |
|
| 191 | + ); |
|
| 192 | + $base_plupload_config = json_encode($plupload_init); |
|
| 193 | + |
|
| 194 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 195 | + 'upload_img_size' => geodir_max_upload_size()); |
|
| 196 | + |
|
| 197 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 198 | + |
|
| 199 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload');
|
|
| 200 | + } // End if for add place page |
|
| 201 | + |
|
| 202 | + wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
|
| 203 | + if ($is_detail_page) {
|
|
| 204 | 204 | wp_enqueue_script('geodirectory-post-custom-js');
|
| 205 | 205 | } |
| 206 | 206 | |
| 207 | - // font awesome rating script |
|
| 207 | + // font awesome rating script |
|
| 208 | 208 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
| 209 | 209 | wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true);
|
| 210 | 210 | wp_enqueue_script('geodir-barrating-js');
|
@@ -213,11 +213,11 @@ discard block |
||
| 213 | 213 | wp_enqueue_script('geodir-jRating-js');
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
|
| 217 | - wp_enqueue_script('geodir-on-document-load');
|
|
| 216 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
|
| 217 | + wp_enqueue_script('geodir-on-document-load');
|
|
| 218 | 218 | |
| 219 | - wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
|
| 220 | - wp_enqueue_script('google-geometa');
|
|
| 219 | + wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true);
|
|
| 220 | + wp_enqueue_script('google-geometa');
|
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | */ |
| 232 | 232 | function geodir_header_scripts() |
| 233 | 233 | {
|
| 234 | - echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
|
|
| 235 | - echo stripslashes(get_option('geodir_header_scripts'));
|
|
| 234 | + echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>';
|
|
| 235 | + echo stripslashes(get_option('geodir_header_scripts'));
|
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -245,7 +245,7 @@ discard block |
||
| 245 | 245 | */ |
| 246 | 246 | function geodir_google_analytics_tracking_code() |
| 247 | 247 | {
|
| 248 | - if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
|
|
| 248 | + if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?>
|
|
| 249 | 249 | |
| 250 | 250 | <script> |
| 251 | 251 | (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
@@ -260,9 +260,9 @@ discard block |
||
| 260 | 260 | </script> |
| 261 | 261 | |
| 262 | 262 | <?php |
| 263 | - }elseif(get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
|
|
| 264 | - echo stripslashes(get_option('geodir_ga_tracking_code'));
|
|
| 265 | - } |
|
| 263 | + }elseif(get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){
|
|
| 264 | + echo stripslashes(get_option('geodir_ga_tracking_code'));
|
|
| 265 | + } |
|
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | /** |
@@ -276,16 +276,16 @@ discard block |
||
| 276 | 276 | function geodir_footer_scripts() |
| 277 | 277 | {
|
| 278 | 278 | |
| 279 | - echo stripslashes(get_option('geodir_footer_scripts'));
|
|
| 279 | + echo stripslashes(get_option('geodir_footer_scripts'));
|
|
| 280 | 280 | |
| 281 | - /* |
|
| 281 | + /* |
|
| 282 | 282 | * Apple suck and can't/won't fix bugs: https://bugs.webkit.org/show_bug.cgi?id=136041 |
| 283 | 283 | * |
| 284 | 284 | * Flexbox wont wrap on ios for search form items |
| 285 | 285 | */ |
| 286 | - if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
|
|
| 287 | - echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
|
|
| 288 | - } |
|
| 286 | + if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) {
|
|
| 287 | + echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>";
|
|
| 288 | + } |
|
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
@@ -299,12 +299,12 @@ discard block |
||
| 299 | 299 | */ |
| 300 | 300 | function geodir_add_async_forscript($url) |
| 301 | 301 | {
|
| 302 | - if (strpos($url, '#asyncload')===false) |
|
| 303 | - return $url; |
|
| 304 | - else if (is_admin()) |
|
| 305 | - return str_replace('#asyncload', '', $url);
|
|
| 306 | - else |
|
| 307 | - return str_replace('#asyncload', '', $url)."' async='async";
|
|
| 302 | + if (strpos($url, '#asyncload')===false) |
|
| 303 | + return $url; |
|
| 304 | + else if (is_admin()) |
|
| 305 | + return str_replace('#asyncload', '', $url);
|
|
| 306 | + else |
|
| 307 | + return str_replace('#asyncload', '', $url)."' async='async";
|
|
| 308 | 308 | } |
| 309 | 309 | add_filter('clean_url', 'geodir_add_async_forscript', 11, 1);
|
| 310 | 310 | |
@@ -317,17 +317,17 @@ discard block |
||
| 317 | 317 | function geodir_templates_styles() |
| 318 | 318 | {
|
| 319 | 319 | |
| 320 | - wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
|
|
| 321 | - wp_enqueue_style('geodir-core-scss');
|
|
| 322 | - wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
|
|
| 320 | + wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION);
|
|
| 321 | + wp_enqueue_style('geodir-core-scss');
|
|
| 322 | + wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION);
|
|
| 323 | 323 | |
| 324 | - if(is_rtl()){
|
|
| 325 | - wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
|
|
| 326 | - wp_enqueue_style('geodirectory-frontend-rtl-style');
|
|
| 327 | - } |
|
| 324 | + if(is_rtl()){
|
|
| 325 | + wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION);
|
|
| 326 | + wp_enqueue_style('geodirectory-frontend-rtl-style');
|
|
| 327 | + } |
|
| 328 | 328 | |
| 329 | - wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 330 | - wp_enqueue_style('font-awesome');
|
|
| 329 | + wp_register_style('font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION);
|
|
| 330 | + wp_enqueue_style('font-awesome');
|
|
| 331 | 331 | |
| 332 | 332 | |
| 333 | 333 | } |
@@ -341,7 +341,7 @@ discard block |
||
| 341 | 341 | */ |
| 342 | 342 | function geodir_get_sidebar() |
| 343 | 343 | {
|
| 344 | - get_sidebar('geodirectory');
|
|
| 344 | + get_sidebar('geodirectory');
|
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | /** |
@@ -360,122 +360,122 @@ discard block |
||
| 360 | 360 | * @param bool $always_show Do you want to show the pagination always? Default: false. |
| 361 | 361 | */ |
| 362 | 362 | function geodir_pagination($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) {
|
| 363 | - global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id; |
|
| 363 | + global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id; |
|
| 364 | 364 | |
| 365 | - if (empty($prelabel)) {
|
|
| 366 | - $prelabel = '<strong><</strong>'; |
|
| 367 | - } |
|
| 365 | + if (empty($prelabel)) {
|
|
| 366 | + $prelabel = '<strong><</strong>'; |
|
| 367 | + } |
|
| 368 | 368 | |
| 369 | - if (empty($nxtlabel)) {
|
|
| 370 | - $nxtlabel = '<strong>></strong>'; |
|
| 371 | - } |
|
| 369 | + if (empty($nxtlabel)) {
|
|
| 370 | + $nxtlabel = '<strong>></strong>'; |
|
| 371 | + } |
|
| 372 | 372 | |
| 373 | - $half_pages_to_show = round($pages_to_show / 2); |
|
| 373 | + $half_pages_to_show = round($pages_to_show / 2); |
|
| 374 | 374 | |
| 375 | - if (geodir_is_page('home')) // dont apply default pagination for geodirectory home page.
|
|
| 376 | - return; |
|
| 375 | + if (geodir_is_page('home')) // dont apply default pagination for geodirectory home page.
|
|
| 376 | + return; |
|
| 377 | 377 | |
| 378 | - if (!is_single()) {
|
|
| 379 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 380 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 381 | - } |
|
| 382 | - $numposts = $wp_query->found_posts; |
|
| 378 | + if (!is_single()) {
|
|
| 379 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 380 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000);
|
|
| 381 | + } |
|
| 382 | + $numposts = $wp_query->found_posts; |
|
| 383 | 383 | |
| 384 | - $max_page = ceil($numposts / $posts_per_page); |
|
| 384 | + $max_page = ceil($numposts / $posts_per_page); |
|
| 385 | 385 | |
| 386 | - if (empty($paged)) {
|
|
| 387 | - $paged = 1; |
|
| 388 | - } |
|
| 386 | + if (empty($paged)) {
|
|
| 387 | + $paged = 1; |
|
| 388 | + } |
|
| 389 | 389 | |
| 390 | - $post_type = geodir_get_current_posttype(); |
|
| 391 | - $listing_type_name = get_post_type_plural_label($post_type); |
|
| 392 | - if (geodir_is_page('listing') || geodir_is_page('search')) {
|
|
| 393 | - $term = array(); |
|
| 390 | + $post_type = geodir_get_current_posttype(); |
|
| 391 | + $listing_type_name = get_post_type_plural_label($post_type); |
|
| 392 | + if (geodir_is_page('listing') || geodir_is_page('search')) {
|
|
| 393 | + $term = array(); |
|
| 394 | 394 | |
| 395 | - if (is_tax()) {
|
|
| 396 | - $term_id = get_queried_object_id(); |
|
| 397 | - $taxonomy = get_query_var('taxonomy');
|
|
| 395 | + if (is_tax()) {
|
|
| 396 | + $term_id = get_queried_object_id(); |
|
| 397 | + $taxonomy = get_query_var('taxonomy');
|
|
| 398 | 398 | |
| 399 | - if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
|
|
| 400 | - $term = get_term($term_id, $post_type . 'category'); |
|
| 401 | - } |
|
| 402 | - } |
|
| 399 | + if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) {
|
|
| 400 | + $term = get_term($term_id, $post_type . 'category'); |
|
| 401 | + } |
|
| 402 | + } |
|
| 403 | 403 | |
| 404 | - if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
|
|
| 405 | - $taxonomy_search = $_REQUEST['s' . $post_type . 'category']; |
|
| 404 | + if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) {
|
|
| 405 | + $taxonomy_search = $_REQUEST['s' . $post_type . 'category']; |
|
| 406 | 406 | |
| 407 | - if (!is_array($taxonomy_search)) {
|
|
| 408 | - $term = get_term((int)$taxonomy_search, $post_type . 'category'); |
|
| 409 | - } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
|
|
| 410 | - $term = get_term((int)$taxonomy_search[0], $post_type . 'category'); |
|
| 411 | - } |
|
| 412 | - } |
|
| 407 | + if (!is_array($taxonomy_search)) {
|
|
| 408 | + $term = get_term((int)$taxonomy_search, $post_type . 'category'); |
|
| 409 | + } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search
|
|
| 410 | + $term = get_term((int)$taxonomy_search[0], $post_type . 'category'); |
|
| 411 | + } |
|
| 412 | + } |
|
| 413 | 413 | |
| 414 | - if (!empty($term) && !is_wp_error($term)) {
|
|
| 415 | - $listing_type_name = $term->name; |
|
| 416 | - } |
|
| 417 | - } |
|
| 414 | + if (!empty($term) && !is_wp_error($term)) {
|
|
| 415 | + $listing_type_name = $term->name; |
|
| 416 | + } |
|
| 417 | + } |
|
| 418 | 418 | |
| 419 | - if ($max_page > 1 || $always_show) {
|
|
| 420 | - // Extra pagination info |
|
| 421 | - $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
|
|
| 422 | - $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
| 423 | - $end_no = min($paged * $posts_per_page, $numposts); |
|
| 419 | + if ($max_page > 1 || $always_show) {
|
|
| 420 | + // Extra pagination info |
|
| 421 | + $geodir_pagination_more_info = get_option('geodir_pagination_advance_info');
|
|
| 422 | + $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
| 423 | + $end_no = min($paged * $posts_per_page, $numposts); |
|
| 424 | 424 | |
| 425 | - if ($geodir_pagination_more_info != '') {
|
|
| 426 | - if ($listing_type_name) {
|
|
| 427 | - $listing_type_name = __($listing_type_name, 'geodirectory'); |
|
| 428 | - $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts);
|
|
| 429 | - } else {
|
|
| 430 | - $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
|
|
| 431 | - } |
|
| 432 | - $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>'; |
|
| 433 | - /** |
|
| 434 | - * Adds an extra pagination info above/under pagination. |
|
| 435 | - * |
|
| 436 | - * @since 1.5.9 |
|
| 437 | - * |
|
| 438 | - * @param string $pagination_info Extra pagination info content. |
|
| 439 | - * @param string $listing_type_name Listing results type. |
|
| 440 | - * @param string $start_no First result number. |
|
| 441 | - * @param string $end_no Last result number. |
|
| 442 | - * @param string $numposts Total number of listings. |
|
| 443 | - * @param string $post_type The post type. |
|
| 444 | - */ |
|
| 445 | - $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
|
|
| 425 | + if ($geodir_pagination_more_info != '') {
|
|
| 426 | + if ($listing_type_name) {
|
|
| 427 | + $listing_type_name = __($listing_type_name, 'geodirectory'); |
|
| 428 | + $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts);
|
|
| 429 | + } else {
|
|
| 430 | + $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts);
|
|
| 431 | + } |
|
| 432 | + $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>'; |
|
| 433 | + /** |
|
| 434 | + * Adds an extra pagination info above/under pagination. |
|
| 435 | + * |
|
| 436 | + * @since 1.5.9 |
|
| 437 | + * |
|
| 438 | + * @param string $pagination_info Extra pagination info content. |
|
| 439 | + * @param string $listing_type_name Listing results type. |
|
| 440 | + * @param string $start_no First result number. |
|
| 441 | + * @param string $end_no Last result number. |
|
| 442 | + * @param string $numposts Total number of listings. |
|
| 443 | + * @param string $post_type The post type. |
|
| 444 | + */ |
|
| 445 | + $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type);
|
|
| 446 | 446 | |
| 447 | - if ($geodir_pagination_more_info == 'before') {
|
|
| 448 | - $before = $before . $pagination_info; |
|
| 449 | - } else if ($geodir_pagination_more_info == 'after') {
|
|
| 450 | - $after = $pagination_info . $after; |
|
| 451 | - } |
|
| 452 | - } |
|
| 447 | + if ($geodir_pagination_more_info == 'before') {
|
|
| 448 | + $before = $before . $pagination_info; |
|
| 449 | + } else if ($geodir_pagination_more_info == 'after') {
|
|
| 450 | + $after = $pagination_info . $after; |
|
| 451 | + } |
|
| 452 | + } |
|
| 453 | 453 | |
| 454 | - echo "$before <div class='Navi gd-navi'>"; |
|
| 455 | - if ($paged >= ($pages_to_show - 1)) {
|
|
| 456 | - echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>';
|
|
| 457 | - } |
|
| 458 | - previous_posts_link($prelabel); |
|
| 459 | - for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
|
|
| 460 | - if ($i >= 1 && $i <= $max_page) {
|
|
| 461 | - if ($i == $paged) {
|
|
| 462 | - echo "<strong class='on'>$i</strong>"; |
|
| 463 | - } else {
|
|
| 464 | - echo ' <a href="' . str_replace('&paged', '&paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
|
|
| 465 | - } |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - next_posts_link($nxtlabel, $max_page); |
|
| 469 | - if (($paged + $half_pages_to_show) < ($max_page)) {
|
|
| 470 | - echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link($max_page)) . '">»</a>';
|
|
| 471 | - } |
|
| 472 | - echo "</div> $after"; |
|
| 473 | - } |
|
| 454 | + echo "$before <div class='Navi gd-navi'>"; |
|
| 455 | + if ($paged >= ($pages_to_show - 1)) {
|
|
| 456 | + echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>';
|
|
| 457 | + } |
|
| 458 | + previous_posts_link($prelabel); |
|
| 459 | + for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) {
|
|
| 460 | + if ($i >= 1 && $i <= $max_page) {
|
|
| 461 | + if ($i == $paged) {
|
|
| 462 | + echo "<strong class='on'>$i</strong>"; |
|
| 463 | + } else {
|
|
| 464 | + echo ' <a href="' . str_replace('&paged', '&paged', get_pagenum_link($i)) . '">' . $i . '</a> ';
|
|
| 465 | + } |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + next_posts_link($nxtlabel, $max_page); |
|
| 469 | + if (($paged + $half_pages_to_show) < ($max_page)) {
|
|
| 470 | + echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link($max_page)) . '">»</a>';
|
|
| 471 | + } |
|
| 472 | + echo "</div> $after"; |
|
| 473 | + } |
|
| 474 | 474 | |
| 475 | - if (function_exists('geodir_location_geo_home_link')) {
|
|
| 476 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 477 | - } |
|
| 478 | - } |
|
| 475 | + if (function_exists('geodir_location_geo_home_link')) {
|
|
| 476 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2);
|
|
| 477 | + } |
|
| 478 | + } |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | /** |
@@ -486,20 +486,20 @@ discard block |
||
| 486 | 486 | */ |
| 487 | 487 | function geodir_listingsearch_scripts() |
| 488 | 488 | {
|
| 489 | - if (get_option('gd_search_dist') != '') {
|
|
| 490 | - $dist = get_option('gd_search_dist');
|
|
| 491 | - } else {
|
|
| 492 | - $dist = 500; |
|
| 493 | - } |
|
| 494 | - $dist_dif = 1000; |
|
| 495 | - |
|
| 496 | - if ($dist <= 5000) $dist_dif = 500; |
|
| 497 | - if ($dist <= 1000) $dist_dif = 100; |
|
| 498 | - if ($dist <= 500) $dist_dif = 50; |
|
| 499 | - if ($dist <= 100) $dist_dif = 10; |
|
| 500 | - if ($dist <= 50) $dist_dif = 5; |
|
| 501 | - |
|
| 502 | - ?> |
|
| 489 | + if (get_option('gd_search_dist') != '') {
|
|
| 490 | + $dist = get_option('gd_search_dist');
|
|
| 491 | + } else {
|
|
| 492 | + $dist = 500; |
|
| 493 | + } |
|
| 494 | + $dist_dif = 1000; |
|
| 495 | + |
|
| 496 | + if ($dist <= 5000) $dist_dif = 500; |
|
| 497 | + if ($dist <= 1000) $dist_dif = 100; |
|
| 498 | + if ($dist <= 500) $dist_dif = 50; |
|
| 499 | + if ($dist <= 100) $dist_dif = 10; |
|
| 500 | + if ($dist <= 50) $dist_dif = 5; |
|
| 501 | + |
|
| 502 | + ?> |
|
| 503 | 503 | <script type="text/javascript"> |
| 504 | 504 | |
| 505 | 505 | jQuery(function ($) {
|
@@ -557,20 +557,20 @@ discard block |
||
| 557 | 557 | * @package GeoDirectory |
| 558 | 558 | */ |
| 559 | 559 | function geodir_add_sharelocation_scripts() {
|
| 560 | - $default_search_for_text = SEARCH_FOR_TEXT; |
|
| 561 | - if (get_option('geodir_search_field_default_text'))
|
|
| 562 | - $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
|
|
| 560 | + $default_search_for_text = SEARCH_FOR_TEXT; |
|
| 561 | + if (get_option('geodir_search_field_default_text'))
|
|
| 562 | + $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory');
|
|
| 563 | 563 | |
| 564 | - $default_near_text = NEAR_TEXT; |
|
| 565 | - if (get_option('geodir_near_field_default_text'))
|
|
| 566 | - $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
|
|
| 564 | + $default_near_text = NEAR_TEXT; |
|
| 565 | + if (get_option('geodir_near_field_default_text'))
|
|
| 566 | + $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory');
|
|
| 567 | 567 | |
| 568 | - $search_location = geodir_get_default_location(); |
|
| 568 | + $search_location = geodir_get_default_location(); |
|
| 569 | 569 | |
| 570 | - $default_search_for_text = addslashes(stripslashes($default_search_for_text)); |
|
| 571 | - $default_near_text = addslashes(stripslashes($default_near_text)); |
|
| 572 | - $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : ''; |
|
| 573 | - ?> |
|
| 570 | + $default_search_for_text = addslashes(stripslashes($default_search_for_text)); |
|
| 571 | + $default_near_text = addslashes(stripslashes($default_near_text)); |
|
| 572 | + $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : ''; |
|
| 573 | + ?> |
|
| 574 | 574 | <script type="text/javascript"> |
| 575 | 575 | var default_location = '<?php echo $city ;?>'; |
| 576 | 576 | var latlng; |
@@ -651,14 +651,14 @@ discard block |
||
| 651 | 651 | initialise2(); |
| 652 | 652 | } else {
|
| 653 | 653 | <?php |
| 654 | - $near_add = get_option('geodir_search_near_addition');
|
|
| 655 | - /** |
|
| 656 | - * Adds any extra info to the near search box query when trying to geolocate it via google api. |
|
| 657 | - * |
|
| 658 | - * @since 1.0.0 |
|
| 659 | - */ |
|
| 660 | - $near_add2 = apply_filters('geodir_search_near_addition', '');
|
|
| 661 | - ?> |
|
| 654 | + $near_add = get_option('geodir_search_near_addition');
|
|
| 655 | + /** |
|
| 656 | + * Adds any extra info to the near search box query when trying to geolocate it via google api. |
|
| 657 | + * |
|
| 658 | + * @since 1.0.0 |
|
| 659 | + */ |
|
| 660 | + $near_add2 = apply_filters('geodir_search_near_addition', '');
|
|
| 661 | + ?> |
|
| 662 | 662 | if (window.gdMaps === 'google') {
|
| 663 | 663 | Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>},
|
| 664 | 664 | function (results, status) {
|
@@ -772,32 +772,32 @@ discard block |
||
| 772 | 772 | */ |
| 773 | 773 | function geodir_show_badges_on_image($which, $post, $link) |
| 774 | 774 | {
|
| 775 | - $return = ''; |
|
| 776 | - switch ($which) {
|
|
| 777 | - case 'featured': |
|
| 778 | - /** |
|
| 779 | - * Filter the featured image badge html that appears in the listings pages over the thumbnail. |
|
| 780 | - * |
|
| 781 | - * @since 1.0.0 |
|
| 782 | - * @param object $post The post object. |
|
| 783 | - * @param string $link The link to the post. |
|
| 784 | - */ |
|
| 785 | - $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>',$post,$link);
|
|
| 786 | - break; |
|
| 787 | - case 'new' : |
|
| 788 | - /** |
|
| 789 | - * Filter the new image badge html that appears in the listings pages over the thumbnail. |
|
| 790 | - * |
|
| 791 | - * @since 1.0.0 |
|
| 792 | - * @param object $post The post object. |
|
| 793 | - * @param string $link The link to the post. |
|
| 794 | - */ |
|
| 795 | - $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>',$post,$link);
|
|
| 796 | - break; |
|
| 797 | - |
|
| 798 | - } |
|
| 775 | + $return = ''; |
|
| 776 | + switch ($which) {
|
|
| 777 | + case 'featured': |
|
| 778 | + /** |
|
| 779 | + * Filter the featured image badge html that appears in the listings pages over the thumbnail. |
|
| 780 | + * |
|
| 781 | + * @since 1.0.0 |
|
| 782 | + * @param object $post The post object. |
|
| 783 | + * @param string $link The link to the post. |
|
| 784 | + */ |
|
| 785 | + $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>',$post,$link);
|
|
| 786 | + break; |
|
| 787 | + case 'new' : |
|
| 788 | + /** |
|
| 789 | + * Filter the new image badge html that appears in the listings pages over the thumbnail. |
|
| 790 | + * |
|
| 791 | + * @since 1.0.0 |
|
| 792 | + * @param object $post The post object. |
|
| 793 | + * @param string $link The link to the post. |
|
| 794 | + */ |
|
| 795 | + $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>',$post,$link);
|
|
| 796 | + break; |
|
| 797 | + |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | - return $return; |
|
| 800 | + return $return; |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | /** |
@@ -806,8 +806,8 @@ discard block |
||
| 806 | 806 | * @since 1.6.22 |
| 807 | 807 | */ |
| 808 | 808 | function geodir_fix_script_conflict() {
|
| 809 | - if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
|
|
| 810 | - wp_dequeue_script( 'flexslider' ); |
|
| 811 | - } |
|
| 809 | + if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) {
|
|
| 810 | + wp_dequeue_script( 'flexslider' ); |
|
| 811 | + } |
|
| 812 | 812 | } |
| 813 | 813 | add_action( 'wp_enqueue_scripts', 'geodir_fix_script_conflict', 100 ); |
| 814 | 814 | \ No newline at end of file |