@@ -19,35 +19,35 @@ discard block |
||
| 19 | 19 | */ |
| 20 | 20 | function geodir_cfi_fieldset($html,$cf){ |
| 21 | 21 | |
| 22 | - $html_var = $cf['htmlvar_name']; |
|
| 23 | - |
|
| 24 | - // Check if there is a custom field specific filter. |
|
| 25 | - if(has_filter("geodir_custom_field_input_fieldset_{$html_var}")){ |
|
| 26 | - /** |
|
| 27 | - * Filter the fieldset html by individual custom field. |
|
| 28 | - * |
|
| 29 | - * @param string $html The html to filter. |
|
| 30 | - * @param array $cf The custom field array. |
|
| 31 | - * @since 1.6.6 |
|
| 32 | - */ |
|
| 33 | - $html = apply_filters("geodir_custom_field_input_fieldset_{$html_var}",$html,$cf); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - // If no html then we run the standard output. |
|
| 37 | - if(empty($html)) { |
|
| 38 | - |
|
| 39 | - ob_start(); // Start buffering; |
|
| 40 | - ?> |
|
| 22 | + $html_var = $cf['htmlvar_name']; |
|
| 23 | + |
|
| 24 | + // Check if there is a custom field specific filter. |
|
| 25 | + if(has_filter("geodir_custom_field_input_fieldset_{$html_var}")){ |
|
| 26 | + /** |
|
| 27 | + * Filter the fieldset html by individual custom field. |
|
| 28 | + * |
|
| 29 | + * @param string $html The html to filter. |
|
| 30 | + * @param array $cf The custom field array. |
|
| 31 | + * @since 1.6.6 |
|
| 32 | + */ |
|
| 33 | + $html = apply_filters("geodir_custom_field_input_fieldset_{$html_var}",$html,$cf); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + // If no html then we run the standard output. |
|
| 37 | + if(empty($html)) { |
|
| 38 | + |
|
| 39 | + ob_start(); // Start buffering; |
|
| 40 | + ?> |
|
| 41 | 41 | <h5 id="geodir_fieldset_<?php echo (int) $cf['id']; ?>" class="geodir-fieldset-row" |
| 42 | 42 | gd-fieldset="<?php echo (int) $cf['id']; ?>"><?php echo __( $cf['site_title'], 'geodirectory' ); ?> |
| 43 | 43 | <?php if ( $cf['desc'] != '' ) { |
| 44 | - echo '<small>( ' . __( $cf['desc'], 'geodirectory' ) . ' )</small>'; |
|
| 45 | - } ?></h5> |
|
| 44 | + echo '<small>( ' . __( $cf['desc'], 'geodirectory' ) . ' )</small>'; |
|
| 45 | + } ?></h5> |
|
| 46 | 46 | <?php |
| 47 | - $html = ob_get_clean(); |
|
| 48 | - } |
|
| 47 | + $html = ob_get_clean(); |
|
| 48 | + } |
|
| 49 | 49 | |
| 50 | - return $html; |
|
| 50 | + return $html; |
|
| 51 | 51 | } |
| 52 | 52 | add_filter('geodir_custom_field_input_fieldset','geodir_cfi_fieldset',10,2); |
| 53 | 53 | |
@@ -64,47 +64,47 @@ discard block |
||
| 64 | 64 | */ |
| 65 | 65 | function geodir_cfi_text($html,$cf){ |
| 66 | 66 | |
| 67 | - $html_var = $cf['htmlvar_name']; |
|
| 68 | - |
|
| 69 | - // Check if there is a custom field specific filter. |
|
| 70 | - if(has_filter("geodir_custom_field_input_text_{$html_var}")){ |
|
| 71 | - /** |
|
| 72 | - * Filter the text html by individual custom field. |
|
| 73 | - * |
|
| 74 | - * @param string $html The html to filter. |
|
| 75 | - * @param array $cf The custom field array. |
|
| 76 | - * @since 1.6.6 |
|
| 77 | - */ |
|
| 78 | - $html = apply_filters("geodir_custom_field_input_text_{$html_var}",$html,$cf); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - // If no html then we run the standard output. |
|
| 82 | - if(empty($html)) { |
|
| 83 | - |
|
| 84 | - ob_start(); // Start buffering; |
|
| 85 | - |
|
| 86 | - $value = geodir_get_cf_value($cf); |
|
| 87 | - $type = $cf['type']; |
|
| 88 | - //number and float validation $validation_pattern |
|
| 89 | - if(isset($cf['data_type']) && $cf['data_type']=='INT'){$type = 'number';} |
|
| 90 | - elseif(isset($cf['data_type']) && $cf['data_type']=='FLOAT'){$type = 'float';} |
|
| 91 | - |
|
| 92 | - //validation |
|
| 93 | - if(isset($cf['validation_pattern']) && $cf['validation_pattern']){ |
|
| 94 | - $validation = 'pattern="'.$cf['validation_pattern'].'"'; |
|
| 95 | - }else{$validation='';} |
|
| 96 | - |
|
| 97 | - // validation message |
|
| 98 | - if(isset($cf['validation_msg']) && $cf['validation_msg']){ |
|
| 99 | - $validation_msg = 'title="'.$cf['validation_msg'].'"'; |
|
| 100 | - }else{$validation_msg='';} |
|
| 101 | - ?> |
|
| 67 | + $html_var = $cf['htmlvar_name']; |
|
| 68 | + |
|
| 69 | + // Check if there is a custom field specific filter. |
|
| 70 | + if(has_filter("geodir_custom_field_input_text_{$html_var}")){ |
|
| 71 | + /** |
|
| 72 | + * Filter the text html by individual custom field. |
|
| 73 | + * |
|
| 74 | + * @param string $html The html to filter. |
|
| 75 | + * @param array $cf The custom field array. |
|
| 76 | + * @since 1.6.6 |
|
| 77 | + */ |
|
| 78 | + $html = apply_filters("geodir_custom_field_input_text_{$html_var}",$html,$cf); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + // If no html then we run the standard output. |
|
| 82 | + if(empty($html)) { |
|
| 83 | + |
|
| 84 | + ob_start(); // Start buffering; |
|
| 85 | + |
|
| 86 | + $value = geodir_get_cf_value($cf); |
|
| 87 | + $type = $cf['type']; |
|
| 88 | + //number and float validation $validation_pattern |
|
| 89 | + if(isset($cf['data_type']) && $cf['data_type']=='INT'){$type = 'number';} |
|
| 90 | + elseif(isset($cf['data_type']) && $cf['data_type']=='FLOAT'){$type = 'float';} |
|
| 91 | + |
|
| 92 | + //validation |
|
| 93 | + if(isset($cf['validation_pattern']) && $cf['validation_pattern']){ |
|
| 94 | + $validation = 'pattern="'.$cf['validation_pattern'].'"'; |
|
| 95 | + }else{$validation='';} |
|
| 96 | + |
|
| 97 | + // validation message |
|
| 98 | + if(isset($cf['validation_msg']) && $cf['validation_msg']){ |
|
| 99 | + $validation_msg = 'title="'.$cf['validation_msg'].'"'; |
|
| 100 | + }else{$validation_msg='';} |
|
| 101 | + ?> |
|
| 102 | 102 | |
| 103 | 103 | <div id="<?php echo $cf['name'];?>_row" |
| 104 | 104 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 105 | 105 | <label> |
| 106 | 106 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 107 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 107 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 108 | 108 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 109 | 109 | </label> |
| 110 | 110 | <input field_type="<?php echo $type;?>" name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" |
@@ -116,10 +116,10 @@ discard block |
||
| 116 | 116 | </div> |
| 117 | 117 | |
| 118 | 118 | <?php |
| 119 | - $html = ob_get_clean(); |
|
| 120 | - } |
|
| 119 | + $html = ob_get_clean(); |
|
| 120 | + } |
|
| 121 | 121 | |
| 122 | - return $html; |
|
| 122 | + return $html; |
|
| 123 | 123 | } |
| 124 | 124 | add_filter('geodir_custom_field_input_text','geodir_cfi_text',10,2); |
| 125 | 125 | |
@@ -135,35 +135,35 @@ discard block |
||
| 135 | 135 | */ |
| 136 | 136 | function geodir_cfi_email($html,$cf){ |
| 137 | 137 | |
| 138 | - $html_var = $cf['htmlvar_name']; |
|
| 138 | + $html_var = $cf['htmlvar_name']; |
|
| 139 | 139 | |
| 140 | - // Check if there is a custom field specific filter. |
|
| 141 | - if(has_filter("geodir_custom_field_input_email_{$html_var}")){ |
|
| 142 | - /** |
|
| 143 | - * Filter the email html by individual custom field. |
|
| 144 | - * |
|
| 145 | - * @param string $html The html to filter. |
|
| 146 | - * @param array $cf The custom field array. |
|
| 147 | - * @since 1.6.6 |
|
| 148 | - */ |
|
| 149 | - $html = apply_filters("geodir_custom_field_input_email_{$html_var}",$html,$cf); |
|
| 150 | - } |
|
| 140 | + // Check if there is a custom field specific filter. |
|
| 141 | + if(has_filter("geodir_custom_field_input_email_{$html_var}")){ |
|
| 142 | + /** |
|
| 143 | + * Filter the email html by individual custom field. |
|
| 144 | + * |
|
| 145 | + * @param string $html The html to filter. |
|
| 146 | + * @param array $cf The custom field array. |
|
| 147 | + * @since 1.6.6 |
|
| 148 | + */ |
|
| 149 | + $html = apply_filters("geodir_custom_field_input_email_{$html_var}",$html,$cf); |
|
| 150 | + } |
|
| 151 | 151 | |
| 152 | - // If no html then we run the standard output. |
|
| 153 | - if(empty($html)) { |
|
| 152 | + // If no html then we run the standard output. |
|
| 153 | + if(empty($html)) { |
|
| 154 | 154 | |
| 155 | - ob_start(); // Start buffering; |
|
| 156 | - $value = geodir_get_cf_value($cf); |
|
| 155 | + ob_start(); // Start buffering; |
|
| 156 | + $value = geodir_get_cf_value($cf); |
|
| 157 | 157 | |
| 158 | - if ($value == $cf['default']) { |
|
| 159 | - $value = ''; |
|
| 160 | - }?> |
|
| 158 | + if ($value == $cf['default']) { |
|
| 159 | + $value = ''; |
|
| 160 | + }?> |
|
| 161 | 161 | |
| 162 | 162 | <div id="<?php echo $cf['name'];?>_row" |
| 163 | 163 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 164 | 164 | <label> |
| 165 | 165 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 166 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 166 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 167 | 167 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 168 | 168 | </label> |
| 169 | 169 | <input field_type="<?php echo $cf['type'];?>" name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" |
@@ -175,10 +175,10 @@ discard block |
||
| 175 | 175 | </div> |
| 176 | 176 | |
| 177 | 177 | <?php |
| 178 | - $html = ob_get_clean(); |
|
| 179 | - } |
|
| 178 | + $html = ob_get_clean(); |
|
| 179 | + } |
|
| 180 | 180 | |
| 181 | - return $html; |
|
| 181 | + return $html; |
|
| 182 | 182 | } |
| 183 | 183 | add_filter('geodir_custom_field_input_email','geodir_cfi_email',10,2); |
| 184 | 184 | |
@@ -195,35 +195,35 @@ discard block |
||
| 195 | 195 | */ |
| 196 | 196 | function geodir_cfi_phone($html,$cf){ |
| 197 | 197 | |
| 198 | - $html_var = $cf['htmlvar_name']; |
|
| 198 | + $html_var = $cf['htmlvar_name']; |
|
| 199 | 199 | |
| 200 | - // Check if there is a custom field specific filter. |
|
| 201 | - if(has_filter("geodir_custom_field_input_phone_{$html_var}")){ |
|
| 202 | - /** |
|
| 203 | - * Filter the phone html by individual custom field. |
|
| 204 | - * |
|
| 205 | - * @param string $html The html to filter. |
|
| 206 | - * @param array $cf The custom field array. |
|
| 207 | - * @since 1.6.6 |
|
| 208 | - */ |
|
| 209 | - $html = apply_filters("geodir_custom_field_input_phone_{$html_var}",$html,$cf); |
|
| 210 | - } |
|
| 200 | + // Check if there is a custom field specific filter. |
|
| 201 | + if(has_filter("geodir_custom_field_input_phone_{$html_var}")){ |
|
| 202 | + /** |
|
| 203 | + * Filter the phone html by individual custom field. |
|
| 204 | + * |
|
| 205 | + * @param string $html The html to filter. |
|
| 206 | + * @param array $cf The custom field array. |
|
| 207 | + * @since 1.6.6 |
|
| 208 | + */ |
|
| 209 | + $html = apply_filters("geodir_custom_field_input_phone_{$html_var}",$html,$cf); |
|
| 210 | + } |
|
| 211 | 211 | |
| 212 | - // If no html then we run the standard output. |
|
| 213 | - if(empty($html)) { |
|
| 212 | + // If no html then we run the standard output. |
|
| 213 | + if(empty($html)) { |
|
| 214 | 214 | |
| 215 | - ob_start(); // Start buffering; |
|
| 216 | - $value = geodir_get_cf_value($cf); |
|
| 215 | + ob_start(); // Start buffering; |
|
| 216 | + $value = geodir_get_cf_value($cf); |
|
| 217 | 217 | |
| 218 | - if ($value == $cf['default']) { |
|
| 219 | - $value = ''; |
|
| 220 | - }?> |
|
| 218 | + if ($value == $cf['default']) { |
|
| 219 | + $value = ''; |
|
| 220 | + }?> |
|
| 221 | 221 | |
| 222 | 222 | <div id="<?php echo $cf['name'];?>_row" |
| 223 | 223 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 224 | 224 | <label> |
| 225 | 225 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 226 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 226 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 227 | 227 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 228 | 228 | </label> |
| 229 | 229 | <input field_type="<?php echo $cf['type'];?>" name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" |
@@ -235,10 +235,10 @@ discard block |
||
| 235 | 235 | </div> |
| 236 | 236 | |
| 237 | 237 | <?php |
| 238 | - $html = ob_get_clean(); |
|
| 239 | - } |
|
| 238 | + $html = ob_get_clean(); |
|
| 239 | + } |
|
| 240 | 240 | |
| 241 | - return $html; |
|
| 241 | + return $html; |
|
| 242 | 242 | } |
| 243 | 243 | add_filter('geodir_custom_field_input_phone','geodir_cfi_phone',10,2); |
| 244 | 244 | |
@@ -255,35 +255,35 @@ discard block |
||
| 255 | 255 | */ |
| 256 | 256 | function geodir_cfi_url($html,$cf){ |
| 257 | 257 | |
| 258 | - $html_var = $cf['htmlvar_name']; |
|
| 258 | + $html_var = $cf['htmlvar_name']; |
|
| 259 | 259 | |
| 260 | - // Check if there is a custom field specific filter. |
|
| 261 | - if(has_filter("geodir_custom_field_input_url_{$html_var}")){ |
|
| 262 | - /** |
|
| 263 | - * Filter the url html by individual custom field. |
|
| 264 | - * |
|
| 265 | - * @param string $html The html to filter. |
|
| 266 | - * @param array $cf The custom field array. |
|
| 267 | - * @since 1.6.6 |
|
| 268 | - */ |
|
| 269 | - $html = apply_filters("geodir_custom_field_input_url_{$html_var}",$html,$cf); |
|
| 270 | - } |
|
| 260 | + // Check if there is a custom field specific filter. |
|
| 261 | + if(has_filter("geodir_custom_field_input_url_{$html_var}")){ |
|
| 262 | + /** |
|
| 263 | + * Filter the url html by individual custom field. |
|
| 264 | + * |
|
| 265 | + * @param string $html The html to filter. |
|
| 266 | + * @param array $cf The custom field array. |
|
| 267 | + * @since 1.6.6 |
|
| 268 | + */ |
|
| 269 | + $html = apply_filters("geodir_custom_field_input_url_{$html_var}",$html,$cf); |
|
| 270 | + } |
|
| 271 | 271 | |
| 272 | - // If no html then we run the standard output. |
|
| 273 | - if(empty($html)) { |
|
| 272 | + // If no html then we run the standard output. |
|
| 273 | + if(empty($html)) { |
|
| 274 | 274 | |
| 275 | - ob_start(); // Start buffering; |
|
| 276 | - $value = geodir_get_cf_value($cf); |
|
| 275 | + ob_start(); // Start buffering; |
|
| 276 | + $value = geodir_get_cf_value($cf); |
|
| 277 | 277 | |
| 278 | - if ($value == $cf['default']) { |
|
| 279 | - $value = ''; |
|
| 280 | - }?> |
|
| 278 | + if ($value == $cf['default']) { |
|
| 279 | + $value = ''; |
|
| 280 | + }?> |
|
| 281 | 281 | |
| 282 | 282 | <div id="<?php echo $cf['name'];?>_row" |
| 283 | 283 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 284 | 284 | <label> |
| 285 | 285 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 286 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 286 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 287 | 287 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 288 | 288 | </label> |
| 289 | 289 | <input field_type="<?php echo $cf['type'];?>" name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" |
@@ -298,10 +298,10 @@ discard block |
||
| 298 | 298 | </div> |
| 299 | 299 | |
| 300 | 300 | <?php |
| 301 | - $html = ob_get_clean(); |
|
| 302 | - } |
|
| 301 | + $html = ob_get_clean(); |
|
| 302 | + } |
|
| 303 | 303 | |
| 304 | - return $html; |
|
| 304 | + return $html; |
|
| 305 | 305 | } |
| 306 | 306 | add_filter('geodir_custom_field_input_url','geodir_cfi_url',10,2); |
| 307 | 307 | |
@@ -317,48 +317,48 @@ discard block |
||
| 317 | 317 | */ |
| 318 | 318 | function geodir_cfi_radio($html,$cf){ |
| 319 | 319 | |
| 320 | - $html_var = $cf['htmlvar_name']; |
|
| 320 | + $html_var = $cf['htmlvar_name']; |
|
| 321 | 321 | |
| 322 | - // Check if there is a custom field specific filter. |
|
| 323 | - if(has_filter("geodir_custom_field_input_radio_{$html_var}")){ |
|
| 324 | - /** |
|
| 325 | - * Filter the radio html by individual custom field. |
|
| 326 | - * |
|
| 327 | - * @param string $html The html to filter. |
|
| 328 | - * @param array $cf The custom field array. |
|
| 329 | - * @since 1.6.6 |
|
| 330 | - */ |
|
| 331 | - $html = apply_filters("geodir_custom_field_input_radio_{$html_var}",$html,$cf); |
|
| 332 | - } |
|
| 322 | + // Check if there is a custom field specific filter. |
|
| 323 | + if(has_filter("geodir_custom_field_input_radio_{$html_var}")){ |
|
| 324 | + /** |
|
| 325 | + * Filter the radio html by individual custom field. |
|
| 326 | + * |
|
| 327 | + * @param string $html The html to filter. |
|
| 328 | + * @param array $cf The custom field array. |
|
| 329 | + * @since 1.6.6 |
|
| 330 | + */ |
|
| 331 | + $html = apply_filters("geodir_custom_field_input_radio_{$html_var}",$html,$cf); |
|
| 332 | + } |
|
| 333 | 333 | |
| 334 | - // If no html then we run the standard output. |
|
| 335 | - if(empty($html)) { |
|
| 334 | + // If no html then we run the standard output. |
|
| 335 | + if(empty($html)) { |
|
| 336 | 336 | |
| 337 | - ob_start(); // Start buffering; |
|
| 338 | - $value = geodir_get_cf_value($cf); |
|
| 337 | + ob_start(); // Start buffering; |
|
| 338 | + $value = geodir_get_cf_value($cf); |
|
| 339 | 339 | |
| 340 | - ?> |
|
| 340 | + ?> |
|
| 341 | 341 | <div id="<?php echo $cf['name'];?>_row" |
| 342 | 342 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 343 | 343 | <label> |
| 344 | 344 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 345 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 345 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 346 | 346 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 347 | 347 | </label> |
| 348 | 348 | <?php if ($cf['option_values']) { |
| 349 | - $option_values = geodir_string_values_to_options($cf['option_values'], true); |
|
| 349 | + $option_values = geodir_string_values_to_options($cf['option_values'], true); |
|
| 350 | 350 | |
| 351 | - if (!empty($option_values)) { |
|
| 352 | - foreach ($option_values as $option_value) { |
|
| 353 | - if (empty($option_value['optgroup'])) { |
|
| 354 | - ?> |
|
| 351 | + if (!empty($option_values)) { |
|
| 352 | + foreach ($option_values as $option_value) { |
|
| 353 | + if (empty($option_value['optgroup'])) { |
|
| 354 | + ?> |
|
| 355 | 355 | <span class="gd-radios"><input name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" <?php checked($value, $option_value['value']);?> value="<?php echo esc_attr($option_value['value']); ?>" class="gd-checkbox" field_type="<?php echo $cf['type'];?>" type="radio" /><?php echo $option_value['label']; ?></span> |
| 356 | 356 | <?php |
| 357 | - } |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - } |
|
| 361 | - ?> |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + } |
|
| 361 | + ?> |
|
| 362 | 362 | <span class="geodir_message_note"><?php _e($cf['desc'], 'geodirectory');?></span> |
| 363 | 363 | <?php if ($cf['is_required']) { ?> |
| 364 | 364 | <span class="geodir_message_error"><?php _e($cf['required_msg'], 'geodirectory'); ?></span> |
@@ -366,10 +366,10 @@ discard block |
||
| 366 | 366 | </div> |
| 367 | 367 | |
| 368 | 368 | <?php |
| 369 | - $html = ob_get_clean(); |
|
| 370 | - } |
|
| 369 | + $html = ob_get_clean(); |
|
| 370 | + } |
|
| 371 | 371 | |
| 372 | - return $html; |
|
| 372 | + return $html; |
|
| 373 | 373 | } |
| 374 | 374 | add_filter('geodir_custom_field_input_radio','geodir_cfi_radio',10,2); |
| 375 | 375 | |
@@ -385,46 +385,46 @@ discard block |
||
| 385 | 385 | */ |
| 386 | 386 | function geodir_cfi_checkbox($html,$cf){ |
| 387 | 387 | |
| 388 | - $html_var = $cf['htmlvar_name']; |
|
| 388 | + $html_var = $cf['htmlvar_name']; |
|
| 389 | 389 | |
| 390 | - // Check if there is a custom field specific filter. |
|
| 391 | - if(has_filter("geodir_custom_field_input_checkbox_{$html_var}")){ |
|
| 392 | - /** |
|
| 393 | - * Filter the checkbox html by individual custom field. |
|
| 394 | - * |
|
| 395 | - * @param string $html The html to filter. |
|
| 396 | - * @param array $cf The custom field array. |
|
| 397 | - * @since 1.6.6 |
|
| 398 | - */ |
|
| 399 | - $html = apply_filters("geodir_custom_field_input_checkbox_{$html_var}",$html,$cf); |
|
| 400 | - } |
|
| 390 | + // Check if there is a custom field specific filter. |
|
| 391 | + if(has_filter("geodir_custom_field_input_checkbox_{$html_var}")){ |
|
| 392 | + /** |
|
| 393 | + * Filter the checkbox html by individual custom field. |
|
| 394 | + * |
|
| 395 | + * @param string $html The html to filter. |
|
| 396 | + * @param array $cf The custom field array. |
|
| 397 | + * @since 1.6.6 |
|
| 398 | + */ |
|
| 399 | + $html = apply_filters("geodir_custom_field_input_checkbox_{$html_var}",$html,$cf); |
|
| 400 | + } |
|
| 401 | 401 | |
| 402 | - // If no html then we run the standard output. |
|
| 403 | - if(empty($html)) { |
|
| 402 | + // If no html then we run the standard output. |
|
| 403 | + if(empty($html)) { |
|
| 404 | 404 | |
| 405 | - ob_start(); // Start buffering; |
|
| 406 | - $value = geodir_get_cf_value($cf); |
|
| 405 | + ob_start(); // Start buffering; |
|
| 406 | + $value = geodir_get_cf_value($cf); |
|
| 407 | 407 | |
| 408 | 408 | |
| 409 | - if ($value == '' && $cf['default']) { |
|
| 410 | - $value = '1'; |
|
| 411 | - } |
|
| 412 | - ?> |
|
| 409 | + if ($value == '' && $cf['default']) { |
|
| 410 | + $value = '1'; |
|
| 411 | + } |
|
| 412 | + ?> |
|
| 413 | 413 | |
| 414 | 414 | <div id="<?php echo $cf['name'];?>_row" |
| 415 | 415 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 416 | 416 | <label> |
| 417 | 417 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 418 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 418 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 419 | 419 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 420 | 420 | </label> |
| 421 | 421 | <?php if ($value != '1') { |
| 422 | - $value = '0'; |
|
| 423 | - }?> |
|
| 422 | + $value = '0'; |
|
| 423 | + }?> |
|
| 424 | 424 | <input type="hidden" name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" value="<?php echo esc_attr($value);?>"/> |
| 425 | 425 | <input <?php if ($value == '1') { |
| 426 | - echo 'checked="checked"'; |
|
| 427 | - }?> value="1" class="gd-checkbox" field_type="<?php echo $cf['type'];?>" type="checkbox" |
|
| 426 | + echo 'checked="checked"'; |
|
| 427 | + }?> value="1" class="gd-checkbox" field_type="<?php echo $cf['type'];?>" type="checkbox" |
|
| 428 | 428 | onchange="if(this.checked){jQuery('#<?php echo $cf['name'];?>').val('1');} else{ jQuery('#<?php echo $cf['name'];?>').val('0');}"/> |
| 429 | 429 | <span class="geodir_message_note"><?php _e($cf['desc'], 'geodirectory');?></span> |
| 430 | 430 | <?php if ($cf['is_required']) { ?> |
@@ -433,10 +433,10 @@ discard block |
||
| 433 | 433 | </div> |
| 434 | 434 | |
| 435 | 435 | <?php |
| 436 | - $html = ob_get_clean(); |
|
| 437 | - } |
|
| 436 | + $html = ob_get_clean(); |
|
| 437 | + } |
|
| 438 | 438 | |
| 439 | - return $html; |
|
| 439 | + return $html; |
|
| 440 | 440 | } |
| 441 | 441 | add_filter('geodir_custom_field_input_checkbox','geodir_cfi_checkbox',10,2); |
| 442 | 442 | |
@@ -452,52 +452,52 @@ discard block |
||
| 452 | 452 | */ |
| 453 | 453 | function geodir_cfi_textarea($html,$cf){ |
| 454 | 454 | |
| 455 | - $html_var = $cf['htmlvar_name']; |
|
| 455 | + $html_var = $cf['htmlvar_name']; |
|
| 456 | 456 | |
| 457 | - // Check if there is a custom field specific filter. |
|
| 458 | - if(has_filter("geodir_custom_field_input_textarea_{$html_var}")){ |
|
| 459 | - /** |
|
| 460 | - * Filter the textarea html by individual custom field. |
|
| 461 | - * |
|
| 462 | - * @param string $html The html to filter. |
|
| 463 | - * @param array $cf The custom field array. |
|
| 464 | - * @since 1.6.6 |
|
| 465 | - */ |
|
| 466 | - $html = apply_filters("geodir_custom_field_input_textarea_{$html_var}",$html,$cf); |
|
| 467 | - } |
|
| 457 | + // Check if there is a custom field specific filter. |
|
| 458 | + if(has_filter("geodir_custom_field_input_textarea_{$html_var}")){ |
|
| 459 | + /** |
|
| 460 | + * Filter the textarea html by individual custom field. |
|
| 461 | + * |
|
| 462 | + * @param string $html The html to filter. |
|
| 463 | + * @param array $cf The custom field array. |
|
| 464 | + * @since 1.6.6 |
|
| 465 | + */ |
|
| 466 | + $html = apply_filters("geodir_custom_field_input_textarea_{$html_var}",$html,$cf); |
|
| 467 | + } |
|
| 468 | 468 | |
| 469 | - // If no html then we run the standard output. |
|
| 470 | - if(empty($html)) { |
|
| 469 | + // If no html then we run the standard output. |
|
| 470 | + if(empty($html)) { |
|
| 471 | 471 | |
| 472 | - ob_start(); // Start buffering; |
|
| 473 | - $value = geodir_get_cf_value($cf); |
|
| 472 | + ob_start(); // Start buffering; |
|
| 473 | + $value = geodir_get_cf_value($cf); |
|
| 474 | 474 | |
| 475 | - $extra_fields = unserialize($cf['extra_fields']); |
|
| 476 | - ?> |
|
| 475 | + $extra_fields = unserialize($cf['extra_fields']); |
|
| 476 | + ?> |
|
| 477 | 477 | |
| 478 | 478 | <div id="<?php echo $cf['name'];?>_row" |
| 479 | 479 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 480 | 480 | <label> |
| 481 | 481 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 482 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 482 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 483 | 483 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 484 | 484 | </label><?php |
| 485 | 485 | |
| 486 | 486 | |
| 487 | - if (is_array($extra_fields) && in_array('1', $extra_fields)) { |
|
| 487 | + if (is_array($extra_fields) && in_array('1', $extra_fields)) { |
|
| 488 | 488 | |
| 489 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?> |
|
| 489 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);?> |
|
| 490 | 490 | |
| 491 | 491 | <div class="editor" field_id="<?php echo $cf['name'];?>" field_type="editor"> |
| 492 | 492 | <?php wp_editor(stripslashes($value), $cf['name'], $editor_settings); ?> |
| 493 | 493 | </div><?php |
| 494 | 494 | |
| 495 | - } else { |
|
| 495 | + } else { |
|
| 496 | 496 | |
| 497 | - ?><textarea field_type="<?php echo $cf['type'];?>" class="geodir_textarea" name="<?php echo $cf['name'];?>" |
|
| 497 | + ?><textarea field_type="<?php echo $cf['type'];?>" class="geodir_textarea" name="<?php echo $cf['name'];?>" |
|
| 498 | 498 | id="<?php echo $cf['name'];?>"><?php echo stripslashes($value);?></textarea><?php |
| 499 | 499 | |
| 500 | - }?> |
|
| 500 | + }?> |
|
| 501 | 501 | |
| 502 | 502 | |
| 503 | 503 | <span class="geodir_message_note"><?php _e($cf['desc'], 'geodirectory');?></span> |
@@ -507,10 +507,10 @@ discard block |
||
| 507 | 507 | </div> |
| 508 | 508 | |
| 509 | 509 | <?php |
| 510 | - $html = ob_get_clean(); |
|
| 511 | - } |
|
| 510 | + $html = ob_get_clean(); |
|
| 511 | + } |
|
| 512 | 512 | |
| 513 | - return $html; |
|
| 513 | + return $html; |
|
| 514 | 514 | } |
| 515 | 515 | add_filter('geodir_custom_field_input_textarea','geodir_cfi_textarea',10,2); |
| 516 | 516 | |
@@ -526,53 +526,53 @@ discard block |
||
| 526 | 526 | */ |
| 527 | 527 | function geodir_cfi_select($html,$cf){ |
| 528 | 528 | |
| 529 | - $html_var = $cf['htmlvar_name']; |
|
| 529 | + $html_var = $cf['htmlvar_name']; |
|
| 530 | 530 | |
| 531 | - // Check if there is a custom field specific filter. |
|
| 532 | - if(has_filter("geodir_custom_field_input_select_{$html_var}")){ |
|
| 533 | - /** |
|
| 534 | - * Filter the select html by individual custom field. |
|
| 535 | - * |
|
| 536 | - * @param string $html The html to filter. |
|
| 537 | - * @param array $cf The custom field array. |
|
| 538 | - * @since 1.6.6 |
|
| 539 | - */ |
|
| 540 | - $html = apply_filters("geodir_custom_field_input_select_{$html_var}",$html,$cf); |
|
| 541 | - } |
|
| 531 | + // Check if there is a custom field specific filter. |
|
| 532 | + if(has_filter("geodir_custom_field_input_select_{$html_var}")){ |
|
| 533 | + /** |
|
| 534 | + * Filter the select html by individual custom field. |
|
| 535 | + * |
|
| 536 | + * @param string $html The html to filter. |
|
| 537 | + * @param array $cf The custom field array. |
|
| 538 | + * @since 1.6.6 |
|
| 539 | + */ |
|
| 540 | + $html = apply_filters("geodir_custom_field_input_select_{$html_var}",$html,$cf); |
|
| 541 | + } |
|
| 542 | 542 | |
| 543 | - // If no html then we run the standard output. |
|
| 544 | - if(empty($html)) { |
|
| 543 | + // If no html then we run the standard output. |
|
| 544 | + if(empty($html)) { |
|
| 545 | 545 | |
| 546 | - ob_start(); // Start buffering; |
|
| 547 | - $value = geodir_get_cf_value($cf); |
|
| 546 | + ob_start(); // Start buffering; |
|
| 547 | + $value = geodir_get_cf_value($cf); |
|
| 548 | 548 | |
| 549 | - ?> |
|
| 549 | + ?> |
|
| 550 | 550 | <div id="<?php echo $cf['name'];?>_row" |
| 551 | 551 | class="<?php if ($cf['is_required']) echo 'required_field';?> geodir_form_row geodir_custom_fields clearfix gd-fieldset-details"> |
| 552 | 552 | <label> |
| 553 | 553 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 554 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 554 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 555 | 555 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 556 | 556 | </label> |
| 557 | 557 | <?php |
| 558 | - $option_values_arr = geodir_string_values_to_options($cf['option_values'], true); |
|
| 559 | - $select_options = ''; |
|
| 560 | - if (!empty($option_values_arr)) { |
|
| 561 | - foreach ($option_values_arr as $option_row) { |
|
| 562 | - if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) { |
|
| 563 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 564 | - |
|
| 565 | - $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 566 | - } else { |
|
| 567 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 568 | - $option_value = isset($option_row['value']) ? $option_row['value'] : ''; |
|
| 569 | - $selected = $option_value == $value ? 'selected="selected"' : ''; |
|
| 570 | - |
|
| 571 | - $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
| 572 | - } |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - ?> |
|
| 558 | + $option_values_arr = geodir_string_values_to_options($cf['option_values'], true); |
|
| 559 | + $select_options = ''; |
|
| 560 | + if (!empty($option_values_arr)) { |
|
| 561 | + foreach ($option_values_arr as $option_row) { |
|
| 562 | + if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) { |
|
| 563 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 564 | + |
|
| 565 | + $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 566 | + } else { |
|
| 567 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 568 | + $option_value = isset($option_row['value']) ? $option_row['value'] : ''; |
|
| 569 | + $selected = $option_value == $value ? 'selected="selected"' : ''; |
|
| 570 | + |
|
| 571 | + $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
| 572 | + } |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | + ?> |
|
| 576 | 576 | <select field_type="<?php echo $cf['type'];?>" name="<?php echo $cf['name'];?>" id="<?php echo $cf['name'];?>" |
| 577 | 577 | class="geodir_textfield textfield_x chosen_select" |
| 578 | 578 | data-placeholder="<?php echo __('Choose', 'geodirectory') . ' ' . $site_title . '…';?>" |
@@ -584,10 +584,10 @@ discard block |
||
| 584 | 584 | </div> |
| 585 | 585 | |
| 586 | 586 | <?php |
| 587 | - $html = ob_get_clean(); |
|
| 588 | - } |
|
| 587 | + $html = ob_get_clean(); |
|
| 588 | + } |
|
| 589 | 589 | |
| 590 | - return $html; |
|
| 590 | + return $html; |
|
| 591 | 591 | } |
| 592 | 592 | add_filter('geodir_custom_field_input_select','geodir_cfi_select',10,2); |
| 593 | 593 | |
@@ -603,36 +603,36 @@ discard block |
||
| 603 | 603 | */ |
| 604 | 604 | function geodir_cfi_multiselect($html,$cf){ |
| 605 | 605 | |
| 606 | - $html_var = $cf['htmlvar_name']; |
|
| 607 | - |
|
| 608 | - // Check if there is a custom field specific filter. |
|
| 609 | - if(has_filter("geodir_custom_field_input_multiselect_{$html_var}")){ |
|
| 610 | - /** |
|
| 611 | - * Filter the multiselect html by individual custom field. |
|
| 612 | - * |
|
| 613 | - * @param string $html The html to filter. |
|
| 614 | - * @param array $cf The custom field array. |
|
| 615 | - * @since 1.6.6 |
|
| 616 | - */ |
|
| 617 | - $html = apply_filters("geodir_custom_field_input_multiselect_{$html_var}",$html,$cf); |
|
| 618 | - } |
|
| 619 | - |
|
| 620 | - // If no html then we run the standard output. |
|
| 621 | - if(empty($html)) { |
|
| 622 | - |
|
| 623 | - ob_start(); // Start buffering; |
|
| 624 | - $value = geodir_get_cf_value($cf); |
|
| 625 | - |
|
| 626 | - $multi_display = 'select'; |
|
| 627 | - if (!empty($cf['extra_fields'])) { |
|
| 628 | - $multi_display = unserialize($cf['extra_fields']); |
|
| 629 | - } |
|
| 630 | - ?> |
|
| 606 | + $html_var = $cf['htmlvar_name']; |
|
| 607 | + |
|
| 608 | + // Check if there is a custom field specific filter. |
|
| 609 | + if(has_filter("geodir_custom_field_input_multiselect_{$html_var}")){ |
|
| 610 | + /** |
|
| 611 | + * Filter the multiselect html by individual custom field. |
|
| 612 | + * |
|
| 613 | + * @param string $html The html to filter. |
|
| 614 | + * @param array $cf The custom field array. |
|
| 615 | + * @since 1.6.6 |
|
| 616 | + */ |
|
| 617 | + $html = apply_filters("geodir_custom_field_input_multiselect_{$html_var}",$html,$cf); |
|
| 618 | + } |
|
| 619 | + |
|
| 620 | + // If no html then we run the standard output. |
|
| 621 | + if(empty($html)) { |
|
| 622 | + |
|
| 623 | + ob_start(); // Start buffering; |
|
| 624 | + $value = geodir_get_cf_value($cf); |
|
| 625 | + |
|
| 626 | + $multi_display = 'select'; |
|
| 627 | + if (!empty($cf['extra_fields'])) { |
|
| 628 | + $multi_display = unserialize($cf['extra_fields']); |
|
| 629 | + } |
|
| 630 | + ?> |
|
| 631 | 631 | <div id="<?php echo $cf['name']; ?>_row" |
| 632 | 632 | class="<?php if ($cf['is_required']) echo 'required_field'; ?> geodir_form_row clearfix gd-fieldset-details"> |
| 633 | 633 | <label> |
| 634 | 634 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 635 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 635 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 636 | 636 | <?php if ($cf['is_required']) echo '<span>*</span>'; ?> |
| 637 | 637 | </label> |
| 638 | 638 | <input type="hidden" name="gd_field_<?php echo $cf['name']; ?>" value="1"/> |
@@ -643,61 +643,61 @@ discard block |
||
| 643 | 643 | data-placeholder="<?php _e('Select', 'geodirectory'); ?>" |
| 644 | 644 | option-ajaxchosen="false"> |
| 645 | 645 | <?php |
| 646 | - } else { |
|
| 647 | - echo '<ul class="gd_multi_choice">'; |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - $option_values_arr = geodir_string_values_to_options($cf['option_values'], true); |
|
| 651 | - $select_options = ''; |
|
| 652 | - if (!empty($option_values_arr)) { |
|
| 653 | - foreach ($option_values_arr as $option_row) { |
|
| 654 | - if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) { |
|
| 655 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 656 | - |
|
| 657 | - if ($multi_display == 'select') { |
|
| 658 | - $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 659 | - } else { |
|
| 660 | - $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : ''; |
|
| 661 | - } |
|
| 662 | - } else { |
|
| 663 | - if (!is_array($value) && $value != '') { |
|
| 664 | - $value = trim($value); |
|
| 665 | - } |
|
| 646 | + } else { |
|
| 647 | + echo '<ul class="gd_multi_choice">'; |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + $option_values_arr = geodir_string_values_to_options($cf['option_values'], true); |
|
| 651 | + $select_options = ''; |
|
| 652 | + if (!empty($option_values_arr)) { |
|
| 653 | + foreach ($option_values_arr as $option_row) { |
|
| 654 | + if (isset($option_row['optgroup']) && ($option_row['optgroup'] == 'start' || $option_row['optgroup'] == 'end')) { |
|
| 655 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 656 | + |
|
| 657 | + if ($multi_display == 'select') { |
|
| 658 | + $select_options .= $option_row['optgroup'] == 'start' ? '<optgroup label="' . esc_attr($option_label) . '">' : '</optgroup>'; |
|
| 659 | + } else { |
|
| 660 | + $select_options .= $option_row['optgroup'] == 'start' ? '<li>' . $option_label . '</li>' : ''; |
|
| 661 | + } |
|
| 662 | + } else { |
|
| 663 | + if (!is_array($value) && $value != '') { |
|
| 664 | + $value = trim($value); |
|
| 665 | + } |
|
| 666 | 666 | |
| 667 | - $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 668 | - $option_value = isset($option_row['value']) ? $option_row['value'] : ''; |
|
| 669 | - $selected = $option_value == $value ? 'selected="selected"' : ''; |
|
| 670 | - $selected = ''; |
|
| 671 | - $checked = ''; |
|
| 672 | - |
|
| 673 | - if ((!is_array($value) && trim($value) != '') || (is_array($value) && !empty($value))) { |
|
| 674 | - if (!is_array($value)) { |
|
| 675 | - $value_array = explode(',', $value); |
|
| 676 | - } else { |
|
| 677 | - $value_array = $value; |
|
| 678 | - } |
|
| 679 | - |
|
| 680 | - if (is_array($value_array)) { |
|
| 681 | - $value_array = array_map('trim', $value_array); |
|
| 667 | + $option_label = isset($option_row['label']) ? $option_row['label'] : ''; |
|
| 668 | + $option_value = isset($option_row['value']) ? $option_row['value'] : ''; |
|
| 669 | + $selected = $option_value == $value ? 'selected="selected"' : ''; |
|
| 670 | + $selected = ''; |
|
| 671 | + $checked = ''; |
|
| 672 | + |
|
| 673 | + if ((!is_array($value) && trim($value) != '') || (is_array($value) && !empty($value))) { |
|
| 674 | + if (!is_array($value)) { |
|
| 675 | + $value_array = explode(',', $value); |
|
| 676 | + } else { |
|
| 677 | + $value_array = $value; |
|
| 678 | + } |
|
| 679 | + |
|
| 680 | + if (is_array($value_array)) { |
|
| 681 | + $value_array = array_map('trim', $value_array); |
|
| 682 | 682 | |
| 683 | - if (in_array($option_value, $value_array)) { |
|
| 684 | - $selected = 'selected="selected"'; |
|
| 685 | - $checked = 'checked="checked"'; |
|
| 686 | - } |
|
| 687 | - } |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - if ($multi_display == 'select') { |
|
| 691 | - $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
| 692 | - } else { |
|
| 693 | - $select_options .= '<li><input name="' . $cf['name'] . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" /> ' . $option_label . ' </li>'; |
|
| 694 | - } |
|
| 695 | - } |
|
| 696 | - } |
|
| 697 | - } |
|
| 698 | - echo $select_options; |
|
| 699 | - |
|
| 700 | - if ($multi_display == 'select') { ?></select></div> |
|
| 683 | + if (in_array($option_value, $value_array)) { |
|
| 684 | + $selected = 'selected="selected"'; |
|
| 685 | + $checked = 'checked="checked"'; |
|
| 686 | + } |
|
| 687 | + } |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + if ($multi_display == 'select') { |
|
| 691 | + $select_options .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>'; |
|
| 692 | + } else { |
|
| 693 | + $select_options .= '<li><input name="' . $cf['name'] . '[]" ' . $checked . ' value="' . esc_attr($option_value) . '" class="gd-' . $multi_display . '" field_type="' . $multi_display . '" type="' . $multi_display . '" /> ' . $option_label . ' </li>'; |
|
| 694 | + } |
|
| 695 | + } |
|
| 696 | + } |
|
| 697 | + } |
|
| 698 | + echo $select_options; |
|
| 699 | + |
|
| 700 | + if ($multi_display == 'select') { ?></select></div> |
|
| 701 | 701 | <?php } else { ?></ul><?php } ?> |
| 702 | 702 | <span class="geodir_message_note"><?php _e($cf['desc'], 'geodirectory'); ?></span> |
| 703 | 703 | <?php if ($cf['is_required']) { ?> |
@@ -705,10 +705,10 @@ discard block |
||
| 705 | 705 | <?php } ?> |
| 706 | 706 | </div> |
| 707 | 707 | <?php |
| 708 | - $html = ob_get_clean(); |
|
| 709 | - } |
|
| 708 | + $html = ob_get_clean(); |
|
| 709 | + } |
|
| 710 | 710 | |
| 711 | - return $html; |
|
| 711 | + return $html; |
|
| 712 | 712 | } |
| 713 | 713 | add_filter('geodir_custom_field_input_multiselect','geodir_cfi_multiselect',10,2); |
| 714 | 714 | |
@@ -724,32 +724,32 @@ discard block |
||
| 724 | 724 | */ |
| 725 | 725 | function geodir_cfi_html($html,$cf){ |
| 726 | 726 | |
| 727 | - $html_var = $cf['htmlvar_name']; |
|
| 727 | + $html_var = $cf['htmlvar_name']; |
|
| 728 | 728 | |
| 729 | - // Check if there is a custom field specific filter. |
|
| 730 | - if(has_filter("geodir_custom_field_input_html_{$html_var}")){ |
|
| 731 | - /** |
|
| 732 | - * Filter the html html by individual custom field. |
|
| 733 | - * |
|
| 734 | - * @param string $html The html to filter. |
|
| 735 | - * @param array $cf The custom field array. |
|
| 736 | - * @since 1.6.6 |
|
| 737 | - */ |
|
| 738 | - $html = apply_filters("geodir_custom_field_input_html_{$html_var}",$html,$cf); |
|
| 739 | - } |
|
| 729 | + // Check if there is a custom field specific filter. |
|
| 730 | + if(has_filter("geodir_custom_field_input_html_{$html_var}")){ |
|
| 731 | + /** |
|
| 732 | + * Filter the html html by individual custom field. |
|
| 733 | + * |
|
| 734 | + * @param string $html The html to filter. |
|
| 735 | + * @param array $cf The custom field array. |
|
| 736 | + * @since 1.6.6 |
|
| 737 | + */ |
|
| 738 | + $html = apply_filters("geodir_custom_field_input_html_{$html_var}",$html,$cf); |
|
| 739 | + } |
|
| 740 | 740 | |
| 741 | - // If no html then we run the standard output. |
|
| 742 | - if(empty($html)) { |
|
| 741 | + // If no html then we run the standard output. |
|
| 742 | + if(empty($html)) { |
|
| 743 | 743 | |
| 744 | - ob_start(); // Start buffering; |
|
| 745 | - $value = geodir_get_cf_value($cf); |
|
| 746 | - ?> |
|
| 744 | + ob_start(); // Start buffering; |
|
| 745 | + $value = geodir_get_cf_value($cf); |
|
| 746 | + ?> |
|
| 747 | 747 | |
| 748 | 748 | <div id="<?php echo $cf['name']; ?>_row" |
| 749 | 749 | class="<?php if ($cf['is_required']) echo 'required_field'; ?> geodir_form_row clearfix gd-fieldset-details"> |
| 750 | 750 | <label> |
| 751 | 751 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 752 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 752 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 753 | 753 | <?php if ($cf['is_required']) echo '<span>*</span>'; ?> |
| 754 | 754 | </label> |
| 755 | 755 | |
@@ -767,10 +767,10 @@ discard block |
||
| 767 | 767 | </div> |
| 768 | 768 | |
| 769 | 769 | <?php |
| 770 | - $html = ob_get_clean(); |
|
| 771 | - } |
|
| 770 | + $html = ob_get_clean(); |
|
| 771 | + } |
|
| 772 | 772 | |
| 773 | - return $html; |
|
| 773 | + return $html; |
|
| 774 | 774 | } |
| 775 | 775 | add_filter('geodir_custom_field_input_html','geodir_cfi_html',10,2); |
| 776 | 776 | |
@@ -787,68 +787,68 @@ discard block |
||
| 787 | 787 | */ |
| 788 | 788 | function geodir_cfi_datepicker($html,$cf){ |
| 789 | 789 | |
| 790 | - $html_var = $cf['htmlvar_name']; |
|
| 790 | + $html_var = $cf['htmlvar_name']; |
|
| 791 | 791 | |
| 792 | - // Check if there is a custom field specific filter. |
|
| 793 | - if(has_filter("geodir_custom_field_input_datepicker_{$html_var}")){ |
|
| 794 | - /** |
|
| 795 | - * Filter the datepicker html by individual custom field. |
|
| 796 | - * |
|
| 797 | - * @param string $html The html to filter. |
|
| 798 | - * @param array $cf The custom field array. |
|
| 799 | - * @since 1.6.6 |
|
| 800 | - */ |
|
| 801 | - $html = apply_filters("geodir_custom_field_input_datepicker_{$html_var}",$html,$cf); |
|
| 802 | - } |
|
| 792 | + // Check if there is a custom field specific filter. |
|
| 793 | + if(has_filter("geodir_custom_field_input_datepicker_{$html_var}")){ |
|
| 794 | + /** |
|
| 795 | + * Filter the datepicker html by individual custom field. |
|
| 796 | + * |
|
| 797 | + * @param string $html The html to filter. |
|
| 798 | + * @param array $cf The custom field array. |
|
| 799 | + * @since 1.6.6 |
|
| 800 | + */ |
|
| 801 | + $html = apply_filters("geodir_custom_field_input_datepicker_{$html_var}",$html,$cf); |
|
| 802 | + } |
|
| 803 | 803 | |
| 804 | - // If no html then we run the standard output. |
|
| 805 | - if(empty($html)) { |
|
| 804 | + // If no html then we run the standard output. |
|
| 805 | + if(empty($html)) { |
|
| 806 | 806 | |
| 807 | - ob_start(); // Start buffering; |
|
| 808 | - $value = geodir_get_cf_value($cf); |
|
| 807 | + ob_start(); // Start buffering; |
|
| 808 | + $value = geodir_get_cf_value($cf); |
|
| 809 | 809 | |
| 810 | - $extra_fields = unserialize($cf['extra_fields']); |
|
| 811 | - $name = $cf['name']; |
|
| 810 | + $extra_fields = unserialize($cf['extra_fields']); |
|
| 811 | + $name = $cf['name']; |
|
| 812 | 812 | |
| 813 | - if ($extra_fields['date_format'] == '') |
|
| 814 | - $extra_fields['date_format'] = 'yy-mm-dd'; |
|
| 813 | + if ($extra_fields['date_format'] == '') |
|
| 814 | + $extra_fields['date_format'] = 'yy-mm-dd'; |
|
| 815 | 815 | |
| 816 | - $date_format = $extra_fields['date_format']; |
|
| 817 | - $jquery_date_format = $date_format; |
|
| 816 | + $date_format = $extra_fields['date_format']; |
|
| 817 | + $jquery_date_format = $date_format; |
|
| 818 | 818 | |
| 819 | 819 | |
| 820 | - // check if we need to change the format or not |
|
| 821 | - $date_format_len = strlen(str_replace(' ', '', $date_format)); |
|
| 822 | - if($date_format_len>5){// if greater then 5 then it's the old style format. |
|
| 820 | + // check if we need to change the format or not |
|
| 821 | + $date_format_len = strlen(str_replace(' ', '', $date_format)); |
|
| 822 | + if($date_format_len>5){// if greater then 5 then it's the old style format. |
|
| 823 | 823 | |
| 824 | - $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format |
|
| 825 | - $replace = array('d','j','l','m','n','F','Y');//PHP date format |
|
| 824 | + $search = array('dd','d','DD','mm','m','MM','yy'); //jQuery UI datepicker format |
|
| 825 | + $replace = array('d','j','l','m','n','F','Y');//PHP date format |
|
| 826 | 826 | |
| 827 | - $date_format = str_replace($search, $replace, $date_format); |
|
| 828 | - }else{ |
|
| 829 | - $jquery_date_format = geodir_date_format_php_to_jqueryui( $jquery_date_format ); |
|
| 830 | - } |
|
| 827 | + $date_format = str_replace($search, $replace, $date_format); |
|
| 828 | + }else{ |
|
| 829 | + $jquery_date_format = geodir_date_format_php_to_jqueryui( $jquery_date_format ); |
|
| 830 | + } |
|
| 831 | 831 | |
| 832 | - if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty |
|
| 833 | - if($value && !isset($_REQUEST['backandedit'])) { |
|
| 834 | - //$time = strtotime($value); |
|
| 835 | - //$value = date_i18n($date_format, $time); |
|
| 836 | - } |
|
| 837 | - $value = geodir_date($value, 'Y-m-d', $date_format); |
|
| 832 | + if($value=='0000-00-00'){$value='';}//if date not set, then mark it empty |
|
| 833 | + if($value && !isset($_REQUEST['backandedit'])) { |
|
| 834 | + //$time = strtotime($value); |
|
| 835 | + //$value = date_i18n($date_format, $time); |
|
| 836 | + } |
|
| 837 | + $value = geodir_date($value, 'Y-m-d', $date_format); |
|
| 838 | 838 | |
| 839 | - ?> |
|
| 839 | + ?> |
|
| 840 | 840 | <script type="text/javascript"> |
| 841 | 841 | |
| 842 | 842 | jQuery(function () { |
| 843 | 843 | |
| 844 | 844 | jQuery("#<?php echo $cf['name'];?>").datepicker({changeMonth: true, changeYear: true <?php |
| 845 | - /** |
|
| 846 | - * Used to add extra option to datepicker per custom field. |
|
| 847 | - * |
|
| 848 | - * @since 1.5.7 |
|
| 849 | - * @param string $name The custom field name. |
|
| 850 | - */ |
|
| 851 | - echo apply_filters("gd_datepicker_extra_{$name}",'');?>}); |
|
| 845 | + /** |
|
| 846 | + * Used to add extra option to datepicker per custom field. |
|
| 847 | + * |
|
| 848 | + * @since 1.5.7 |
|
| 849 | + * @param string $name The custom field name. |
|
| 850 | + */ |
|
| 851 | + echo apply_filters("gd_datepicker_extra_{$name}",'');?>}); |
|
| 852 | 852 | |
| 853 | 853 | jQuery("#<?php echo $name;?>").datepicker("option", "dateFormat", '<?php echo $jquery_date_format;?>'); |
| 854 | 854 | |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | <label> |
| 865 | 865 | |
| 866 | 866 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 867 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 867 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 868 | 868 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 869 | 869 | </label> |
| 870 | 870 | |
@@ -878,10 +878,10 @@ discard block |
||
| 878 | 878 | </div> |
| 879 | 879 | |
| 880 | 880 | <?php |
| 881 | - $html = ob_get_clean(); |
|
| 882 | - } |
|
| 881 | + $html = ob_get_clean(); |
|
| 882 | + } |
|
| 883 | 883 | |
| 884 | - return $html; |
|
| 884 | + return $html; |
|
| 885 | 885 | } |
| 886 | 886 | add_filter('geodir_custom_field_input_datepicker','geodir_cfi_datepicker',10,2); |
| 887 | 887 | |
@@ -897,31 +897,31 @@ discard block |
||
| 897 | 897 | */ |
| 898 | 898 | function geodir_cfi_time($html,$cf){ |
| 899 | 899 | |
| 900 | - $html_var = $cf['htmlvar_name']; |
|
| 900 | + $html_var = $cf['htmlvar_name']; |
|
| 901 | 901 | |
| 902 | - // Check if there is a custom field specific filter. |
|
| 903 | - if(has_filter("geodir_custom_field_input_time_{$html_var}")){ |
|
| 904 | - /** |
|
| 905 | - * Filter the time html by individual custom field. |
|
| 906 | - * |
|
| 907 | - * @param string $html The html to filter. |
|
| 908 | - * @param array $cf The custom field array. |
|
| 909 | - * @since 1.6.6 |
|
| 910 | - */ |
|
| 911 | - $html = apply_filters("geodir_custom_field_input_time_{$html_var}",$html,$cf); |
|
| 912 | - } |
|
| 902 | + // Check if there is a custom field specific filter. |
|
| 903 | + if(has_filter("geodir_custom_field_input_time_{$html_var}")){ |
|
| 904 | + /** |
|
| 905 | + * Filter the time html by individual custom field. |
|
| 906 | + * |
|
| 907 | + * @param string $html The html to filter. |
|
| 908 | + * @param array $cf The custom field array. |
|
| 909 | + * @since 1.6.6 |
|
| 910 | + */ |
|
| 911 | + $html = apply_filters("geodir_custom_field_input_time_{$html_var}",$html,$cf); |
|
| 912 | + } |
|
| 913 | 913 | |
| 914 | - // If no html then we run the standard output. |
|
| 915 | - if(empty($html)) { |
|
| 914 | + // If no html then we run the standard output. |
|
| 915 | + if(empty($html)) { |
|
| 916 | 916 | |
| 917 | - ob_start(); // Start buffering; |
|
| 918 | - $value = geodir_get_cf_value($cf); |
|
| 917 | + ob_start(); // Start buffering; |
|
| 918 | + $value = geodir_get_cf_value($cf); |
|
| 919 | 919 | |
| 920 | - $name = $cf['name']; |
|
| 920 | + $name = $cf['name']; |
|
| 921 | 921 | |
| 922 | - if ($value != '') |
|
| 923 | - $value = date('H:i', strtotime($value)); |
|
| 924 | - ?> |
|
| 922 | + if ($value != '') |
|
| 923 | + $value = date('H:i', strtotime($value)); |
|
| 924 | + ?> |
|
| 925 | 925 | <script type="text/javascript"> |
| 926 | 926 | jQuery(document).ready(function () { |
| 927 | 927 | |
@@ -937,7 +937,7 @@ discard block |
||
| 937 | 937 | <label> |
| 938 | 938 | |
| 939 | 939 | <?php $site_title = __($cf['site_title'], 'geodirectory'); |
| 940 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 940 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 941 | 941 | <?php if ($cf['is_required']) echo '<span>*</span>';?> |
| 942 | 942 | </label> |
| 943 | 943 | <input readonly="readonly" field_type="<?php echo $cf['type'];?>" name="<?php echo $name;?>" |
@@ -949,10 +949,10 @@ discard block |
||
| 949 | 949 | <?php } ?> |
| 950 | 950 | </div> |
| 951 | 951 | <?php |
| 952 | - $html = ob_get_clean(); |
|
| 953 | - } |
|
| 952 | + $html = ob_get_clean(); |
|
| 953 | + } |
|
| 954 | 954 | |
| 955 | - return $html; |
|
| 955 | + return $html; |
|
| 956 | 956 | } |
| 957 | 957 | add_filter('geodir_custom_field_input_time','geodir_cfi_time',10,2); |
| 958 | 958 | |
@@ -968,100 +968,100 @@ discard block |
||
| 968 | 968 | */ |
| 969 | 969 | function geodir_cfi_address($html,$cf){ |
| 970 | 970 | |
| 971 | - $html_var = $cf['htmlvar_name']; |
|
| 972 | - |
|
| 973 | - // Check if there is a custom field specific filter. |
|
| 974 | - if(has_filter("geodir_custom_field_input_address_{$html_var}")){ |
|
| 975 | - /** |
|
| 976 | - * Filter the address html by individual custom field. |
|
| 977 | - * |
|
| 978 | - * @param string $html The html to filter. |
|
| 979 | - * @param array $cf The custom field array. |
|
| 980 | - * @since 1.6.6 |
|
| 981 | - */ |
|
| 982 | - $html = apply_filters("geodir_custom_field_input_address_{$html_var}",$html,$cf); |
|
| 983 | - } |
|
| 984 | - |
|
| 985 | - // If no html then we run the standard output. |
|
| 986 | - if(empty($html)) { |
|
| 987 | - |
|
| 988 | - global $gd_session; |
|
| 989 | - ob_start(); // Start buffering; |
|
| 990 | - $value = geodir_get_cf_value($cf); |
|
| 991 | - $name = $cf['name']; |
|
| 992 | - $type = $cf['type']; |
|
| 993 | - $admin_desc = $cf['desc']; |
|
| 994 | - $is_required = $cf['is_required']; |
|
| 995 | - $required_msg = $cf['required_msg']; |
|
| 996 | - $site_title = $cf['site_title']; |
|
| 997 | - $is_admin = $cf['is_admin']; |
|
| 998 | - $extra_fields = stripslashes_deep(unserialize($cf['extra_fields'])); |
|
| 999 | - $prefix = $name . '_'; |
|
| 1000 | - |
|
| 1001 | - ($site_title != '') ? $address_title = $site_title : $address_title = geodir_ucwords($prefix . ' address'); |
|
| 1002 | - ($extra_fields['zip_lable'] != '') ? $zip_title = $extra_fields['zip_lable'] : $zip_title = geodir_ucwords($prefix . ' zip/post code '); |
|
| 1003 | - ($extra_fields['map_lable'] != '') ? $map_title = $extra_fields['map_lable'] : $map_title = geodir_ucwords('set address on map'); |
|
| 1004 | - ($extra_fields['mapview_lable'] != '') ? $mapview_title = $extra_fields['mapview_lable'] : $mapview_title = geodir_ucwords($prefix . ' mapview'); |
|
| 1005 | - |
|
| 1006 | - $address = ''; |
|
| 1007 | - $zip = ''; |
|
| 1008 | - $mapview = ''; |
|
| 1009 | - $mapzoom = ''; |
|
| 1010 | - $lat = ''; |
|
| 1011 | - $lng = ''; |
|
| 1012 | - |
|
| 1013 | - if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) { |
|
| 1014 | - $post = $gd_ses_listing; |
|
| 1015 | - $address = $post[$prefix . 'address']; |
|
| 1016 | - $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : ''; |
|
| 1017 | - $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : ''; |
|
| 1018 | - $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : ''; |
|
| 1019 | - $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : ''; |
|
| 1020 | - $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : ''; |
|
| 1021 | - } else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) { |
|
| 1022 | - $post_info = (array)$post_info; |
|
| 1023 | - |
|
| 1024 | - $address = $post_info[$prefix . 'address']; |
|
| 1025 | - $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : ''; |
|
| 1026 | - $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : ''; |
|
| 1027 | - $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : ''; |
|
| 1028 | - $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : ''; |
|
| 1029 | - $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : ''; |
|
| 1030 | - } |
|
| 1031 | - |
|
| 1032 | - $location = geodir_get_default_location(); |
|
| 1033 | - if (empty($city)) $city = isset($location->city) ? $location->city : ''; |
|
| 1034 | - if (empty($region)) $region = isset($location->region) ? $location->region : ''; |
|
| 1035 | - if (empty($country)) $country = isset($location->country) ? $location->country : ''; |
|
| 1036 | - |
|
| 1037 | - $lat_lng_blank = false; |
|
| 1038 | - if (empty($lat) && empty($lng)) { |
|
| 1039 | - $lat_lng_blank = true; |
|
| 1040 | - } |
|
| 1041 | - |
|
| 1042 | - if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : ''; |
|
| 1043 | - if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : ''; |
|
| 1044 | - |
|
| 1045 | - /** |
|
| 1046 | - * Filter the default latitude. |
|
| 1047 | - * |
|
| 1048 | - * @since 1.0.0 |
|
| 1049 | - * |
|
| 1050 | - * @param float $lat Default latitude. |
|
| 1051 | - * @param bool $is_admin For admin use only?. |
|
| 1052 | - */ |
|
| 1053 | - $lat = apply_filters('geodir_default_latitude', $lat, $is_admin); |
|
| 1054 | - /** |
|
| 1055 | - * Filter the default longitude. |
|
| 1056 | - * |
|
| 1057 | - * @since 1.0.0 |
|
| 1058 | - * |
|
| 1059 | - * @param float $lat Default longitude. |
|
| 1060 | - * @param bool $is_admin For admin use only?. |
|
| 1061 | - */ |
|
| 1062 | - $lng = apply_filters('geodir_default_longitude', $lng, $is_admin); |
|
| 1063 | - |
|
| 1064 | - ?> |
|
| 971 | + $html_var = $cf['htmlvar_name']; |
|
| 972 | + |
|
| 973 | + // Check if there is a custom field specific filter. |
|
| 974 | + if(has_filter("geodir_custom_field_input_address_{$html_var}")){ |
|
| 975 | + /** |
|
| 976 | + * Filter the address html by individual custom field. |
|
| 977 | + * |
|
| 978 | + * @param string $html The html to filter. |
|
| 979 | + * @param array $cf The custom field array. |
|
| 980 | + * @since 1.6.6 |
|
| 981 | + */ |
|
| 982 | + $html = apply_filters("geodir_custom_field_input_address_{$html_var}",$html,$cf); |
|
| 983 | + } |
|
| 984 | + |
|
| 985 | + // If no html then we run the standard output. |
|
| 986 | + if(empty($html)) { |
|
| 987 | + |
|
| 988 | + global $gd_session; |
|
| 989 | + ob_start(); // Start buffering; |
|
| 990 | + $value = geodir_get_cf_value($cf); |
|
| 991 | + $name = $cf['name']; |
|
| 992 | + $type = $cf['type']; |
|
| 993 | + $admin_desc = $cf['desc']; |
|
| 994 | + $is_required = $cf['is_required']; |
|
| 995 | + $required_msg = $cf['required_msg']; |
|
| 996 | + $site_title = $cf['site_title']; |
|
| 997 | + $is_admin = $cf['is_admin']; |
|
| 998 | + $extra_fields = stripslashes_deep(unserialize($cf['extra_fields'])); |
|
| 999 | + $prefix = $name . '_'; |
|
| 1000 | + |
|
| 1001 | + ($site_title != '') ? $address_title = $site_title : $address_title = geodir_ucwords($prefix . ' address'); |
|
| 1002 | + ($extra_fields['zip_lable'] != '') ? $zip_title = $extra_fields['zip_lable'] : $zip_title = geodir_ucwords($prefix . ' zip/post code '); |
|
| 1003 | + ($extra_fields['map_lable'] != '') ? $map_title = $extra_fields['map_lable'] : $map_title = geodir_ucwords('set address on map'); |
|
| 1004 | + ($extra_fields['mapview_lable'] != '') ? $mapview_title = $extra_fields['mapview_lable'] : $mapview_title = geodir_ucwords($prefix . ' mapview'); |
|
| 1005 | + |
|
| 1006 | + $address = ''; |
|
| 1007 | + $zip = ''; |
|
| 1008 | + $mapview = ''; |
|
| 1009 | + $mapzoom = ''; |
|
| 1010 | + $lat = ''; |
|
| 1011 | + $lng = ''; |
|
| 1012 | + |
|
| 1013 | + if (isset($_REQUEST['backandedit']) && $_REQUEST['backandedit'] && $gd_ses_listing = $gd_session->get('listing')) { |
|
| 1014 | + $post = $gd_ses_listing; |
|
| 1015 | + $address = $post[$prefix . 'address']; |
|
| 1016 | + $zip = isset($post[$prefix . 'zip']) ? $post[$prefix . 'zip'] : ''; |
|
| 1017 | + $lat = isset($post[$prefix . 'latitude']) ? $post[$prefix . 'latitude'] : ''; |
|
| 1018 | + $lng = isset($post[$prefix . 'longitude']) ? $post[$prefix . 'longitude'] : ''; |
|
| 1019 | + $mapview = isset($post[$prefix . 'mapview']) ? $post[$prefix . 'mapview'] : ''; |
|
| 1020 | + $mapzoom = isset($post[$prefix . 'mapzoom']) ? $post[$prefix . 'mapzoom'] : ''; |
|
| 1021 | + } else if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '' && $post_info = geodir_get_post_info($_REQUEST['pid'])) { |
|
| 1022 | + $post_info = (array)$post_info; |
|
| 1023 | + |
|
| 1024 | + $address = $post_info[$prefix . 'address']; |
|
| 1025 | + $zip = isset($post_info[$prefix . 'zip']) ? $post_info[$prefix . 'zip'] : ''; |
|
| 1026 | + $lat = isset($post_info[$prefix . 'latitude']) ? $post_info[$prefix . 'latitude'] : ''; |
|
| 1027 | + $lng = isset($post_info[$prefix . 'longitude']) ? $post_info[$prefix . 'longitude'] : ''; |
|
| 1028 | + $mapview = isset($post_info[$prefix . 'mapview']) ? $post_info[$prefix . 'mapview'] : ''; |
|
| 1029 | + $mapzoom = isset($post_info[$prefix . 'mapzoom']) ? $post_info[$prefix . 'mapzoom'] : ''; |
|
| 1030 | + } |
|
| 1031 | + |
|
| 1032 | + $location = geodir_get_default_location(); |
|
| 1033 | + if (empty($city)) $city = isset($location->city) ? $location->city : ''; |
|
| 1034 | + if (empty($region)) $region = isset($location->region) ? $location->region : ''; |
|
| 1035 | + if (empty($country)) $country = isset($location->country) ? $location->country : ''; |
|
| 1036 | + |
|
| 1037 | + $lat_lng_blank = false; |
|
| 1038 | + if (empty($lat) && empty($lng)) { |
|
| 1039 | + $lat_lng_blank = true; |
|
| 1040 | + } |
|
| 1041 | + |
|
| 1042 | + if (empty($lat)) $lat = isset($location->city_latitude) ? $location->city_latitude : ''; |
|
| 1043 | + if (empty($lng)) $lng = isset($location->city_longitude) ? $location->city_longitude : ''; |
|
| 1044 | + |
|
| 1045 | + /** |
|
| 1046 | + * Filter the default latitude. |
|
| 1047 | + * |
|
| 1048 | + * @since 1.0.0 |
|
| 1049 | + * |
|
| 1050 | + * @param float $lat Default latitude. |
|
| 1051 | + * @param bool $is_admin For admin use only?. |
|
| 1052 | + */ |
|
| 1053 | + $lat = apply_filters('geodir_default_latitude', $lat, $is_admin); |
|
| 1054 | + /** |
|
| 1055 | + * Filter the default longitude. |
|
| 1056 | + * |
|
| 1057 | + * @since 1.0.0 |
|
| 1058 | + * |
|
| 1059 | + * @param float $lat Default longitude. |
|
| 1060 | + * @param bool $is_admin For admin use only?. |
|
| 1061 | + */ |
|
| 1062 | + $lng = apply_filters('geodir_default_longitude', $lng, $is_admin); |
|
| 1063 | + |
|
| 1064 | + ?> |
|
| 1065 | 1065 | |
| 1066 | 1066 | <div id="geodir_<?php echo $prefix . 'address';?>_row" |
| 1067 | 1067 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
@@ -1080,17 +1080,17 @@ discard block |
||
| 1080 | 1080 | |
| 1081 | 1081 | |
| 1082 | 1082 | <?php |
| 1083 | - /** |
|
| 1084 | - * Called after the address input on the add listings. |
|
| 1085 | - * |
|
| 1086 | - * This is used by the location manage to add further locations info etc. |
|
| 1087 | - * |
|
| 1088 | - * @since 1.0.0 |
|
| 1089 | - * @param array $cf The array of setting for the custom field. {@see geodir_custom_field_save()}. |
|
| 1090 | - */ |
|
| 1091 | - do_action('geodir_address_extra_listing_fields', $cf); |
|
| 1092 | - |
|
| 1093 | - if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?> |
|
| 1083 | + /** |
|
| 1084 | + * Called after the address input on the add listings. |
|
| 1085 | + * |
|
| 1086 | + * This is used by the location manage to add further locations info etc. |
|
| 1087 | + * |
|
| 1088 | + * @since 1.0.0 |
|
| 1089 | + * @param array $cf The array of setting for the custom field. {@see geodir_custom_field_save()}. |
|
| 1090 | + */ |
|
| 1091 | + do_action('geodir_address_extra_listing_fields', $cf); |
|
| 1092 | + |
|
| 1093 | + if (isset($extra_fields['show_zip']) && $extra_fields['show_zip']) { ?> |
|
| 1094 | 1094 | |
| 1095 | 1095 | <div id="geodir_<?php echo $prefix . 'zip'; ?>_row" |
| 1096 | 1096 | class="<?php /*if($is_required) echo 'required_field';*/ ?> geodir_form_row clearfix gd-fieldset-details"> |
@@ -1111,22 +1111,22 @@ discard block |
||
| 1111 | 1111 | |
| 1112 | 1112 | <div id="geodir_<?php echo $prefix . 'map'; ?>_row" class="geodir_form_row clearfix gd-fieldset-details"> |
| 1113 | 1113 | <?php |
| 1114 | - /** |
|
| 1115 | - * Contains add listing page map functions. |
|
| 1116 | - * |
|
| 1117 | - * @since 1.0.0 |
|
| 1118 | - */ |
|
| 1119 | - include(geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php"); |
|
| 1120 | - if ($lat_lng_blank) { |
|
| 1121 | - $lat = ''; |
|
| 1122 | - $lng = ''; |
|
| 1123 | - } |
|
| 1124 | - ?> |
|
| 1114 | + /** |
|
| 1115 | + * Contains add listing page map functions. |
|
| 1116 | + * |
|
| 1117 | + * @since 1.0.0 |
|
| 1118 | + */ |
|
| 1119 | + include(geodir_plugin_path() . "/geodirectory-functions/map-functions/map_on_add_listing_page.php"); |
|
| 1120 | + if ($lat_lng_blank) { |
|
| 1121 | + $lat = ''; |
|
| 1122 | + $lng = ''; |
|
| 1123 | + } |
|
| 1124 | + ?> |
|
| 1125 | 1125 | <span class="geodir_message_note"><?php echo GET_MAP_MSG; ?></span> |
| 1126 | 1126 | </div> |
| 1127 | 1127 | <?php |
| 1128 | - /* show lat lng */ |
|
| 1129 | - $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?> |
|
| 1128 | + /* show lat lng */ |
|
| 1129 | + $style_latlng = ((isset($extra_fields['show_latlng']) && $extra_fields['show_latlng']) || is_admin()) ? '' : 'style="display:none"'; ?> |
|
| 1130 | 1130 | <div id="geodir_<?php echo $prefix . 'latitude'; ?>_row" |
| 1131 | 1131 | class="<?php if ($is_required) echo 'required_field'; ?> geodir_form_row clearfix gd-fieldset-details" <?php echo $style_latlng; ?>> |
| 1132 | 1132 | <label> |
@@ -1167,27 +1167,27 @@ discard block |
||
| 1167 | 1167 | class="gd-checkbox" |
| 1168 | 1168 | name="<?php echo $prefix . 'mapview'; ?>" |
| 1169 | 1169 | id="<?php echo $prefix . 'mapview'; ?>" <?php if ($mapview == 'ROADMAP' || $mapview == '') { |
| 1170 | - echo 'checked="checked"'; |
|
| 1171 | - } ?> value="ROADMAP" size="25"/> <?php _e('Default Map', 'geodirectory'); ?></span> |
|
| 1170 | + echo 'checked="checked"'; |
|
| 1171 | + } ?> value="ROADMAP" size="25"/> <?php _e('Default Map', 'geodirectory'); ?></span> |
|
| 1172 | 1172 | <span class="geodir_user_define"> <input field_type="<?php echo $type; ?>" type="radio" |
| 1173 | 1173 | class="gd-checkbox" |
| 1174 | 1174 | name="<?php echo $prefix . 'mapview'; ?>" |
| 1175 | 1175 | id="map_view1" <?php if ($mapview == 'SATELLITE') { |
| 1176 | - echo 'checked="checked"'; |
|
| 1177 | - } ?> value="SATELLITE" size="25"/> <?php _e('Satellite Map', 'geodirectory'); ?></span> |
|
| 1176 | + echo 'checked="checked"'; |
|
| 1177 | + } ?> value="SATELLITE" size="25"/> <?php _e('Satellite Map', 'geodirectory'); ?></span> |
|
| 1178 | 1178 | |
| 1179 | 1179 | <span class="geodir_user_define"><input field_type="<?php echo $type; ?>" type="radio" |
| 1180 | 1180 | class="gd-checkbox" |
| 1181 | 1181 | name="<?php echo $prefix . 'mapview'; ?>" |
| 1182 | 1182 | id="map_view2" <?php if ($mapview == 'HYBRID') { |
| 1183 | - echo 'checked="checked"'; |
|
| 1184 | - } ?> value="HYBRID" size="25"/> <?php _e('Hybrid Map', 'geodirectory'); ?></span> |
|
| 1183 | + echo 'checked="checked"'; |
|
| 1184 | + } ?> value="HYBRID" size="25"/> <?php _e('Hybrid Map', 'geodirectory'); ?></span> |
|
| 1185 | 1185 | <span class="geodir_user_define"><input field_type="<?php echo $type; ?>" type="radio" |
| 1186 | 1186 | class="gd-checkbox" |
| 1187 | 1187 | name="<?php echo $prefix . 'mapview'; ?>" |
| 1188 | 1188 | id="map_view3" <?php if ($mapview == 'TERRAIN') { |
| 1189 | - echo 'checked="checked"'; |
|
| 1190 | - } ?> value="TERRAIN" size="25"/> <?php _e('Terrain Map', 'geodirectory'); ?></span> |
|
| 1189 | + echo 'checked="checked"'; |
|
| 1190 | + } ?> value="TERRAIN" size="25"/> <?php _e('Terrain Map', 'geodirectory'); ?></span> |
|
| 1191 | 1191 | |
| 1192 | 1192 | |
| 1193 | 1193 | </div> |
@@ -1195,14 +1195,14 @@ discard block |
||
| 1195 | 1195 | |
| 1196 | 1196 | <?php if (isset($extra_fields['show_mapzoom']) && $extra_fields['show_mapzoom']) { ?> |
| 1197 | 1197 | <input type="hidden" value="<?php if (isset($mapzoom)) { |
| 1198 | - echo esc_attr($mapzoom); |
|
| 1199 | - } ?>" name="<?php echo $prefix . 'mapzoom'; ?>" id="<?php echo $prefix . 'mapzoom'; ?>"/> |
|
| 1198 | + echo esc_attr($mapzoom); |
|
| 1199 | + } ?>" name="<?php echo $prefix . 'mapzoom'; ?>" id="<?php echo $prefix . 'mapzoom'; ?>"/> |
|
| 1200 | 1200 | <?php } |
| 1201 | 1201 | |
| 1202 | - $html = ob_get_clean(); |
|
| 1203 | - } |
|
| 1202 | + $html = ob_get_clean(); |
|
| 1203 | + } |
|
| 1204 | 1204 | |
| 1205 | - return $html; |
|
| 1205 | + return $html; |
|
| 1206 | 1206 | } |
| 1207 | 1207 | add_filter('geodir_custom_field_input_address','geodir_cfi_address',10,2); |
| 1208 | 1208 | |
@@ -1219,137 +1219,137 @@ discard block |
||
| 1219 | 1219 | */ |
| 1220 | 1220 | function geodir_cfi_taxonomy($html,$cf){ |
| 1221 | 1221 | |
| 1222 | - $html_var = $cf['htmlvar_name']; |
|
| 1223 | - |
|
| 1224 | - // Check if there is a custom field specific filter. |
|
| 1225 | - if(has_filter("geodir_custom_field_input_taxonomy_{$html_var}")){ |
|
| 1226 | - /** |
|
| 1227 | - * Filter the taxonomy html by individual custom field. |
|
| 1228 | - * |
|
| 1229 | - * @param string $html The html to filter. |
|
| 1230 | - * @param array $cf The custom field array. |
|
| 1231 | - * @since 1.6.6 |
|
| 1232 | - */ |
|
| 1233 | - $html = apply_filters("geodir_custom_field_input_taxonomy_{$html_var}",$html,$cf); |
|
| 1234 | - } |
|
| 1235 | - |
|
| 1236 | - // If no html then we run the standard output. |
|
| 1237 | - if(empty($html)) { |
|
| 1238 | - |
|
| 1239 | - ob_start(); // Start buffering; |
|
| 1240 | - $value = geodir_get_cf_value($cf); |
|
| 1241 | - |
|
| 1242 | - $name = $cf['name']; |
|
| 1243 | - $site_title = $cf['site_title']; |
|
| 1244 | - $admin_desc = $cf['desc']; |
|
| 1245 | - $is_required = $cf['is_required']; |
|
| 1246 | - $is_admin = $cf['is_admin']; |
|
| 1247 | - $required_msg = $cf['required_msg']; |
|
| 1248 | - |
|
| 1249 | - if ($value == $cf['default']) { |
|
| 1250 | - $value = ''; |
|
| 1251 | - } ?> |
|
| 1222 | + $html_var = $cf['htmlvar_name']; |
|
| 1223 | + |
|
| 1224 | + // Check if there is a custom field specific filter. |
|
| 1225 | + if(has_filter("geodir_custom_field_input_taxonomy_{$html_var}")){ |
|
| 1226 | + /** |
|
| 1227 | + * Filter the taxonomy html by individual custom field. |
|
| 1228 | + * |
|
| 1229 | + * @param string $html The html to filter. |
|
| 1230 | + * @param array $cf The custom field array. |
|
| 1231 | + * @since 1.6.6 |
|
| 1232 | + */ |
|
| 1233 | + $html = apply_filters("geodir_custom_field_input_taxonomy_{$html_var}",$html,$cf); |
|
| 1234 | + } |
|
| 1235 | + |
|
| 1236 | + // If no html then we run the standard output. |
|
| 1237 | + if(empty($html)) { |
|
| 1238 | + |
|
| 1239 | + ob_start(); // Start buffering; |
|
| 1240 | + $value = geodir_get_cf_value($cf); |
|
| 1241 | + |
|
| 1242 | + $name = $cf['name']; |
|
| 1243 | + $site_title = $cf['site_title']; |
|
| 1244 | + $admin_desc = $cf['desc']; |
|
| 1245 | + $is_required = $cf['is_required']; |
|
| 1246 | + $is_admin = $cf['is_admin']; |
|
| 1247 | + $required_msg = $cf['required_msg']; |
|
| 1248 | + |
|
| 1249 | + if ($value == $cf['default']) { |
|
| 1250 | + $value = ''; |
|
| 1251 | + } ?> |
|
| 1252 | 1252 | <div id="<?php echo $name;?>_row" |
| 1253 | 1253 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
| 1254 | 1254 | <label> |
| 1255 | 1255 | <?php $site_title = __($site_title, 'geodirectory'); |
| 1256 | - echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 1256 | + echo (trim($site_title)) ? $site_title : ' '; ?> |
|
| 1257 | 1257 | <?php if ($is_required) echo '<span>*</span>';?> |
| 1258 | 1258 | </label> |
| 1259 | 1259 | |
| 1260 | 1260 | <div id="<?php echo $name;?>" class="geodir_taxonomy_field" style="float:left; width:70%;"> |
| 1261 | 1261 | <?php |
| 1262 | - global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats; |
|
| 1262 | + global $wpdb, $post, $cat_display, $post_cat, $package_id, $exclude_cats; |
|
| 1263 | 1263 | |
| 1264 | - $exclude_cats = array(); |
|
| 1264 | + $exclude_cats = array(); |
|
| 1265 | 1265 | |
| 1266 | - if ($is_admin == '1') { |
|
| 1266 | + if ($is_admin == '1') { |
|
| 1267 | 1267 | |
| 1268 | - $post_type = get_post_type(); |
|
| 1268 | + $post_type = get_post_type(); |
|
| 1269 | 1269 | |
| 1270 | - $package_info = array(); |
|
| 1270 | + $package_info = array(); |
|
| 1271 | 1271 | |
| 1272 | - $package_info = (array)geodir_post_package_info($package_info, $post, $post_type); |
|
| 1272 | + $package_info = (array)geodir_post_package_info($package_info, $post, $post_type); |
|
| 1273 | 1273 | |
| 1274 | - if (!empty($package_info)) { |
|
| 1274 | + if (!empty($package_info)) { |
|
| 1275 | 1275 | |
| 1276 | - if (isset($package_info['cat']) && $package_info['cat'] != '') { |
|
| 1276 | + if (isset($package_info['cat']) && $package_info['cat'] != '') { |
|
| 1277 | 1277 | |
| 1278 | - $exclude_cats = explode(',', $package_info['cat']); |
|
| 1278 | + $exclude_cats = explode(',', $package_info['cat']); |
|
| 1279 | 1279 | |
| 1280 | - } |
|
| 1281 | - } |
|
| 1282 | - } |
|
| 1280 | + } |
|
| 1281 | + } |
|
| 1282 | + } |
|
| 1283 | 1283 | |
| 1284 | - $cat_display = unserialize($cf['extra_fields']); |
|
| 1284 | + $cat_display = unserialize($cf['extra_fields']); |
|
| 1285 | 1285 | |
| 1286 | - if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) { |
|
| 1286 | + if (isset($_REQUEST['backandedit']) && (is_array($post_cat[$name]) && !empty($post_cat[$name]))) { |
|
| 1287 | 1287 | |
| 1288 | - $post_cat = implode(",", $post_cat[$name]); |
|
| 1288 | + $post_cat = implode(",", $post_cat[$name]); |
|
| 1289 | 1289 | |
| 1290 | - } else { |
|
| 1291 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 1292 | - $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true); |
|
| 1293 | - } |
|
| 1290 | + } else { |
|
| 1291 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 1292 | + $post_cat = geodir_get_post_meta($_REQUEST['pid'], $name, true); |
|
| 1293 | + } |
|
| 1294 | 1294 | |
| 1295 | 1295 | |
| 1296 | - global $geodir_addon_list; |
|
| 1297 | - if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') { |
|
| 1296 | + global $geodir_addon_list; |
|
| 1297 | + if (!empty($geodir_addon_list) && array_key_exists('geodir_payment_manager', $geodir_addon_list) && $geodir_addon_list['geodir_payment_manager'] == 'yes') { |
|
| 1298 | 1298 | |
| 1299 | - $catadd_limit = $wpdb->get_var( |
|
| 1300 | - $wpdb->prepare( |
|
| 1301 | - "SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d", |
|
| 1302 | - array($package_id) |
|
| 1303 | - ) |
|
| 1304 | - ); |
|
| 1299 | + $catadd_limit = $wpdb->get_var( |
|
| 1300 | + $wpdb->prepare( |
|
| 1301 | + "SELECT cat_limit FROM " . GEODIR_PRICE_TABLE . " WHERE pid = %d", |
|
| 1302 | + array($package_id) |
|
| 1303 | + ) |
|
| 1304 | + ); |
|
| 1305 | 1305 | |
| 1306 | 1306 | |
| 1307 | - } else { |
|
| 1308 | - $catadd_limit = 0; |
|
| 1309 | - } |
|
| 1307 | + } else { |
|
| 1308 | + $catadd_limit = 0; |
|
| 1309 | + } |
|
| 1310 | 1310 | |
| 1311 | 1311 | |
| 1312 | - if ($cat_display != '' && $cat_display != 'ajax_chained') { |
|
| 1312 | + if ($cat_display != '' && $cat_display != 'ajax_chained') { |
|
| 1313 | 1313 | |
| 1314 | - $required_limit_msg = ''; |
|
| 1315 | - if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') { |
|
| 1314 | + $required_limit_msg = ''; |
|
| 1315 | + if ($catadd_limit > 0 && $cat_display != 'select' && $cat_display != 'radio') { |
|
| 1316 | 1316 | |
| 1317 | - $required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory'); |
|
| 1317 | + $required_limit_msg = __('Only select', 'geodirectory') . ' ' . $catadd_limit . __(' categories for this package.', 'geodirectory'); |
|
| 1318 | 1318 | |
| 1319 | - } else { |
|
| 1320 | - $required_limit_msg = $required_msg; |
|
| 1321 | - } |
|
| 1319 | + } else { |
|
| 1320 | + $required_limit_msg = $required_msg; |
|
| 1321 | + } |
|
| 1322 | 1322 | |
| 1323 | - echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']" />'; |
|
| 1323 | + echo '<input type="hidden" cat_limit="' . $catadd_limit . '" id="cat_limit" value="' . esc_attr($required_limit_msg) . '" name="cat_limit[' . $name . ']" />'; |
|
| 1324 | 1324 | |
| 1325 | 1325 | |
| 1326 | - if ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 1326 | + if ($cat_display == 'select' || $cat_display == 'multiselect') { |
|
| 1327 | 1327 | |
| 1328 | - $cat_display == ''; |
|
| 1329 | - $multiple = ''; |
|
| 1330 | - if ($cat_display == 'multiselect') |
|
| 1331 | - $multiple = 'multiple="multiple"'; |
|
| 1328 | + $cat_display == ''; |
|
| 1329 | + $multiple = ''; |
|
| 1330 | + if ($cat_display == 'multiselect') |
|
| 1331 | + $multiple = 'multiple="multiple"'; |
|
| 1332 | 1332 | |
| 1333 | - echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">'; |
|
| 1333 | + echo '<select id="' . $name . '" ' . $multiple . ' type="' . $name . '" name="post_category[' . $name . '][]" alt="' . $name . '" field_type="' . $cat_display . '" class="geodir_textfield textfield_x chosen_select" data-placeholder="' . __('Select Category', 'geodirectory') . '">'; |
|
| 1334 | 1334 | |
| 1335 | 1335 | |
| 1336 | - if ($cat_display == 'select') |
|
| 1337 | - echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>'; |
|
| 1336 | + if ($cat_display == 'select') |
|
| 1337 | + echo '<option value="">' . __('Select Category', 'geodirectory') . '</option>'; |
|
| 1338 | 1338 | |
| 1339 | - } |
|
| 1339 | + } |
|
| 1340 | 1340 | |
| 1341 | - echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0); |
|
| 1341 | + echo geodir_custom_taxonomy_walker($name, $catadd_limit = 0); |
|
| 1342 | 1342 | |
| 1343 | - if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 1344 | - echo '</select>'; |
|
| 1343 | + if ($cat_display == 'select' || $cat_display == 'multiselect') |
|
| 1344 | + echo '</select>'; |
|
| 1345 | 1345 | |
| 1346 | - } else { |
|
| 1346 | + } else { |
|
| 1347 | 1347 | |
| 1348 | - echo geodir_custom_taxonomy_walker2($name, $catadd_limit); |
|
| 1348 | + echo geodir_custom_taxonomy_walker2($name, $catadd_limit); |
|
| 1349 | 1349 | |
| 1350 | - } |
|
| 1350 | + } |
|
| 1351 | 1351 | |
| 1352 | - ?> |
|
| 1352 | + ?> |
|
| 1353 | 1353 | </div> |
| 1354 | 1354 | |
| 1355 | 1355 | <span class="geodir_message_note"><?php _e($admin_desc, 'geodirectory');?></span> |
@@ -1359,10 +1359,10 @@ discard block |
||
| 1359 | 1359 | </div> |
| 1360 | 1360 | |
| 1361 | 1361 | <?php |
| 1362 | - $html = ob_get_clean(); |
|
| 1363 | - } |
|
| 1362 | + $html = ob_get_clean(); |
|
| 1363 | + } |
|
| 1364 | 1364 | |
| 1365 | - return $html; |
|
| 1365 | + return $html; |
|
| 1366 | 1366 | } |
| 1367 | 1367 | add_filter('geodir_custom_field_input_taxonomy','geodir_cfi_taxonomy',10,2); |
| 1368 | 1368 | |
@@ -1378,74 +1378,74 @@ discard block |
||
| 1378 | 1378 | */ |
| 1379 | 1379 | function geodir_cfi_file($html,$cf){ |
| 1380 | 1380 | |
| 1381 | - $html_var = $cf['htmlvar_name']; |
|
| 1381 | + $html_var = $cf['htmlvar_name']; |
|
| 1382 | 1382 | |
| 1383 | - // Check if there is a custom field specific filter. |
|
| 1384 | - if(has_filter("geodir_custom_field_input_file_{$html_var}")){ |
|
| 1385 | - /** |
|
| 1386 | - * Filter the file html by individual custom field. |
|
| 1387 | - * |
|
| 1388 | - * @param string $html The html to filter. |
|
| 1389 | - * @param array $cf The custom field array. |
|
| 1390 | - * @since 1.6.6 |
|
| 1391 | - */ |
|
| 1392 | - $html = apply_filters("geodir_custom_field_input_file_{$html_var}",$html,$cf); |
|
| 1393 | - } |
|
| 1383 | + // Check if there is a custom field specific filter. |
|
| 1384 | + if(has_filter("geodir_custom_field_input_file_{$html_var}")){ |
|
| 1385 | + /** |
|
| 1386 | + * Filter the file html by individual custom field. |
|
| 1387 | + * |
|
| 1388 | + * @param string $html The html to filter. |
|
| 1389 | + * @param array $cf The custom field array. |
|
| 1390 | + * @since 1.6.6 |
|
| 1391 | + */ |
|
| 1392 | + $html = apply_filters("geodir_custom_field_input_file_{$html_var}",$html,$cf); |
|
| 1393 | + } |
|
| 1394 | 1394 | |
| 1395 | - // If no html then we run the standard output. |
|
| 1396 | - if(empty($html)) { |
|
| 1395 | + // If no html then we run the standard output. |
|
| 1396 | + if(empty($html)) { |
|
| 1397 | 1397 | |
| 1398 | - ob_start(); // Start buffering; |
|
| 1399 | - $value = geodir_get_cf_value($cf); |
|
| 1398 | + ob_start(); // Start buffering; |
|
| 1399 | + $value = geodir_get_cf_value($cf); |
|
| 1400 | 1400 | |
| 1401 | - $name = $cf['name']; |
|
| 1402 | - $site_title = $cf['site_title']; |
|
| 1403 | - $admin_desc = $cf['desc']; |
|
| 1404 | - $is_required = $cf['is_required']; |
|
| 1405 | - $required_msg = $cf['required_msg']; |
|
| 1406 | - $extra_fields = unserialize($cf['extra_fields']); |
|
| 1401 | + $name = $cf['name']; |
|
| 1402 | + $site_title = $cf['site_title']; |
|
| 1403 | + $admin_desc = $cf['desc']; |
|
| 1404 | + $is_required = $cf['is_required']; |
|
| 1405 | + $required_msg = $cf['required_msg']; |
|
| 1406 | + $extra_fields = unserialize($cf['extra_fields']); |
|
| 1407 | 1407 | |
| 1408 | 1408 | |
| 1409 | - // adjust values here |
|
| 1410 | - $file_id = $name; // 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 |
|
| 1409 | + // adjust values here |
|
| 1410 | + $file_id = $name; // 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 |
|
| 1411 | 1411 | |
| 1412 | - if ($value != '') { |
|
| 1412 | + if ($value != '') { |
|
| 1413 | 1413 | |
| 1414 | - $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls. |
|
| 1414 | + $file_value = trim($value, ","); // this will be initial value of the above form field. Image urls. |
|
| 1415 | 1415 | |
| 1416 | - } else |
|
| 1417 | - $file_value = ''; |
|
| 1416 | + } else |
|
| 1417 | + $file_value = ''; |
|
| 1418 | 1418 | |
| 1419 | - if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) |
|
| 1420 | - $file_multiple = true; // allow multiple files upload |
|
| 1421 | - else |
|
| 1422 | - $file_multiple = false; |
|
| 1419 | + if (isset($extra_fields['file_multiple']) && $extra_fields['file_multiple']) |
|
| 1420 | + $file_multiple = true; // allow multiple files upload |
|
| 1421 | + else |
|
| 1422 | + $file_multiple = false; |
|
| 1423 | 1423 | |
| 1424 | - if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) |
|
| 1425 | - $file_image_limit = $extra_fields['image_limit']; |
|
| 1426 | - else |
|
| 1427 | - $file_image_limit = 1; |
|
| 1424 | + if (isset($extra_fields['image_limit']) && $extra_fields['image_limit']) |
|
| 1425 | + $file_image_limit = $extra_fields['image_limit']; |
|
| 1426 | + else |
|
| 1427 | + $file_image_limit = 1; |
|
| 1428 | 1428 | |
| 1429 | - $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1429 | + $file_width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1430 | 1430 | |
| 1431 | - $file_height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1431 | + $file_height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1432 | 1432 | |
| 1433 | - if (!empty($file_value)) { |
|
| 1434 | - $curImages = explode(',', $file_value); |
|
| 1435 | - if (!empty($curImages)) |
|
| 1436 | - $file_totImg = count($curImages); |
|
| 1437 | - } |
|
| 1433 | + if (!empty($file_value)) { |
|
| 1434 | + $curImages = explode(',', $file_value); |
|
| 1435 | + if (!empty($curImages)) |
|
| 1436 | + $file_totImg = count($curImages); |
|
| 1437 | + } |
|
| 1438 | 1438 | |
| 1439 | - $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : ''; |
|
| 1440 | - $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : ''; |
|
| 1439 | + $allowed_file_types = !empty($extra_fields['gd_file_types']) && is_array($extra_fields['gd_file_types']) && !in_array("*", $extra_fields['gd_file_types'] ) ? implode(",", $extra_fields['gd_file_types']) : ''; |
|
| 1440 | + $display_file_types = $allowed_file_types != '' ? '.' . implode(", .", $extra_fields['gd_file_types']) : ''; |
|
| 1441 | 1441 | |
| 1442 | - ?> |
|
| 1442 | + ?> |
|
| 1443 | 1443 | <?php /*?> <h5 class="geodir-form_title"> <?php echo $site_title; ?> |
| 1444 | 1444 | <?php if($file_image_limit!=0 && $file_image_limit==1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('image with this package').')</small>';} ?> |
| 1445 | 1445 | <?php if($file_image_limit!=0 && $file_image_limit>1 ){echo '<br /><small>('.__('You can upload').' '.$file_image_limit.' '.__('images with this package').')</small>';} ?> |
| 1446 | 1446 | <?php if($file_image_limit==0){echo '<br /><small>('.__('You can upload unlimited images with this package').')</small>';} ?> |
| 1447 | 1447 | </h5> <?php */ |
| 1448 | - ?> |
|
| 1448 | + ?> |
|
| 1449 | 1449 | |
| 1450 | 1450 | <div id="<?php echo $name;?>_row" |
| 1451 | 1451 | class="<?php if ($is_required) echo 'required_field';?> geodir_form_row clearfix gd-fieldset-details"> |
@@ -1453,7 +1453,7 @@ discard block |
||
| 1453 | 1453 | <div id="<?php echo $file_id; ?>dropbox" style="text-align:center;"> |
| 1454 | 1454 | <label |
| 1455 | 1455 | style="text-align:left; padding-top:10px;"><?php $site_title = __($site_title, 'geodirectory'); |
| 1456 | - echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label> |
|
| 1456 | + echo $site_title; ?><?php if ($is_required) echo '<span>*</span>';?></label> |
|
| 1457 | 1457 | <input class="geodir-custom-file-upload" field_type="file" type="hidden" |
| 1458 | 1458 | name="<?php echo $file_id; ?>" id="<?php echo $file_id; ?>" |
| 1459 | 1459 | value="<?php echo esc_attr($file_value); ?>"/> |
@@ -1465,17 +1465,17 @@ discard block |
||
| 1465 | 1465 | <?php } ?> |
| 1466 | 1466 | <input type="hidden" name="<?php echo $file_id; ?>totImg" id="<?php echo $file_id; ?>totImg" |
| 1467 | 1467 | value="<?php if (isset($file_totImg)) { |
| 1468 | - echo esc_attr($file_totImg); |
|
| 1469 | - } else { |
|
| 1470 | - echo '0'; |
|
| 1471 | - } ?>"/> |
|
| 1468 | + echo esc_attr($file_totImg); |
|
| 1469 | + } else { |
|
| 1470 | + echo '0'; |
|
| 1471 | + } ?>"/> |
|
| 1472 | 1472 | |
| 1473 | 1473 | <div style="float:left; width:55%;"> |
| 1474 | 1474 | <div |
| 1475 | 1475 | class="plupload-upload-uic hide-if-no-js <?php if ($file_multiple): ?>plupload-upload-uic-multiple<?php endif; ?>" |
| 1476 | 1476 | id="<?php echo $file_id; ?>plupload-upload-ui" style="float:left; width:30%;"> |
| 1477 | 1477 | <?php /*?><h4><?php _e('Drop files to upload');?></h4><br/><?php */ |
| 1478 | - ?> |
|
| 1478 | + ?> |
|
| 1479 | 1479 | <input id="<?php echo $file_id; ?>plupload-browse-button" type="button" |
| 1480 | 1480 | value="<?php ($file_image_limit > 1 ? esc_attr_e('Select Files', 'geodirectory') : esc_attr_e('Select File', 'geodirectory') ); ?>" |
| 1481 | 1481 | class="geodir_button" style="margin-top:10px;"/> |
@@ -1494,7 +1494,7 @@ discard block |
||
| 1494 | 1494 | style=" clear:inherit; margin-top:0; margin-left:15px; padding-top:10px; float:left; width:50%;"> |
| 1495 | 1495 | </div> |
| 1496 | 1496 | <?php /*?><span id="upload-msg" ><?php _e('Please drag & drop the images to rearrange the order');?></span><?php */ |
| 1497 | - ?> |
|
| 1497 | + ?> |
|
| 1498 | 1498 | |
| 1499 | 1499 | <span id="<?php echo $file_id; ?>upload-error" style="display:none"></span> |
| 1500 | 1500 | |
@@ -1508,9 +1508,9 @@ discard block |
||
| 1508 | 1508 | |
| 1509 | 1509 | |
| 1510 | 1510 | <?php |
| 1511 | - $html = ob_get_clean(); |
|
| 1512 | - } |
|
| 1511 | + $html = ob_get_clean(); |
|
| 1512 | + } |
|
| 1513 | 1513 | |
| 1514 | - return $html; |
|
| 1514 | + return $html; |
|
| 1515 | 1515 | } |
| 1516 | 1516 | add_filter('geodir_custom_field_input_file','geodir_cfi_file',10,2); |
| 1517 | 1517 | \ No newline at end of file |
@@ -13,125 +13,125 @@ 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('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
|
|
| 115 | - } |
|
| 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('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL);
|
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - if ($geodir_map_name == 'osm') {
|
|
| 118 | - // Leaflet OpenStreetMap |
|
| 119 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 120 | - wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 117 | + if ($geodir_map_name == 'osm') {
|
|
| 118 | + // Leaflet OpenStreetMap |
|
| 119 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION);
|
|
| 120 | + wp_enqueue_style('geodirectory-leaflet-style');
|
|
| 121 | 121 | |
| 122 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 123 | - wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 122 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 123 | + wp_enqueue_script('geodirectory-leaflet-script');
|
|
| 124 | 124 | |
| 125 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 126 | - wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 127 | - } |
|
| 128 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 125 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION);
|
|
| 126 | + wp_enqueue_script('geodirectory-leaflet-geo-script');
|
|
| 127 | + } |
|
| 128 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
| 129 | 129 | |
| 130 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 131 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 130 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true);
|
|
| 131 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 132 | 132 | |
| 133 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 134 | - wp_enqueue_script('geodirectory-goMap-script');
|
|
| 133 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION);
|
|
| 134 | + wp_enqueue_script('geodirectory-goMap-script');
|
|
| 135 | 135 | |
| 136 | 136 | // font awesome rating script |
| 137 | 137 | if (get_option('geodir_reviewrating_enable_font_awesome')) {
|
@@ -142,167 +142,167 @@ discard block |
||
| 142 | 142 | wp_enqueue_script('geodir-jRating-js');
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 146 | - wp_enqueue_script('geodir-on-document-load');
|
|
| 147 | - |
|
| 148 | - |
|
| 149 | - // SCRIPT FOR UPLOAD |
|
| 150 | - wp_enqueue_script('plupload-all');
|
|
| 151 | - wp_enqueue_script('jquery-ui-sortable');
|
|
| 152 | - |
|
| 153 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 154 | - wp_enqueue_script('geodirectory-plupload-script');
|
|
| 155 | - |
|
| 156 | - // SCRIPT FOR UPLOAD END |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - // place js config array for plupload |
|
| 160 | - $plupload_init = array( |
|
| 161 | - 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 162 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 163 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 164 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 165 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 166 | - 'multiple_queues' => true, |
|
| 167 | - 'max_file_size' => geodir_max_upload_size(), |
|
| 168 | - 'url' => admin_url('admin-ajax.php'),
|
|
| 169 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 170 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 171 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 172 | - 'multipart' => true, |
|
| 173 | - 'urlstream_upload' => true, |
|
| 174 | - 'multi_selection' => false, // will be added per uploader |
|
| 175 | - // additional post data to send to our ajax hook |
|
| 176 | - 'multipart_params' => array( |
|
| 177 | - '_ajax_nonce' => "", // will be added per uploader |
|
| 178 | - 'action' => 'plupload_action', // the ajax action name |
|
| 179 | - 'imgid' => 0 // will be added per uploader |
|
| 180 | - ) |
|
| 181 | - ); |
|
| 182 | - $base_plupload_config = json_encode($plupload_init); |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - $thumb_img_arr = array(); |
|
| 186 | - |
|
| 187 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 188 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 189 | - |
|
| 190 | - $totImg = ''; |
|
| 191 | - $image_limit = ''; |
|
| 192 | - if (!empty($thumb_img_arr)) {
|
|
| 193 | - $totImg = count($thumb_img_arr); |
|
| 194 | - } |
|
| 145 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION);
|
|
| 146 | + wp_enqueue_script('geodir-on-document-load');
|
|
| 147 | + |
|
| 148 | + |
|
| 149 | + // SCRIPT FOR UPLOAD |
|
| 150 | + wp_enqueue_script('plupload-all');
|
|
| 151 | + wp_enqueue_script('jquery-ui-sortable');
|
|
| 152 | + |
|
| 153 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION);
|
|
| 154 | + wp_enqueue_script('geodirectory-plupload-script');
|
|
| 155 | + |
|
| 156 | + // SCRIPT FOR UPLOAD END |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + // place js config array for plupload |
|
| 160 | + $plupload_init = array( |
|
| 161 | + 'runtimes' => 'html5,silverlight,flash,html4', |
|
| 162 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
| 163 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
| 164 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
| 165 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
| 166 | + 'multiple_queues' => true, |
|
| 167 | + 'max_file_size' => geodir_max_upload_size(), |
|
| 168 | + 'url' => admin_url('admin-ajax.php'),
|
|
| 169 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'),
|
|
| 170 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'),
|
|
| 171 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')),
|
|
| 172 | + 'multipart' => true, |
|
| 173 | + 'urlstream_upload' => true, |
|
| 174 | + 'multi_selection' => false, // will be added per uploader |
|
| 175 | + // additional post data to send to our ajax hook |
|
| 176 | + 'multipart_params' => array( |
|
| 177 | + '_ajax_nonce' => "", // will be added per uploader |
|
| 178 | + 'action' => 'plupload_action', // the ajax action name |
|
| 179 | + 'imgid' => 0 // will be added per uploader |
|
| 180 | + ) |
|
| 181 | + ); |
|
| 182 | + $base_plupload_config = json_encode($plupload_init); |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + $thumb_img_arr = array(); |
|
| 186 | + |
|
| 187 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
| 188 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
| 189 | + |
|
| 190 | + $totImg = ''; |
|
| 191 | + $image_limit = ''; |
|
| 192 | + if (!empty($thumb_img_arr)) {
|
|
| 193 | + $totImg = count($thumb_img_arr); |
|
| 194 | + } |
|
| 195 | 195 | |
| 196 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 197 | - 'totalImg' => $totImg, |
|
| 198 | - 'image_limit' => $image_limit, |
|
| 199 | - 'upload_img_size' => geodir_max_upload_size()); |
|
| 196 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config,
|
|
| 197 | + 'totalImg' => $totImg, |
|
| 198 | + 'image_limit' => $image_limit, |
|
| 199 | + 'upload_img_size' => geodir_max_upload_size()); |
|
| 200 | 200 | |
| 201 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 201 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init);
|
|
| 202 | 202 | |
| 203 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 204 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 203 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php')));
|
|
| 204 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data);
|
|
| 205 | 205 | |
| 206 | 206 | |
| 207 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 208 | - wp_enqueue_script('geodirectory-admin-script');
|
|
| 207 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION);
|
|
| 208 | + wp_enqueue_script('geodirectory-admin-script');
|
|
| 209 | 209 | |
| 210 | - wp_enqueue_style('farbtastic');
|
|
| 211 | - wp_enqueue_script('farbtastic');
|
|
| 210 | + wp_enqueue_style('farbtastic');
|
|
| 211 | + wp_enqueue_script('farbtastic');
|
|
| 212 | 212 | |
| 213 | - $screen = get_current_screen(); |
|
| 214 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 215 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 216 | - } |
|
| 213 | + $screen = get_current_screen(); |
|
| 214 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) {
|
|
| 215 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js');
|
|
| 216 | + } |
|
| 217 | 217 | |
| 218 | - $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
|
|
| 219 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 218 | + $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true')));
|
|
| 219 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data);
|
|
| 220 | 220 | |
| 221 | - } |
|
| 221 | + } |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if (!function_exists('geodir_admin_menu')) {
|
| 225 | - /** |
|
| 226 | - * Admin Menus |
|
| 227 | - * |
|
| 228 | - * Sets up the admin menus in wordpress. |
|
| 229 | - * |
|
| 230 | - * @since 1.0.0 |
|
| 231 | - * @package GeoDirectory |
|
| 232 | - * @global array $menu Menu array. |
|
| 233 | - * @global object $geodirectory GeoDirectory plugin object. |
|
| 234 | - */ |
|
| 235 | - function geodir_admin_menu() |
|
| 236 | - {
|
|
| 237 | - global $menu, $geodirectory; |
|
| 225 | + /** |
|
| 226 | + * Admin Menus |
|
| 227 | + * |
|
| 228 | + * Sets up the admin menus in wordpress. |
|
| 229 | + * |
|
| 230 | + * @since 1.0.0 |
|
| 231 | + * @package GeoDirectory |
|
| 232 | + * @global array $menu Menu array. |
|
| 233 | + * @global object $geodirectory GeoDirectory plugin object. |
|
| 234 | + */ |
|
| 235 | + function geodir_admin_menu() |
|
| 236 | + {
|
|
| 237 | + global $menu, $geodirectory; |
|
| 238 | 238 | |
| 239 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 239 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory');
|
|
| 240 | 240 | |
| 241 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 241 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984');
|
|
| 242 | 242 | |
| 243 | 243 | |
| 244 | - } |
|
| 244 | + } |
|
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | if (!function_exists('geodir_admin_menu_order')) {
|
| 248 | - /** |
|
| 249 | - * Order admin menus. |
|
| 250 | - * |
|
| 251 | - * @since 1.0.0 |
|
| 252 | - * @package GeoDirectory |
|
| 253 | - * @param array $menu_order Menu order array. |
|
| 254 | - * @return array Modified menu order array. |
|
| 255 | - */ |
|
| 256 | - function geodir_admin_menu_order($menu_order) |
|
| 257 | - {
|
|
| 258 | - |
|
| 259 | - // Initialize our custom order array |
|
| 260 | - $geodir_menu_order = array(); |
|
| 261 | - |
|
| 262 | - // Get the index of our custom separator |
|
| 263 | - $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 264 | - |
|
| 265 | - // Get index of posttype menu |
|
| 266 | - $post_types = geodir_get_posttypes(); |
|
| 267 | - |
|
| 268 | - // Loop through menu order and do some rearranging |
|
| 269 | - foreach ($menu_order as $index => $item) : |
|
| 270 | - |
|
| 271 | - if ((('geodirectory') == $item)) :
|
|
| 272 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 273 | - if (!empty($post_types)) {
|
|
| 274 | - foreach ($post_types as $post_type) {
|
|
| 275 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - $geodir_menu_order[] = $item; |
|
| 248 | + /** |
|
| 249 | + * Order admin menus. |
|
| 250 | + * |
|
| 251 | + * @since 1.0.0 |
|
| 252 | + * @package GeoDirectory |
|
| 253 | + * @param array $menu_order Menu order array. |
|
| 254 | + * @return array Modified menu order array. |
|
| 255 | + */ |
|
| 256 | + function geodir_admin_menu_order($menu_order) |
|
| 257 | + {
|
|
| 279 | 258 | |
| 280 | - unset($menu_order[$geodir_separator]); |
|
| 281 | - //unset( $menu_order[$geodir_places] ); |
|
| 282 | - elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 283 | - $geodir_menu_order[] = $item; |
|
| 284 | - endif; |
|
| 259 | + // Initialize our custom order array |
|
| 260 | + $geodir_menu_order = array(); |
|
| 285 | 261 | |
| 286 | - endforeach; |
|
| 262 | + // Get the index of our custom separator |
|
| 263 | + $geodir_separator = array_search('separator-geodirectory', $menu_order);
|
|
| 287 | 264 | |
| 288 | - // Return order |
|
| 289 | - return $geodir_menu_order; |
|
| 290 | - } |
|
| 265 | + // Get index of posttype menu |
|
| 266 | + $post_types = geodir_get_posttypes(); |
|
| 267 | + |
|
| 268 | + // Loop through menu order and do some rearranging |
|
| 269 | + foreach ($menu_order as $index => $item) : |
|
| 270 | + |
|
| 271 | + if ((('geodirectory') == $item)) :
|
|
| 272 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
| 273 | + if (!empty($post_types)) {
|
|
| 274 | + foreach ($post_types as $post_type) {
|
|
| 275 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + $geodir_menu_order[] = $item; |
|
| 279 | + |
|
| 280 | + unset($menu_order[$geodir_separator]); |
|
| 281 | + //unset( $menu_order[$geodir_places] ); |
|
| 282 | + elseif (!in_array($item, array('separator-geodirectory'))) :
|
|
| 283 | + $geodir_menu_order[] = $item; |
|
| 284 | + endif; |
|
| 285 | + |
|
| 286 | + endforeach; |
|
| 287 | + |
|
| 288 | + // Return order |
|
| 289 | + return $geodir_menu_order; |
|
| 290 | + } |
|
| 291 | 291 | } |
| 292 | 292 | |
| 293 | 293 | if (!function_exists('geodir_admin_custom_menu_order')) {
|
| 294 | - /** |
|
| 295 | - * Enables custom menu order. |
|
| 296 | - * |
|
| 297 | - * @since 1.0.0 |
|
| 298 | - * @package GeoDirectory |
|
| 299 | - * @return bool |
|
| 300 | - */ |
|
| 301 | - function geodir_admin_custom_menu_order() |
|
| 302 | - {
|
|
| 303 | - if (!current_user_can('manage_options')) return false;
|
|
| 304 | - return true; |
|
| 305 | - } |
|
| 294 | + /** |
|
| 295 | + * Enables custom menu order. |
|
| 296 | + * |
|
| 297 | + * @since 1.0.0 |
|
| 298 | + * @package GeoDirectory |
|
| 299 | + * @return bool |
|
| 300 | + */ |
|
| 301 | + function geodir_admin_custom_menu_order() |
|
| 302 | + {
|
|
| 303 | + if (!current_user_can('manage_options')) return false;
|
|
| 304 | + return true; |
|
| 305 | + } |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | /** |
@@ -313,51 +313,51 @@ discard block |
||
| 313 | 313 | */ |
| 314 | 314 | function geodir_before_admin_panel() |
| 315 | 315 | {
|
| 316 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 317 | - echo '<div id="message" class="updated fade"> |
|
| 316 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') {
|
|
| 317 | + echo '<div id="message" class="updated fade"> |
|
| 318 | 318 | <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>
|
| 319 | 319 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p>
|
| 320 | 320 | </div>'; |
| 321 | 321 | |
| 322 | - } |
|
| 322 | + } |
|
| 323 | 323 | |
| 324 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 325 | - switch ($_REQUEST['msg']) {
|
|
| 326 | - case 'success': |
|
| 327 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 328 | - flush_rewrite_rules(false); |
|
| 324 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') {
|
|
| 325 | + switch ($_REQUEST['msg']) {
|
|
| 326 | + case 'success': |
|
| 327 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>';
|
|
| 328 | + flush_rewrite_rules(false); |
|
| 329 | 329 | |
| 330 | - break; |
|
| 330 | + break; |
|
| 331 | 331 | case 'fail': |
| 332 | 332 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
| 333 | 333 | |
| 334 | 334 | if ($gderr == 21) |
| 335 | - 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>';
|
|
| 335 | + 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>';
|
|
| 336 | 336 | else |
| 337 | 337 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>';
|
| 338 | - break; |
|
| 339 | - } |
|
| 340 | - } |
|
| 338 | + break; |
|
| 339 | + } |
|
| 340 | + } |
|
| 341 | 341 | |
| 342 | - $geodir_load_map = get_option('geodir_load_map');
|
|
| 343 | - $need_map_key = false; |
|
| 344 | - if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
|
|
| 345 | - $need_map_key = true; |
|
| 346 | - } |
|
| 342 | + $geodir_load_map = get_option('geodir_load_map');
|
|
| 343 | + $need_map_key = false; |
|
| 344 | + if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){
|
|
| 345 | + $need_map_key = true; |
|
| 346 | + } |
|
| 347 | 347 | |
| 348 | - if (!geodir_get_map_api_key() && $need_map_key) {
|
|
| 349 | - 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>';
|
|
| 350 | - } |
|
| 348 | + if (!geodir_get_map_api_key() && $need_map_key) {
|
|
| 349 | + 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>';
|
|
| 350 | + } |
|
| 351 | 351 | |
| 352 | - if (!geodir_is_default_location_set()) {
|
|
| 353 | - 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>';
|
|
| 352 | + if (!geodir_is_default_location_set()) {
|
|
| 353 | + 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>';
|
|
| 354 | 354 | |
| 355 | - } |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - if (!function_exists('curl_init')) {
|
|
| 358 | - 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>';
|
|
| 357 | + if (!function_exists('curl_init')) {
|
|
| 358 | + 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>';
|
|
| 359 | 359 | |
| 360 | - } |
|
| 360 | + } |
|
| 361 | 361 | |
| 362 | 362 | |
| 363 | 363 | |
@@ -374,19 +374,19 @@ discard block |
||
| 374 | 374 | */ |
| 375 | 375 | function geodir_handle_option_form_submit($current_tab) |
| 376 | 376 | {
|
| 377 | - global $geodir_settings; |
|
| 378 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 379 | - /** |
|
| 380 | - * Contains settings array for current tab. |
|
| 381 | - * |
|
| 382 | - * @since 1.0.0 |
|
| 383 | - * @package GeoDirectory |
|
| 384 | - */ |
|
| 385 | - include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 386 | - } |
|
| 387 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 388 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 389 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 377 | + global $geodir_settings; |
|
| 378 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) {
|
|
| 379 | + /** |
|
| 380 | + * Contains settings array for current tab. |
|
| 381 | + * |
|
| 382 | + * @since 1.0.0 |
|
| 383 | + * @package GeoDirectory |
|
| 384 | + */ |
|
| 385 | + include_once('option-pages/' . $current_tab . '_array.php');
|
|
| 386 | + } |
|
| 387 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
| 388 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 389 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory'));
|
|
| 390 | 390 | |
| 391 | 391 | /** |
| 392 | 392 | * Fires before updating geodirectory admin settings. |
@@ -398,38 +398,38 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | do_action('geodir_before_update_options', $current_tab, $geodir_settings);
|
| 400 | 400 | |
| 401 | - if (!empty($geodir_settings[$current_tab])) |
|
| 402 | - geodir_update_options($geodir_settings[$current_tab]); |
|
| 401 | + if (!empty($geodir_settings[$current_tab])) |
|
| 402 | + geodir_update_options($geodir_settings[$current_tab]); |
|
| 403 | 403 | |
| 404 | - /** |
|
| 405 | - * Called after GeoDirectory options settings are updated. |
|
| 406 | - * |
|
| 407 | - * @since 1.0.0 |
|
| 408 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 409 | - * @see 'geodir_before_update_options' |
|
| 410 | - */ |
|
| 411 | - do_action('geodir_update_options', $geodir_settings);
|
|
| 404 | + /** |
|
| 405 | + * Called after GeoDirectory options settings are updated. |
|
| 406 | + * |
|
| 407 | + * @since 1.0.0 |
|
| 408 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
| 409 | + * @see 'geodir_before_update_options' |
|
| 410 | + */ |
|
| 411 | + do_action('geodir_update_options', $geodir_settings);
|
|
| 412 | 412 | |
| 413 | - /** |
|
| 414 | - * Called after GeoDirectory options settings are updated. |
|
| 415 | - * |
|
| 416 | - * Provides tab specific settings. |
|
| 417 | - * |
|
| 418 | - * @since 1.0.0 |
|
| 419 | - * @param string $current_tab The current settings tab name. |
|
| 420 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 421 | - */ |
|
| 422 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 413 | + /** |
|
| 414 | + * Called after GeoDirectory options settings are updated. |
|
| 415 | + * |
|
| 416 | + * Provides tab specific settings. |
|
| 417 | + * |
|
| 418 | + * @since 1.0.0 |
|
| 419 | + * @param string $current_tab The current settings tab name. |
|
| 420 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
| 421 | + */ |
|
| 422 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]);
|
|
| 423 | 423 | |
| 424 | - flush_rewrite_rules(false); |
|
| 424 | + flush_rewrite_rules(false); |
|
| 425 | 425 | |
| 426 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 426 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
| 427 | 427 | |
| 428 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 428 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success');
|
|
| 429 | 429 | |
| 430 | - wp_redirect($redirect_url); |
|
| 431 | - exit(); |
|
| 432 | - endif; |
|
| 430 | + wp_redirect($redirect_url); |
|
| 431 | + exit(); |
|
| 432 | + endif; |
|
| 433 | 433 | |
| 434 | 434 | |
| 435 | 435 | } |
@@ -447,144 +447,144 @@ discard block |
||
| 447 | 447 | * @return bool Returns true if saved. |
| 448 | 448 | */ |
| 449 | 449 | function geodir_update_options($options, $dummy = false) {
|
| 450 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 450 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
| 451 | 451 | |
| 452 | - foreach ($options as $value) {
|
|
| 453 | - if ($dummy && isset($value['std'])) |
|
| 454 | - $_POST[$value['id']] = $value['std']; |
|
| 452 | + foreach ($options as $value) {
|
|
| 453 | + if ($dummy && isset($value['std'])) |
|
| 454 | + $_POST[$value['id']] = $value['std']; |
|
| 455 | 455 | |
| 456 | 456 | |
| 457 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 457 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
| 458 | 458 | |
| 459 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 460 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 461 | - } else {
|
|
| 462 | - update_option($value['id'], 0); |
|
| 463 | - } |
|
| 459 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 460 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 461 | + } else {
|
|
| 462 | + update_option($value['id'], 0); |
|
| 463 | + } |
|
| 464 | 464 | |
| 465 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 465 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
| 466 | 466 | |
| 467 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 468 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 469 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 470 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 471 | - update_option($value['id'] . '_crop', 1); |
|
| 472 | - else : |
|
| 473 | - update_option($value['id'] . '_crop', 0); |
|
| 474 | - endif; |
|
| 475 | - } else {
|
|
| 476 | - update_option($value['id'] . '_width', $value['std']); |
|
| 477 | - update_option($value['id'] . '_height', $value['std']); |
|
| 478 | - update_option($value['id'] . '_crop', 1); |
|
| 479 | - } |
|
| 467 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) {
|
|
| 468 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
| 469 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
| 470 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
| 471 | + update_option($value['id'] . '_crop', 1); |
|
| 472 | + else : |
|
| 473 | + update_option($value['id'] . '_crop', 0); |
|
| 474 | + endif; |
|
| 475 | + } else {
|
|
| 476 | + update_option($value['id'] . '_width', $value['std']); |
|
| 477 | + update_option($value['id'] . '_height', $value['std']); |
|
| 478 | + update_option($value['id'] . '_crop', 1); |
|
| 479 | + } |
|
| 480 | 480 | |
| 481 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 482 | - $post_types = array(); |
|
| 483 | - $categories = array(); |
|
| 481 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
| 482 | + $post_types = array(); |
|
| 483 | + $categories = array(); |
|
| 484 | 484 | |
| 485 | - if (!empty($_POST['home_map_post_types'])) : |
|
| 486 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 487 | - $post_types[] = $post_type; |
|
| 488 | - endforeach; |
|
| 489 | - endif; |
|
| 485 | + if (!empty($_POST['home_map_post_types'])) : |
|
| 486 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
| 487 | + $post_types[] = $post_type; |
|
| 488 | + endforeach; |
|
| 489 | + endif; |
|
| 490 | 490 | |
| 491 | - update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 491 | + update_option('geodir_exclude_post_type_on_map', $post_types);
|
|
| 492 | 492 | |
| 493 | - if (!empty($_POST['post_category'])) : |
|
| 494 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 495 | - $categories[$texonomy] = array(); |
|
| 496 | - foreach ($cat_arr as $category) : |
|
| 497 | - $categories[$texonomy][] = $category; |
|
| 498 | - endforeach; |
|
| 499 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 500 | - endforeach; |
|
| 501 | - endif; |
|
| 502 | - update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 503 | - update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 504 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 493 | + if (!empty($_POST['post_category'])) : |
|
| 494 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
| 495 | + $categories[$texonomy] = array(); |
|
| 496 | + foreach ($cat_arr as $category) : |
|
| 497 | + $categories[$texonomy][] = $category; |
|
| 498 | + endforeach; |
|
| 499 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
| 500 | + endforeach; |
|
| 501 | + endif; |
|
| 502 | + update_option('geodir_exclude_cat_on_map', $categories);
|
|
| 503 | + update_option('geodir_exclude_cat_on_map_upgrade', 1);
|
|
| 504 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
| 505 | 505 | |
| 506 | 506 | |
| 507 | - if (!empty($_POST['geodir_default_map_language'])): |
|
| 508 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 509 | - endif; |
|
| 507 | + if (!empty($_POST['geodir_default_map_language'])): |
|
| 508 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']);
|
|
| 509 | + endif; |
|
| 510 | 510 | |
| 511 | 511 | |
| 512 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 513 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 514 | - endif; |
|
| 512 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
| 513 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']);
|
|
| 514 | + endif; |
|
| 515 | 515 | |
| 516 | 516 | |
| 517 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 517 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
| 518 | 518 | |
| 519 | 519 | |
| 520 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 520 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file
|
|
| 521 | 521 | |
| 522 | - if (get_option($value['id'])) {
|
|
| 523 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 524 | - $noimg_name = end($image_name_arr); |
|
| 525 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 526 | - if (file_exists($img_path)) |
|
| 527 | - unlink($img_path); |
|
| 528 | - } |
|
| 522 | + if (get_option($value['id'])) {
|
|
| 523 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 524 | + $noimg_name = end($image_name_arr); |
|
| 525 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 526 | + if (file_exists($img_path)) |
|
| 527 | + unlink($img_path); |
|
| 528 | + } |
|
| 529 | 529 | |
| 530 | - update_option($value['id'], ''); |
|
| 531 | - } |
|
| 530 | + update_option($value['id'], ''); |
|
| 531 | + } |
|
| 532 | 532 | |
| 533 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 534 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 535 | - |
|
| 536 | - if (!empty($filename)): |
|
| 537 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 538 | - $uplaods = array(); |
|
| 539 | - |
|
| 540 | - foreach ($uploadedfile as $key => $uplaod): |
|
| 541 | - if ($key == 'name'): |
|
| 542 | - $uplaods[$key] = $filename; |
|
| 543 | - else : |
|
| 544 | - $uplaods[$key] = $uplaod; |
|
| 545 | - endif; |
|
| 546 | - endforeach; |
|
| 547 | - |
|
| 548 | - $uploads = wp_upload_dir(); |
|
| 549 | - |
|
| 550 | - if (get_option($value['id'])) {
|
|
| 551 | - $image_name_arr = explode('/', get_option($value['id']));
|
|
| 552 | - $noimg_name = end($image_name_arr); |
|
| 553 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 554 | - if (file_exists($img_path)) |
|
| 555 | - unlink($img_path); |
|
| 556 | - } |
|
| 533 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
| 534 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
| 535 | + |
|
| 536 | + if (!empty($filename)): |
|
| 537 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
| 538 | + $uplaods = array(); |
|
| 539 | + |
|
| 540 | + foreach ($uploadedfile as $key => $uplaod): |
|
| 541 | + if ($key == 'name'): |
|
| 542 | + $uplaods[$key] = $filename; |
|
| 543 | + else : |
|
| 544 | + $uplaods[$key] = $uplaod; |
|
| 545 | + endif; |
|
| 546 | + endforeach; |
|
| 547 | + |
|
| 548 | + $uploads = wp_upload_dir(); |
|
| 549 | + |
|
| 550 | + if (get_option($value['id'])) {
|
|
| 551 | + $image_name_arr = explode('/', get_option($value['id']));
|
|
| 552 | + $noimg_name = end($image_name_arr); |
|
| 553 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
| 554 | + if (file_exists($img_path)) |
|
| 555 | + unlink($img_path); |
|
| 556 | + } |
|
| 557 | 557 | |
| 558 | - $upload_overrides = array('test_form' => false);
|
|
| 559 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 558 | + $upload_overrides = array('test_form' => false);
|
|
| 559 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
| 560 | 560 | |
| 561 | - update_option($value['id'], $movefile['url']); |
|
| 561 | + update_option($value['id'], $movefile['url']); |
|
| 562 | 562 | |
| 563 | - endif; |
|
| 563 | + endif; |
|
| 564 | 564 | |
| 565 | - if (!get_option($value['id']) && isset($value['value'])): |
|
| 566 | - update_option($value['id'], $value['value']); |
|
| 567 | - endif; |
|
| 565 | + if (!get_option($value['id']) && isset($value['value'])): |
|
| 566 | + update_option($value['id'], $value['value']); |
|
| 567 | + endif; |
|
| 568 | 568 | |
| 569 | 569 | |
| 570 | - else : |
|
| 571 | - // same menu setting per theme. |
|
| 572 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 573 | - $theme = wp_get_theme(); |
|
| 574 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 575 | - } |
|
| 570 | + else : |
|
| 571 | + // same menu setting per theme. |
|
| 572 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) {
|
|
| 573 | + $theme = wp_get_theme(); |
|
| 574 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]);
|
|
| 575 | + } |
|
| 576 | 576 | |
| 577 | - if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 578 | - update_option($value['id'], $_POST[$value['id']]); |
|
| 579 | - } else {
|
|
| 580 | - delete_option($value['id']); |
|
| 581 | - } |
|
| 577 | + if (isset($value['id']) && isset($_POST[$value['id']])) {
|
|
| 578 | + update_option($value['id'], $_POST[$value['id']]); |
|
| 579 | + } else {
|
|
| 580 | + delete_option($value['id']); |
|
| 581 | + } |
|
| 582 | 582 | |
| 583 | - endif; |
|
| 584 | - } |
|
| 585 | - if ($dummy) |
|
| 586 | - $_POST = array(); |
|
| 587 | - return true; |
|
| 583 | + endif; |
|
| 584 | + } |
|
| 585 | + if ($dummy) |
|
| 586 | + $_POST = array(); |
|
| 587 | + return true; |
|
| 588 | 588 | |
| 589 | 589 | } |
| 590 | 590 | |
@@ -633,33 +633,33 @@ discard block |
||
| 633 | 633 | function places_custom_fields_tab($tabs) |
| 634 | 634 | {
|
| 635 | 635 | |
| 636 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 636 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 637 | 637 | |
| 638 | - if (!empty($geodir_post_types)) {
|
|
| 638 | + if (!empty($geodir_post_types)) {
|
|
| 639 | 639 | |
| 640 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 640 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
| 641 | 641 | |
| 642 | - $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
| 642 | + $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
| 643 | 643 | |
| 644 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 645 | - 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
|
|
| 646 | - 'subtabs' => array( |
|
| 647 | - array('subtab' => 'custom_fields',
|
|
| 648 | - 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 649 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 650 | - array('subtab' => 'sorting_options',
|
|
| 651 | - 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 652 | - 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 653 | - ), |
|
| 654 | - 'tab_index' => 9, |
|
| 655 | - 'request' => array('listing_type' => $geodir_post_type)
|
|
| 656 | - ); |
|
| 644 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
| 645 | + 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug),
|
|
| 646 | + 'subtabs' => array( |
|
| 647 | + array('subtab' => 'custom_fields',
|
|
| 648 | + 'label' => __('Custom Fields', 'geodirectory'),
|
|
| 649 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 650 | + array('subtab' => 'sorting_options',
|
|
| 651 | + 'label' => __('Sorting Options', 'geodirectory'),
|
|
| 652 | + 'request' => array('listing_type' => $geodir_post_type)),
|
|
| 653 | + ), |
|
| 654 | + 'tab_index' => 9, |
|
| 655 | + 'request' => array('listing_type' => $geodir_post_type)
|
|
| 656 | + ); |
|
| 657 | 657 | |
| 658 | - endforeach; |
|
| 658 | + endforeach; |
|
| 659 | 659 | |
| 660 | - } |
|
| 660 | + } |
|
| 661 | 661 | |
| 662 | - return $tabs; |
|
| 662 | + return $tabs; |
|
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | |
@@ -675,9 +675,9 @@ discard block |
||
| 675 | 675 | */ |
| 676 | 676 | function geodir_tools_setting_tab($tabs) |
| 677 | 677 | {
|
| 678 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 679 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 680 | - return $tabs; |
|
| 678 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
| 679 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory'));
|
|
| 680 | + return $tabs; |
|
| 681 | 681 | } |
| 682 | 682 | |
| 683 | 683 | /** |
@@ -692,8 +692,8 @@ discard block |
||
| 692 | 692 | */ |
| 693 | 693 | function geodir_compatibility_setting_tab($tabs) |
| 694 | 694 | {
|
| 695 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 696 | - return $tabs; |
|
| 695 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory'));
|
|
| 696 | + return $tabs; |
|
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | |
@@ -709,144 +709,144 @@ discard block |
||
| 709 | 709 | */ |
| 710 | 710 | function geodir_extend_geodirectory_setting_tab($tabs) |
| 711 | 711 | {
|
| 712 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
|
|
| 713 | - return $tabs; |
|
| 712 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank');
|
|
| 713 | + return $tabs; |
|
| 714 | 714 | } |
| 715 | 715 | |
| 716 | 716 | |
| 717 | 717 | if (!function_exists('geodir_edit_post_columns')) {
|
| 718 | - /** |
|
| 719 | - * Modify admin post listing page columns. |
|
| 720 | - * |
|
| 721 | - * @since 1.0.0 |
|
| 722 | - * @package GeoDirectory |
|
| 723 | - * @param array $columns The column array. |
|
| 724 | - * @return array Altered column array. |
|
| 725 | - */ |
|
| 726 | - function geodir_edit_post_columns($columns) |
|
| 727 | - {
|
|
| 728 | - |
|
| 729 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 730 | - 'categorys' => __('Categories', 'geodirectory'));
|
|
| 731 | - |
|
| 732 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 733 | - {
|
|
| 734 | - $offset = 0; // should we prepend $array with $data? |
|
| 735 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 736 | - } |
|
| 718 | + /** |
|
| 719 | + * Modify admin post listing page columns. |
|
| 720 | + * |
|
| 721 | + * @since 1.0.0 |
|
| 722 | + * @package GeoDirectory |
|
| 723 | + * @param array $columns The column array. |
|
| 724 | + * @return array Altered column array. |
|
| 725 | + */ |
|
| 726 | + function geodir_edit_post_columns($columns) |
|
| 727 | + {
|
|
| 737 | 728 | |
| 738 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 729 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'),
|
|
| 730 | + 'categorys' => __('Categories', 'geodirectory'));
|
|
| 739 | 731 | |
| 740 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 732 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist
|
|
| 733 | + {
|
|
| 734 | + $offset = 0; // should we prepend $array with $data? |
|
| 735 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
| 736 | + } |
|
| 741 | 737 | |
| 742 | - return $columns; |
|
| 743 | - } |
|
| 738 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
| 739 | + |
|
| 740 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory')));
|
|
| 741 | + |
|
| 742 | + return $columns; |
|
| 743 | + } |
|
| 744 | 744 | } |
| 745 | 745 | |
| 746 | 746 | |
| 747 | 747 | if (!function_exists('geodir_manage_post_columns')) {
|
| 748 | - /** |
|
| 749 | - * Adds content to our custom post listing page columns. |
|
| 750 | - * |
|
| 751 | - * @since 1.0.0 |
|
| 752 | - * @package GeoDirectory |
|
| 753 | - * @global object $wpdb WordPress Database object. |
|
| 754 | - * @global object $post WordPress Post object. |
|
| 755 | - * @param string $column The column name. |
|
| 756 | - * @param int $post_id The post ID. |
|
| 757 | - */ |
|
| 758 | - function geodir_manage_post_columns($column, $post_id) |
|
| 759 | - {
|
|
| 760 | - global $post, $wpdb; |
|
| 761 | - |
|
| 762 | - switch ($column): |
|
| 763 | - /* If displaying the 'city' column. */ |
|
| 764 | - case 'location' : |
|
| 765 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 766 | - $location = geodir_get_location($location_id); |
|
| 767 | - /* If no city is found, output a default message. */ |
|
| 768 | - if (empty($location)) {
|
|
| 769 | - _e('Unknown', 'geodirectory');
|
|
| 770 | - } else {
|
|
| 771 | - /* If there is a city id, append 'city name' to the text string. */ |
|
| 772 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 773 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 774 | - } |
|
| 775 | - break; |
|
| 776 | - |
|
| 777 | - /* If displaying the 'expire' column. */ |
|
| 778 | - case 'expire' : |
|
| 779 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 780 | - $d1 = $expire_date; // get expire_date |
|
| 781 | - $d2 = date('Y-m-d'); // get current date
|
|
| 782 | - $state = __('days left', 'geodirectory');
|
|
| 783 | - $date_diff_text = ''; |
|
| 784 | - $expire_class = 'expire_left'; |
|
| 785 | - if ($expire_date != 'Never') {
|
|
| 786 | - if (strtotime($d1) < strtotime($d2)) {
|
|
| 787 | - $state = __('days overdue', 'geodirectory');
|
|
| 788 | - $expire_class = 'expire_over'; |
|
| 789 | - } |
|
| 790 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 791 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 792 | - } |
|
| 793 | - /* If no expire_date is found, output a default message. */ |
|
| 794 | - if (empty($expire_date)) |
|
| 795 | - echo __('Unknown', 'geodirectory');
|
|
| 796 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 797 | - else |
|
| 798 | - echo $expire_date . $date_diff_text; |
|
| 799 | - break; |
|
| 800 | - |
|
| 801 | - /* If displaying the 'categorys' column. */ |
|
| 802 | - case 'categorys' : |
|
| 803 | - |
|
| 804 | - /* Get the categorys for the post. */ |
|
| 805 | - |
|
| 806 | - |
|
| 807 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 808 | - |
|
| 809 | - /* If terms were found. */ |
|
| 810 | - if (!empty($terms)) {
|
|
| 811 | - $out = array(); |
|
| 812 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 813 | - foreach ($terms as $term) {
|
|
| 814 | - if (!strstr($term->taxonomy, 'tag')) {
|
|
| 815 | - $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 816 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 817 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 818 | - ); |
|
| 819 | - } |
|
| 820 | - } |
|
| 821 | - /* Join the terms, separating them with a comma. */ |
|
| 822 | - echo(join(', ', $out));
|
|
| 823 | - } /* If no terms were found, output a default message. */ |
|
| 824 | - else {
|
|
| 825 | - _e('No Categories', 'geodirectory');
|
|
| 826 | - } |
|
| 827 | - break; |
|
| 748 | + /** |
|
| 749 | + * Adds content to our custom post listing page columns. |
|
| 750 | + * |
|
| 751 | + * @since 1.0.0 |
|
| 752 | + * @package GeoDirectory |
|
| 753 | + * @global object $wpdb WordPress Database object. |
|
| 754 | + * @global object $post WordPress Post object. |
|
| 755 | + * @param string $column The column name. |
|
| 756 | + * @param int $post_id The post ID. |
|
| 757 | + */ |
|
| 758 | + function geodir_manage_post_columns($column, $post_id) |
|
| 759 | + {
|
|
| 760 | + global $post, $wpdb; |
|
| 761 | + |
|
| 762 | + switch ($column): |
|
| 763 | + /* If displaying the 'city' column. */ |
|
| 764 | + case 'location' : |
|
| 765 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
| 766 | + $location = geodir_get_location($location_id); |
|
| 767 | + /* If no city is found, output a default message. */ |
|
| 768 | + if (empty($location)) {
|
|
| 769 | + _e('Unknown', 'geodirectory');
|
|
| 770 | + } else {
|
|
| 771 | + /* If there is a city id, append 'city name' to the text string. */ |
|
| 772 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : '';
|
|
| 773 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
| 774 | + } |
|
| 775 | + break; |
|
| 776 | + |
|
| 777 | + /* If displaying the 'expire' column. */ |
|
| 778 | + case 'expire' : |
|
| 779 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
| 780 | + $d1 = $expire_date; // get expire_date |
|
| 781 | + $d2 = date('Y-m-d'); // get current date
|
|
| 782 | + $state = __('days left', 'geodirectory');
|
|
| 783 | + $date_diff_text = ''; |
|
| 784 | + $expire_class = 'expire_left'; |
|
| 785 | + if ($expire_date != 'Never') {
|
|
| 786 | + if (strtotime($d1) < strtotime($d2)) {
|
|
| 787 | + $state = __('days overdue', 'geodirectory');
|
|
| 788 | + $expire_class = 'expire_over'; |
|
| 789 | + } |
|
| 790 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
| 791 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>';
|
|
| 792 | + } |
|
| 793 | + /* If no expire_date is found, output a default message. */ |
|
| 794 | + if (empty($expire_date)) |
|
| 795 | + echo __('Unknown', 'geodirectory');
|
|
| 796 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
| 797 | + else |
|
| 798 | + echo $expire_date . $date_diff_text; |
|
| 799 | + break; |
|
| 828 | 800 | |
| 829 | - endswitch; |
|
| 830 | - } |
|
| 801 | + /* If displaying the 'categorys' column. */ |
|
| 802 | + case 'categorys' : |
|
| 803 | + |
|
| 804 | + /* Get the categorys for the post. */ |
|
| 805 | + |
|
| 806 | + |
|
| 807 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
| 808 | + |
|
| 809 | + /* If terms were found. */ |
|
| 810 | + if (!empty($terms)) {
|
|
| 811 | + $out = array(); |
|
| 812 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
| 813 | + foreach ($terms as $term) {
|
|
| 814 | + if (!strstr($term->taxonomy, 'tag')) {
|
|
| 815 | + $out[] = sprintf('<a href="%s">%s</a>',
|
|
| 816 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')),
|
|
| 817 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display'))
|
|
| 818 | + ); |
|
| 819 | + } |
|
| 820 | + } |
|
| 821 | + /* Join the terms, separating them with a comma. */ |
|
| 822 | + echo(join(', ', $out));
|
|
| 823 | + } /* If no terms were found, output a default message. */ |
|
| 824 | + else {
|
|
| 825 | + _e('No Categories', 'geodirectory');
|
|
| 826 | + } |
|
| 827 | + break; |
|
| 828 | + |
|
| 829 | + endswitch; |
|
| 830 | + } |
|
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | |
| 834 | 834 | if (!function_exists('geodir_post_sortable_columns')) {
|
| 835 | - /** |
|
| 836 | - * Makes admin post listing page columns sortable. |
|
| 837 | - * |
|
| 838 | - * @since 1.0.0 |
|
| 839 | - * @package GeoDirectory |
|
| 840 | - * @param array $columns The column array. |
|
| 841 | - * @return array Altered column array. |
|
| 842 | - */ |
|
| 843 | - function geodir_post_sortable_columns($columns) |
|
| 844 | - {
|
|
| 845 | - |
|
| 846 | - $columns['expire'] = 'expire'; |
|
| 847 | - |
|
| 848 | - return $columns; |
|
| 849 | - } |
|
| 835 | + /** |
|
| 836 | + * Makes admin post listing page columns sortable. |
|
| 837 | + * |
|
| 838 | + * @since 1.0.0 |
|
| 839 | + * @package GeoDirectory |
|
| 840 | + * @param array $columns The column array. |
|
| 841 | + * @return array Altered column array. |
|
| 842 | + */ |
|
| 843 | + function geodir_post_sortable_columns($columns) |
|
| 844 | + {
|
|
| 845 | + |
|
| 846 | + $columns['expire'] = 'expire'; |
|
| 847 | + |
|
| 848 | + return $columns; |
|
| 849 | + } |
|
| 850 | 850 | } |
| 851 | 851 | |
| 852 | 852 | /** |
@@ -860,32 +860,32 @@ discard block |
||
| 860 | 860 | * @param int $post_id The post ID. |
| 861 | 861 | */ |
| 862 | 862 | function geodir_post_information_save($post_id, $post) {
|
| 863 | - global $wpdb, $current_user; |
|
| 863 | + global $wpdb, $current_user; |
|
| 864 | 864 | |
| 865 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 866 | - return; |
|
| 867 | - } |
|
| 865 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) {
|
|
| 866 | + return; |
|
| 867 | + } |
|
| 868 | 868 | |
| 869 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 869 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 870 | 870 | |
| 871 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 872 | - return; |
|
| 871 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE)
|
|
| 872 | + return; |
|
| 873 | 873 | |
| 874 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 875 | - if (isset($_REQUEST['_status'])) |
|
| 876 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 874 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) {
|
|
| 875 | + if (isset($_REQUEST['_status'])) |
|
| 876 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
| 877 | 877 | |
| 878 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 879 | - return; |
|
| 878 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
| 879 | + return; |
|
| 880 | 880 | |
| 881 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 882 | - return; |
|
| 881 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
| 882 | + return; |
|
| 883 | 883 | |
| 884 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 885 | - return; |
|
| 884 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
| 885 | + return; |
|
| 886 | 886 | |
| 887 | - geodir_save_listing($_REQUEST); |
|
| 888 | - } |
|
| 887 | + geodir_save_listing($_REQUEST); |
|
| 888 | + } |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | /** |
@@ -901,102 +901,102 @@ discard block |
||
| 901 | 901 | */ |
| 902 | 902 | function geodir_admin_fields($options) |
| 903 | 903 | {
|
| 904 | - global $geodirectory; |
|
| 905 | - |
|
| 906 | - $first_title = true; |
|
| 907 | - $tab_id = ''; |
|
| 908 | - $i = 0; |
|
| 909 | - foreach ($options as $value) : |
|
| 910 | - if (!isset($value['name'])) $value['name'] = ''; |
|
| 911 | - if (!isset($value['class'])) $value['class'] = ''; |
|
| 912 | - if (!isset($value['css'])) $value['css'] = ''; |
|
| 913 | - if (!isset($value['std'])) $value['std'] = ''; |
|
| 914 | - $desc = ''; |
|
| 915 | - switch ($value['type']) : |
|
| 916 | - case 'dummy_installer': |
|
| 917 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 918 | - geodir_autoinstall_admin_header($post_type); |
|
| 919 | - break; |
|
| 920 | - case 'title': |
|
| 921 | - |
|
| 922 | - if ($i == 0) {
|
|
| 923 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 924 | - echo '<div class="inner_content_tab_main">'; |
|
| 925 | - } |
|
| 904 | + global $geodirectory; |
|
| 905 | + |
|
| 906 | + $first_title = true; |
|
| 907 | + $tab_id = ''; |
|
| 908 | + $i = 0; |
|
| 909 | + foreach ($options as $value) : |
|
| 910 | + if (!isset($value['name'])) $value['name'] = ''; |
|
| 911 | + if (!isset($value['class'])) $value['class'] = ''; |
|
| 912 | + if (!isset($value['css'])) $value['css'] = ''; |
|
| 913 | + if (!isset($value['std'])) $value['std'] = ''; |
|
| 914 | + $desc = ''; |
|
| 915 | + switch ($value['type']) : |
|
| 916 | + case 'dummy_installer': |
|
| 917 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
| 918 | + geodir_autoinstall_admin_header($post_type); |
|
| 919 | + break; |
|
| 920 | + case 'title': |
|
| 921 | + |
|
| 922 | + if ($i == 0) {
|
|
| 923 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
| 924 | + echo '<div class="inner_content_tab_main">'; |
|
| 925 | + } |
|
| 926 | 926 | |
| 927 | - $i++; |
|
| 927 | + $i++; |
|
| 928 | 928 | |
| 929 | - if (isset($value['id']) && $value['id']) |
|
| 930 | - $tab_id = $value['id']; |
|
| 929 | + if (isset($value['id']) && $value['id']) |
|
| 930 | + $tab_id = $value['id']; |
|
| 931 | 931 | |
| 932 | - if (isset($value['desc']) && $value['desc']) |
|
| 933 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 932 | + if (isset($value['desc']) && $value['desc']) |
|
| 933 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
| 934 | 934 | |
| 935 | - if (isset($value['name']) && $value['name']) {
|
|
| 936 | - if ($first_title === true) {
|
|
| 937 | - $first_title = false; |
|
| 938 | - } else {
|
|
| 939 | - echo '</div>'; |
|
| 940 | - } |
|
| 941 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 935 | + if (isset($value['name']) && $value['name']) {
|
|
| 936 | + if ($first_title === true) {
|
|
| 937 | + $first_title = false; |
|
| 938 | + } else {
|
|
| 939 | + echo '</div>'; |
|
| 940 | + } |
|
| 941 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
| 942 | 942 | |
| 943 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 944 | - } |
|
| 943 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 944 | + } |
|
| 945 | 945 | |
| 946 | - /** |
|
| 947 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 948 | - * |
|
| 949 | - * The action is called dynamically geodir_settings_$value['id']. |
|
| 950 | - * |
|
| 951 | - * @since 1.0.0 |
|
| 952 | - */ |
|
| 953 | - do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 954 | - break; |
|
| 955 | - |
|
| 956 | - case 'no_tabs': |
|
| 957 | - |
|
| 958 | - echo '<div class="inner_content_tab_main">'; |
|
| 959 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 960 | - |
|
| 961 | - break; |
|
| 962 | - |
|
| 963 | - case 'sectionstart': |
|
| 964 | - if (isset($value['desc']) && $value['desc']) |
|
| 965 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 966 | - if (isset($value['name']) && $value['name']) |
|
| 967 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 968 | - /** |
|
| 969 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 970 | - * |
|
| 971 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 972 | - * |
|
| 973 | - * @since 1.0.0 |
|
| 974 | - */ |
|
| 975 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 976 | - echo '<table class="form-table">' . "\n\n"; |
|
| 977 | - |
|
| 978 | - break; |
|
| 979 | - case 'sectionend': |
|
| 980 | - /** |
|
| 981 | - * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 982 | - * |
|
| 983 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 984 | - * |
|
| 985 | - * @since 1.0.0 |
|
| 986 | - */ |
|
| 987 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 988 | - echo '</table>'; |
|
| 989 | - /** |
|
| 990 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 991 | - * |
|
| 992 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 993 | - * |
|
| 994 | - * @since 1.0.0 |
|
| 995 | - */ |
|
| 996 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 997 | - break; |
|
| 998 | - case 'text': |
|
| 999 | - ?> |
|
| 946 | + /** |
|
| 947 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
| 948 | + * |
|
| 949 | + * The action is called dynamically geodir_settings_$value['id']. |
|
| 950 | + * |
|
| 951 | + * @since 1.0.0 |
|
| 952 | + */ |
|
| 953 | + do_action('geodir_settings_' . sanitize_title($value['id']));
|
|
| 954 | + break; |
|
| 955 | + |
|
| 956 | + case 'no_tabs': |
|
| 957 | + |
|
| 958 | + echo '<div class="inner_content_tab_main">'; |
|
| 959 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
| 960 | + |
|
| 961 | + break; |
|
| 962 | + |
|
| 963 | + case 'sectionstart': |
|
| 964 | + if (isset($value['desc']) && $value['desc']) |
|
| 965 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
| 966 | + if (isset($value['name']) && $value['name']) |
|
| 967 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
| 968 | + /** |
|
| 969 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
| 970 | + * |
|
| 971 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
| 972 | + * |
|
| 973 | + * @since 1.0.0 |
|
| 974 | + */ |
|
| 975 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start');
|
|
| 976 | + echo '<table class="form-table">' . "\n\n"; |
|
| 977 | + |
|
| 978 | + break; |
|
| 979 | + case 'sectionend': |
|
| 980 | + /** |
|
| 981 | + * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 982 | + * |
|
| 983 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 984 | + * |
|
| 985 | + * @since 1.0.0 |
|
| 986 | + */ |
|
| 987 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end');
|
|
| 988 | + echo '</table>'; |
|
| 989 | + /** |
|
| 990 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
| 991 | + * |
|
| 992 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
| 993 | + * |
|
| 994 | + * @since 1.0.0 |
|
| 995 | + */ |
|
| 996 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after');
|
|
| 997 | + break; |
|
| 998 | + case 'text': |
|
| 999 | + ?> |
|
| 1000 | 1000 | <tr valign="top"> |
| 1001 | 1001 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1002 | 1002 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1005,15 +1005,15 @@ discard block |
||
| 1005 | 1005 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1006 | 1006 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1007 | 1007 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1008 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1009 | - } else {
|
|
| 1010 | - echo esc_attr($value['std']); |
|
| 1011 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1008 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1009 | + } else {
|
|
| 1010 | + echo esc_attr($value['std']); |
|
| 1011 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1012 | 1012 | </tr><?php |
| 1013 | - break; |
|
| 1013 | + break; |
|
| 1014 | 1014 | |
| 1015 | - case 'map-key': |
|
| 1016 | - ?> |
|
| 1015 | + case 'map-key': |
|
| 1016 | + ?> |
|
| 1017 | 1017 | <tr valign="top"> |
| 1018 | 1018 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1019 | 1019 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1022,17 +1022,17 @@ discard block |
||
| 1022 | 1022 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1023 | 1023 | style=" <?php echo esc_attr($value['css']); ?>" |
| 1024 | 1024 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1025 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1026 | - } else {
|
|
| 1027 | - echo esc_attr($value['std']); |
|
| 1028 | - } ?>"/> |
|
| 1025 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1026 | + } else {
|
|
| 1027 | + echo esc_attr($value['std']); |
|
| 1028 | + } ?>"/> |
|
| 1029 | 1029 | <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>
|
| 1030 | 1030 | <span class="description"><?php echo $value['desc']; ?></span></td> |
| 1031 | 1031 | </tr><?php |
| 1032 | - break; |
|
| 1032 | + break; |
|
| 1033 | 1033 | |
| 1034 | - case 'password': |
|
| 1035 | - ?> |
|
| 1034 | + case 'password': |
|
| 1035 | + ?> |
|
| 1036 | 1036 | <tr valign="top"> |
| 1037 | 1037 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1038 | 1038 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1041,42 +1041,42 @@ discard block |
||
| 1041 | 1041 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?>
|
| 1042 | 1042 | style="<?php echo esc_attr($value['css']); ?>" |
| 1043 | 1043 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1044 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1045 | - } else {
|
|
| 1046 | - echo esc_attr($value['std']); |
|
| 1047 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1044 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1045 | + } else {
|
|
| 1046 | + echo esc_attr($value['std']); |
|
| 1047 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
| 1048 | 1048 | </tr><?php |
| 1049 | - break; |
|
| 1049 | + break; |
|
| 1050 | 1050 | |
| 1051 | - case 'html_content': |
|
| 1052 | - ?> |
|
| 1051 | + case 'html_content': |
|
| 1052 | + ?> |
|
| 1053 | 1053 | <tr valign="top"> |
| 1054 | 1054 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1055 | 1055 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
| 1056 | 1056 | </tr><?php |
| 1057 | - break; |
|
| 1057 | + break; |
|
| 1058 | 1058 | |
| 1059 | - case 'color' : |
|
| 1060 | - ?> |
|
| 1059 | + case 'color' : |
|
| 1060 | + ?> |
|
| 1061 | 1061 | <tr valign="top"> |
| 1062 | 1062 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1063 | 1063 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
| 1064 | 1064 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
| 1065 | 1065 | style="<?php echo esc_attr($value['css']); ?>" |
| 1066 | 1066 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) {
|
| 1067 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1068 | - } else {
|
|
| 1069 | - echo esc_attr($value['std']); |
|
| 1070 | - } ?>" class="colorpick"/> <span |
|
| 1067 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
| 1068 | + } else {
|
|
| 1069 | + echo esc_attr($value['std']); |
|
| 1070 | + } ?>" class="colorpick"/> <span |
|
| 1071 | 1071 | class="description"><?php echo $value['desc']; ?></span> |
| 1072 | 1072 | |
| 1073 | 1073 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
| 1074 | 1074 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
| 1075 | 1075 | </td> |
| 1076 | 1076 | </tr><?php |
| 1077 | - break; |
|
| 1078 | - case 'image_width' : |
|
| 1079 | - ?> |
|
| 1077 | + break; |
|
| 1078 | + case 'image_width' : |
|
| 1079 | + ?> |
|
| 1080 | 1080 | <tr valign="top"> |
| 1081 | 1081 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1082 | 1082 | <td class="forminp"> |
@@ -1098,11 +1098,11 @@ discard block |
||
| 1098 | 1098 | |
| 1099 | 1099 | <span class="description"><?php echo $value['desc'] ?></span></td> |
| 1100 | 1100 | </tr><?php |
| 1101 | - break; |
|
| 1102 | - case 'select': |
|
| 1103 | - $option_value = get_option($value['id']); |
|
| 1104 | - $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1105 | - ?> |
|
| 1101 | + break; |
|
| 1102 | + case 'select': |
|
| 1103 | + $option_value = get_option($value['id']); |
|
| 1104 | + $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
| 1105 | + ?> |
|
| 1106 | 1106 | <tr valign="top"> |
| 1107 | 1107 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1108 | 1108 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1111,33 +1111,33 @@ discard block |
||
| 1111 | 1111 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
| 1112 | 1112 | option-ajaxchosen="false"> |
| 1113 | 1113 | <?php |
| 1114 | - foreach ($value['options'] as $key => $val) {
|
|
| 1115 | - $geodir_select_value = ''; |
|
| 1116 | - if ($option_value != '') {
|
|
| 1117 | - if ($option_value != '' && $option_value == $key) |
|
| 1118 | - $geodir_select_value = ' selected="selected" '; |
|
| 1119 | - } else {
|
|
| 1120 | - if ($value['std'] == $key) |
|
| 1121 | - $geodir_select_value = ' selected="selected" '; |
|
| 1122 | - } |
|
| 1123 | - ?> |
|
| 1114 | + foreach ($value['options'] as $key => $val) {
|
|
| 1115 | + $geodir_select_value = ''; |
|
| 1116 | + if ($option_value != '') {
|
|
| 1117 | + if ($option_value != '' && $option_value == $key) |
|
| 1118 | + $geodir_select_value = ' selected="selected" '; |
|
| 1119 | + } else {
|
|
| 1120 | + if ($value['std'] == $key) |
|
| 1121 | + $geodir_select_value = ' selected="selected" '; |
|
| 1122 | + } |
|
| 1123 | + ?> |
|
| 1124 | 1124 | <option |
| 1125 | 1125 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option> |
| 1126 | 1126 | <?php |
| 1127 | - } |
|
| 1128 | - ?> |
|
| 1127 | + } |
|
| 1128 | + ?> |
|
| 1129 | 1129 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1130 | 1130 | </td> |
| 1131 | 1131 | </tr><?php |
| 1132 | - break; |
|
| 1132 | + break; |
|
| 1133 | 1133 | |
| 1134 | - case 'multiselect': |
|
| 1135 | - $option_values = get_option($value['id']); |
|
| 1136 | - if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1137 | - $option_values = $value['std']; |
|
| 1138 | - } |
|
| 1139 | - $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1140 | - ?> |
|
| 1134 | + case 'multiselect': |
|
| 1135 | + $option_values = get_option($value['id']); |
|
| 1136 | + if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) {
|
|
| 1137 | + $option_values = $value['std']; |
|
| 1138 | + } |
|
| 1139 | + $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
| 1140 | + ?> |
|
| 1141 | 1141 | <tr valign="top"> |
| 1142 | 1142 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1143 | 1143 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -1147,25 +1147,25 @@ discard block |
||
| 1147 | 1147 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
| 1148 | 1148 | option-ajaxchosen="false"> |
| 1149 | 1149 | <?php |
| 1150 | - foreach ($value['options'] as $key => $val) {
|
|
| 1151 | - if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1152 | - ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 1153 | - } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1154 | - ?></optgroup><?php |
|
| 1155 | - } else {
|
|
| 1156 | - ?> |
|
| 1150 | + foreach ($value['options'] as $key => $val) {
|
|
| 1151 | + if (strpos($key, 'optgroup_start-') === 0) {
|
|
| 1152 | + ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
| 1153 | + } else if (strpos($key, 'optgroup_end-') === 0) {
|
|
| 1154 | + ?></optgroup><?php |
|
| 1155 | + } else {
|
|
| 1156 | + ?> |
|
| 1157 | 1157 | <option |
| 1158 | 1158 | value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option> |
| 1159 | 1159 | <?php |
| 1160 | - } |
|
| 1161 | - } |
|
| 1162 | - ?> |
|
| 1160 | + } |
|
| 1161 | + } |
|
| 1162 | + ?> |
|
| 1163 | 1163 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1164 | 1164 | </td> |
| 1165 | 1165 | </tr><?php |
| 1166 | - break; |
|
| 1167 | - case 'file': |
|
| 1168 | - ?> |
|
| 1166 | + break; |
|
| 1167 | + case 'file': |
|
| 1168 | + ?> |
|
| 1169 | 1169 | <tr valign="top"> |
| 1170 | 1170 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
| 1171 | 1171 | <td class="forminp"> |
@@ -1185,87 +1185,87 @@ discard block |
||
| 1185 | 1185 | <?php } ?> |
| 1186 | 1186 | </td> |
| 1187 | 1187 | </tr><?php |
| 1188 | - break; |
|
| 1189 | - case 'map_default_settings' : |
|
| 1190 | - ?> |
|
| 1188 | + break; |
|
| 1189 | + case 'map_default_settings' : |
|
| 1190 | + ?> |
|
| 1191 | 1191 | |
| 1192 | 1192 | <tr valign="top"> |
| 1193 | 1193 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th>
|
| 1194 | 1194 | <td width="60%"> |
| 1195 | 1195 | <select name="geodir_default_map_language" style="width:60%"> |
| 1196 | 1196 | <?php |
| 1197 | - $arr_map_langages = array( |
|
| 1198 | - 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1199 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1200 | - 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1201 | - 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1202 | - 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1203 | - 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1204 | - 'da' => __('DANISH', 'geodirectory'),
|
|
| 1205 | - 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1206 | - 'el' => __('GREEK', 'geodirectory'),
|
|
| 1207 | - 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1208 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1209 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1210 | - 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1211 | - 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1212 | - 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1213 | - 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1214 | - 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1215 | - 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1216 | - 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1217 | - 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1218 | - 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1219 | - 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1220 | - 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1221 | - 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1222 | - 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1223 | - 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1224 | - 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1225 | - 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1226 | - 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1227 | - 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1228 | - 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1229 | - 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1230 | - 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1231 | - 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1232 | - 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1233 | - 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1234 | - 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1235 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1236 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1237 | - 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1238 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1239 | - 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1240 | - 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1241 | - 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1242 | - 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1243 | - 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1244 | - 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1245 | - 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1246 | - 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1247 | - 'th' => __('THAI', 'geodirectory'),
|
|
| 1248 | - 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1249 | - 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1250 | - 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1251 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1252 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1253 | - ); |
|
| 1254 | - $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1255 | - if (empty($geodir_default_map_language)) |
|
| 1256 | - $geodir_default_map_language = 'en'; |
|
| 1257 | - foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1258 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1259 | - $geodir_default_language_selected = "selected='selected'"; |
|
| 1260 | - else |
|
| 1261 | - $geodir_default_language_selected = ''; |
|
| 1262 | - |
|
| 1263 | - ?> |
|
| 1197 | + $arr_map_langages = array( |
|
| 1198 | + 'ar' => __('ARABIC', 'geodirectory'),
|
|
| 1199 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1200 | + 'bg' => __('BULGARIAN', 'geodirectory'),
|
|
| 1201 | + 'bn' => __('BENGALI', 'geodirectory'),
|
|
| 1202 | + 'ca' => __('CATALAN', 'geodirectory'),
|
|
| 1203 | + 'cs' => __('CZECH', 'geodirectory'),
|
|
| 1204 | + 'da' => __('DANISH', 'geodirectory'),
|
|
| 1205 | + 'de' => __('GERMAN', 'geodirectory'),
|
|
| 1206 | + 'el' => __('GREEK', 'geodirectory'),
|
|
| 1207 | + 'en' => __('ENGLISH', 'geodirectory'),
|
|
| 1208 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'),
|
|
| 1209 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'),
|
|
| 1210 | + 'es' => __('SPANISH', 'geodirectory'),
|
|
| 1211 | + 'eu' => __('BASQUE', 'geodirectory'),
|
|
| 1212 | + 'fa' => __('FARSI', 'geodirectory'),
|
|
| 1213 | + 'fi' => __('FINNISH', 'geodirectory'),
|
|
| 1214 | + 'fil' => __('FILIPINO', 'geodirectory'),
|
|
| 1215 | + 'fr' => __('FRENCH', 'geodirectory'),
|
|
| 1216 | + 'gl' => __('GALICIAN', 'geodirectory'),
|
|
| 1217 | + 'gu' => __('GUJARATI', 'geodirectory'),
|
|
| 1218 | + 'hi' => __('HINDI', 'geodirectory'),
|
|
| 1219 | + 'hr' => __('CROATIAN', 'geodirectory'),
|
|
| 1220 | + 'hu' => __('HUNGARIAN', 'geodirectory'),
|
|
| 1221 | + 'id' => __('INDONESIAN', 'geodirectory'),
|
|
| 1222 | + 'it' => __('ITALIAN', 'geodirectory'),
|
|
| 1223 | + 'iw' => __('HEBREW', 'geodirectory'),
|
|
| 1224 | + 'ja' => __('JAPANESE', 'geodirectory'),
|
|
| 1225 | + 'kn' => __('KANNADA', 'geodirectory'),
|
|
| 1226 | + 'ko' => __('KOREAN', 'geodirectory'),
|
|
| 1227 | + 'lt' => __('LITHUANIAN', 'geodirectory'),
|
|
| 1228 | + 'lv' => __('LATVIAN', 'geodirectory'),
|
|
| 1229 | + 'ml' => __('MALAYALAM', 'geodirectory'),
|
|
| 1230 | + 'mr' => __('MARATHI', 'geodirectory'),
|
|
| 1231 | + 'nl' => __('DUTCH', 'geodirectory'),
|
|
| 1232 | + 'no' => __('NORWEGIAN', 'geodirectory'),
|
|
| 1233 | + 'pl' => __('POLISH', 'geodirectory'),
|
|
| 1234 | + 'pt' => __('PORTUGUESE', 'geodirectory'),
|
|
| 1235 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'),
|
|
| 1236 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'),
|
|
| 1237 | + 'ro' => __('ROMANIAN', 'geodirectory'),
|
|
| 1238 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1239 | + 'ru' => __('RUSSIAN', 'geodirectory'),
|
|
| 1240 | + 'sk' => __('SLOVAK', 'geodirectory'),
|
|
| 1241 | + 'sl' => __('SLOVENIAN', 'geodirectory'),
|
|
| 1242 | + 'sr' => __('SERBIAN', 'geodirectory'),
|
|
| 1243 | + 'sv' => __(' SWEDISH', 'geodirectory'),
|
|
| 1244 | + 'tl' => __('TAGALOG', 'geodirectory'),
|
|
| 1245 | + 'ta' => __('TAMIL', 'geodirectory'),
|
|
| 1246 | + 'te' => __('TELUGU', 'geodirectory'),
|
|
| 1247 | + 'th' => __('THAI', 'geodirectory'),
|
|
| 1248 | + 'tr' => __('TURKISH', 'geodirectory'),
|
|
| 1249 | + 'uk' => __('UKRAINIAN', 'geodirectory'),
|
|
| 1250 | + 'vi' => __('VIETNAMESE', 'geodirectory'),
|
|
| 1251 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'),
|
|
| 1252 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'),
|
|
| 1253 | + ); |
|
| 1254 | + $geodir_default_map_language = get_option('geodir_default_map_language');
|
|
| 1255 | + if (empty($geodir_default_map_language)) |
|
| 1256 | + $geodir_default_map_language = 'en'; |
|
| 1257 | + foreach ($arr_map_langages as $language_key => $language_txt) {
|
|
| 1258 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
| 1259 | + $geodir_default_language_selected = "selected='selected'"; |
|
| 1260 | + else |
|
| 1261 | + $geodir_default_language_selected = ''; |
|
| 1262 | + |
|
| 1263 | + ?> |
|
| 1264 | 1264 | <option |
| 1265 | 1265 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
| 1266 | 1266 | |
| 1267 | 1267 | <?php } |
| 1268 | - ?> |
|
| 1268 | + ?> |
|
| 1269 | 1269 | </select> |
| 1270 | 1270 | </td> |
| 1271 | 1271 | </tr> |
@@ -1276,46 +1276,46 @@ discard block |
||
| 1276 | 1276 | <td width="60%"> |
| 1277 | 1277 | <select name="geodir_default_map_search_pt" style="width:60%"> |
| 1278 | 1278 | <?php |
| 1279 | - $post_types = geodir_get_posttypes('array');
|
|
| 1280 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1281 | - if (empty($geodir_default_map_search_pt)) |
|
| 1282 | - $geodir_default_map_search_pt = 'gd_place'; |
|
| 1283 | - if (is_array($post_types)) {
|
|
| 1284 | - foreach ($post_types as $key => $post_types_obj) {
|
|
| 1285 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1286 | - $geodir_search_pt_selected = "selected='selected'"; |
|
| 1287 | - else |
|
| 1288 | - $geodir_search_pt_selected = ''; |
|
| 1289 | - |
|
| 1290 | - ?> |
|
| 1279 | + $post_types = geodir_get_posttypes('array');
|
|
| 1280 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt');
|
|
| 1281 | + if (empty($geodir_default_map_search_pt)) |
|
| 1282 | + $geodir_default_map_search_pt = 'gd_place'; |
|
| 1283 | + if (is_array($post_types)) {
|
|
| 1284 | + foreach ($post_types as $key => $post_types_obj) {
|
|
| 1285 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
| 1286 | + $geodir_search_pt_selected = "selected='selected'"; |
|
| 1287 | + else |
|
| 1288 | + $geodir_search_pt_selected = ''; |
|
| 1289 | + |
|
| 1290 | + ?> |
|
| 1291 | 1291 | <option |
| 1292 | 1292 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo __($post_types_obj['labels']['singular_name'], 'geodirectory'); ?></option> |
| 1293 | 1293 | |
| 1294 | 1294 | <?php } |
| 1295 | 1295 | |
| 1296 | - } |
|
| 1296 | + } |
|
| 1297 | 1297 | |
| 1298 | - ?> |
|
| 1298 | + ?> |
|
| 1299 | 1299 | </select> |
| 1300 | 1300 | </td> |
| 1301 | 1301 | </tr> |
| 1302 | 1302 | |
| 1303 | 1303 | <?php |
| 1304 | - break; |
|
| 1304 | + break; |
|
| 1305 | 1305 | |
| 1306 | - case 'map': |
|
| 1307 | - ?> |
|
| 1306 | + case 'map': |
|
| 1307 | + ?> |
|
| 1308 | 1308 | <tr valign="top"> |
| 1309 | 1309 | <td class="forminp"> |
| 1310 | 1310 | <?php |
| 1311 | - global $post_cat, $cat_display; |
|
| 1312 | - $post_types = geodir_get_posttypes('object');
|
|
| 1313 | - $cat_display = 'checkbox'; |
|
| 1314 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1315 | - $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1316 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1317 | - $count = 1; |
|
| 1318 | - ?> |
|
| 1311 | + global $post_cat, $cat_display; |
|
| 1312 | + $post_types = geodir_get_posttypes('object');
|
|
| 1313 | + $cat_display = 'checkbox'; |
|
| 1314 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map');
|
|
| 1315 | + $gd_cats = get_option('geodir_exclude_cat_on_map');
|
|
| 1316 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade');
|
|
| 1317 | + $count = 1; |
|
| 1318 | + ?> |
|
| 1319 | 1319 | <table width="70%" class="widefat"> |
| 1320 | 1320 | <thead> |
| 1321 | 1321 | <tr> |
@@ -1324,18 +1324,18 @@ discard block |
||
| 1324 | 1324 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
| 1325 | 1325 | </tr> |
| 1326 | 1326 | <?php |
| 1327 | - $gd_categs = $gd_cats; |
|
| 1328 | - foreach ($post_types as $key => $post_types_obj) : |
|
| 1329 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1330 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1331 | - if ($gd_cats_upgrade) {
|
|
| 1332 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1333 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1334 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1335 | - } |
|
| 1336 | - $post_cat = implode(',', $gd_cats);
|
|
| 1337 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1338 | - ?> |
|
| 1327 | + $gd_categs = $gd_cats; |
|
| 1328 | + foreach ($post_types as $key => $post_types_obj) : |
|
| 1329 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
| 1330 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
| 1331 | + if ($gd_cats_upgrade) {
|
|
| 1332 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
| 1333 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
| 1334 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
| 1335 | + } |
|
| 1336 | + $post_cat = implode(',', $gd_cats);
|
|
| 1337 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
| 1338 | + ?> |
|
| 1339 | 1339 | <tr> |
| 1340 | 1340 | <td valign="top" width="5%"><?php echo $count; ?></td> |
| 1341 | 1341 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -1356,19 +1356,19 @@ discard block |
||
| 1356 | 1356 | </td> |
| 1357 | 1357 | </tr> |
| 1358 | 1358 | <?php |
| 1359 | - break; |
|
| 1359 | + break; |
|
| 1360 | 1360 | |
| 1361 | - case 'checkbox' : |
|
| 1361 | + case 'checkbox' : |
|
| 1362 | 1362 | |
| 1363 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1364 | - ?> |
|
| 1363 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
| 1364 | + ?> |
|
| 1365 | 1365 | <tr valign="top"> |
| 1366 | 1366 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1367 | 1367 | <td class="forminp"> |
| 1368 | 1368 | <?php |
| 1369 | - endif; |
|
| 1369 | + endif; |
|
| 1370 | 1370 | |
| 1371 | - ?> |
|
| 1371 | + ?> |
|
| 1372 | 1372 | <fieldset> |
| 1373 | 1373 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1374 | 1374 | <label for="<?php echo $value['id'] ?>"> |
@@ -1378,49 +1378,49 @@ discard block |
||
| 1378 | 1378 | </fieldset> |
| 1379 | 1379 | <?php |
| 1380 | 1380 | |
| 1381 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1382 | - ?> |
|
| 1381 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
| 1382 | + ?> |
|
| 1383 | 1383 | </td> |
| 1384 | 1384 | </tr> |
| 1385 | 1385 | <?php |
| 1386 | - endif; |
|
| 1386 | + endif; |
|
| 1387 | 1387 | |
| 1388 | - break; |
|
| 1388 | + break; |
|
| 1389 | 1389 | |
| 1390 | - case 'radio' : |
|
| 1390 | + case 'radio' : |
|
| 1391 | 1391 | |
| 1392 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1393 | - ?> |
|
| 1392 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
| 1393 | + ?> |
|
| 1394 | 1394 | <tr valign="top"> |
| 1395 | 1395 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1396 | 1396 | <td class="forminp"> |
| 1397 | 1397 | <?php |
| 1398 | - endif; |
|
| 1398 | + endif; |
|
| 1399 | 1399 | |
| 1400 | - ?> |
|
| 1400 | + ?> |
|
| 1401 | 1401 | <fieldset> |
| 1402 | 1402 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
| 1403 | 1403 | <label for="<?php echo $value['id'];?>"> |
| 1404 | 1404 | <input name="<?php echo esc_attr($value['id']); ?>" |
| 1405 | 1405 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
| 1406 | 1406 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) {
|
| 1407 | - echo 'checked="checked"'; |
|
| 1408 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1407 | + echo 'checked="checked"'; |
|
| 1408 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> />
|
|
| 1409 | 1409 | <?php echo $value['desc']; ?></label><br> |
| 1410 | 1410 | </fieldset> |
| 1411 | 1411 | <?php |
| 1412 | 1412 | |
| 1413 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1414 | - ?> |
|
| 1413 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
| 1414 | + ?> |
|
| 1415 | 1415 | </td> |
| 1416 | 1416 | </tr> |
| 1417 | 1417 | <?php |
| 1418 | - endif; |
|
| 1418 | + endif; |
|
| 1419 | 1419 | |
| 1420 | - break; |
|
| 1420 | + break; |
|
| 1421 | 1421 | |
| 1422 | - case 'textarea': |
|
| 1423 | - ?> |
|
| 1422 | + case 'textarea': |
|
| 1423 | + ?> |
|
| 1424 | 1424 | <tr valign="top"> |
| 1425 | 1425 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1426 | 1426 | <td class="forminp"> |
@@ -1433,30 +1433,30 @@ discard block |
||
| 1433 | 1433 | |
| 1434 | 1434 | </td> |
| 1435 | 1435 | </tr><?php |
| 1436 | - break; |
|
| 1436 | + break; |
|
| 1437 | 1437 | |
| 1438 | - case 'editor': |
|
| 1439 | - ?> |
|
| 1438 | + case 'editor': |
|
| 1439 | + ?> |
|
| 1440 | 1440 | <tr valign="top"> |
| 1441 | 1441 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1442 | 1442 | <td class="forminp"><?php |
| 1443 | - if (get_option($value['id'])) |
|
| 1444 | - $content = stripslashes(get_option($value['id'])); |
|
| 1445 | - else |
|
| 1446 | - $content = $value['std']; |
|
| 1443 | + if (get_option($value['id'])) |
|
| 1444 | + $content = stripslashes(get_option($value['id'])); |
|
| 1445 | + else |
|
| 1446 | + $content = $value['std']; |
|
| 1447 | 1447 | |
| 1448 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1448 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10);
|
|
| 1449 | 1449 | |
| 1450 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1450 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
| 1451 | 1451 | |
| 1452 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1452 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
| 1453 | 1453 | |
| 1454 | 1454 | </td> |
| 1455 | 1455 | </tr><?php |
| 1456 | - break; |
|
| 1456 | + break; |
|
| 1457 | 1457 | |
| 1458 | - case 'single_select_page' : |
|
| 1459 | - // WPML |
|
| 1458 | + case 'single_select_page' : |
|
| 1459 | + // WPML |
|
| 1460 | 1460 | $switch_lang = false; |
| 1461 | 1461 | $disabled = ''; |
| 1462 | 1462 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
@@ -1474,18 +1474,18 @@ discard block |
||
| 1474 | 1474 | // |
| 1475 | 1475 | $page_setting = (int)get_option($value['id']); |
| 1476 | 1476 | |
| 1477 | - $args = array('name' => $value['id'],
|
|
| 1478 | - 'id' => $value['id'], |
|
| 1479 | - 'sort_column' => 'menu_order', |
|
| 1480 | - 'sort_order' => 'ASC', |
|
| 1481 | - 'show_option_none' => ' ', |
|
| 1482 | - 'class' => $value['class'], |
|
| 1483 | - 'echo' => false, |
|
| 1484 | - 'selected' => $page_setting); |
|
| 1477 | + $args = array('name' => $value['id'],
|
|
| 1478 | + 'id' => $value['id'], |
|
| 1479 | + 'sort_column' => 'menu_order', |
|
| 1480 | + 'sort_order' => 'ASC', |
|
| 1481 | + 'show_option_none' => ' ', |
|
| 1482 | + 'class' => $value['class'], |
|
| 1483 | + 'echo' => false, |
|
| 1484 | + 'selected' => $page_setting); |
|
| 1485 | 1485 | |
| 1486 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1486 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
| 1487 | 1487 | |
| 1488 | - ?> |
|
| 1488 | + ?> |
|
| 1489 | 1489 | <tr valign="top" class="single_select_page"> |
| 1490 | 1490 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1491 | 1491 | <td class="forminp"> |
@@ -1496,17 +1496,17 @@ discard block |
||
| 1496 | 1496 | if ($switch_lang) {
|
| 1497 | 1497 | $sitepress->switch_lang($switch_lang, true); |
| 1498 | 1498 | } |
| 1499 | - break; |
|
| 1500 | - case 'single_select_country' : |
|
| 1501 | - $country_setting = (string)get_option($value['id']); |
|
| 1502 | - if (strstr($country_setting, ':')) : |
|
| 1503 | - $country = current(explode(':', $country_setting));
|
|
| 1504 | - $state = end(explode(':', $country_setting));
|
|
| 1505 | - else : |
|
| 1506 | - $country = $country_setting; |
|
| 1507 | - $state = '*'; |
|
| 1508 | - endif; |
|
| 1509 | - ?> |
|
| 1499 | + break; |
|
| 1500 | + case 'single_select_country' : |
|
| 1501 | + $country_setting = (string)get_option($value['id']); |
|
| 1502 | + if (strstr($country_setting, ':')) : |
|
| 1503 | + $country = current(explode(':', $country_setting));
|
|
| 1504 | + $state = end(explode(':', $country_setting));
|
|
| 1505 | + else : |
|
| 1506 | + $country = $country_setting; |
|
| 1507 | + $state = '*'; |
|
| 1508 | + endif; |
|
| 1509 | + ?> |
|
| 1510 | 1510 | <tr valign="top"> |
| 1511 | 1511 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
| 1512 | 1512 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1517,12 +1517,12 @@ discard block |
||
| 1517 | 1517 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
| 1518 | 1518 | </td> |
| 1519 | 1519 | </tr><?php |
| 1520 | - break; |
|
| 1521 | - case 'multi_select_countries' : |
|
| 1522 | - $countries = $geodirectory->countries->countries; |
|
| 1523 | - asort($countries); |
|
| 1524 | - $selections = (array)get_option($value['id']); |
|
| 1525 | - ?> |
|
| 1520 | + break; |
|
| 1521 | + case 'multi_select_countries' : |
|
| 1522 | + $countries = $geodirectory->countries->countries; |
|
| 1523 | + asort($countries); |
|
| 1524 | + $selections = (array)get_option($value['id']); |
|
| 1525 | + ?> |
|
| 1526 | 1526 | <tr valign="top"> |
| 1527 | 1527 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1528 | 1528 | <td class="forminp"> |
@@ -1530,21 +1530,21 @@ discard block |
||
| 1530 | 1530 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>"
|
| 1531 | 1531 | title="Country" class="chosen_select"> |
| 1532 | 1532 | <?php |
| 1533 | - if ($countries) foreach ($countries as $key => $val) : |
|
| 1534 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1535 | - endforeach; |
|
| 1536 | - ?> |
|
| 1533 | + if ($countries) foreach ($countries as $key => $val) : |
|
| 1534 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
| 1535 | + endforeach; |
|
| 1536 | + ?> |
|
| 1537 | 1537 | </select> |
| 1538 | 1538 | </td> |
| 1539 | 1539 | </tr> |
| 1540 | 1540 | |
| 1541 | 1541 | <?php |
| 1542 | 1542 | |
| 1543 | - break; |
|
| 1543 | + break; |
|
| 1544 | 1544 | |
| 1545 | - case 'google_analytics' : |
|
| 1546 | - $selections = (array)get_option($value['id']); |
|
| 1547 | - ?> |
|
| 1545 | + case 'google_analytics' : |
|
| 1546 | + $selections = (array)get_option($value['id']); |
|
| 1547 | + ?> |
|
| 1548 | 1548 | <tr valign="top"> |
| 1549 | 1549 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
| 1550 | 1550 | <td class="forminp"> |
@@ -1552,62 +1552,62 @@ discard block |
||
| 1552 | 1552 | |
| 1553 | 1553 | <?php |
| 1554 | 1554 | |
| 1555 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1556 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1557 | - $state = "&state=123";//any string |
|
| 1558 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1559 | - $response_type = "&response_type=code"; |
|
| 1560 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1561 | - $access_type = "&access_type=offline"; |
|
| 1562 | - $approval_prompt = "&approval_prompt=force"; |
|
| 1555 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
| 1556 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
| 1557 | + $state = "&state=123";//any string |
|
| 1558 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 1559 | + $response_type = "&response_type=code"; |
|
| 1560 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 1561 | + $access_type = "&access_type=offline"; |
|
| 1562 | + $approval_prompt = "&approval_prompt=force"; |
|
| 1563 | 1563 | |
| 1564 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1564 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
| 1565 | 1565 | |
| 1566 | 1566 | |
| 1567 | - if (get_option('geodir_ga_auth_token')) {
|
|
| 1568 | - ?> |
|
| 1567 | + if (get_option('geodir_ga_auth_token')) {
|
|
| 1568 | + ?> |
|
| 1569 | 1569 | <span class="button-primary" |
| 1570 | 1570 | onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize');?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span>
|
| 1571 | 1571 | <span style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span>
|
| 1572 | 1572 | <?php |
| 1573 | - global $gd_ga_errors; |
|
| 1574 | - if(!empty($gd_ga_errors)){
|
|
| 1575 | - print_r($gd_ga_errors); |
|
| 1576 | - } |
|
| 1577 | - } else {
|
|
| 1578 | - ?> |
|
| 1573 | + global $gd_ga_errors; |
|
| 1574 | + if(!empty($gd_ga_errors)){
|
|
| 1575 | + print_r($gd_ga_errors); |
|
| 1576 | + } |
|
| 1577 | + } else {
|
|
| 1578 | + ?> |
|
| 1579 | 1579 | <span class="button-primary" |
| 1580 | 1580 | 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>
|
| 1581 | 1581 | <?php |
| 1582 | - } |
|
| 1583 | - ?> |
|
| 1582 | + } |
|
| 1583 | + ?> |
|
| 1584 | 1584 | </td> |
| 1585 | 1585 | </tr> |
| 1586 | 1586 | |
| 1587 | 1587 | <?php |
| 1588 | 1588 | |
| 1589 | 1589 | |
| 1590 | - break; |
|
| 1590 | + break; |
|
| 1591 | 1591 | |
| 1592 | - case 'field_seperator' : |
|
| 1592 | + case 'field_seperator' : |
|
| 1593 | 1593 | |
| 1594 | - ?> |
|
| 1594 | + ?> |
|
| 1595 | 1595 | <tr valign="top"> |
| 1596 | 1596 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
| 1597 | 1597 | </tr> |
| 1598 | 1598 | <?php |
| 1599 | 1599 | |
| 1600 | - break; |
|
| 1600 | + break; |
|
| 1601 | 1601 | |
| 1602 | - endswitch; |
|
| 1602 | + endswitch; |
|
| 1603 | 1603 | |
| 1604 | - endforeach; |
|
| 1604 | + endforeach; |
|
| 1605 | 1605 | |
| 1606 | - if ($first_title === false) {
|
|
| 1607 | - echo "</div>"; |
|
| 1608 | - } |
|
| 1606 | + if ($first_title === false) {
|
|
| 1607 | + echo "</div>"; |
|
| 1608 | + } |
|
| 1609 | 1609 | |
| 1610 | - ?> |
|
| 1610 | + ?> |
|
| 1611 | 1611 | |
| 1612 | 1612 | <script type="text/javascript"> |
| 1613 | 1613 | |
@@ -1667,33 +1667,33 @@ discard block |
||
| 1667 | 1667 | */ |
| 1668 | 1668 | function geodir_post_info_setting() |
| 1669 | 1669 | {
|
| 1670 | - global $post, $post_id; |
|
| 1671 | - |
|
| 1672 | - $post_type = get_post_type(); |
|
| 1673 | - |
|
| 1674 | - $package_info = array(); |
|
| 1675 | - |
|
| 1676 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1677 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1678 | - echo '<div id="geodir_wrapper">'; |
|
| 1679 | - /** |
|
| 1680 | - * Called before the GD custom fields are output in the wp-admin area. |
|
| 1681 | - * |
|
| 1682 | - * @since 1.0.0 |
|
| 1683 | - * @see 'geodir_after_default_field_in_meta_box' |
|
| 1684 | - */ |
|
| 1685 | - do_action('geodir_before_default_field_in_meta_box');
|
|
| 1686 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 1687 | - // to display all fields in one information box |
|
| 1688 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 1689 | - /** |
|
| 1690 | - * Called after the GD custom fields are output in the wp-admin area. |
|
| 1691 | - * |
|
| 1692 | - * @since 1.0.0 |
|
| 1693 | - * @see 'geodir_before_default_field_in_meta_box' |
|
| 1694 | - */ |
|
| 1695 | - do_action('geodir_after_default_field_in_meta_box');
|
|
| 1696 | - echo '</div>'; |
|
| 1670 | + global $post, $post_id; |
|
| 1671 | + |
|
| 1672 | + $post_type = get_post_type(); |
|
| 1673 | + |
|
| 1674 | + $package_info = array(); |
|
| 1675 | + |
|
| 1676 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1677 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
| 1678 | + echo '<div id="geodir_wrapper">'; |
|
| 1679 | + /** |
|
| 1680 | + * Called before the GD custom fields are output in the wp-admin area. |
|
| 1681 | + * |
|
| 1682 | + * @since 1.0.0 |
|
| 1683 | + * @see 'geodir_after_default_field_in_meta_box' |
|
| 1684 | + */ |
|
| 1685 | + do_action('geodir_before_default_field_in_meta_box');
|
|
| 1686 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
| 1687 | + // to display all fields in one information box |
|
| 1688 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
| 1689 | + /** |
|
| 1690 | + * Called after the GD custom fields are output in the wp-admin area. |
|
| 1691 | + * |
|
| 1692 | + * @since 1.0.0 |
|
| 1693 | + * @see 'geodir_before_default_field_in_meta_box' |
|
| 1694 | + */ |
|
| 1695 | + do_action('geodir_after_default_field_in_meta_box');
|
|
| 1696 | + echo '</div>'; |
|
| 1697 | 1697 | } |
| 1698 | 1698 | |
| 1699 | 1699 | /** |
@@ -1706,18 +1706,18 @@ discard block |
||
| 1706 | 1706 | */ |
| 1707 | 1707 | function geodir_post_addinfo_setting() |
| 1708 | 1708 | {
|
| 1709 | - global $post, $post_id; |
|
| 1709 | + global $post, $post_id; |
|
| 1710 | 1710 | |
| 1711 | - $post_type = get_post_type(); |
|
| 1711 | + $post_type = get_post_type(); |
|
| 1712 | 1712 | |
| 1713 | - $package_info = array(); |
|
| 1713 | + $package_info = array(); |
|
| 1714 | 1714 | |
| 1715 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1715 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
| 1716 | 1716 | |
| 1717 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 1718 | - echo '<div id="geodir_wrapper">'; |
|
| 1719 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 1720 | - echo '</div>'; |
|
| 1717 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
| 1718 | + echo '<div id="geodir_wrapper">'; |
|
| 1719 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
| 1720 | + echo '</div>'; |
|
| 1721 | 1721 | |
| 1722 | 1722 | } |
| 1723 | 1723 | |
@@ -1731,60 +1731,60 @@ discard block |
||
| 1731 | 1731 | */ |
| 1732 | 1732 | function geodir_post_attachments() |
| 1733 | 1733 | {
|
| 1734 | - global $post, $post_id; |
|
| 1734 | + global $post, $post_id; |
|
| 1735 | 1735 | |
| 1736 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 1736 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
| 1737 | 1737 | |
| 1738 | - if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 1739 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 1740 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 1741 | - } |
|
| 1738 | + if (geodir_get_featured_image($post_id, 'thumbnail')) {
|
|
| 1739 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>';
|
|
| 1740 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
| 1741 | + } |
|
| 1742 | 1742 | |
| 1743 | - $image_limit = 0; |
|
| 1743 | + $image_limit = 0; |
|
| 1744 | 1744 | |
| 1745 | - ?> |
|
| 1745 | + ?> |
|
| 1746 | 1746 | |
| 1747 | 1747 | |
| 1748 | 1748 | <h5 class="form_title"> |
| 1749 | 1749 | <?php if ($image_limit != 0 && $image_limit == 1) {
|
| 1750 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 1751 | - } ?> |
|
| 1750 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>';
|
|
| 1751 | + } ?> |
|
| 1752 | 1752 | <?php if ($image_limit != 0 && $image_limit > 1) {
|
| 1753 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 1754 | - } ?> |
|
| 1753 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>';
|
|
| 1754 | + } ?> |
|
| 1755 | 1755 | <?php if ($image_limit == 0) {
|
| 1756 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 1757 | - } ?> |
|
| 1756 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>';
|
|
| 1757 | + } ?> |
|
| 1758 | 1758 | </h5> |
| 1759 | 1759 | |
| 1760 | 1760 | |
| 1761 | 1761 | <?php |
| 1762 | 1762 | |
| 1763 | - $curImages = geodir_get_images($post_id); |
|
| 1764 | - $place_img_array = array(); |
|
| 1763 | + $curImages = geodir_get_images($post_id); |
|
| 1764 | + $place_img_array = array(); |
|
| 1765 | 1765 | |
| 1766 | - if (!empty($curImages)): |
|
| 1767 | - foreach ($curImages as $p_img): |
|
| 1768 | - $place_img_array[] = $p_img->src; |
|
| 1769 | - endforeach; |
|
| 1770 | - endif; |
|
| 1766 | + if (!empty($curImages)): |
|
| 1767 | + foreach ($curImages as $p_img): |
|
| 1768 | + $place_img_array[] = $p_img->src; |
|
| 1769 | + endforeach; |
|
| 1770 | + endif; |
|
| 1771 | 1771 | |
| 1772 | - if (!empty($place_img_array)) |
|
| 1773 | - $curImages = implode(',', $place_img_array);
|
|
| 1772 | + if (!empty($place_img_array)) |
|
| 1773 | + $curImages = implode(',', $place_img_array);
|
|
| 1774 | 1774 | |
| 1775 | 1775 | |
| 1776 | - // adjust values here |
|
| 1777 | - $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 |
|
| 1776 | + // adjust values here |
|
| 1777 | + $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 |
|
| 1778 | 1778 | |
| 1779 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 1779 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
| 1780 | 1780 | |
| 1781 | - $multiple = true; // allow multiple files upload |
|
| 1781 | + $multiple = true; // allow multiple files upload |
|
| 1782 | 1782 | |
| 1783 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1783 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
| 1784 | 1784 | |
| 1785 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1785 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
| 1786 | 1786 | |
| 1787 | - ?> |
|
| 1787 | + ?> |
|
| 1788 | 1788 | |
| 1789 | 1789 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
| 1790 | 1790 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -1826,13 +1826,13 @@ discard block |
||
| 1826 | 1826 | */ |
| 1827 | 1827 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
| 1828 | 1828 | {
|
| 1829 | - $post_type = get_post_type($post_ID); |
|
| 1829 | + $post_type = get_post_type($post_ID); |
|
| 1830 | 1830 | |
| 1831 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1832 | - 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) {
|
|
| 1833 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 1834 | - } |
|
| 1835 | - } |
|
| 1831 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') {
|
|
| 1832 | + 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) {
|
|
| 1833 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
| 1834 | + } |
|
| 1835 | + } |
|
| 1836 | 1836 | } |
| 1837 | 1837 | |
| 1838 | 1838 | /** |
@@ -1847,39 +1847,39 @@ discard block |
||
| 1847 | 1847 | */ |
| 1848 | 1848 | function geodir_notification_add_bcc_option($settings) |
| 1849 | 1849 | {
|
| 1850 | - if (!empty($settings)) {
|
|
| 1851 | - $new_settings = array(); |
|
| 1852 | - foreach ($settings as $setting) {
|
|
| 1853 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 1854 | - $geodir_bcc_listing_published_yes = array( |
|
| 1855 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 1856 | - 'desc' => __('Yes', 'geodirectory'),
|
|
| 1857 | - 'id' => 'geodir_bcc_listing_published', |
|
| 1858 | - 'std' => 'yes', |
|
| 1859 | - 'type' => 'radio', |
|
| 1860 | - 'value' => '1', |
|
| 1861 | - 'radiogroup' => 'start' |
|
| 1862 | - ); |
|
| 1863 | - |
|
| 1864 | - $geodir_bcc_listing_published_no = array( |
|
| 1865 | - 'name' => __('Listing published', 'geodirectory'),
|
|
| 1866 | - 'desc' => __('No', 'geodirectory'),
|
|
| 1867 | - 'id' => 'geodir_bcc_listing_published', |
|
| 1868 | - 'std' => 'yes', |
|
| 1869 | - 'type' => 'radio', |
|
| 1870 | - 'value' => '0', |
|
| 1871 | - 'radiogroup' => 'end' |
|
| 1872 | - ); |
|
| 1873 | - |
|
| 1874 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 1875 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 1876 | - } |
|
| 1877 | - $new_settings[] = $setting; |
|
| 1878 | - } |
|
| 1879 | - $settings = $new_settings; |
|
| 1880 | - } |
|
| 1850 | + if (!empty($settings)) {
|
|
| 1851 | + $new_settings = array(); |
|
| 1852 | + foreach ($settings as $setting) {
|
|
| 1853 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') {
|
|
| 1854 | + $geodir_bcc_listing_published_yes = array( |
|
| 1855 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 1856 | + 'desc' => __('Yes', 'geodirectory'),
|
|
| 1857 | + 'id' => 'geodir_bcc_listing_published', |
|
| 1858 | + 'std' => 'yes', |
|
| 1859 | + 'type' => 'radio', |
|
| 1860 | + 'value' => '1', |
|
| 1861 | + 'radiogroup' => 'start' |
|
| 1862 | + ); |
|
| 1863 | + |
|
| 1864 | + $geodir_bcc_listing_published_no = array( |
|
| 1865 | + 'name' => __('Listing published', 'geodirectory'),
|
|
| 1866 | + 'desc' => __('No', 'geodirectory'),
|
|
| 1867 | + 'id' => 'geodir_bcc_listing_published', |
|
| 1868 | + 'std' => 'yes', |
|
| 1869 | + 'type' => 'radio', |
|
| 1870 | + 'value' => '0', |
|
| 1871 | + 'radiogroup' => 'end' |
|
| 1872 | + ); |
|
| 1873 | + |
|
| 1874 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
| 1875 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
| 1876 | + } |
|
| 1877 | + $new_settings[] = $setting; |
|
| 1878 | + } |
|
| 1879 | + $settings = $new_settings; |
|
| 1880 | + } |
|
| 1881 | 1881 | |
| 1882 | - return $settings; |
|
| 1882 | + return $settings; |
|
| 1883 | 1883 | } |
| 1884 | 1884 | |
| 1885 | 1885 | |
@@ -1894,19 +1894,19 @@ discard block |
||
| 1894 | 1894 | */ |
| 1895 | 1895 | function get_gd_theme_compat_callback() |
| 1896 | 1896 | {
|
| 1897 | - global $wpdb; |
|
| 1898 | - $themes = get_option('gd_theme_compats');
|
|
| 1899 | - |
|
| 1900 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 1901 | - if (isset($_POST['export'])) {
|
|
| 1902 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 1903 | - } else {
|
|
| 1904 | - echo json_encode($themes[$_POST['theme']]); |
|
| 1905 | - } |
|
| 1897 | + global $wpdb; |
|
| 1898 | + $themes = get_option('gd_theme_compats');
|
|
| 1906 | 1899 | |
| 1907 | - } |
|
| 1900 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) {
|
|
| 1901 | + if (isset($_POST['export'])) {
|
|
| 1902 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
| 1903 | + } else {
|
|
| 1904 | + echo json_encode($themes[$_POST['theme']]); |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + } |
|
| 1908 | 1908 | |
| 1909 | - die(); |
|
| 1909 | + die(); |
|
| 1910 | 1910 | } |
| 1911 | 1911 | |
| 1912 | 1912 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback');
|
@@ -1920,20 +1920,20 @@ discard block |
||
| 1920 | 1920 | */ |
| 1921 | 1921 | function get_gd_theme_compat_import_callback() |
| 1922 | 1922 | {
|
| 1923 | - global $wpdb; |
|
| 1924 | - $themes = get_option('gd_theme_compats');
|
|
| 1925 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 1926 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 1927 | - if (!empty($json) && is_array($json)) {
|
|
| 1928 | - $key = sanitize_text_field(key($json)); |
|
| 1929 | - $themes[$key] = $json[$key]; |
|
| 1930 | - update_option('gd_theme_compats', $themes);
|
|
| 1931 | - echo $key; |
|
| 1932 | - die(); |
|
| 1933 | - } |
|
| 1934 | - } |
|
| 1935 | - echo '0'; |
|
| 1936 | - die(); |
|
| 1923 | + global $wpdb; |
|
| 1924 | + $themes = get_option('gd_theme_compats');
|
|
| 1925 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) {
|
|
| 1926 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
| 1927 | + if (!empty($json) && is_array($json)) {
|
|
| 1928 | + $key = sanitize_text_field(key($json)); |
|
| 1929 | + $themes[$key] = $json[$key]; |
|
| 1930 | + update_option('gd_theme_compats', $themes);
|
|
| 1931 | + echo $key; |
|
| 1932 | + die(); |
|
| 1933 | + } |
|
| 1934 | + } |
|
| 1935 | + echo '0'; |
|
| 1936 | + die(); |
|
| 1937 | 1937 | } |
| 1938 | 1938 | |
| 1939 | 1939 | |
@@ -1946,39 +1946,39 @@ discard block |
||
| 1946 | 1946 | */ |
| 1947 | 1947 | function gd_set_theme_compat() |
| 1948 | 1948 | {
|
| 1949 | - global $wpdb; |
|
| 1950 | - $theme = wp_get_theme(); |
|
| 1949 | + global $wpdb; |
|
| 1950 | + $theme = wp_get_theme(); |
|
| 1951 | 1951 | |
| 1952 | - if ($theme->parent()) {
|
|
| 1953 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 1954 | - } else {
|
|
| 1955 | - $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 1956 | - } |
|
| 1952 | + if ($theme->parent()) {
|
|
| 1953 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name'));
|
|
| 1954 | + } else {
|
|
| 1955 | + $theme_name = str_replace(" ", "_", $theme->get('Name'));
|
|
| 1956 | + } |
|
| 1957 | 1957 | |
| 1958 | - $theme_compats = get_option('gd_theme_compats');
|
|
| 1959 | - $current_compat = get_option('gd_theme_compat');
|
|
| 1960 | - $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 1958 | + $theme_compats = get_option('gd_theme_compats');
|
|
| 1959 | + $current_compat = get_option('gd_theme_compat');
|
|
| 1960 | + $current_compat = str_replace("_custom", "", $current_compat);
|
|
| 1961 | 1961 | |
| 1962 | - if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
|
|
| 1963 | - return; |
|
| 1964 | - }// if already running correct compat then bail |
|
| 1962 | + if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) {
|
|
| 1963 | + return; |
|
| 1964 | + }// if already running correct compat then bail |
|
| 1965 | 1965 | |
| 1966 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 1967 | - update_option('gd_theme_compat', $theme_name);
|
|
| 1968 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 1966 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it
|
|
| 1967 | + update_option('gd_theme_compat', $theme_name);
|
|
| 1968 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]);
|
|
| 1969 | 1969 | |
| 1970 | - // if there are default options to set then set them |
|
| 1971 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 1970 | + // if there are default options to set then set them |
|
| 1971 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) {
|
|
| 1972 | 1972 | |
| 1973 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 1974 | - update_option($key, $val); |
|
| 1975 | - } |
|
| 1976 | - } |
|
| 1973 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) {
|
|
| 1974 | + update_option($key, $val); |
|
| 1975 | + } |
|
| 1976 | + } |
|
| 1977 | 1977 | |
| 1978 | - } else {
|
|
| 1979 | - update_option('gd_theme_compat', '');
|
|
| 1980 | - update_option('theme_compatibility_setting', '');
|
|
| 1981 | - } |
|
| 1978 | + } else {
|
|
| 1979 | + update_option('gd_theme_compat', '');
|
|
| 1980 | + update_option('theme_compatibility_setting', '');
|
|
| 1981 | + } |
|
| 1982 | 1982 | |
| 1983 | 1983 | |
| 1984 | 1984 | } |
@@ -1993,9 +1993,9 @@ discard block |
||
| 1993 | 1993 | */ |
| 1994 | 1994 | function gd_check_avada_compat() |
| 1995 | 1995 | {
|
| 1996 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 1997 | - add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 1998 | - } |
|
| 1996 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) {
|
|
| 1997 | + add_action('admin_notices', 'gd_avada_compat_warning');
|
|
| 1998 | + } |
|
| 1999 | 1999 | } |
| 2000 | 2000 | |
| 2001 | 2001 | |
@@ -2008,22 +2008,22 @@ discard block |
||
| 2008 | 2008 | function gd_avada_compat_warning() |
| 2009 | 2009 | {
|
| 2010 | 2010 | |
| 2011 | - /* |
|
| 2011 | + /* |
|
| 2012 | 2012 | $msg_type = error |
| 2013 | 2013 | $msg_type = updated fade |
| 2014 | 2014 | $msg_type = update-nag |
| 2015 | 2015 | */ |
| 2016 | 2016 | |
| 2017 | - $plugin = 'avada-nag'; |
|
| 2018 | - $timestamp = 'avada-nag1234'; |
|
| 2019 | - $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');
|
|
| 2020 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2021 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2022 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2023 | - echo "<p>$message</p>"; |
|
| 2024 | - echo "</div>"; |
|
| 2017 | + $plugin = 'avada-nag'; |
|
| 2018 | + $timestamp = 'avada-nag1234'; |
|
| 2019 | + $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');
|
|
| 2020 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
| 2021 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
| 2022 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > ";
|
|
| 2023 | + echo "<p>$message</p>"; |
|
| 2024 | + echo "</div>"; |
|
| 2025 | 2025 | |
| 2026 | - ?> |
|
| 2026 | + ?> |
|
| 2027 | 2027 | <script> |
| 2028 | 2028 | function gdRemoveANotification($plugin, $timestamp) {
|
| 2029 | 2029 | |
@@ -2091,10 +2091,10 @@ discard block |
||
| 2091 | 2091 | */ |
| 2092 | 2092 | function geodir_avada_remove_notification() |
| 2093 | 2093 | {
|
| 2094 | - update_option('avada_nag', TRUE);
|
|
| 2094 | + update_option('avada_nag', TRUE);
|
|
| 2095 | 2095 | |
| 2096 | - // Always die in functions echoing ajax content |
|
| 2097 | - die(); |
|
| 2096 | + // Always die in functions echoing ajax content |
|
| 2097 | + die(); |
|
| 2098 | 2098 | } |
| 2099 | 2099 | |
| 2100 | 2100 | |
@@ -2116,9 +2116,9 @@ discard block |
||
| 2116 | 2116 | global $post, $typenow, $current_screen; |
| 2117 | 2117 | |
| 2118 | 2118 | $post_type = NULL; |
| 2119 | - if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2119 | + if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
| 2120 | 2120 | $post_type = get_post_type($_REQUEST['post']); |
| 2121 | - elseif ($post && isset($post->post_type)) |
|
| 2121 | + elseif ($post && isset($post->post_type)) |
|
| 2122 | 2122 | $post_type = $post->post_type; |
| 2123 | 2123 | elseif ($typenow) |
| 2124 | 2124 | $post_type = $typenow; |
@@ -2153,7 +2153,7 @@ discard block |
||
| 2153 | 2153 | // Don't allow same slug url for listing and location |
| 2154 | 2154 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) {
|
| 2155 | 2155 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21');
|
| 2156 | - wp_redirect($redirect_url); |
|
| 2156 | + wp_redirect($redirect_url); |
|
| 2157 | 2157 | exit; |
| 2158 | 2158 | } |
| 2159 | 2159 | |
@@ -2183,10 +2183,10 @@ discard block |
||
| 2183 | 2183 | * @package GeoDirectory |
| 2184 | 2184 | */ |
| 2185 | 2185 | function geodir_hide_admin_preview_button() {
|
| 2186 | - global $post_type; |
|
| 2187 | - $post_types = geodir_get_posttypes(); |
|
| 2188 | - if(in_array($post_type, $post_types)) |
|
| 2189 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2186 | + global $post_type; |
|
| 2187 | + $post_types = geodir_get_posttypes(); |
|
| 2188 | + if(in_array($post_type, $post_types)) |
|
| 2189 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>';
|
|
| 2190 | 2190 | } |
| 2191 | 2191 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
| 2192 | 2192 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -2201,7 +2201,7 @@ discard block |
||
| 2201 | 2201 | */ |
| 2202 | 2202 | function geodir_import_export_tab( $tabs ) {
|
| 2203 | 2203 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
| 2204 | - return $tabs; |
|
| 2204 | + return $tabs; |
|
| 2205 | 2205 | } |
| 2206 | 2206 | |
| 2207 | 2207 | /** |
@@ -2216,26 +2216,26 @@ discard block |
||
| 2216 | 2216 | function geodir_import_export_page() {
|
| 2217 | 2217 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
| 2218 | 2218 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
| 2219 | - /** |
|
| 2220 | - * Filter sample category data csv file url. |
|
| 2221 | - * |
|
| 2222 | - * @since 1.0.0 |
|
| 2223 | - * @package GeoDirectory |
|
| 2224 | - * |
|
| 2225 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2226 | - */ |
|
| 2219 | + /** |
|
| 2220 | + * Filter sample category data csv file url. |
|
| 2221 | + * |
|
| 2222 | + * @since 1.0.0 |
|
| 2223 | + * @package GeoDirectory |
|
| 2224 | + * |
|
| 2225 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
| 2226 | + */ |
|
| 2227 | 2227 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
| 2228 | 2228 | |
| 2229 | 2229 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
| 2230 | - /** |
|
| 2231 | - * Filter sample post data csv file url. |
|
| 2232 | - * |
|
| 2233 | - * @since 1.0.0 |
|
| 2234 | - * @package GeoDirectory |
|
| 2235 | - * |
|
| 2236 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2237 | - */ |
|
| 2238 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2230 | + /** |
|
| 2231 | + * Filter sample post data csv file url. |
|
| 2232 | + * |
|
| 2233 | + * @since 1.0.0 |
|
| 2234 | + * @package GeoDirectory |
|
| 2235 | + * |
|
| 2236 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
| 2237 | + */ |
|
| 2238 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
| 2239 | 2239 | |
| 2240 | 2240 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
| 2241 | 2241 | |
@@ -2258,14 +2258,14 @@ discard block |
||
| 2258 | 2258 | $gd_chunksize_options[100000] = 100000; |
| 2259 | 2259 | |
| 2260 | 2260 | /** |
| 2261 | - * Filter max entries per export csv file. |
|
| 2262 | - * |
|
| 2263 | - * @since 1.5.6 |
|
| 2264 | - * @package GeoDirectory |
|
| 2265 | - * |
|
| 2266 | - * @param string $gd_chunksize_options Entries options. |
|
| 2267 | - */ |
|
| 2268 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2261 | + * Filter max entries per export csv file. |
|
| 2262 | + * |
|
| 2263 | + * @since 1.5.6 |
|
| 2264 | + * @package GeoDirectory |
|
| 2265 | + * |
|
| 2266 | + * @param string $gd_chunksize_options Entries options. |
|
| 2267 | + */ |
|
| 2268 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
| 2269 | 2269 | |
| 2270 | 2270 | $gd_chunksize_option = ''; |
| 2271 | 2271 | foreach ($gd_chunksize_options as $value => $title) {
|
@@ -2282,12 +2282,12 @@ discard block |
||
| 2282 | 2282 | <div class="gd-content-heading"> |
| 2283 | 2283 | |
| 2284 | 2284 | <?php |
| 2285 | - ini_set('max_execution_time', 999999);
|
|
| 2286 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2287 | - ini_restore('max_execution_time');
|
|
| 2285 | + ini_set('max_execution_time', 999999);
|
|
| 2286 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
| 2287 | + ini_restore('max_execution_time');
|
|
| 2288 | 2288 | |
| 2289 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2290 | - ?> |
|
| 2289 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting
|
|
| 2290 | + ?> |
|
| 2291 | 2291 | <div id="gd_ie_reqs" class="metabox-holder"> |
| 2292 | 2292 | <div class="meta-box-sortables ui-sortable"> |
| 2293 | 2293 | <div class="postbox"> |
@@ -2462,7 +2462,7 @@ discard block |
||
| 2462 | 2462 | * Called just after the sample CSV download link. |
| 2463 | 2463 | * |
| 2464 | 2464 | * @since 1.0.0 |
| 2465 | - * @package GeoDirectory |
|
| 2465 | + * @package GeoDirectory |
|
| 2466 | 2466 | */ |
| 2467 | 2467 | do_action('geodir_sample_cats_csv_download_link');
|
| 2468 | 2468 | ?> |
@@ -2547,11 +2547,11 @@ discard block |
||
| 2547 | 2547 | * |
| 2548 | 2548 | * Called after the last setting on the GD > Import & Export page. |
| 2549 | 2549 | * @since 1.4.6 |
| 2550 | - * @package GeoDirectory |
|
| 2550 | + * @package GeoDirectory |
|
| 2551 | 2551 | * |
| 2552 | 2552 | * @param array $gd_posttypes GD post types. |
| 2553 | - * @param array $gd_chunksize_options File chunk size options. |
|
| 2554 | - * @param string $nonce Wordpress security token for GD import & export. |
|
| 2553 | + * @param array $gd_chunksize_options File chunk size options. |
|
| 2554 | + * @param string $nonce Wordpress security token for GD import & export. |
|
| 2555 | 2555 | */ |
| 2556 | 2556 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
| 2557 | 2557 | ?> |
@@ -3238,44 +3238,44 @@ discard block |
||
| 3238 | 3238 | function geodir_init_filesystem() |
| 3239 | 3239 | {
|
| 3240 | 3240 | |
| 3241 | - if(!function_exists('get_filesystem_method')){
|
|
| 3242 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3243 | - } |
|
| 3244 | - $access_type = get_filesystem_method(); |
|
| 3245 | - if ($access_type === 'direct') {
|
|
| 3246 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3247 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3248 | - |
|
| 3249 | - /* initialize the API */ |
|
| 3250 | - if (!WP_Filesystem($creds)) {
|
|
| 3251 | - /* any problems and we exit */ |
|
| 3252 | - //return '@@@3'; |
|
| 3253 | - return false; |
|
| 3254 | - } |
|
| 3241 | + if(!function_exists('get_filesystem_method')){
|
|
| 3242 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
| 3243 | + } |
|
| 3244 | + $access_type = get_filesystem_method(); |
|
| 3245 | + if ($access_type === 'direct') {
|
|
| 3246 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
| 3247 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3248 | + |
|
| 3249 | + /* initialize the API */ |
|
| 3250 | + if (!WP_Filesystem($creds)) {
|
|
| 3251 | + /* any problems and we exit */ |
|
| 3252 | + //return '@@@3'; |
|
| 3253 | + return false; |
|
| 3254 | + } |
|
| 3255 | 3255 | |
| 3256 | - global $wp_filesystem; |
|
| 3257 | - return $wp_filesystem; |
|
| 3258 | - /* do our file manipulations below */ |
|
| 3259 | - } elseif (defined('FTP_USER')) {
|
|
| 3260 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3256 | + global $wp_filesystem; |
|
| 3257 | + return $wp_filesystem; |
|
| 3258 | + /* do our file manipulations below */ |
|
| 3259 | + } elseif (defined('FTP_USER')) {
|
|
| 3260 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
| 3261 | + |
|
| 3262 | + /* initialize the API */ |
|
| 3263 | + if (!WP_Filesystem($creds)) {
|
|
| 3264 | + /* any problems and we exit */ |
|
| 3265 | + //return '@@@33'; |
|
| 3266 | + return false; |
|
| 3267 | + } |
|
| 3261 | 3268 | |
| 3262 | - /* initialize the API */ |
|
| 3263 | - if (!WP_Filesystem($creds)) {
|
|
| 3264 | - /* any problems and we exit */ |
|
| 3265 | - //return '@@@33'; |
|
| 3266 | - return false; |
|
| 3267 | - } |
|
| 3269 | + global $wp_filesystem; |
|
| 3270 | + //return '@@@1'; |
|
| 3271 | + return $wp_filesystem; |
|
| 3268 | 3272 | |
| 3269 | - global $wp_filesystem; |
|
| 3270 | - //return '@@@1'; |
|
| 3271 | - return $wp_filesystem; |
|
| 3272 | - |
|
| 3273 | - } else {
|
|
| 3274 | - //return '@@@2'; |
|
| 3275 | - /* don't have direct write access. Prompt user with our notice */ |
|
| 3276 | - add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3277 | - return false; |
|
| 3278 | - } |
|
| 3273 | + } else {
|
|
| 3274 | + //return '@@@2'; |
|
| 3275 | + /* don't have direct write access. Prompt user with our notice */ |
|
| 3276 | + add_action('admin_notice', 'geodir_filesystem_notice');
|
|
| 3277 | + return false; |
|
| 3278 | + } |
|
| 3279 | 3279 | |
| 3280 | 3280 | } |
| 3281 | 3281 | |
@@ -3293,10 +3293,10 @@ discard block |
||
| 3293 | 3293 | */ |
| 3294 | 3294 | function geodir_filesystem_notice() |
| 3295 | 3295 | { if ( defined( 'DOING_AJAX' ) ){return;}
|
| 3296 | - $access_type = get_filesystem_method(); |
|
| 3297 | - if ($access_type === 'direct') {
|
|
| 3298 | - } elseif (!defined('FTP_USER')) {
|
|
| 3299 | - ?> |
|
| 3296 | + $access_type = get_filesystem_method(); |
|
| 3297 | + if ($access_type === 'direct') {
|
|
| 3298 | + } elseif (!defined('FTP_USER')) {
|
|
| 3299 | + ?> |
|
| 3300 | 3300 | <div class="error"> |
| 3301 | 3301 | <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'); ?>
|
| 3302 | 3302 | <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> |
@@ -3323,1258 +3323,1258 @@ discard block |
||
| 3323 | 3323 | * @return string Json data. |
| 3324 | 3324 | */ |
| 3325 | 3325 | function geodir_ajax_import_export() {
|
| 3326 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3326 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
| 3327 | 3327 | |
| 3328 | - error_reporting(0); |
|
| 3328 | + error_reporting(0); |
|
| 3329 | 3329 | |
| 3330 | - $xstart = microtime(true); |
|
| 3330 | + $xstart = microtime(true); |
|
| 3331 | 3331 | |
| 3332 | - // try to set higher limits for import |
|
| 3333 | - $max_input_time = ini_get('max_input_time');
|
|
| 3334 | - $max_execution_time = ini_get('max_execution_time');
|
|
| 3335 | - $memory_limit= ini_get('memory_limit');
|
|
| 3332 | + // try to set higher limits for import |
|
| 3333 | + $max_input_time = ini_get('max_input_time');
|
|
| 3334 | + $max_execution_time = ini_get('max_execution_time');
|
|
| 3335 | + $memory_limit= ini_get('memory_limit');
|
|
| 3336 | 3336 | |
| 3337 | - if(!$max_input_time || $max_input_time<3000){
|
|
| 3338 | - ini_set('max_input_time', 3000);
|
|
| 3339 | - } |
|
| 3337 | + if(!$max_input_time || $max_input_time<3000){
|
|
| 3338 | + ini_set('max_input_time', 3000);
|
|
| 3339 | + } |
|
| 3340 | 3340 | |
| 3341 | - if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3342 | - ini_set('max_execution_time', 3000);
|
|
| 3343 | - } |
|
| 3341 | + if(!$max_execution_time || $max_execution_time<3000){
|
|
| 3342 | + ini_set('max_execution_time', 3000);
|
|
| 3343 | + } |
|
| 3344 | 3344 | |
| 3345 | - if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3346 | - if(str_replace('M','',$memory_limit)<256){
|
|
| 3347 | - ini_set('memory_limit', '256M');
|
|
| 3348 | - } |
|
| 3349 | - } |
|
| 3345 | + if($memory_limit && str_replace('M','',$memory_limit)){
|
|
| 3346 | + if(str_replace('M','',$memory_limit)<256){
|
|
| 3347 | + ini_set('memory_limit', '256M');
|
|
| 3348 | + } |
|
| 3349 | + } |
|
| 3350 | 3350 | |
| 3351 | - $json = array(); |
|
| 3351 | + $json = array(); |
|
| 3352 | 3352 | |
| 3353 | - if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3354 | - wp_send_json( $json ); |
|
| 3355 | - } |
|
| 3353 | + if ( !current_user_can( 'manage_options' ) ) {
|
|
| 3354 | + wp_send_json( $json ); |
|
| 3355 | + } |
|
| 3356 | 3356 | |
| 3357 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3358 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3359 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3357 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
| 3358 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
| 3359 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
| 3360 | 3360 | |
| 3361 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3362 | - wp_send_json( $json ); |
|
| 3363 | - } |
|
| 3361 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) {
|
|
| 3362 | + wp_send_json( $json ); |
|
| 3363 | + } |
|
| 3364 | 3364 | |
| 3365 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3366 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3367 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3368 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3365 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
| 3366 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
| 3367 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
| 3368 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
| 3369 | 3369 | |
| 3370 | - $wp_filesystem = geodir_init_filesystem(); |
|
| 3371 | - if (!$wp_filesystem) {
|
|
| 3372 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3373 | - wp_send_json( $json ); |
|
| 3374 | - } |
|
| 3370 | + $wp_filesystem = geodir_init_filesystem(); |
|
| 3371 | + if (!$wp_filesystem) {
|
|
| 3372 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
| 3373 | + wp_send_json( $json ); |
|
| 3374 | + } |
|
| 3375 | 3375 | |
| 3376 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3377 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3378 | - wp_send_json( $json ); |
|
| 3379 | - } |
|
| 3376 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
|
| 3377 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
| 3378 | + wp_send_json( $json ); |
|
| 3379 | + } |
|
| 3380 | 3380 | |
| 3381 | - $csv_file_dir = geodir_path_import_export( false ); |
|
| 3382 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3383 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3384 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3385 | - wp_send_json( $json ); |
|
| 3386 | - } |
|
| 3387 | - } |
|
| 3381 | + $csv_file_dir = geodir_path_import_export( false ); |
|
| 3382 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) {
|
|
| 3383 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) {
|
|
| 3384 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3385 | + wp_send_json( $json ); |
|
| 3386 | + } |
|
| 3387 | + } |
|
| 3388 | 3388 | |
| 3389 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3390 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3391 | - |
|
| 3392 | - switch ( $task ) {
|
|
| 3393 | - case 'export_posts': {
|
|
| 3394 | - // WPML |
|
| 3395 | - $is_wpml = geodir_is_wpml(); |
|
| 3396 | - if ($is_wpml) {
|
|
| 3397 | - global $sitepress; |
|
| 3398 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3389 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 3390 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false;
|
|
| 3391 | + |
|
| 3392 | + switch ( $task ) {
|
|
| 3393 | + case 'export_posts': {
|
|
| 3394 | + // WPML |
|
| 3395 | + $is_wpml = geodir_is_wpml(); |
|
| 3396 | + if ($is_wpml) {
|
|
| 3397 | + global $sitepress; |
|
| 3398 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3399 | 3399 | |
| 3400 | - $sitepress->switch_lang('all', true);
|
|
| 3401 | - } |
|
| 3402 | - // WPML |
|
| 3403 | - if ( $post_type == 'gd_event' ) {
|
|
| 3404 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3405 | - } |
|
| 3406 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 3400 | + $sitepress->switch_lang('all', true);
|
|
| 3401 | + } |
|
| 3402 | + // WPML |
|
| 3403 | + if ( $post_type == 'gd_event' ) {
|
|
| 3404 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
| 3405 | + } |
|
| 3406 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 3407 | 3407 | |
| 3408 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3409 | - if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
|
|
| 3410 | - $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
| 3411 | - } |
|
| 3412 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3413 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3414 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3415 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3416 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3408 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
| 3409 | + if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) {
|
|
| 3410 | + $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
| 3411 | + } |
|
| 3412 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
| 3413 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3414 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3415 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3416 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
| 3417 | 3417 | |
| 3418 | - $chunk_file_paths = array(); |
|
| 3418 | + $chunk_file_paths = array(); |
|
| 3419 | 3419 | |
| 3420 | - if ( isset( $_REQUEST['_c'] ) ) {
|
|
| 3421 | - $json['total'] = $posts_count; |
|
| 3422 | - // WPML |
|
| 3423 | - if ($is_wpml) {
|
|
| 3424 | - $sitepress->switch_lang($active_lang, true); |
|
| 3425 | - } |
|
| 3426 | - // WPML |
|
| 3427 | - wp_send_json( $json ); |
|
| 3428 | - gd_die(); |
|
| 3429 | - } else if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3430 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3431 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3432 | - $percentage = min( $percentage, 100 ); |
|
| 3420 | + if ( isset( $_REQUEST['_c'] ) ) {
|
|
| 3421 | + $json['total'] = $posts_count; |
|
| 3422 | + // WPML |
|
| 3423 | + if ($is_wpml) {
|
|
| 3424 | + $sitepress->switch_lang($active_lang, true); |
|
| 3425 | + } |
|
| 3426 | + // WPML |
|
| 3427 | + wp_send_json( $json ); |
|
| 3428 | + gd_die(); |
|
| 3429 | + } else if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3430 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3431 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
| 3432 | + $percentage = min( $percentage, 100 ); |
|
| 3433 | 3433 | |
| 3434 | - $json['percentage'] = $percentage; |
|
| 3435 | - // WPML |
|
| 3436 | - if ($is_wpml) {
|
|
| 3437 | - $sitepress->switch_lang($active_lang, true); |
|
| 3438 | - } |
|
| 3439 | - // WPML |
|
| 3440 | - wp_send_json( $json ); |
|
| 3441 | - gd_die(); |
|
| 3442 | - } else {
|
|
| 3443 | - if ( !$posts_count > 0 ) {
|
|
| 3444 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3445 | - } else {
|
|
| 3446 | - $total_posts = $posts_count; |
|
| 3447 | - if ($chunk_per_page > $total_posts) {
|
|
| 3448 | - $chunk_per_page = $total_posts; |
|
| 3449 | - } |
|
| 3450 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3434 | + $json['percentage'] = $percentage; |
|
| 3435 | + // WPML |
|
| 3436 | + if ($is_wpml) {
|
|
| 3437 | + $sitepress->switch_lang($active_lang, true); |
|
| 3438 | + } |
|
| 3439 | + // WPML |
|
| 3440 | + wp_send_json( $json ); |
|
| 3441 | + gd_die(); |
|
| 3442 | + } else {
|
|
| 3443 | + if ( !$posts_count > 0 ) {
|
|
| 3444 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3445 | + } else {
|
|
| 3446 | + $total_posts = $posts_count; |
|
| 3447 | + if ($chunk_per_page > $total_posts) {
|
|
| 3448 | + $chunk_per_page = $total_posts; |
|
| 3449 | + } |
|
| 3450 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
| 3451 | 3451 | |
| 3452 | - $j = $chunk_page_no; |
|
| 3453 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3452 | + $j = $chunk_page_no; |
|
| 3453 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
| 3454 | 3454 | |
| 3455 | - $per_page = 500; |
|
| 3456 | - if ($per_page > $chunk_per_page) {
|
|
| 3457 | - $per_page = $chunk_per_page; |
|
| 3458 | - } |
|
| 3459 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3455 | + $per_page = 500; |
|
| 3456 | + if ($per_page > $chunk_per_page) {
|
|
| 3457 | + $per_page = $chunk_per_page; |
|
| 3458 | + } |
|
| 3459 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3460 | 3460 | |
| 3461 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3462 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3461 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3462 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
| 3463 | 3463 | |
| 3464 | - $clear = $i == 0 ? true : false; |
|
| 3465 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3466 | - } |
|
| 3464 | + $clear = $i == 0 ? true : false; |
|
| 3465 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
| 3466 | + } |
|
| 3467 | 3467 | |
| 3468 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3469 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3470 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3471 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3472 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3468 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3469 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3470 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3471 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3472 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3473 | 3473 | |
| 3474 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3475 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3476 | - } |
|
| 3474 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3475 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3476 | + } |
|
| 3477 | 3477 | |
| 3478 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3479 | - $json['total'] = $posts_count; |
|
| 3480 | - $json['files'] = $chunk_file_paths; |
|
| 3481 | - } else {
|
|
| 3482 | - if ($j > 1) {
|
|
| 3483 | - $json['total'] = $posts_count; |
|
| 3484 | - $json['files'] = array(); |
|
| 3485 | - } else {
|
|
| 3486 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3487 | - } |
|
| 3488 | - } |
|
| 3489 | - } |
|
| 3490 | - // WPML |
|
| 3491 | - if ($is_wpml) {
|
|
| 3492 | - $sitepress->switch_lang($active_lang, true); |
|
| 3493 | - } |
|
| 3494 | - // WPML |
|
| 3495 | - wp_send_json( $json ); |
|
| 3496 | - } |
|
| 3497 | - } |
|
| 3498 | - break; |
|
| 3499 | - case 'export_cats': {
|
|
| 3500 | - // WPML |
|
| 3501 | - $is_wpml = geodir_is_wpml(); |
|
| 3502 | - if ($is_wpml) {
|
|
| 3503 | - global $sitepress; |
|
| 3504 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3478 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3479 | + $json['total'] = $posts_count; |
|
| 3480 | + $json['files'] = $chunk_file_paths; |
|
| 3481 | + } else {
|
|
| 3482 | + if ($j > 1) {
|
|
| 3483 | + $json['total'] = $posts_count; |
|
| 3484 | + $json['files'] = array(); |
|
| 3485 | + } else {
|
|
| 3486 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3487 | + } |
|
| 3488 | + } |
|
| 3489 | + } |
|
| 3490 | + // WPML |
|
| 3491 | + if ($is_wpml) {
|
|
| 3492 | + $sitepress->switch_lang($active_lang, true); |
|
| 3493 | + } |
|
| 3494 | + // WPML |
|
| 3495 | + wp_send_json( $json ); |
|
| 3496 | + } |
|
| 3497 | + } |
|
| 3498 | + break; |
|
| 3499 | + case 'export_cats': {
|
|
| 3500 | + // WPML |
|
| 3501 | + $is_wpml = geodir_is_wpml(); |
|
| 3502 | + if ($is_wpml) {
|
|
| 3503 | + global $sitepress; |
|
| 3504 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3505 | 3505 | |
| 3506 | - $sitepress->switch_lang('all', true);
|
|
| 3507 | - } |
|
| 3508 | - // WPML |
|
| 3509 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3506 | + $sitepress->switch_lang('all', true);
|
|
| 3507 | + } |
|
| 3508 | + // WPML |
|
| 3509 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
| 3510 | 3510 | |
| 3511 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3512 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3513 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3514 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3515 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3511 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
| 3512 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3513 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3514 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3515 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
| 3516 | 3516 | |
| 3517 | - $chunk_file_paths = array(); |
|
| 3517 | + $chunk_file_paths = array(); |
|
| 3518 | 3518 | |
| 3519 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3520 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3521 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3522 | - $percentage = min( $percentage, 100 ); |
|
| 3519 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3520 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3521 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
| 3522 | + $percentage = min( $percentage, 100 ); |
|
| 3523 | 3523 | |
| 3524 | - $json['percentage'] = $percentage; |
|
| 3525 | - // WPML |
|
| 3526 | - if ($is_wpml) {
|
|
| 3527 | - $sitepress->switch_lang($active_lang, true); |
|
| 3528 | - } |
|
| 3529 | - // WPML |
|
| 3530 | - wp_send_json( $json ); |
|
| 3531 | - } else {
|
|
| 3532 | - if ( !$terms_count > 0 ) {
|
|
| 3533 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3534 | - } else {
|
|
| 3535 | - $total_terms = $terms_count; |
|
| 3536 | - if ($chunk_per_page > $terms_count) {
|
|
| 3537 | - $chunk_per_page = $terms_count; |
|
| 3538 | - } |
|
| 3539 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3524 | + $json['percentage'] = $percentage; |
|
| 3525 | + // WPML |
|
| 3526 | + if ($is_wpml) {
|
|
| 3527 | + $sitepress->switch_lang($active_lang, true); |
|
| 3528 | + } |
|
| 3529 | + // WPML |
|
| 3530 | + wp_send_json( $json ); |
|
| 3531 | + } else {
|
|
| 3532 | + if ( !$terms_count > 0 ) {
|
|
| 3533 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3534 | + } else {
|
|
| 3535 | + $total_terms = $terms_count; |
|
| 3536 | + if ($chunk_per_page > $terms_count) {
|
|
| 3537 | + $chunk_per_page = $terms_count; |
|
| 3538 | + } |
|
| 3539 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
| 3540 | 3540 | |
| 3541 | - $j = $chunk_page_no; |
|
| 3542 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3541 | + $j = $chunk_page_no; |
|
| 3542 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
| 3543 | 3543 | |
| 3544 | - $per_page = 500; |
|
| 3545 | - if ($per_page > $chunk_per_page) {
|
|
| 3546 | - $per_page = $chunk_per_page; |
|
| 3547 | - } |
|
| 3548 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3544 | + $per_page = 500; |
|
| 3545 | + if ($per_page > $chunk_per_page) {
|
|
| 3546 | + $per_page = $chunk_per_page; |
|
| 3547 | + } |
|
| 3548 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3549 | 3549 | |
| 3550 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3551 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3550 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3551 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
| 3552 | 3552 | |
| 3553 | - $clear = $i == 0 ? true : false; |
|
| 3554 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3555 | - } |
|
| 3553 | + $clear = $i == 0 ? true : false; |
|
| 3554 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
| 3555 | + } |
|
| 3556 | 3556 | |
| 3557 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3558 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3559 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3560 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3561 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3557 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3558 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3559 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3560 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3561 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3562 | 3562 | |
| 3563 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3564 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3565 | - } |
|
| 3563 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3564 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3565 | + } |
|
| 3566 | 3566 | |
| 3567 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3568 | - $json['total'] = $terms_count; |
|
| 3569 | - $json['files'] = $chunk_file_paths; |
|
| 3570 | - } else {
|
|
| 3571 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3572 | - } |
|
| 3573 | - } |
|
| 3574 | - // WPML |
|
| 3575 | - if ($is_wpml) {
|
|
| 3576 | - $sitepress->switch_lang($active_lang, true); |
|
| 3577 | - } |
|
| 3578 | - // WPML |
|
| 3579 | - wp_send_json( $json ); |
|
| 3580 | - } |
|
| 3581 | - } |
|
| 3582 | - break; |
|
| 3583 | - case 'export_locations': {
|
|
| 3584 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3585 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3586 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3587 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3588 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3567 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3568 | + $json['total'] = $terms_count; |
|
| 3569 | + $json['files'] = $chunk_file_paths; |
|
| 3570 | + } else {
|
|
| 3571 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
| 3572 | + } |
|
| 3573 | + } |
|
| 3574 | + // WPML |
|
| 3575 | + if ($is_wpml) {
|
|
| 3576 | + $sitepress->switch_lang($active_lang, true); |
|
| 3577 | + } |
|
| 3578 | + // WPML |
|
| 3579 | + wp_send_json( $json ); |
|
| 3580 | + } |
|
| 3581 | + } |
|
| 3582 | + break; |
|
| 3583 | + case 'export_locations': {
|
|
| 3584 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3585 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
| 3586 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3587 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3588 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
| 3589 | 3589 | |
| 3590 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3590 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
| 3591 | 3591 | |
| 3592 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3593 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3594 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3595 | - $percentage = min( $percentage, 100 ); |
|
| 3592 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3593 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3594 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3595 | + $percentage = min( $percentage, 100 ); |
|
| 3596 | 3596 | |
| 3597 | - $json['percentage'] = $percentage; |
|
| 3598 | - wp_send_json( $json ); |
|
| 3599 | - } else {
|
|
| 3600 | - $chunk_file_paths = array(); |
|
| 3597 | + $json['percentage'] = $percentage; |
|
| 3598 | + wp_send_json( $json ); |
|
| 3599 | + } else {
|
|
| 3600 | + $chunk_file_paths = array(); |
|
| 3601 | 3601 | |
| 3602 | - if ( !$items_count > 0 ) {
|
|
| 3603 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3604 | - } else {
|
|
| 3605 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3606 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3602 | + if ( !$items_count > 0 ) {
|
|
| 3603 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3604 | + } else {
|
|
| 3605 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3606 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3607 | 3607 | |
| 3608 | - $j = $chunk_page_no; |
|
| 3609 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3608 | + $j = $chunk_page_no; |
|
| 3609 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
| 3610 | 3610 | |
| 3611 | - $per_page = 500; |
|
| 3612 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3613 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3611 | + $per_page = 500; |
|
| 3612 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3613 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3614 | 3614 | |
| 3615 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3616 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3615 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3616 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3617 | 3617 | |
| 3618 | - $clear = $i == 0 ? true : false; |
|
| 3619 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3620 | - } |
|
| 3618 | + $clear = $i == 0 ? true : false; |
|
| 3619 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3620 | + } |
|
| 3621 | 3621 | |
| 3622 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3623 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3624 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3625 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3626 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3622 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3623 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3624 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3625 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3626 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3627 | 3627 | |
| 3628 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3629 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3630 | - } |
|
| 3628 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3629 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3630 | + } |
|
| 3631 | 3631 | |
| 3632 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3633 | - $json['total'] = $items_count; |
|
| 3634 | - $json['files'] = $chunk_file_paths; |
|
| 3635 | - } else {
|
|
| 3636 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3637 | - } |
|
| 3638 | - } |
|
| 3639 | - wp_send_json( $json ); |
|
| 3640 | - } |
|
| 3641 | - } |
|
| 3642 | - break; |
|
| 3643 | - case 'export_hoods': {
|
|
| 3644 | - $file_url_base = geodir_path_import_export() . '/'; |
|
| 3645 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3646 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3647 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3648 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3632 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3633 | + $json['total'] = $items_count; |
|
| 3634 | + $json['files'] = $chunk_file_paths; |
|
| 3635 | + } else {
|
|
| 3636 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3637 | + } |
|
| 3638 | + } |
|
| 3639 | + wp_send_json( $json ); |
|
| 3640 | + } |
|
| 3641 | + } |
|
| 3642 | + break; |
|
| 3643 | + case 'export_hoods': {
|
|
| 3644 | + $file_url_base = geodir_path_import_export() . '/'; |
|
| 3645 | + $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
| 3646 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
| 3647 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
| 3648 | + $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
| 3649 | 3649 | |
| 3650 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3650 | + $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
| 3651 | 3651 | |
| 3652 | - if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3653 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3654 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3655 | - $percentage = min( $percentage, 100 ); |
|
| 3652 | + if ( isset( $_REQUEST['_st'] ) ) {
|
|
| 3653 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
| 3654 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
| 3655 | + $percentage = min( $percentage, 100 ); |
|
| 3656 | 3656 | |
| 3657 | - $json['percentage'] = $percentage; |
|
| 3658 | - wp_send_json( $json ); |
|
| 3659 | - } else {
|
|
| 3660 | - $chunk_file_paths = array(); |
|
| 3657 | + $json['percentage'] = $percentage; |
|
| 3658 | + wp_send_json( $json ); |
|
| 3659 | + } else {
|
|
| 3660 | + $chunk_file_paths = array(); |
|
| 3661 | 3661 | |
| 3662 | - if ( !$items_count > 0 ) {
|
|
| 3663 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3664 | - } else {
|
|
| 3665 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3666 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3662 | + if ( !$items_count > 0 ) {
|
|
| 3663 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
| 3664 | + } else {
|
|
| 3665 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
| 3666 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
| 3667 | 3667 | |
| 3668 | - $j = $chunk_page_no; |
|
| 3669 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3668 | + $j = $chunk_page_no; |
|
| 3669 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
| 3670 | 3670 | |
| 3671 | - $per_page = 500; |
|
| 3672 | - $per_page = min( $per_page, $chunk_per_page ); |
|
| 3673 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3671 | + $per_page = 500; |
|
| 3672 | + $per_page = min( $per_page, $chunk_per_page ); |
|
| 3673 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
| 3674 | 3674 | |
| 3675 | - for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3676 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3675 | + for ( $i = 0; $i <= $total_pages; $i++ ) {
|
|
| 3676 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
| 3677 | 3677 | |
| 3678 | - $clear = $i == 0 ? true : false; |
|
| 3679 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3680 | - } |
|
| 3678 | + $clear = $i == 0 ? true : false; |
|
| 3679 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
| 3680 | + } |
|
| 3681 | 3681 | |
| 3682 | - if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3683 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3684 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3685 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3686 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3682 | + if ( $wp_filesystem->exists( $file_path_temp ) ) {
|
|
| 3683 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
| 3684 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
| 3685 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
| 3686 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
| 3687 | 3687 | |
| 3688 | - $file_url = $file_url_base . $chunk_file_name; |
|
| 3689 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3690 | - } |
|
| 3688 | + $file_url = $file_url_base . $chunk_file_name; |
|
| 3689 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2));
|
|
| 3690 | + } |
|
| 3691 | 3691 | |
| 3692 | - if ( !empty($chunk_file_paths) ) {
|
|
| 3693 | - $json['total'] = $items_count; |
|
| 3694 | - $json['files'] = $chunk_file_paths; |
|
| 3695 | - } else {
|
|
| 3696 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3697 | - } |
|
| 3698 | - } |
|
| 3699 | - wp_send_json( $json ); |
|
| 3700 | - } |
|
| 3701 | - } |
|
| 3702 | - break; |
|
| 3703 | - case 'prepare_import': |
|
| 3704 | - case 'import_cat': |
|
| 3705 | - case 'import_post': |
|
| 3706 | - case 'import_loc': |
|
| 3707 | - case 'import_hood': {
|
|
| 3708 | - // WPML |
|
| 3709 | - $is_wpml = geodir_is_wpml(); |
|
| 3710 | - if ($is_wpml) {
|
|
| 3711 | - global $sitepress; |
|
| 3712 | - $active_lang = ICL_LANGUAGE_CODE; |
|
| 3713 | - } |
|
| 3714 | - // WPML |
|
| 3692 | + if ( !empty($chunk_file_paths) ) {
|
|
| 3693 | + $json['total'] = $items_count; |
|
| 3694 | + $json['files'] = $chunk_file_paths; |
|
| 3695 | + } else {
|
|
| 3696 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
| 3697 | + } |
|
| 3698 | + } |
|
| 3699 | + wp_send_json( $json ); |
|
| 3700 | + } |
|
| 3701 | + } |
|
| 3702 | + break; |
|
| 3703 | + case 'prepare_import': |
|
| 3704 | + case 'import_cat': |
|
| 3705 | + case 'import_post': |
|
| 3706 | + case 'import_loc': |
|
| 3707 | + case 'import_hood': {
|
|
| 3708 | + // WPML |
|
| 3709 | + $is_wpml = geodir_is_wpml(); |
|
| 3710 | + if ($is_wpml) {
|
|
| 3711 | + global $sitepress; |
|
| 3712 | + $active_lang = ICL_LANGUAGE_CODE; |
|
| 3713 | + } |
|
| 3714 | + // WPML |
|
| 3715 | 3715 | |
| 3716 | - ini_set( 'auto_detect_line_endings', true ); |
|
| 3716 | + ini_set( 'auto_detect_line_endings', true ); |
|
| 3717 | 3717 | |
| 3718 | - $uploads = wp_upload_dir(); |
|
| 3719 | - $uploads_dir = $uploads['path']; |
|
| 3720 | - $uploads_subdir = $uploads['subdir']; |
|
| 3718 | + $uploads = wp_upload_dir(); |
|
| 3719 | + $uploads_dir = $uploads['path']; |
|
| 3720 | + $uploads_subdir = $uploads['subdir']; |
|
| 3721 | 3721 | |
| 3722 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3723 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3722 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
| 3723 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
| 3724 | 3724 | |
| 3725 | - $csv_file_arr = explode( '/', $csv_file ); |
|
| 3726 | - $csv_filename = end( $csv_file_arr ); |
|
| 3727 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3725 | + $csv_file_arr = explode( '/', $csv_file ); |
|
| 3726 | + $csv_filename = end( $csv_file_arr ); |
|
| 3727 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
| 3728 | 3728 | |
| 3729 | - $json['file'] = $csv_file; |
|
| 3730 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3731 | - $file = array(); |
|
| 3729 | + $json['file'] = $csv_file; |
|
| 3730 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
| 3731 | + $file = array(); |
|
| 3732 | 3732 | |
| 3733 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3734 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3733 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) {
|
|
| 3734 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
| 3735 | 3735 | |
| 3736 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 3737 | - $json['error'] = NULL; |
|
| 3738 | - $json['rows'] = 0; |
|
| 3736 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 3737 | + $json['error'] = NULL; |
|
| 3738 | + $json['rows'] = 0; |
|
| 3739 | 3739 | |
| 3740 | - $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
| 3741 | - setlocale(LC_ALL, 'en_US.UTF-8'); |
|
| 3742 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 3743 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 3744 | - if ( !empty( $data ) ) {
|
|
| 3745 | - $file[] = $data; |
|
| 3746 | - } |
|
| 3747 | - } |
|
| 3748 | - fclose($handle); |
|
| 3749 | - } |
|
| 3750 | - setlocale(LC_ALL, $lc_all); |
|
| 3740 | + $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
| 3741 | + setlocale(LC_ALL, 'en_US.UTF-8'); |
|
| 3742 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) {
|
|
| 3743 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) {
|
|
| 3744 | + if ( !empty( $data ) ) {
|
|
| 3745 | + $file[] = $data; |
|
| 3746 | + } |
|
| 3747 | + } |
|
| 3748 | + fclose($handle); |
|
| 3749 | + } |
|
| 3750 | + setlocale(LC_ALL, $lc_all); |
|
| 3751 | 3751 | |
| 3752 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 3752 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 3753 | 3753 | |
| 3754 | - if (!$json['rows'] > 0) {
|
|
| 3755 | - $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 3756 | - } |
|
| 3757 | - } else {
|
|
| 3758 | - wp_send_json( $json ); |
|
| 3759 | - } |
|
| 3760 | - } else {
|
|
| 3761 | - wp_send_json( $json ); |
|
| 3762 | - } |
|
| 3754 | + if (!$json['rows'] > 0) {
|
|
| 3755 | + $json['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 3756 | + } |
|
| 3757 | + } else {
|
|
| 3758 | + wp_send_json( $json ); |
|
| 3759 | + } |
|
| 3760 | + } else {
|
|
| 3761 | + wp_send_json( $json ); |
|
| 3762 | + } |
|
| 3763 | 3763 | |
| 3764 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 3765 | - wp_send_json( $json ); |
|
| 3766 | - } |
|
| 3764 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) {
|
|
| 3765 | + wp_send_json( $json ); |
|
| 3766 | + } |
|
| 3767 | 3767 | |
| 3768 | - $total = $json['rows']; |
|
| 3769 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 3770 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 3768 | + $total = $json['rows']; |
|
| 3769 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
| 3770 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
| 3771 | 3771 | |
| 3772 | - $count = $limit; |
|
| 3772 | + $count = $limit; |
|
| 3773 | 3773 | |
| 3774 | - if ($count < $total) {
|
|
| 3775 | - $count = $processed + $count; |
|
| 3776 | - if ($count > $total) {
|
|
| 3777 | - $count = $total; |
|
| 3778 | - } |
|
| 3779 | - } else {
|
|
| 3780 | - $count = $total; |
|
| 3781 | - } |
|
| 3774 | + if ($count < $total) {
|
|
| 3775 | + $count = $processed + $count; |
|
| 3776 | + if ($count > $total) {
|
|
| 3777 | + $count = $total; |
|
| 3778 | + } |
|
| 3779 | + } else {
|
|
| 3780 | + $count = $total; |
|
| 3781 | + } |
|
| 3782 | 3782 | |
| 3783 | - $created = 0; |
|
| 3784 | - $updated = 0; |
|
| 3785 | - $skipped = 0; |
|
| 3786 | - $invalid = 0; |
|
| 3787 | - $invalid_addr = 0; |
|
| 3788 | - $images = 0; |
|
| 3783 | + $created = 0; |
|
| 3784 | + $updated = 0; |
|
| 3785 | + $skipped = 0; |
|
| 3786 | + $invalid = 0; |
|
| 3787 | + $invalid_addr = 0; |
|
| 3788 | + $images = 0; |
|
| 3789 | 3789 | |
| 3790 | - $gd_post_info = array(); |
|
| 3791 | - $countpost = 0; |
|
| 3790 | + $gd_post_info = array(); |
|
| 3791 | + $countpost = 0; |
|
| 3792 | 3792 | |
| 3793 | - $post_types = geodir_get_posttypes(); |
|
| 3793 | + $post_types = geodir_get_posttypes(); |
|
| 3794 | 3794 | |
| 3795 | - if ( $task == 'import_cat' ) {
|
|
| 3796 | - if (!empty($file)) {
|
|
| 3797 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 3795 | + if ( $task == 'import_cat' ) {
|
|
| 3796 | + if (!empty($file)) {
|
|
| 3797 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 3798 | 3798 | |
| 3799 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 3800 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 3801 | - wp_send_json( $json ); |
|
| 3802 | - exit; |
|
| 3803 | - } |
|
| 3799 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 3800 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 3801 | + wp_send_json( $json ); |
|
| 3802 | + exit; |
|
| 3803 | + } |
|
| 3804 | 3804 | |
| 3805 | - $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 3805 | + $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory');
|
|
| 3806 | 3806 | |
| 3807 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 3808 | - $index = $processed + $i; |
|
| 3807 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 3808 | + $index = $processed + $i; |
|
| 3809 | 3809 | |
| 3810 | - if (isset($file[$index])) {
|
|
| 3811 | - $row = $file[$index]; |
|
| 3812 | - $row = array_map( 'trim', $row ); |
|
| 3813 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 3810 | + if (isset($file[$index])) {
|
|
| 3811 | + $row = $file[$index]; |
|
| 3812 | + $row = array_map( 'trim', $row ); |
|
| 3813 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 3814 | 3814 | |
| 3815 | - $cat_id = ''; |
|
| 3816 | - $cat_name = ''; |
|
| 3817 | - $cat_slug = ''; |
|
| 3818 | - $cat_posttype = ''; |
|
| 3819 | - $cat_parent = ''; |
|
| 3820 | - $cat_description = ''; |
|
| 3821 | - $cat_schema = ''; |
|
| 3822 | - $cat_top_description = ''; |
|
| 3823 | - $cat_image = ''; |
|
| 3824 | - $cat_icon = ''; |
|
| 3825 | - $cat_language = ''; |
|
| 3826 | - $cat_id_original = ''; |
|
| 3815 | + $cat_id = ''; |
|
| 3816 | + $cat_name = ''; |
|
| 3817 | + $cat_slug = ''; |
|
| 3818 | + $cat_posttype = ''; |
|
| 3819 | + $cat_parent = ''; |
|
| 3820 | + $cat_description = ''; |
|
| 3821 | + $cat_schema = ''; |
|
| 3822 | + $cat_top_description = ''; |
|
| 3823 | + $cat_image = ''; |
|
| 3824 | + $cat_icon = ''; |
|
| 3825 | + $cat_language = ''; |
|
| 3826 | + $cat_id_original = ''; |
|
| 3827 | 3827 | |
| 3828 | - $c = 0; |
|
| 3829 | - foreach ($columns as $column ) {
|
|
| 3830 | - if ( $column == 'cat_id' ) {
|
|
| 3831 | - $cat_id = (int)$row[$c]; |
|
| 3832 | - } else if ( $column == 'cat_name' ) {
|
|
| 3833 | - $cat_name = $row[$c]; |
|
| 3834 | - } else if ( $column == 'cat_slug' ) {
|
|
| 3835 | - $cat_slug = $row[$c]; |
|
| 3836 | - } else if ( $column == 'cat_posttype' ) {
|
|
| 3837 | - $cat_posttype = $row[$c]; |
|
| 3838 | - } else if ( $column == 'cat_parent' ) {
|
|
| 3839 | - $cat_parent = trim($row[$c]); |
|
| 3840 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 3841 | - $cat_schema = $row[$c]; |
|
| 3842 | - } else if ( $column == 'cat_description' ) {
|
|
| 3843 | - $cat_description = $row[$c]; |
|
| 3844 | - } else if ( $column == 'cat_top_description' ) {
|
|
| 3845 | - $cat_top_description = $row[$c]; |
|
| 3846 | - } else if ( $column == 'cat_image' ) {
|
|
| 3847 | - $cat_image = $row[$c]; |
|
| 3848 | - } else if ( $column == 'cat_icon' ) {
|
|
| 3849 | - $cat_icon = $row[$c]; |
|
| 3850 | - } |
|
| 3851 | - // WPML |
|
| 3852 | - if ( $is_wpml ) {
|
|
| 3853 | - if ( $column == 'cat_language' ) {
|
|
| 3854 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 3855 | - } else if ( $column == 'cat_id_original' ) {
|
|
| 3856 | - $cat_id_original = (int)$row[$c]; |
|
| 3857 | - } |
|
| 3858 | - } |
|
| 3859 | - // WPML |
|
| 3860 | - $c++; |
|
| 3861 | - } |
|
| 3828 | + $c = 0; |
|
| 3829 | + foreach ($columns as $column ) {
|
|
| 3830 | + if ( $column == 'cat_id' ) {
|
|
| 3831 | + $cat_id = (int)$row[$c]; |
|
| 3832 | + } else if ( $column == 'cat_name' ) {
|
|
| 3833 | + $cat_name = $row[$c]; |
|
| 3834 | + } else if ( $column == 'cat_slug' ) {
|
|
| 3835 | + $cat_slug = $row[$c]; |
|
| 3836 | + } else if ( $column == 'cat_posttype' ) {
|
|
| 3837 | + $cat_posttype = $row[$c]; |
|
| 3838 | + } else if ( $column == 'cat_parent' ) {
|
|
| 3839 | + $cat_parent = trim($row[$c]); |
|
| 3840 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) {
|
|
| 3841 | + $cat_schema = $row[$c]; |
|
| 3842 | + } else if ( $column == 'cat_description' ) {
|
|
| 3843 | + $cat_description = $row[$c]; |
|
| 3844 | + } else if ( $column == 'cat_top_description' ) {
|
|
| 3845 | + $cat_top_description = $row[$c]; |
|
| 3846 | + } else if ( $column == 'cat_image' ) {
|
|
| 3847 | + $cat_image = $row[$c]; |
|
| 3848 | + } else if ( $column == 'cat_icon' ) {
|
|
| 3849 | + $cat_icon = $row[$c]; |
|
| 3850 | + } |
|
| 3851 | + // WPML |
|
| 3852 | + if ( $is_wpml ) {
|
|
| 3853 | + if ( $column == 'cat_language' ) {
|
|
| 3854 | + $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
| 3855 | + } else if ( $column == 'cat_id_original' ) {
|
|
| 3856 | + $cat_id_original = (int)$row[$c]; |
|
| 3857 | + } |
|
| 3858 | + } |
|
| 3859 | + // WPML |
|
| 3860 | + $c++; |
|
| 3861 | + } |
|
| 3862 | 3862 | |
| 3863 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 3864 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 3863 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) {
|
|
| 3864 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 3865 | 3865 | |
| 3866 | - $invalid++; |
|
| 3867 | - continue; |
|
| 3868 | - } |
|
| 3866 | + $invalid++; |
|
| 3867 | + continue; |
|
| 3868 | + } |
|
| 3869 | 3869 | |
| 3870 | - // WPML |
|
| 3871 | - if ($is_wpml && $cat_language != '') {
|
|
| 3872 | - $sitepress->switch_lang($cat_language, true); |
|
| 3873 | - } |
|
| 3874 | - // WPML |
|
| 3870 | + // WPML |
|
| 3871 | + if ($is_wpml && $cat_language != '') {
|
|
| 3872 | + $sitepress->switch_lang($cat_language, true); |
|
| 3873 | + } |
|
| 3874 | + // WPML |
|
| 3875 | 3875 | |
| 3876 | - $term_data = array(); |
|
| 3877 | - $term_data['name'] = $cat_name; |
|
| 3878 | - $term_data['slug'] = $cat_slug; |
|
| 3879 | - $term_data['description'] = $cat_description; |
|
| 3880 | - $term_data['cat_schema'] = $cat_schema; |
|
| 3881 | - $term_data['top_description'] = $cat_top_description; |
|
| 3882 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 3883 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 3876 | + $term_data = array(); |
|
| 3877 | + $term_data['name'] = $cat_name; |
|
| 3878 | + $term_data['slug'] = $cat_slug; |
|
| 3879 | + $term_data['description'] = $cat_description; |
|
| 3880 | + $term_data['cat_schema'] = $cat_schema; |
|
| 3881 | + $term_data['top_description'] = $cat_top_description; |
|
| 3882 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
| 3883 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
| 3884 | 3884 | |
| 3885 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 3885 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
| 3886 | 3886 | |
| 3887 | - $taxonomy = $cat_posttype . 'category'; |
|
| 3887 | + $taxonomy = $cat_posttype . 'category'; |
|
| 3888 | 3888 | |
| 3889 | - $term_data['taxonomy'] = $taxonomy; |
|
| 3889 | + $term_data['taxonomy'] = $taxonomy; |
|
| 3890 | 3890 | |
| 3891 | - $term_parent_id = 0; |
|
| 3892 | - if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 3893 | - $term_parent = ''; |
|
| 3891 | + $term_parent_id = 0; |
|
| 3892 | + if ($cat_parent != "" || (int)$cat_parent > 0) {
|
|
| 3893 | + $term_parent = ''; |
|
| 3894 | 3894 | |
| 3895 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 3896 | - // |
|
| 3897 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 3898 | - // |
|
| 3899 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 3900 | - // |
|
| 3901 | - } else {
|
|
| 3902 | - $term_parent_data = array(); |
|
| 3903 | - $term_parent_data['name'] = $cat_parent; |
|
| 3904 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 3905 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
| 3895 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) {
|
|
| 3896 | + // |
|
| 3897 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) {
|
|
| 3898 | + // |
|
| 3899 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) {
|
|
| 3900 | + // |
|
| 3901 | + } else {
|
|
| 3902 | + $term_parent_data = array(); |
|
| 3903 | + $term_parent_data['name'] = $cat_parent; |
|
| 3904 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
| 3905 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
| 3906 | 3906 | |
| 3907 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 3908 | - } |
|
| 3907 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
| 3908 | + } |
|
| 3909 | 3909 | |
| 3910 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 3911 | - $term_parent_id = (int)$term_parent->term_id; |
|
| 3912 | - } |
|
| 3913 | - } |
|
| 3914 | - $term_data['parent'] = (int)$term_parent_id; |
|
| 3910 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) {
|
|
| 3911 | + $term_parent_id = (int)$term_parent->term_id; |
|
| 3912 | + } |
|
| 3913 | + } |
|
| 3914 | + $term_data['parent'] = (int)$term_parent_id; |
|
| 3915 | 3915 | |
| 3916 | - $term_id = NULL; |
|
| 3917 | - if ( $import_choice == 'update' ) {
|
|
| 3918 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3919 | - $term_data['term_id'] = $term['term_id']; |
|
| 3916 | + $term_id = NULL; |
|
| 3917 | + if ( $import_choice == 'update' ) {
|
|
| 3918 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3919 | + $term_data['term_id'] = $term['term_id']; |
|
| 3920 | 3920 | |
| 3921 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3922 | - $updated++; |
|
| 3923 | - } else {
|
|
| 3924 | - $invalid++; |
|
| 3925 | - 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' ) ); |
|
| 3926 | - } |
|
| 3927 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3928 | - $term_data['term_id'] = $term['term_id']; |
|
| 3921 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) {
|
|
| 3922 | + $updated++; |
|
| 3923 | + } else {
|
|
| 3924 | + $invalid++; |
|
| 3925 | + 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' ) ); |
|
| 3926 | + } |
|
| 3927 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $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 {
|
|
| 3937 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3938 | - $created++; |
|
| 3939 | - } else {
|
|
| 3940 | - $invalid++; |
|
| 3941 | - 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' ) ); |
|
| 3942 | - } |
|
| 3943 | - } |
|
| 3944 | - } else if ( $import_choice == 'skip' ) {
|
|
| 3945 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3946 | - $skipped++; |
|
| 3947 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3948 | - $skipped++; |
|
| 3949 | - } else {
|
|
| 3950 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3951 | - $created++; |
|
| 3952 | - } else {
|
|
| 3953 | - $invalid++; |
|
| 3954 | - 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' ) ); |
|
| 3955 | - } |
|
| 3956 | - } |
|
| 3957 | - } else {
|
|
| 3958 | - $invalid++; |
|
| 3959 | - 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' ) ); |
|
| 3960 | - } |
|
| 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 {
|
|
| 3937 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3938 | + $created++; |
|
| 3939 | + } else {
|
|
| 3940 | + $invalid++; |
|
| 3941 | + 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' ) ); |
|
| 3942 | + } |
|
| 3943 | + } |
|
| 3944 | + } else if ( $import_choice == 'skip' ) {
|
|
| 3945 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) {
|
|
| 3946 | + $skipped++; |
|
| 3947 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
|
| 3948 | + $skipped++; |
|
| 3949 | + } else {
|
|
| 3950 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) {
|
|
| 3951 | + $created++; |
|
| 3952 | + } else {
|
|
| 3953 | + $invalid++; |
|
| 3954 | + 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' ) ); |
|
| 3955 | + } |
|
| 3956 | + } |
|
| 3957 | + } else {
|
|
| 3958 | + $invalid++; |
|
| 3959 | + 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' ) ); |
|
| 3960 | + } |
|
| 3961 | 3961 | |
| 3962 | - if ( $term_id ) {
|
|
| 3963 | - // WPML |
|
| 3964 | - if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 3965 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
| 3966 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 3967 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 3968 | - |
|
| 3969 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 3962 | + if ( $term_id ) {
|
|
| 3963 | + // WPML |
|
| 3964 | + if ($is_wpml && $cat_id_original > 0 && $cat_language != '') {
|
|
| 3965 | + $wpml_element_type = 'tax_' . $taxonomy; |
|
| 3966 | + $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
| 3967 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 3968 | + |
|
| 3969 | + $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
| 3970 | 3970 | |
| 3971 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 3972 | - } |
|
| 3973 | - // WPML |
|
| 3971 | + $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
| 3972 | + } |
|
| 3973 | + // WPML |
|
| 3974 | 3974 | |
| 3975 | - if ( isset( $term_data['top_description'] ) ) {
|
|
| 3976 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 3977 | - } |
|
| 3975 | + if ( isset( $term_data['top_description'] ) ) {
|
|
| 3976 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
| 3977 | + } |
|
| 3978 | 3978 | |
| 3979 | - if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 3980 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 3981 | - } |
|
| 3979 | + if ( isset( $term_data['cat_schema'] ) ) {
|
|
| 3980 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
| 3981 | + } |
|
| 3982 | 3982 | |
| 3983 | - $attachment = false; |
|
| 3984 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 3985 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 3986 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 3983 | + $attachment = false; |
|
| 3984 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) {
|
|
| 3985 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
| 3986 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
| 3987 | 3987 | |
| 3988 | - if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 3989 | - $attachment = true; |
|
| 3990 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 3991 | - } |
|
| 3992 | - } |
|
| 3988 | + if ( basename($cat_image) != $term_data['image'] ) {
|
|
| 3989 | + $attachment = true; |
|
| 3990 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
| 3991 | + } |
|
| 3992 | + } |
|
| 3993 | 3993 | |
| 3994 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 3995 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 3996 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 3997 | - |
|
| 3998 | - if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 3999 | - $attachment = true; |
|
| 4000 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4001 | - } |
|
| 4002 | - } |
|
| 3994 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) {
|
|
| 3995 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
| 3996 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
| 3997 | + |
|
| 3998 | + if ( basename($cat_icon) != $term_data['icon'] ) {
|
|
| 3999 | + $attachment = true; |
|
| 4000 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
| 4001 | + } |
|
| 4002 | + } |
|
| 4003 | 4003 | |
| 4004 | - if ( $attachment ) {
|
|
| 4005 | - $images++; |
|
| 4006 | - } |
|
| 4007 | - } |
|
| 4004 | + if ( $attachment ) {
|
|
| 4005 | + $images++; |
|
| 4006 | + } |
|
| 4007 | + } |
|
| 4008 | 4008 | |
| 4009 | - // WPML |
|
| 4010 | - if ($is_wpml && $cat_language != '') {
|
|
| 4011 | - $sitepress->switch_lang($active_lang, true); |
|
| 4012 | - } |
|
| 4013 | - // WPML |
|
| 4014 | - } |
|
| 4015 | - } |
|
| 4016 | - } |
|
| 4009 | + // WPML |
|
| 4010 | + if ($is_wpml && $cat_language != '') {
|
|
| 4011 | + $sitepress->switch_lang($active_lang, true); |
|
| 4012 | + } |
|
| 4013 | + // WPML |
|
| 4014 | + } |
|
| 4015 | + } |
|
| 4016 | + } |
|
| 4017 | 4017 | |
| 4018 | - $json = array(); |
|
| 4019 | - $json['processed'] = $limit; |
|
| 4020 | - $json['created'] = $created; |
|
| 4021 | - $json['updated'] = $updated; |
|
| 4022 | - $json['skipped'] = $skipped; |
|
| 4023 | - $json['invalid'] = $invalid; |
|
| 4024 | - $json['images'] = $images; |
|
| 4018 | + $json = array(); |
|
| 4019 | + $json['processed'] = $limit; |
|
| 4020 | + $json['created'] = $created; |
|
| 4021 | + $json['updated'] = $updated; |
|
| 4022 | + $json['skipped'] = $skipped; |
|
| 4023 | + $json['invalid'] = $invalid; |
|
| 4024 | + $json['images'] = $images; |
|
| 4025 | 4025 | |
| 4026 | - wp_send_json( $json ); |
|
| 4027 | - exit; |
|
| 4028 | - } else if ( $task == 'import_post' ) {
|
|
| 4029 | - $xtimings['###1'] = microtime(true)-$xstart; |
|
| 4030 | - //run some stuff to make the import quicker |
|
| 4031 | - wp_defer_term_counting( true ); |
|
| 4032 | - wp_defer_comment_counting( true ); |
|
| 4033 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4026 | + wp_send_json( $json ); |
|
| 4027 | + exit; |
|
| 4028 | + } else if ( $task == 'import_post' ) {
|
|
| 4029 | + $xtimings['###1'] = microtime(true)-$xstart; |
|
| 4030 | + //run some stuff to make the import quicker |
|
| 4031 | + wp_defer_term_counting( true ); |
|
| 4032 | + wp_defer_comment_counting( true ); |
|
| 4033 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
| 4034 | 4034 | // |
| 4035 | 4035 | // remove_all_actions('publish_post');
|
| 4036 | 4036 | // remove_all_actions('transition_post_status');
|
| 4037 | 4037 | // remove_all_actions('publish_future_post');
|
| 4038 | 4038 | |
| 4039 | - if (!empty($file)) {
|
|
| 4040 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 4041 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4042 | - $default_status = 'publish'; |
|
| 4043 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4039 | + if (!empty($file)) {
|
|
| 4040 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 4041 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
| 4042 | + $default_status = 'publish'; |
|
| 4043 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
| 4044 | 4044 | |
| 4045 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4045 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4046 | 4046 | |
| 4047 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4048 | - $json['error'] = CSV_INVAILD_FILE; |
|
| 4049 | - wp_send_json( $json ); |
|
| 4050 | - exit; |
|
| 4051 | - } |
|
| 4052 | - $xtimings['###2'] = microtime(true)-$xstart; |
|
| 4053 | - $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4054 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4055 | - $processed_actual = 0; |
|
| 4056 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4057 | - $index = $processed + $i; |
|
| 4058 | - $gd_post = array(); |
|
| 4047 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4048 | + $json['error'] = CSV_INVAILD_FILE; |
|
| 4049 | + wp_send_json( $json ); |
|
| 4050 | + exit; |
|
| 4051 | + } |
|
| 4052 | + $xtimings['###2'] = microtime(true)-$xstart; |
|
| 4053 | + $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory');
|
|
| 4054 | + $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
| 4055 | + $processed_actual = 0; |
|
| 4056 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4057 | + $index = $processed + $i; |
|
| 4058 | + $gd_post = array(); |
|
| 4059 | 4059 | |
| 4060 | - if (isset($file[$index])) {
|
|
| 4061 | - $processed_actual++; |
|
| 4062 | - $row = $file[$index]; |
|
| 4063 | - $row = array_map( 'trim', $row ); |
|
| 4064 | - //$row = array_map( 'utf8_encode', $row ); |
|
| 4065 | - $row = array_map( 'addslashes_gpc', $row ); |
|
| 4060 | + if (isset($file[$index])) {
|
|
| 4061 | + $processed_actual++; |
|
| 4062 | + $row = $file[$index]; |
|
| 4063 | + $row = array_map( 'trim', $row ); |
|
| 4064 | + //$row = array_map( 'utf8_encode', $row ); |
|
| 4065 | + $row = array_map( 'addslashes_gpc', $row ); |
|
| 4066 | 4066 | |
| 4067 | - $post_id = ''; |
|
| 4068 | - $post_title = ''; |
|
| 4069 | - $post_author = ''; |
|
| 4070 | - $post_content = ''; |
|
| 4071 | - $post_category_arr = array(); |
|
| 4072 | - $default_category = ''; |
|
| 4073 | - $post_tags = array(); |
|
| 4074 | - $post_type = ''; |
|
| 4075 | - $post_status = ''; |
|
| 4076 | - $geodir_video = ''; |
|
| 4077 | - $post_address = ''; |
|
| 4078 | - $post_city = ''; |
|
| 4079 | - $post_region = ''; |
|
| 4080 | - $post_country = ''; |
|
| 4081 | - $post_zip = ''; |
|
| 4082 | - $post_latitude = ''; |
|
| 4083 | - $post_longitude = ''; |
|
| 4084 | - $post_neighbourhood = ''; |
|
| 4085 | - $neighbourhood_latitude = ''; |
|
| 4086 | - $neighbourhood_longitude = ''; |
|
| 4087 | - $geodir_timing = ''; |
|
| 4088 | - $geodir_contact = ''; |
|
| 4089 | - $geodir_email = ''; |
|
| 4090 | - $geodir_website = ''; |
|
| 4091 | - $geodir_twitter = ''; |
|
| 4092 | - $geodir_facebook = ''; |
|
| 4093 | - $geodir_twitter = ''; |
|
| 4094 | - $post_images = array(); |
|
| 4067 | + $post_id = ''; |
|
| 4068 | + $post_title = ''; |
|
| 4069 | + $post_author = ''; |
|
| 4070 | + $post_content = ''; |
|
| 4071 | + $post_category_arr = array(); |
|
| 4072 | + $default_category = ''; |
|
| 4073 | + $post_tags = array(); |
|
| 4074 | + $post_type = ''; |
|
| 4075 | + $post_status = ''; |
|
| 4076 | + $geodir_video = ''; |
|
| 4077 | + $post_address = ''; |
|
| 4078 | + $post_city = ''; |
|
| 4079 | + $post_region = ''; |
|
| 4080 | + $post_country = ''; |
|
| 4081 | + $post_zip = ''; |
|
| 4082 | + $post_latitude = ''; |
|
| 4083 | + $post_longitude = ''; |
|
| 4084 | + $post_neighbourhood = ''; |
|
| 4085 | + $neighbourhood_latitude = ''; |
|
| 4086 | + $neighbourhood_longitude = ''; |
|
| 4087 | + $geodir_timing = ''; |
|
| 4088 | + $geodir_contact = ''; |
|
| 4089 | + $geodir_email = ''; |
|
| 4090 | + $geodir_website = ''; |
|
| 4091 | + $geodir_twitter = ''; |
|
| 4092 | + $geodir_facebook = ''; |
|
| 4093 | + $geodir_twitter = ''; |
|
| 4094 | + $post_images = array(); |
|
| 4095 | 4095 | |
| 4096 | - $expire_date = 'Never'; |
|
| 4096 | + $expire_date = 'Never'; |
|
| 4097 | 4097 | |
| 4098 | - $language = ''; |
|
| 4099 | - $original_post_id = ''; |
|
| 4098 | + $language = ''; |
|
| 4099 | + $original_post_id = ''; |
|
| 4100 | 4100 | |
| 4101 | - $c = 0; |
|
| 4102 | - foreach ($columns as $column ) {
|
|
| 4103 | - $gd_post[$column] = $row[$c]; |
|
| 4101 | + $c = 0; |
|
| 4102 | + foreach ($columns as $column ) {
|
|
| 4103 | + $gd_post[$column] = $row[$c]; |
|
| 4104 | 4104 | |
| 4105 | - if ( $column == 'post_id' ) {
|
|
| 4106 | - $post_id = $row[$c]; |
|
| 4107 | - } else if ( $column == 'post_title' ) {
|
|
| 4108 | - $post_title = sanitize_text_field($row[$c]); |
|
| 4109 | - } else if ( $column == 'post_author' ) {
|
|
| 4110 | - $post_author = $row[$c]; |
|
| 4111 | - } else if ( $column == 'post_content' ) {
|
|
| 4112 | - $post_content = $row[$c]; |
|
| 4113 | - } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4114 | - $post_category_arr = explode( ',', $row[$c] ); |
|
| 4115 | - } else if ( $column == 'default_category' ) {
|
|
| 4116 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4117 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4118 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4119 | - } else if ( $column == 'post_type' ) {
|
|
| 4120 | - $post_type = $row[$c]; |
|
| 4121 | - } else if ( $column == 'post_status' ) {
|
|
| 4122 | - $post_status = sanitize_key( $row[$c] ); |
|
| 4123 | - } else if ( $column == 'is_featured' ) {
|
|
| 4124 | - $is_featured = (int)$row[$c]; |
|
| 4125 | - } else if ( $column == 'geodir_video' ) {
|
|
| 4126 | - $geodir_video = $row[$c]; |
|
| 4127 | - } else if ( $column == 'post_address' ) {
|
|
| 4128 | - $post_address = sanitize_text_field($row[$c]); |
|
| 4129 | - } else if ( $column == 'post_city' ) {
|
|
| 4130 | - $post_city = sanitize_text_field($row[$c]); |
|
| 4131 | - } else if ( $column == 'post_region' ) {
|
|
| 4132 | - $post_region = sanitize_text_field($row[$c]); |
|
| 4133 | - } else if ( $column == 'post_country' ) {
|
|
| 4134 | - $post_country = sanitize_text_field($row[$c]); |
|
| 4135 | - } else if ( $column == 'post_zip' ) {
|
|
| 4136 | - $post_zip = sanitize_text_field($row[$c]); |
|
| 4137 | - } else if ( $column == 'post_latitude' ) {
|
|
| 4138 | - $post_latitude = sanitize_text_field($row[$c]); |
|
| 4139 | - } else if ( $column == 'post_longitude' ) {
|
|
| 4140 | - $post_longitude = sanitize_text_field($row[$c]); |
|
| 4141 | - } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4142 | - $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4143 | - unset($gd_post[$column]); |
|
| 4144 | - } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4145 | - $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4146 | - } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4147 | - $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4148 | - } else if ( $column == 'geodir_timing' ) {
|
|
| 4149 | - $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4150 | - } else if ( $column == 'geodir_contact' ) {
|
|
| 4151 | - $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4152 | - } else if ( $column == 'geodir_email' ) {
|
|
| 4153 | - $geodir_email = sanitize_email($row[$c]); |
|
| 4154 | - } else if ( $column == 'geodir_website' ) {
|
|
| 4155 | - $geodir_website = sanitize_text_field($row[$c]); |
|
| 4156 | - } else if ( $column == 'geodir_twitter' ) {
|
|
| 4157 | - $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4158 | - } else if ( $column == 'geodir_facebook' ) {
|
|
| 4159 | - $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4160 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4161 | - $post_images[] = $row[$c]; |
|
| 4162 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4163 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4164 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4165 | - $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4166 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4167 | - } |
|
| 4168 | - // WPML |
|
| 4169 | - if ($is_wpml) {
|
|
| 4170 | - if ($column == 'language') {
|
|
| 4171 | - $language = geodir_strtolower(trim($row[$c])); |
|
| 4172 | - } else if ($column == 'original_post_id') {
|
|
| 4173 | - $original_post_id = (int)$row[$c]; |
|
| 4174 | - } |
|
| 4175 | - } |
|
| 4176 | - // WPML |
|
| 4177 | - $c++; |
|
| 4178 | - } |
|
| 4179 | - // listing claimed or not |
|
| 4180 | - if ($is_claim_active && isset($gd_post['claimed'])) {
|
|
| 4181 | - $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
| 4182 | - } |
|
| 4105 | + if ( $column == 'post_id' ) {
|
|
| 4106 | + $post_id = $row[$c]; |
|
| 4107 | + } else if ( $column == 'post_title' ) {
|
|
| 4108 | + $post_title = sanitize_text_field($row[$c]); |
|
| 4109 | + } else if ( $column == 'post_author' ) {
|
|
| 4110 | + $post_author = $row[$c]; |
|
| 4111 | + } else if ( $column == 'post_content' ) {
|
|
| 4112 | + $post_content = $row[$c]; |
|
| 4113 | + } else if ( $column == 'post_category' && $row[$c] != '' ) {
|
|
| 4114 | + $post_category_arr = explode( ',', $row[$c] ); |
|
| 4115 | + } else if ( $column == 'default_category' ) {
|
|
| 4116 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
| 4117 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) {
|
|
| 4118 | + $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
| 4119 | + } else if ( $column == 'post_type' ) {
|
|
| 4120 | + $post_type = $row[$c]; |
|
| 4121 | + } else if ( $column == 'post_status' ) {
|
|
| 4122 | + $post_status = sanitize_key( $row[$c] ); |
|
| 4123 | + } else if ( $column == 'is_featured' ) {
|
|
| 4124 | + $is_featured = (int)$row[$c]; |
|
| 4125 | + } else if ( $column == 'geodir_video' ) {
|
|
| 4126 | + $geodir_video = $row[$c]; |
|
| 4127 | + } else if ( $column == 'post_address' ) {
|
|
| 4128 | + $post_address = sanitize_text_field($row[$c]); |
|
| 4129 | + } else if ( $column == 'post_city' ) {
|
|
| 4130 | + $post_city = sanitize_text_field($row[$c]); |
|
| 4131 | + } else if ( $column == 'post_region' ) {
|
|
| 4132 | + $post_region = sanitize_text_field($row[$c]); |
|
| 4133 | + } else if ( $column == 'post_country' ) {
|
|
| 4134 | + $post_country = sanitize_text_field($row[$c]); |
|
| 4135 | + } else if ( $column == 'post_zip' ) {
|
|
| 4136 | + $post_zip = sanitize_text_field($row[$c]); |
|
| 4137 | + } else if ( $column == 'post_latitude' ) {
|
|
| 4138 | + $post_latitude = sanitize_text_field($row[$c]); |
|
| 4139 | + } else if ( $column == 'post_longitude' ) {
|
|
| 4140 | + $post_longitude = sanitize_text_field($row[$c]); |
|
| 4141 | + } else if ( $column == 'post_neighbourhood' ) {
|
|
| 4142 | + $post_neighbourhood = sanitize_text_field($row[$c]); |
|
| 4143 | + unset($gd_post[$column]); |
|
| 4144 | + } else if ( $column == 'neighbourhood_latitude' ) {
|
|
| 4145 | + $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
| 4146 | + } else if ( $column == 'neighbourhood_longitude' ) {
|
|
| 4147 | + $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
| 4148 | + } else if ( $column == 'geodir_timing' ) {
|
|
| 4149 | + $geodir_timing = sanitize_text_field($row[$c]); |
|
| 4150 | + } else if ( $column == 'geodir_contact' ) {
|
|
| 4151 | + $geodir_contact = sanitize_text_field($row[$c]); |
|
| 4152 | + } else if ( $column == 'geodir_email' ) {
|
|
| 4153 | + $geodir_email = sanitize_email($row[$c]); |
|
| 4154 | + } else if ( $column == 'geodir_website' ) {
|
|
| 4155 | + $geodir_website = sanitize_text_field($row[$c]); |
|
| 4156 | + } else if ( $column == 'geodir_twitter' ) {
|
|
| 4157 | + $geodir_twitter = sanitize_text_field($row[$c]); |
|
| 4158 | + } else if ( $column == 'geodir_facebook' ) {
|
|
| 4159 | + $geodir_facebook = sanitize_text_field($row[$c]); |
|
| 4160 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) {
|
|
| 4161 | + $post_images[] = $row[$c]; |
|
| 4162 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) {
|
|
| 4163 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
| 4164 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) {
|
|
| 4165 | + $row[$c] = str_replace('/', '-', $row[$c]);
|
|
| 4166 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
| 4167 | + } |
|
| 4168 | + // WPML |
|
| 4169 | + if ($is_wpml) {
|
|
| 4170 | + if ($column == 'language') {
|
|
| 4171 | + $language = geodir_strtolower(trim($row[$c])); |
|
| 4172 | + } else if ($column == 'original_post_id') {
|
|
| 4173 | + $original_post_id = (int)$row[$c]; |
|
| 4174 | + } |
|
| 4175 | + } |
|
| 4176 | + // WPML |
|
| 4177 | + $c++; |
|
| 4178 | + } |
|
| 4179 | + // listing claimed or not |
|
| 4180 | + if ($is_claim_active && isset($gd_post['claimed'])) {
|
|
| 4181 | + $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
| 4182 | + } |
|
| 4183 | 4183 | |
| 4184 | - // WPML |
|
| 4185 | - if ($is_wpml && $language != '') {
|
|
| 4186 | - $sitepress->switch_lang($language, true); |
|
| 4187 | - } |
|
| 4188 | - // WPML |
|
| 4184 | + // WPML |
|
| 4185 | + if ($is_wpml && $language != '') {
|
|
| 4186 | + $sitepress->switch_lang($language, true); |
|
| 4187 | + } |
|
| 4188 | + // WPML |
|
| 4189 | 4189 | |
| 4190 | - $gd_post['IMAGE'] = $post_images; |
|
| 4190 | + $gd_post['IMAGE'] = $post_images; |
|
| 4191 | 4191 | |
| 4192 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4193 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4192 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 4193 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 4194 | 4194 | |
| 4195 | - $valid = true; |
|
| 4195 | + $valid = true; |
|
| 4196 | 4196 | |
| 4197 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4198 | - $invalid++; |
|
| 4199 | - $valid = false; |
|
| 4200 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4201 | - } |
|
| 4202 | - $xtimings['###3'] = microtime(true)-$xstart; |
|
| 4203 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4204 | - if ( $location_allowed ) {
|
|
| 4205 | - $location_result = geodir_get_default_location(); |
|
| 4206 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4207 | - $invalid_addr++; |
|
| 4208 | - $valid = false; |
|
| 4209 | - 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' ) ); |
|
| 4210 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4211 | - 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 ) ) ) {
|
|
| 4212 | - $invalid_addr++; |
|
| 4213 | - $valid = false; |
|
| 4214 | - 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' ) ); |
|
| 4215 | - } else {
|
|
| 4216 | - if (!$location_manager) {
|
|
| 4217 | - $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. |
|
| 4218 | - } |
|
| 4219 | - } |
|
| 4220 | - } |
|
| 4221 | - } |
|
| 4222 | - $xtimings['###4'] = microtime(true)-$xstart; |
|
| 4223 | - if ( !$valid ) {
|
|
| 4224 | - continue; |
|
| 4225 | - } |
|
| 4197 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) {
|
|
| 4198 | + $invalid++; |
|
| 4199 | + $valid = false; |
|
| 4200 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
| 4201 | + } |
|
| 4202 | + $xtimings['###3'] = microtime(true)-$xstart; |
|
| 4203 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 4204 | + if ( $location_allowed ) {
|
|
| 4205 | + $location_result = geodir_get_default_location(); |
|
| 4206 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) {
|
|
| 4207 | + $invalid_addr++; |
|
| 4208 | + $valid = false; |
|
| 4209 | + 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' ) ); |
|
| 4210 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) {
|
|
| 4211 | + 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 ) ) ) {
|
|
| 4212 | + $invalid_addr++; |
|
| 4213 | + $valid = false; |
|
| 4214 | + 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' ) ); |
|
| 4215 | + } else {
|
|
| 4216 | + if (!$location_manager) {
|
|
| 4217 | + $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. |
|
| 4218 | + } |
|
| 4219 | + } |
|
| 4220 | + } |
|
| 4221 | + } |
|
| 4222 | + $xtimings['###4'] = microtime(true)-$xstart; |
|
| 4223 | + if ( !$valid ) {
|
|
| 4224 | + continue; |
|
| 4225 | + } |
|
| 4226 | 4226 | |
| 4227 | - $cat_taxonomy = $post_type . 'category'; |
|
| 4228 | - $tags_taxonomy = $post_type . '_tags'; |
|
| 4227 | + $cat_taxonomy = $post_type . 'category'; |
|
| 4228 | + $tags_taxonomy = $post_type . '_tags'; |
|
| 4229 | 4229 | |
| 4230 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4231 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4232 | - } |
|
| 4230 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) {
|
|
| 4231 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
| 4232 | + } |
|
| 4233 | 4233 | |
| 4234 | - $post_category = array(); |
|
| 4235 | - $default_category_id = NULL; |
|
| 4236 | - if ( !empty( $post_category_arr ) ) {
|
|
| 4237 | - foreach ( $post_category_arr as $value ) {
|
|
| 4238 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4234 | + $post_category = array(); |
|
| 4235 | + $default_category_id = NULL; |
|
| 4236 | + if ( !empty( $post_category_arr ) ) {
|
|
| 4237 | + foreach ( $post_category_arr as $value ) {
|
|
| 4238 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
| 4239 | 4239 | |
| 4240 | - if ( $category_name != '' ) {
|
|
| 4241 | - $term_category = array(); |
|
| 4240 | + if ( $category_name != '' ) {
|
|
| 4241 | + $term_category = array(); |
|
| 4242 | 4242 | |
| 4243 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4244 | - $term_category = $term; |
|
| 4245 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4246 | - $term_category = $term; |
|
| 4247 | - } else {
|
|
| 4248 | - $term_data = array(); |
|
| 4249 | - $term_data['name'] = $category_name; |
|
| 4250 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4243 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) {
|
|
| 4244 | + $term_category = $term; |
|
| 4245 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) {
|
|
| 4246 | + $term_category = $term; |
|
| 4247 | + } else {
|
|
| 4248 | + $term_data = array(); |
|
| 4249 | + $term_data['name'] = $category_name; |
|
| 4250 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
| 4251 | 4251 | |
| 4252 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4253 | - if ( $term_id ) {
|
|
| 4254 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4255 | - } |
|
| 4256 | - } |
|
| 4252 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
| 4253 | + if ( $term_id ) {
|
|
| 4254 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
| 4255 | + } |
|
| 4256 | + } |
|
| 4257 | 4257 | |
| 4258 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4259 | - $post_category[] = intval($term_category->term_id); |
|
| 4258 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) {
|
|
| 4259 | + $post_category[] = intval($term_category->term_id); |
|
| 4260 | 4260 | |
| 4261 | - if ($category_name == $default_category) {
|
|
| 4262 | - $default_category_id = intval($term_category->term_id); |
|
| 4263 | - } |
|
| 4264 | - } |
|
| 4265 | - } |
|
| 4266 | - } |
|
| 4267 | - } |
|
| 4268 | - $xtimings['###5'] = microtime(true)-$xstart; |
|
| 4269 | - $save_post = array(); |
|
| 4270 | - $save_post['post_title'] = $post_title; |
|
| 4271 | - $save_post['post_content'] = $post_content; |
|
| 4272 | - $save_post['post_type'] = $post_type; |
|
| 4273 | - $save_post['post_author'] = $post_author; |
|
| 4274 | - $save_post['post_status'] = $post_status; |
|
| 4275 | - $save_post['post_category'] = $post_category; |
|
| 4276 | - $save_post['post_tags'] = $post_tags; |
|
| 4277 | - |
|
| 4278 | - $saved_post_id = NULL; |
|
| 4279 | - if ( $import_choice == 'update' ) {
|
|
| 4280 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4261 | + if ($category_name == $default_category) {
|
|
| 4262 | + $default_category_id = intval($term_category->term_id); |
|
| 4263 | + } |
|
| 4264 | + } |
|
| 4265 | + } |
|
| 4266 | + } |
|
| 4267 | + } |
|
| 4268 | + $xtimings['###5'] = microtime(true)-$xstart; |
|
| 4269 | + $save_post = array(); |
|
| 4270 | + $save_post['post_title'] = $post_title; |
|
| 4271 | + $save_post['post_content'] = $post_content; |
|
| 4272 | + $save_post['post_type'] = $post_type; |
|
| 4273 | + $save_post['post_author'] = $post_author; |
|
| 4274 | + $save_post['post_status'] = $post_status; |
|
| 4275 | + $save_post['post_category'] = $post_category; |
|
| 4276 | + $save_post['post_tags'] = $post_tags; |
|
| 4277 | + |
|
| 4278 | + $saved_post_id = NULL; |
|
| 4279 | + if ( $import_choice == 'update' ) {
|
|
| 4280 | + $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
| 4281 | 4281 | |
| 4282 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4283 | - $save_post['ID'] = $post_id; |
|
| 4282 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4283 | + $save_post['ID'] = $post_id; |
|
| 4284 | 4284 | |
| 4285 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4286 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4287 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4288 | - $saved_post_id = 0; |
|
| 4289 | - } else {
|
|
| 4290 | - $saved_post_id = $post_id; |
|
| 4291 | - $updated++; |
|
| 4292 | - } |
|
| 4293 | - } |
|
| 4294 | - } else {
|
|
| 4295 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4296 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4297 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4298 | - $saved_post_id = 0; |
|
| 4299 | - } else {
|
|
| 4300 | - $created++; |
|
| 4301 | - } |
|
| 4302 | - } |
|
| 4303 | - } |
|
| 4285 | + if ( $saved_post_id = wp_update_post( $save_post, true ) ) {
|
|
| 4286 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4287 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4288 | + $saved_post_id = 0; |
|
| 4289 | + } else {
|
|
| 4290 | + $saved_post_id = $post_id; |
|
| 4291 | + $updated++; |
|
| 4292 | + } |
|
| 4293 | + } |
|
| 4294 | + } else {
|
|
| 4295 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4296 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4297 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
| 4298 | + $saved_post_id = 0; |
|
| 4299 | + } else {
|
|
| 4300 | + $created++; |
|
| 4301 | + } |
|
| 4302 | + } |
|
| 4303 | + } |
|
| 4304 | 4304 | |
| 4305 | - if ( !$saved_post_id > 0 ) {
|
|
| 4306 | - $invalid++; |
|
| 4307 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4308 | - } |
|
| 4309 | - } else if ( $import_choice == 'skip' ) {
|
|
| 4310 | - if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4311 | - $skipped++; |
|
| 4312 | - } else {
|
|
| 4313 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4314 | - if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4315 | - $invalid++; |
|
| 4305 | + if ( !$saved_post_id > 0 ) {
|
|
| 4306 | + $invalid++; |
|
| 4307 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
| 4308 | + } |
|
| 4309 | + } else if ( $import_choice == 'skip' ) {
|
|
| 4310 | + if ( $post_id > 0 && get_post( $post_id ) ) {
|
|
| 4311 | + $skipped++; |
|
| 4312 | + } else {
|
|
| 4313 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) {
|
|
| 4314 | + if ( is_wp_error( $saved_post_id ) ) {
|
|
| 4315 | + $invalid++; |
|
| 4316 | 4316 | |
| 4317 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4318 | - $saved_post_id = 0; |
|
| 4319 | - } else {
|
|
| 4320 | - $created++; |
|
| 4321 | - } |
|
| 4322 | - } else {
|
|
| 4323 | - $invalid++; |
|
| 4317 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
| 4318 | + $saved_post_id = 0; |
|
| 4319 | + } else {
|
|
| 4320 | + $created++; |
|
| 4321 | + } |
|
| 4322 | + } else {
|
|
| 4323 | + $invalid++; |
|
| 4324 | 4324 | |
| 4325 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4326 | - } |
|
| 4327 | - } |
|
| 4328 | - } else {
|
|
| 4329 | - $invalid++; |
|
| 4325 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4326 | + } |
|
| 4327 | + } |
|
| 4328 | + } else {
|
|
| 4329 | + $invalid++; |
|
| 4330 | 4330 | |
| 4331 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4332 | - } |
|
| 4333 | - $xtimings['###6'] = microtime(true)-$xstart; |
|
| 4334 | - if ( (int)$saved_post_id > 0 ) {
|
|
| 4335 | - // WPML |
|
| 4336 | - if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4337 | - $wpml_post_type = 'post_' . $post_type; |
|
| 4338 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4339 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4340 | - |
|
| 4341 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4331 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
| 4332 | + } |
|
| 4333 | + $xtimings['###6'] = microtime(true)-$xstart; |
|
| 4334 | + if ( (int)$saved_post_id > 0 ) {
|
|
| 4335 | + // WPML |
|
| 4336 | + if ($is_wpml && $original_post_id > 0 && $language != '') {
|
|
| 4337 | + $wpml_post_type = 'post_' . $post_type; |
|
| 4338 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
| 4339 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
| 4340 | + |
|
| 4341 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
| 4342 | 4342 | |
| 4343 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4344 | - } |
|
| 4345 | - // WPML |
|
| 4346 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4343 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
| 4344 | + } |
|
| 4345 | + // WPML |
|
| 4346 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
| 4347 | 4347 | |
| 4348 | - $gd_post['post_id'] = $saved_post_id; |
|
| 4349 | - $gd_post['ID'] = $saved_post_id; |
|
| 4350 | - $gd_post['post_tags'] = $post_tags; |
|
| 4351 | - $gd_post['post_title'] = $post_title; |
|
| 4352 | - $gd_post['post_status'] = $post_status; |
|
| 4353 | - $gd_post['submit_time'] = time(); |
|
| 4354 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4348 | + $gd_post['post_id'] = $saved_post_id; |
|
| 4349 | + $gd_post['ID'] = $saved_post_id; |
|
| 4350 | + $gd_post['post_tags'] = $post_tags; |
|
| 4351 | + $gd_post['post_title'] = $post_title; |
|
| 4352 | + $gd_post['post_status'] = $post_status; |
|
| 4353 | + $gd_post['submit_time'] = time(); |
|
| 4354 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 4355 | 4355 | |
| 4356 | - // post location |
|
| 4357 | - $post_location_id = 0; |
|
| 4358 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4359 | - $gd_post['post_neighbourhood'] = ''; |
|
| 4356 | + // post location |
|
| 4357 | + $post_location_id = 0; |
|
| 4358 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) {
|
|
| 4359 | + $gd_post['post_neighbourhood'] = ''; |
|
| 4360 | 4360 | |
| 4361 | - $post_location_info = array( |
|
| 4362 | - 'city' => $post_city, |
|
| 4363 | - 'region' => $post_region, |
|
| 4364 | - 'country' => $post_country, |
|
| 4365 | - 'geo_lat' => $post_latitude, |
|
| 4366 | - 'geo_lng' => $post_longitude |
|
| 4367 | - ); |
|
| 4368 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4369 | - $post_location_id = $location_id; |
|
| 4370 | - } |
|
| 4361 | + $post_location_info = array( |
|
| 4362 | + 'city' => $post_city, |
|
| 4363 | + 'region' => $post_region, |
|
| 4364 | + 'country' => $post_country, |
|
| 4365 | + 'geo_lat' => $post_latitude, |
|
| 4366 | + 'geo_lng' => $post_longitude |
|
| 4367 | + ); |
|
| 4368 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) {
|
|
| 4369 | + $post_location_id = $location_id; |
|
| 4370 | + } |
|
| 4371 | 4371 | |
| 4372 | - if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4373 | - $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4372 | + if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) {
|
|
| 4373 | + $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
| 4374 | 4374 | |
| 4375 | - $hood_data = array(); |
|
| 4376 | - $hood_data['hood_location_id'] = $post_location_id; |
|
| 4377 | - $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4375 | + $hood_data = array(); |
|
| 4376 | + $hood_data['hood_location_id'] = $post_location_id; |
|
| 4377 | + $hood_data['hood_name'] = $post_neighbourhood; |
|
| 4378 | 4378 | |
| 4379 | - if (!empty($neighbourhood_info)) {
|
|
| 4380 | - $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4381 | - $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4379 | + if (!empty($neighbourhood_info)) {
|
|
| 4380 | + $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
| 4381 | + $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
| 4382 | 4382 | |
| 4383 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4384 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4385 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4386 | - } |
|
| 4387 | - } |
|
| 4383 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4384 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4385 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4386 | + } |
|
| 4387 | + } |
|
| 4388 | 4388 | |
| 4389 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4390 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4391 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4392 | - } |
|
| 4389 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) {
|
|
| 4390 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
| 4391 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
| 4392 | + } |
|
| 4393 | 4393 | |
| 4394 | - $hood_data['hood_latitude'] = $post_latitude; |
|
| 4395 | - $hood_data['hood_longitude'] = $post_longitude; |
|
| 4396 | - |
|
| 4397 | - $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4398 | - if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4399 | - $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4400 | - } |
|
| 4401 | - } |
|
| 4402 | - } |
|
| 4403 | - $gd_post['post_location_id'] = $post_location_id; |
|
| 4394 | + $hood_data['hood_latitude'] = $post_latitude; |
|
| 4395 | + $hood_data['hood_longitude'] = $post_longitude; |
|
| 4396 | + |
|
| 4397 | + $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
| 4398 | + if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) {
|
|
| 4399 | + $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
| 4400 | + } |
|
| 4401 | + } |
|
| 4402 | + } |
|
| 4403 | + $gd_post['post_location_id'] = $post_location_id; |
|
| 4404 | 4404 | |
| 4405 | - // post package info |
|
| 4406 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4407 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4408 | - $package_id = $gd_post_info->package_id; |
|
| 4409 | - } |
|
| 4405 | + // post package info |
|
| 4406 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
| 4407 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) {
|
|
| 4408 | + $package_id = $gd_post_info->package_id; |
|
| 4409 | + } |
|
| 4410 | 4410 | |
| 4411 | - $package_info = array(); |
|
| 4412 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4413 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4411 | + $package_info = array(); |
|
| 4412 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) {
|
|
| 4413 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
| 4414 | 4414 | |
| 4415 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4416 | - $package_info = array(); |
|
| 4417 | - } |
|
| 4418 | - } |
|
| 4415 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) {
|
|
| 4416 | + $package_info = array(); |
|
| 4417 | + } |
|
| 4418 | + } |
|
| 4419 | 4419 | |
| 4420 | - if (empty($package_info)) {
|
|
| 4421 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4422 | - } |
|
| 4420 | + if (empty($package_info)) {
|
|
| 4421 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
| 4422 | + } |
|
| 4423 | 4423 | |
| 4424 | - if (!empty($package_info)) {
|
|
| 4425 | - $package_id = $package_info['pid']; |
|
| 4424 | + if (!empty($package_info)) {
|
|
| 4425 | + $package_id = $package_info['pid']; |
|
| 4426 | 4426 | |
| 4427 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4428 | - $gd_post['expire_date'] = $expire_date; |
|
| 4429 | - } else {
|
|
| 4430 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4431 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4432 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4433 | - } else {
|
|
| 4434 | - $gd_post['expire_date'] = 'Never'; |
|
| 4435 | - } |
|
| 4436 | - } |
|
| 4427 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) {
|
|
| 4428 | + $gd_post['expire_date'] = $expire_date; |
|
| 4429 | + } else {
|
|
| 4430 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) {
|
|
| 4431 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
| 4432 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
| 4433 | + } else {
|
|
| 4434 | + $gd_post['expire_date'] = 'Never'; |
|
| 4435 | + } |
|
| 4436 | + } |
|
| 4437 | 4437 | |
| 4438 | - $gd_post['package_id'] = $package_id; |
|
| 4439 | - } |
|
| 4438 | + $gd_post['package_id'] = $package_id; |
|
| 4439 | + } |
|
| 4440 | 4440 | |
| 4441 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4441 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 4442 | 4442 | |
| 4443 | - if ($post_type == 'gd_event') {
|
|
| 4444 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4445 | - } |
|
| 4443 | + if ($post_type == 'gd_event') {
|
|
| 4444 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
| 4445 | + } |
|
| 4446 | 4446 | |
| 4447 | - if (isset($gd_post['post_id'])) {
|
|
| 4448 | - unset($gd_post['post_id']); |
|
| 4449 | - } |
|
| 4447 | + if (isset($gd_post['post_id'])) {
|
|
| 4448 | + unset($gd_post['post_id']); |
|
| 4449 | + } |
|
| 4450 | 4450 | |
| 4451 | - // Export franchise fields |
|
| 4452 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4453 | - if ($is_franchise_active) {
|
|
| 4454 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4455 | - $gd_franchise_lock = array(); |
|
| 4451 | + // Export franchise fields |
|
| 4452 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
| 4453 | + if ($is_franchise_active) {
|
|
| 4454 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) {
|
|
| 4455 | + $gd_franchise_lock = array(); |
|
| 4456 | 4456 | |
| 4457 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4458 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4459 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4460 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4461 | - } |
|
| 4457 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) {
|
|
| 4458 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] );
|
|
| 4459 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
| 4460 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
| 4461 | + } |
|
| 4462 | 4462 | |
| 4463 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4464 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4465 | - } else {
|
|
| 4466 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4467 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4468 | - } |
|
| 4469 | - } |
|
| 4470 | - } |
|
| 4463 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
| 4464 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
| 4465 | + } else {
|
|
| 4466 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) {
|
|
| 4467 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
| 4468 | + } |
|
| 4469 | + } |
|
| 4470 | + } |
|
| 4471 | 4471 | |
| 4472 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4473 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4474 | - if ($default_category_id) {
|
|
| 4475 | - $save_post['post_default_category'] = $default_category_id; |
|
| 4476 | - $gd_post['default_category'] = $default_category_id; |
|
| 4477 | - } |
|
| 4478 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4479 | - } |
|
| 4480 | - $xtimings['###7'] = microtime(true)-$xstart; |
|
| 4481 | - // Save post info |
|
| 4482 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4483 | - $xtimings['###8'] = microtime(true)-$xstart; |
|
| 4484 | - // post taxonomies |
|
| 4485 | - if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4486 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4472 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) {
|
|
| 4473 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
| 4474 | + if ($default_category_id) {
|
|
| 4475 | + $save_post['post_default_category'] = $default_category_id; |
|
| 4476 | + $gd_post['default_category'] = $default_category_id; |
|
| 4477 | + } |
|
| 4478 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
| 4479 | + } |
|
| 4480 | + $xtimings['###7'] = microtime(true)-$xstart; |
|
| 4481 | + // Save post info |
|
| 4482 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
| 4483 | + $xtimings['###8'] = microtime(true)-$xstart; |
|
| 4484 | + // post taxonomies |
|
| 4485 | + if ( !empty( $save_post['post_category'] ) ) {
|
|
| 4486 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
| 4487 | 4487 | |
| 4488 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4489 | - if ($default_category_id) {
|
|
| 4490 | - $post_default_category = $default_category_id; |
|
| 4491 | - } |
|
| 4492 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4493 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4494 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4488 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
| 4489 | + if ($default_category_id) {
|
|
| 4490 | + $post_default_category = $default_category_id; |
|
| 4491 | + } |
|
| 4492 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
| 4493 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category'];
|
|
| 4494 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : '';
|
|
| 4495 | 4495 | |
| 4496 | - if ($post_category_str != '' && $post_default_category) {
|
|
| 4497 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4498 | - } |
|
| 4496 | + if ($post_category_str != '' && $post_default_category) {
|
|
| 4497 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
| 4498 | + } |
|
| 4499 | 4499 | |
| 4500 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4500 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
| 4501 | 4501 | |
| 4502 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4503 | - } |
|
| 4504 | - $xtimings['###8.1'] = microtime(true)-$xstart; |
|
| 4505 | - if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4506 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4507 | - } |
|
| 4508 | - $xtimings['###9'] = microtime(true)-$xstart; |
|
| 4509 | - // Post images |
|
| 4510 | - if ( !empty( $post_images ) ) {
|
|
| 4511 | - $post_images = array_unique($post_images); |
|
| 4502 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
| 4503 | + } |
|
| 4504 | + $xtimings['###8.1'] = microtime(true)-$xstart; |
|
| 4505 | + if ( !empty( $save_post['post_tags'] ) ) {
|
|
| 4506 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
| 4507 | + } |
|
| 4508 | + $xtimings['###9'] = microtime(true)-$xstart; |
|
| 4509 | + // Post images |
|
| 4510 | + if ( !empty( $post_images ) ) {
|
|
| 4511 | + $post_images = array_unique($post_images); |
|
| 4512 | 4512 | |
| 4513 | - $old_post_images_arr = array(); |
|
| 4514 | - $saved_post_images_arr = array(); |
|
| 4513 | + $old_post_images_arr = array(); |
|
| 4514 | + $saved_post_images_arr = array(); |
|
| 4515 | 4515 | |
| 4516 | - $order = 1; |
|
| 4516 | + $order = 1; |
|
| 4517 | 4517 | |
| 4518 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4519 | - $xtimings['###9.1'] = microtime(true)-$xstart; |
|
| 4520 | - if (!empty($old_post_images)) {
|
|
| 4521 | - foreach( $old_post_images as $old_post_image ) {
|
|
| 4522 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4523 | - $old_post_images_arr[] = $old_post_image->file; |
|
| 4524 | - } |
|
| 4525 | - } |
|
| 4526 | - } |
|
| 4518 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
| 4519 | + $xtimings['###9.1'] = microtime(true)-$xstart; |
|
| 4520 | + if (!empty($old_post_images)) {
|
|
| 4521 | + foreach( $old_post_images as $old_post_image ) {
|
|
| 4522 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') {
|
|
| 4523 | + $old_post_images_arr[] = $old_post_image->file; |
|
| 4524 | + } |
|
| 4525 | + } |
|
| 4526 | + } |
|
| 4527 | 4527 | |
| 4528 | - foreach ( $post_images as $post_image ) {
|
|
| 4529 | - $image_name = basename( $post_image ); |
|
| 4530 | - $saved_post_images_arr[] = $image_name; |
|
| 4528 | + foreach ( $post_images as $post_image ) {
|
|
| 4529 | + $image_name = basename( $post_image ); |
|
| 4530 | + $saved_post_images_arr[] = $image_name; |
|
| 4531 | 4531 | |
| 4532 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4533 | - continue; // Skip if image already exists. |
|
| 4534 | - } |
|
| 4532 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) {
|
|
| 4533 | + continue; // Skip if image already exists. |
|
| 4534 | + } |
|
| 4535 | 4535 | |
| 4536 | - $image_name_parts = explode( '.', $image_name ); |
|
| 4537 | - array_pop( $image_name_parts ); |
|
| 4538 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4539 | - $xtimings['###9.2'] = microtime(true)-$xstart; |
|
| 4540 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4541 | - $xtimings['###9.3'] = microtime(true)-$xstart; |
|
| 4542 | - if ( !empty( $arr_file_type ) ) {
|
|
| 4543 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 4536 | + $image_name_parts = explode( '.', $image_name ); |
|
| 4537 | + array_pop( $image_name_parts ); |
|
| 4538 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
| 4539 | + $xtimings['###9.2'] = microtime(true)-$xstart; |
|
| 4540 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
| 4541 | + $xtimings['###9.3'] = microtime(true)-$xstart; |
|
| 4542 | + if ( !empty( $arr_file_type ) ) {
|
|
| 4543 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 4544 | 4544 | |
| 4545 | - $attachment = array(); |
|
| 4546 | - $attachment['post_id'] = $saved_post_id; |
|
| 4547 | - $attachment['title'] = $proper_image_name; |
|
| 4548 | - $attachment['content'] = ''; |
|
| 4549 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4550 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 4551 | - $attachment['menu_order'] = $order; |
|
| 4552 | - $attachment['is_featured'] = 0; |
|
| 4553 | - |
|
| 4554 | - $attachment_set = ''; |
|
| 4555 | - foreach ( $attachment as $key => $val ) {
|
|
| 4556 | - if ( $val != '' ) {
|
|
| 4557 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4558 | - } |
|
| 4559 | - } |
|
| 4560 | - $attachment_set = trim( $attachment_set, ", " ); |
|
| 4545 | + $attachment = array(); |
|
| 4546 | + $attachment['post_id'] = $saved_post_id; |
|
| 4547 | + $attachment['title'] = $proper_image_name; |
|
| 4548 | + $attachment['content'] = ''; |
|
| 4549 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
| 4550 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 4551 | + $attachment['menu_order'] = $order; |
|
| 4552 | + $attachment['is_featured'] = 0; |
|
| 4553 | + |
|
| 4554 | + $attachment_set = ''; |
|
| 4555 | + foreach ( $attachment as $key => $val ) {
|
|
| 4556 | + if ( $val != '' ) {
|
|
| 4557 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 4558 | + } |
|
| 4559 | + } |
|
| 4560 | + $attachment_set = trim( $attachment_set, ", " ); |
|
| 4561 | 4561 | |
| 4562 | - // Add new attachment |
|
| 4563 | - $xtimings['###9.4'] = microtime(true)-$xstart; |
|
| 4564 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4565 | - $xtimings['###9.5'] = microtime(true)-$xstart; |
|
| 4566 | - $order++; |
|
| 4567 | - } |
|
| 4568 | - } |
|
| 4569 | - |
|
| 4570 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4571 | - // Remove previous attachment |
|
| 4572 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4573 | - $xtimings['###9.6'] = microtime(true)-$xstart; |
|
| 4574 | - if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4575 | - geodir_set_wp_featured_image($saved_post_id); |
|
| 4576 | - $xtimings['###9.7'] = microtime(true)-$xstart; |
|
| 4577 | - /* |
|
| 4562 | + // Add new attachment |
|
| 4563 | + $xtimings['###9.4'] = microtime(true)-$xstart; |
|
| 4564 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
| 4565 | + $xtimings['###9.5'] = microtime(true)-$xstart; |
|
| 4566 | + $order++; |
|
| 4567 | + } |
|
| 4568 | + } |
|
| 4569 | + |
|
| 4570 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : '';
|
|
| 4571 | + // Remove previous attachment |
|
| 4572 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
| 4573 | + $xtimings['###9.6'] = microtime(true)-$xstart; |
|
| 4574 | + if ( !empty( $saved_post_images_arr ) ) {
|
|
| 4575 | + geodir_set_wp_featured_image($saved_post_id); |
|
| 4576 | + $xtimings['###9.7'] = microtime(true)-$xstart; |
|
| 4577 | + /* |
|
| 4578 | 4578 | $menu_order = 1; |
| 4579 | 4579 | |
| 4580 | 4580 | foreach ( $saved_post_images_arr as $img_name ) {
|
@@ -4587,288 +4587,288 @@ discard block |
||
| 4587 | 4587 | } |
| 4588 | 4588 | $menu_order++; |
| 4589 | 4589 | }*/ |
| 4590 | - } |
|
| 4590 | + } |
|
| 4591 | 4591 | |
| 4592 | - if ( $order > 1 ) {
|
|
| 4593 | - $images++; |
|
| 4594 | - } |
|
| 4595 | - } |
|
| 4596 | - $xtimings['###10'] = microtime(true)-$xstart; |
|
| 4597 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4598 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4599 | - $xtimings['###11'] = microtime(true)-$xstart; |
|
| 4600 | - if (isset($is_featured)) {
|
|
| 4601 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4602 | - } |
|
| 4603 | - if (isset($gd_post['alive_days'])) {
|
|
| 4604 | - geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
| 4605 | - } |
|
| 4606 | - if (isset($gd_post['expire_date'])) {
|
|
| 4607 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4608 | - } |
|
| 4609 | - $xtimings['###12'] = microtime(true)-$xstart; |
|
| 4610 | - } |
|
| 4592 | + if ( $order > 1 ) {
|
|
| 4593 | + $images++; |
|
| 4594 | + } |
|
| 4595 | + } |
|
| 4596 | + $xtimings['###10'] = microtime(true)-$xstart; |
|
| 4597 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 4598 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
| 4599 | + $xtimings['###11'] = microtime(true)-$xstart; |
|
| 4600 | + if (isset($is_featured)) {
|
|
| 4601 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
| 4602 | + } |
|
| 4603 | + if (isset($gd_post['alive_days'])) {
|
|
| 4604 | + geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
| 4605 | + } |
|
| 4606 | + if (isset($gd_post['expire_date'])) {
|
|
| 4607 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
| 4608 | + } |
|
| 4609 | + $xtimings['###12'] = microtime(true)-$xstart; |
|
| 4610 | + } |
|
| 4611 | 4611 | |
| 4612 | - // WPML |
|
| 4613 | - if ($is_wpml && $language != '') {
|
|
| 4614 | - $sitepress->switch_lang($active_lang, true); |
|
| 4615 | - } |
|
| 4616 | - // WPML |
|
| 4617 | - } |
|
| 4618 | - } |
|
| 4619 | - } |
|
| 4612 | + // WPML |
|
| 4613 | + if ($is_wpml && $language != '') {
|
|
| 4614 | + $sitepress->switch_lang($active_lang, true); |
|
| 4615 | + } |
|
| 4616 | + // WPML |
|
| 4617 | + } |
|
| 4618 | + } |
|
| 4619 | + } |
|
| 4620 | 4620 | |
| 4621 | - //undo some stuff to make the import quicker |
|
| 4622 | - wp_defer_term_counting( false ); |
|
| 4623 | - wp_defer_comment_counting( false ); |
|
| 4624 | - $wpdb->query( 'COMMIT;' ); |
|
| 4625 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4626 | - $xtimings['###13'] = microtime(true)-$xstart; |
|
| 4627 | - $json = array(); |
|
| 4628 | - $json['processed'] = $processed_actual; |
|
| 4629 | - $json['created'] = $created; |
|
| 4630 | - $json['updated'] = $updated; |
|
| 4631 | - $json['skipped'] = $skipped; |
|
| 4632 | - $json['invalid'] = $invalid; |
|
| 4633 | - $json['invalid_addr'] = $invalid_addr; |
|
| 4634 | - $json['images'] = $images; |
|
| 4635 | - $json['timing'] = microtime(true)-$xstart; |
|
| 4636 | - $json['timings'] = $xtimings; |
|
| 4621 | + //undo some stuff to make the import quicker |
|
| 4622 | + wp_defer_term_counting( false ); |
|
| 4623 | + wp_defer_comment_counting( false ); |
|
| 4624 | + $wpdb->query( 'COMMIT;' ); |
|
| 4625 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
| 4626 | + $xtimings['###13'] = microtime(true)-$xstart; |
|
| 4627 | + $json = array(); |
|
| 4628 | + $json['processed'] = $processed_actual; |
|
| 4629 | + $json['created'] = $created; |
|
| 4630 | + $json['updated'] = $updated; |
|
| 4631 | + $json['skipped'] = $skipped; |
|
| 4632 | + $json['invalid'] = $invalid; |
|
| 4633 | + $json['invalid_addr'] = $invalid_addr; |
|
| 4634 | + $json['images'] = $images; |
|
| 4635 | + $json['timing'] = microtime(true)-$xstart; |
|
| 4636 | + $json['timings'] = $xtimings; |
|
| 4637 | 4637 | |
| 4638 | 4638 | |
| 4639 | - wp_send_json( $json ); |
|
| 4640 | - exit; |
|
| 4641 | - } else if ( $task == 'import_loc' ) {
|
|
| 4642 | - global $gd_post_types; |
|
| 4643 | - $gd_post_types = $post_types; |
|
| 4639 | + wp_send_json( $json ); |
|
| 4640 | + exit; |
|
| 4641 | + } else if ( $task == 'import_loc' ) {
|
|
| 4642 | + global $gd_post_types; |
|
| 4643 | + $gd_post_types = $post_types; |
|
| 4644 | 4644 | |
| 4645 | - if (!empty($file)) {
|
|
| 4646 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4645 | + if (!empty($file)) {
|
|
| 4646 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4647 | 4647 | |
| 4648 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4649 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4650 | - wp_send_json( $json ); |
|
| 4651 | - } |
|
| 4648 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4649 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4650 | + wp_send_json( $json ); |
|
| 4651 | + } |
|
| 4652 | 4652 | |
| 4653 | - $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4654 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4655 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4656 | - $index = $processed + $i; |
|
| 4653 | + $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory');
|
|
| 4654 | + $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
| 4655 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4656 | + $index = $processed + $i; |
|
| 4657 | 4657 | |
| 4658 | - if (isset($file[$index])) {
|
|
| 4659 | - $row = $file[$index]; |
|
| 4660 | - $row = array_map( 'trim', $row ); |
|
| 4661 | - $data = array(); |
|
| 4658 | + if (isset($file[$index])) {
|
|
| 4659 | + $row = $file[$index]; |
|
| 4660 | + $row = array_map( 'trim', $row ); |
|
| 4661 | + $data = array(); |
|
| 4662 | 4662 | |
| 4663 | - foreach ($columns as $c => $column ) {
|
|
| 4664 | - 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'))) {
|
|
| 4665 | - $data[$column] = $row[$c]; |
|
| 4666 | - } |
|
| 4667 | - } |
|
| 4663 | + foreach ($columns as $c => $column ) {
|
|
| 4664 | + 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'))) {
|
|
| 4665 | + $data[$column] = $row[$c]; |
|
| 4666 | + } |
|
| 4667 | + } |
|
| 4668 | 4668 | |
| 4669 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4670 | - $invalid++; |
|
| 4671 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4672 | - continue; |
|
| 4673 | - } |
|
| 4669 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) {
|
|
| 4670 | + $invalid++; |
|
| 4671 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4672 | + continue; |
|
| 4673 | + } |
|
| 4674 | 4674 | |
| 4675 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4675 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
| 4676 | 4676 | |
| 4677 | - if ( $import_choice == 'update' ) {
|
|
| 4678 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4679 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4680 | - $updated++; |
|
| 4681 | - } else {
|
|
| 4682 | - $invalid++; |
|
| 4683 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4684 | - } |
|
| 4685 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4686 | - $data['location_id'] = (int)$location->location_id; |
|
| 4677 | + if ( $import_choice == 'update' ) {
|
|
| 4678 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4679 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4680 | + $updated++; |
|
| 4681 | + } else {
|
|
| 4682 | + $invalid++; |
|
| 4683 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4684 | + } |
|
| 4685 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4686 | + $data['location_id'] = (int)$location->location_id; |
|
| 4687 | 4687 | |
| 4688 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4689 | - $data['location_id'] = (int)$location->location_id; |
|
| 4690 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4691 | - $data['location_id'] = (int)$location->location_id; |
|
| 4692 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4693 | - $data['location_id'] = (int)$location->location_id; |
|
| 4694 | - } |
|
| 4688 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) {
|
|
| 4689 | + $data['location_id'] = (int)$location->location_id; |
|
| 4690 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) {
|
|
| 4691 | + $data['location_id'] = (int)$location->location_id; |
|
| 4692 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) {
|
|
| 4693 | + $data['location_id'] = (int)$location->location_id; |
|
| 4694 | + } |
|
| 4695 | 4695 | |
| 4696 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4697 | - $updated++; |
|
| 4698 | - } else {
|
|
| 4699 | - $invalid++; |
|
| 4700 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4701 | - } |
|
| 4702 | - } else {
|
|
| 4703 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4704 | - $created++; |
|
| 4705 | - } else {
|
|
| 4706 | - $invalid++; |
|
| 4707 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4708 | - } |
|
| 4709 | - } |
|
| 4710 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4711 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4712 | - $skipped++; |
|
| 4713 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4714 | - $skipped++; |
|
| 4715 | - } else {
|
|
| 4716 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4717 | - $created++; |
|
| 4718 | - } else {
|
|
| 4719 | - $invalid++; |
|
| 4720 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4721 | - } |
|
| 4722 | - } |
|
| 4723 | - } else {
|
|
| 4724 | - $invalid++; |
|
| 4725 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4726 | - } |
|
| 4727 | - } |
|
| 4728 | - } |
|
| 4729 | - } |
|
| 4696 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) {
|
|
| 4697 | + $updated++; |
|
| 4698 | + } else {
|
|
| 4699 | + $invalid++; |
|
| 4700 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4701 | + } |
|
| 4702 | + } else {
|
|
| 4703 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4704 | + $created++; |
|
| 4705 | + } else {
|
|
| 4706 | + $invalid++; |
|
| 4707 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4708 | + } |
|
| 4709 | + } |
|
| 4710 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4711 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) {
|
|
| 4712 | + $skipped++; |
|
| 4713 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) {
|
|
| 4714 | + $skipped++; |
|
| 4715 | + } else {
|
|
| 4716 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) {
|
|
| 4717 | + $created++; |
|
| 4718 | + } else {
|
|
| 4719 | + $invalid++; |
|
| 4720 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4721 | + } |
|
| 4722 | + } |
|
| 4723 | + } else {
|
|
| 4724 | + $invalid++; |
|
| 4725 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
| 4726 | + } |
|
| 4727 | + } |
|
| 4728 | + } |
|
| 4729 | + } |
|
| 4730 | 4730 | |
| 4731 | - $json = array(); |
|
| 4732 | - $json['processed'] = $limit; |
|
| 4733 | - $json['created'] = $created; |
|
| 4734 | - $json['updated'] = $updated; |
|
| 4735 | - $json['skipped'] = $skipped; |
|
| 4736 | - $json['invalid'] = $invalid; |
|
| 4737 | - $json['images'] = $images; |
|
| 4731 | + $json = array(); |
|
| 4732 | + $json['processed'] = $limit; |
|
| 4733 | + $json['created'] = $created; |
|
| 4734 | + $json['updated'] = $updated; |
|
| 4735 | + $json['skipped'] = $skipped; |
|
| 4736 | + $json['invalid'] = $invalid; |
|
| 4737 | + $json['images'] = $images; |
|
| 4738 | 4738 | |
| 4739 | - wp_send_json( $json ); |
|
| 4740 | - } else if ( $task == 'import_hood' ) {
|
|
| 4741 | - if (!empty($file)) {
|
|
| 4742 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4739 | + wp_send_json( $json ); |
|
| 4740 | + } else if ( $task == 'import_hood' ) {
|
|
| 4741 | + if (!empty($file)) {
|
|
| 4742 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
| 4743 | 4743 | |
| 4744 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4745 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4746 | - wp_send_json( $json ); |
|
| 4747 | - } |
|
| 4744 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 4745 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory');
|
|
| 4746 | + wp_send_json( $json ); |
|
| 4747 | + } |
|
| 4748 | 4748 | |
| 4749 | - $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4750 | - $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' ); |
|
| 4751 | - for ($i = 1; $i <= $limit; $i++) {
|
|
| 4752 | - $index = $processed + $i; |
|
| 4749 | + $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory');
|
|
| 4750 | + $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' ); |
|
| 4751 | + for ($i = 1; $i <= $limit; $i++) {
|
|
| 4752 | + $index = $processed + $i; |
|
| 4753 | 4753 | |
| 4754 | - if (isset($file[$index])) {
|
|
| 4755 | - $row = $file[$index]; |
|
| 4756 | - $row = array_map( 'trim', $row ); |
|
| 4757 | - $data = array(); |
|
| 4754 | + if (isset($file[$index])) {
|
|
| 4755 | + $row = $file[$index]; |
|
| 4756 | + $row = array_map( 'trim', $row ); |
|
| 4757 | + $data = array(); |
|
| 4758 | 4758 | |
| 4759 | - foreach ($columns as $c => $column) {
|
|
| 4760 | - if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 4761 | - $data[$column] = sanitize_text_field($row[$c]); |
|
| 4762 | - } |
|
| 4763 | - } |
|
| 4759 | + foreach ($columns as $c => $column) {
|
|
| 4760 | + if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) {
|
|
| 4761 | + $data[$column] = sanitize_text_field($row[$c]); |
|
| 4762 | + } |
|
| 4763 | + } |
|
| 4764 | 4764 | |
| 4765 | - if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4766 | - $invalid++; |
|
| 4767 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4768 | - continue; |
|
| 4769 | - } |
|
| 4765 | + if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) {
|
|
| 4766 | + $invalid++; |
|
| 4767 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4768 | + continue; |
|
| 4769 | + } |
|
| 4770 | 4770 | |
| 4771 | - $location_info = array(); |
|
| 4772 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 4773 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 4774 | - } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 4775 | - $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 4776 | - } |
|
| 4771 | + $location_info = array(); |
|
| 4772 | + if (!empty($data['location_id']) && (int)$data['location_id'] > 0) {
|
|
| 4773 | + $location_info = geodir_get_location_by_id('', (int)$data['location_id']);
|
|
| 4774 | + } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) {
|
|
| 4775 | + $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region']));
|
|
| 4776 | + } |
|
| 4777 | 4777 | |
| 4778 | - if (empty($location_info)) {
|
|
| 4779 | - $invalid++; |
|
| 4780 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4781 | - continue; |
|
| 4782 | - } |
|
| 4778 | + if (empty($location_info)) {
|
|
| 4779 | + $invalid++; |
|
| 4780 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4781 | + continue; |
|
| 4782 | + } |
|
| 4783 | 4783 | |
| 4784 | - $location_id = $location_info->location_id; |
|
| 4784 | + $location_id = $location_info->location_id; |
|
| 4785 | 4785 | |
| 4786 | - $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 4786 | + $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
| 4787 | 4787 | |
| 4788 | - $hood_data = array(); |
|
| 4789 | - $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 4790 | - $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 4791 | - $hood_data['hood_latitude'] = $data['latitude']; |
|
| 4792 | - $hood_data['hood_longitude'] = $data['longitude']; |
|
| 4793 | - $hood_data['hood_location_id'] = $location_id; |
|
| 4788 | + $hood_data = array(); |
|
| 4789 | + $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
| 4790 | + $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
| 4791 | + $hood_data['hood_latitude'] = $data['latitude']; |
|
| 4792 | + $hood_data['hood_longitude'] = $data['longitude']; |
|
| 4793 | + $hood_data['hood_location_id'] = $location_id; |
|
| 4794 | 4794 | |
| 4795 | - if ( $import_choice == 'update' ) {
|
|
| 4796 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4797 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 4795 | + if ( $import_choice == 'update' ) {
|
|
| 4796 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4797 | + $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
| 4798 | 4798 | |
| 4799 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4800 | - $updated++; |
|
| 4801 | - } else {
|
|
| 4802 | - $invalid++; |
|
| 4803 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4804 | - } |
|
| 4805 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4806 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 4799 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4800 | + $updated++; |
|
| 4801 | + } else {
|
|
| 4802 | + $invalid++; |
|
| 4803 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4804 | + } |
|
| 4805 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4806 | + $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
| 4807 | 4807 | |
| 4808 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4809 | - $updated++; |
|
| 4810 | - } else {
|
|
| 4811 | - $invalid++; |
|
| 4812 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4813 | - } |
|
| 4814 | - } else {
|
|
| 4815 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4816 | - $created++; |
|
| 4817 | - } else {
|
|
| 4818 | - $invalid++; |
|
| 4819 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4820 | - } |
|
| 4821 | - } |
|
| 4822 | - } elseif ( $import_choice == 'skip' ) {
|
|
| 4823 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4824 | - $skipped++; |
|
| 4825 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4826 | - $skipped++; |
|
| 4827 | - } else {
|
|
| 4808 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4809 | + $updated++; |
|
| 4810 | + } else {
|
|
| 4811 | + $invalid++; |
|
| 4812 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4813 | + } |
|
| 4814 | + } else {
|
|
| 4815 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4816 | + $created++; |
|
| 4817 | + } else {
|
|
| 4818 | + $invalid++; |
|
| 4819 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4820 | + } |
|
| 4821 | + } |
|
| 4822 | + } elseif ( $import_choice == 'skip' ) {
|
|
| 4823 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) {
|
|
| 4824 | + $skipped++; |
|
| 4825 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) {
|
|
| 4826 | + $skipped++; |
|
| 4827 | + } else {
|
|
| 4828 | 4828 | |
| 4829 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4830 | - $created++; |
|
| 4831 | - } else {
|
|
| 4832 | - $invalid++; |
|
| 4833 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4834 | - } |
|
| 4835 | - } |
|
| 4836 | - } else {
|
|
| 4837 | - $invalid++; |
|
| 4838 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4839 | - } |
|
| 4840 | - } |
|
| 4841 | - } |
|
| 4842 | - } |
|
| 4829 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) {
|
|
| 4830 | + $created++; |
|
| 4831 | + } else {
|
|
| 4832 | + $invalid++; |
|
| 4833 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4834 | + } |
|
| 4835 | + } |
|
| 4836 | + } else {
|
|
| 4837 | + $invalid++; |
|
| 4838 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
| 4839 | + } |
|
| 4840 | + } |
|
| 4841 | + } |
|
| 4842 | + } |
|
| 4843 | 4843 | |
| 4844 | - $json = array(); |
|
| 4845 | - $json['processed'] = $limit; |
|
| 4846 | - $json['created'] = $created; |
|
| 4847 | - $json['updated'] = $updated; |
|
| 4848 | - $json['skipped'] = $skipped; |
|
| 4849 | - $json['invalid'] = $invalid; |
|
| 4850 | - $json['images'] = $images; |
|
| 4844 | + $json = array(); |
|
| 4845 | + $json['processed'] = $limit; |
|
| 4846 | + $json['created'] = $created; |
|
| 4847 | + $json['updated'] = $updated; |
|
| 4848 | + $json['skipped'] = $skipped; |
|
| 4849 | + $json['invalid'] = $invalid; |
|
| 4850 | + $json['images'] = $images; |
|
| 4851 | 4851 | |
| 4852 | - wp_send_json( $json ); |
|
| 4853 | - } |
|
| 4854 | - } |
|
| 4855 | - break; |
|
| 4856 | - case 'import_finish':{
|
|
| 4857 | - /** |
|
| 4858 | - * Run an action when an import finishes. |
|
| 4859 | - * |
|
| 4860 | - * This action can be used to fire functions after an import ends. |
|
| 4861 | - * |
|
| 4862 | - * @since 1.5.3 |
|
| 4863 | - * @package GeoDirectory |
|
| 4864 | - */ |
|
| 4865 | - do_action('geodir_import_finished');
|
|
| 4866 | - } |
|
| 4867 | - break; |
|
| 4852 | + wp_send_json( $json ); |
|
| 4853 | + } |
|
| 4854 | + } |
|
| 4855 | + break; |
|
| 4856 | + case 'import_finish':{
|
|
| 4857 | + /** |
|
| 4858 | + * Run an action when an import finishes. |
|
| 4859 | + * |
|
| 4860 | + * This action can be used to fire functions after an import ends. |
|
| 4861 | + * |
|
| 4862 | + * @since 1.5.3 |
|
| 4863 | + * @package GeoDirectory |
|
| 4864 | + */ |
|
| 4865 | + do_action('geodir_import_finished');
|
|
| 4866 | + } |
|
| 4867 | + break; |
|
| 4868 | 4868 | |
| 4869 | - } |
|
| 4870 | - echo '0'; |
|
| 4871 | - gd_die(); |
|
| 4869 | + } |
|
| 4870 | + echo '0'; |
|
| 4871 | + gd_die(); |
|
| 4872 | 4872 | } |
| 4873 | 4873 | |
| 4874 | 4874 | /** |
@@ -4912,12 +4912,12 @@ discard block |
||
| 4912 | 4912 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
| 4913 | 4913 | } |
| 4914 | 4914 | |
| 4915 | - if( !empty( $term ) ) {
|
|
| 4915 | + if( !empty( $term ) ) {
|
|
| 4916 | 4916 | $result = wp_insert_term( $term, $taxonomy, $args ); |
| 4917 | - if( !is_wp_error( $result ) ) {
|
|
| 4918 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4919 | - } |
|
| 4920 | - } |
|
| 4917 | + if( !is_wp_error( $result ) ) {
|
|
| 4918 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4919 | + } |
|
| 4920 | + } |
|
| 4921 | 4921 | |
| 4922 | 4922 | return false; |
| 4923 | 4923 | } |
@@ -4963,16 +4963,16 @@ discard block |
||
| 4963 | 4963 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 4964 | 4964 | |
| 4965 | 4965 | if( !is_wp_error( $result ) ) {
|
| 4966 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4967 | - } |
|
| 4966 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4967 | + } |
|
| 4968 | 4968 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) {
|
| 4969 | 4969 | $term_data['term_id'] = $term_info['term_id']; |
| 4970 | 4970 | |
| 4971 | 4971 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
| 4972 | 4972 | |
| 4973 | 4973 | if( !is_wp_error( $result ) ) {
|
| 4974 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4975 | - } |
|
| 4974 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
| 4975 | + } |
|
| 4976 | 4976 | } else {
|
| 4977 | 4977 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
| 4978 | 4978 | } |
@@ -4994,47 +4994,47 @@ discard block |
||
| 4994 | 4994 | * @return int Posts count. |
| 4995 | 4995 | */ |
| 4996 | 4996 | function geodir_get_posts_count( $post_type ) {
|
| 4997 | - global $wpdb, $plugin_prefix; |
|
| 4997 | + global $wpdb, $plugin_prefix; |
|
| 4998 | 4998 | |
| 4999 | - if ( !post_type_exists( $post_type ) ) {
|
|
| 5000 | - return 0; |
|
| 5001 | - } |
|
| 4999 | + if ( !post_type_exists( $post_type ) ) {
|
|
| 5000 | + return 0; |
|
| 5001 | + } |
|
| 5002 | 5002 | |
| 5003 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5003 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5004 | 5004 | |
| 5005 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5006 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5007 | - $where_statuses = ''; |
|
| 5008 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5009 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5010 | - } |
|
| 5005 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5006 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5007 | + $where_statuses = ''; |
|
| 5008 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5009 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5010 | + } |
|
| 5011 | 5011 | |
| 5012 | - /** |
|
| 5013 | - * Filter the SQL where clause part to filter posts count in import/export. |
|
| 5014 | - * |
|
| 5015 | - * @since 1.6.4 |
|
| 5016 | - * @package GeoDirectory |
|
| 5017 | - * |
|
| 5018 | - * @param string $where SQL where clause part. |
|
| 5019 | - */ |
|
| 5020 | - $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
| 5021 | - |
|
| 5022 | - $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 );
|
|
| 5023 | - |
|
| 5024 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5012 | + /** |
|
| 5013 | + * Filter the SQL where clause part to filter posts count in import/export. |
|
| 5014 | + * |
|
| 5015 | + * @since 1.6.4 |
|
| 5016 | + * @package GeoDirectory |
|
| 5017 | + * |
|
| 5018 | + * @param string $where SQL where clause part. |
|
| 5019 | + */ |
|
| 5020 | + $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
| 5021 | + |
|
| 5022 | + $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 );
|
|
| 5023 | + |
|
| 5024 | + $posts_count = (int)$wpdb->get_var( $query ); |
|
| 5025 | 5025 | |
| 5026 | - /** |
|
| 5027 | - * Modify returned post counts for the current post type. |
|
| 5028 | - * |
|
| 5029 | - * @since 1.4.6 |
|
| 5030 | - * @package GeoDirectory |
|
| 5031 | - * |
|
| 5032 | - * @param int $posts_count Post counts. |
|
| 5033 | - * @param string $post_type Post type. |
|
| 5034 | - */ |
|
| 5035 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5036 | - |
|
| 5037 | - return $posts_count; |
|
| 5026 | + /** |
|
| 5027 | + * Modify returned post counts for the current post type. |
|
| 5028 | + * |
|
| 5029 | + * @since 1.4.6 |
|
| 5030 | + * @package GeoDirectory |
|
| 5031 | + * |
|
| 5032 | + * @param int $posts_count Post counts. |
|
| 5033 | + * @param string $post_type Post type. |
|
| 5034 | + */ |
|
| 5035 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
| 5036 | + |
|
| 5037 | + return $posts_count; |
|
| 5038 | 5038 | } |
| 5039 | 5039 | |
| 5040 | 5040 | /** |
@@ -5063,10 +5063,10 @@ discard block |
||
| 5063 | 5063 | |
| 5064 | 5064 | if ( !empty( $posts ) ) {
|
| 5065 | 5065 | $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
| 5066 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5067 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5068 | - $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5069 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 5066 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active.
|
|
| 5067 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
| 5068 | + $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false;
|
|
| 5069 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false;
|
|
| 5070 | 5070 | |
| 5071 | 5071 | $csv_row = array(); |
| 5072 | 5072 | $csv_row[] = 'post_id'; |
@@ -5098,7 +5098,7 @@ discard block |
||
| 5098 | 5098 | } |
| 5099 | 5099 | $csv_row[] = 'post_status'; |
| 5100 | 5100 | $csv_row[] = 'is_featured'; |
| 5101 | - // Export claim listing field |
|
| 5101 | + // Export claim listing field |
|
| 5102 | 5102 | if ($is_claim_active) {
|
| 5103 | 5103 | $csv_row[] = 'claimed'; |
| 5104 | 5104 | } |
@@ -5107,7 +5107,7 @@ discard block |
||
| 5107 | 5107 | $csv_row[] = 'alive_days'; |
| 5108 | 5108 | $csv_row[] = 'expire_date'; |
| 5109 | 5109 | } |
| 5110 | - $csv_row[] = 'post_date'; |
|
| 5110 | + $csv_row[] = 'post_date'; |
|
| 5111 | 5111 | $csv_row[] = 'post_address'; |
| 5112 | 5112 | $csv_row[] = 'post_city'; |
| 5113 | 5113 | $csv_row[] = 'post_region'; |
@@ -5115,11 +5115,11 @@ discard block |
||
| 5115 | 5115 | $csv_row[] = 'post_zip'; |
| 5116 | 5116 | $csv_row[] = 'post_latitude'; |
| 5117 | 5117 | $csv_row[] = 'post_longitude'; |
| 5118 | - if ($neighbourhood_active) {
|
|
| 5119 | - $csv_row[] = 'post_neighbourhood'; |
|
| 5120 | - $csv_row[] = 'neighbourhood_latitude'; |
|
| 5121 | - $csv_row[] = 'neighbourhood_longitude'; |
|
| 5122 | - } |
|
| 5118 | + if ($neighbourhood_active) {
|
|
| 5119 | + $csv_row[] = 'post_neighbourhood'; |
|
| 5120 | + $csv_row[] = 'neighbourhood_latitude'; |
|
| 5121 | + $csv_row[] = 'neighbourhood_longitude'; |
|
| 5122 | + } |
|
| 5123 | 5123 | $csv_row[] = 'geodir_timing'; |
| 5124 | 5124 | $csv_row[] = 'geodir_contact'; |
| 5125 | 5125 | $csv_row[] = 'geodir_email'; |
@@ -5151,21 +5151,21 @@ discard block |
||
| 5151 | 5151 | $csv_row[] = 'franchise'; |
| 5152 | 5152 | } |
| 5153 | 5153 | |
| 5154 | - /** |
|
| 5155 | - * Filter columns field names of gd export listings csv. |
|
| 5156 | - * |
|
| 5157 | - * @since 1.6.5 |
|
| 5158 | - * @package GeoDirectory |
|
| 5159 | - * |
|
| 5160 | - * @param array $csv_row Column names being exported in csv. |
|
| 5161 | - * @param string $post_type The post type. |
|
| 5162 | - */ |
|
| 5163 | - $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
|
|
| 5154 | + /** |
|
| 5155 | + * Filter columns field names of gd export listings csv. |
|
| 5156 | + * |
|
| 5157 | + * @since 1.6.5 |
|
| 5158 | + * @package GeoDirectory |
|
| 5159 | + * |
|
| 5160 | + * @param array $csv_row Column names being exported in csv. |
|
| 5161 | + * @param string $post_type The post type. |
|
| 5162 | + */ |
|
| 5163 | + $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type);
|
|
| 5164 | 5164 | |
| 5165 | 5165 | $csv_rows[] = $csv_row; |
| 5166 | 5166 | |
| 5167 | 5167 | $images_count = 5; |
| 5168 | - $xx=0; |
|
| 5168 | + $xx=0; |
|
| 5169 | 5169 | foreach ( $posts as $post ) {$xx++;
|
| 5170 | 5170 | $post_id = $post['ID']; |
| 5171 | 5171 | |
@@ -5296,15 +5296,15 @@ discard block |
||
| 5296 | 5296 | } |
| 5297 | 5297 | $csv_row[] = $post_info['post_status']; // post_status |
| 5298 | 5298 | $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
| 5299 | - if ($is_claim_active) {
|
|
| 5300 | - $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
| 5301 | - } |
|
| 5299 | + if ($is_claim_active) {
|
|
| 5300 | + $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
| 5301 | + } |
|
| 5302 | 5302 | if ($is_payment_plugin) {
|
| 5303 | 5303 | $csv_row[] = (int)$post_info['package_id']; // package_id |
| 5304 | 5304 | $csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days |
| 5305 | 5305 | $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
|
| 5306 | 5306 | } |
| 5307 | - $csv_row[] = $post_info['post_date']; // post_date |
|
| 5307 | + $csv_row[] = $post_info['post_date']; // post_date |
|
| 5308 | 5308 | $csv_row[] = stripslashes($post_info['post_address']); // post_address |
| 5309 | 5309 | $csv_row[] = stripslashes($post_info['post_city']); // post_city |
| 5310 | 5310 | $csv_row[] = stripslashes($post_info['post_region']); // post_region |
@@ -5312,21 +5312,21 @@ discard block |
||
| 5312 | 5312 | $csv_row[] = stripslashes($post_info['post_zip']); // post_zip |
| 5313 | 5313 | $csv_row[] = $post_info['post_latitude']; // post_latitude |
| 5314 | 5314 | $csv_row[] = $post_info['post_longitude']; // post_longitude |
| 5315 | - if ($neighbourhood_active) {
|
|
| 5316 | - $post_neighbourhood = ''; |
|
| 5317 | - $neighbourhood_latitude = ''; |
|
| 5318 | - $neighbourhood_longitude = ''; |
|
| 5319 | - if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5320 | - if (!empty($hood_info)) {
|
|
| 5321 | - $post_neighbourhood = $hood_info->hood_name; |
|
| 5322 | - $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5323 | - $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5324 | - } |
|
| 5325 | - } |
|
| 5326 | - $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
| 5327 | - $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5328 | - $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5329 | - } |
|
| 5315 | + if ($neighbourhood_active) {
|
|
| 5316 | + $post_neighbourhood = ''; |
|
| 5317 | + $neighbourhood_latitude = ''; |
|
| 5318 | + $neighbourhood_longitude = ''; |
|
| 5319 | + if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) {
|
|
| 5320 | + if (!empty($hood_info)) {
|
|
| 5321 | + $post_neighbourhood = $hood_info->hood_name; |
|
| 5322 | + $neighbourhood_latitude = $hood_info->hood_latitude; |
|
| 5323 | + $neighbourhood_longitude = $hood_info->hood_longitude; |
|
| 5324 | + } |
|
| 5325 | + } |
|
| 5326 | + $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
| 5327 | + $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
| 5328 | + $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
| 5329 | + } |
|
| 5330 | 5330 | $csv_row[] = stripslashes($post_info['geodir_timing']); // geodir_timing |
| 5331 | 5331 | $csv_row[] = stripslashes($post_info['geodir_contact']); // geodir_contact |
| 5332 | 5332 | $csv_row[] = stripslashes($post_info['geodir_email']); // geodir_email |
@@ -5366,16 +5366,16 @@ discard block |
||
| 5366 | 5366 | $csv_row[] = (int)$franchise; // franchise id |
| 5367 | 5367 | } |
| 5368 | 5368 | |
| 5369 | - /** |
|
| 5370 | - * Filter columns values of gd export listings csv file |
|
| 5371 | - * |
|
| 5372 | - * @since 1.6.5 |
|
| 5373 | - * @package GeoDirectory |
|
| 5374 | - * |
|
| 5375 | - * @param array $csv_row Field values being exported in csv. |
|
| 5376 | - * @param array $post_info The post info. |
|
| 5377 | - */ |
|
| 5378 | - $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
|
|
| 5369 | + /** |
|
| 5370 | + * Filter columns values of gd export listings csv file |
|
| 5371 | + * |
|
| 5372 | + * @since 1.6.5 |
|
| 5373 | + * @package GeoDirectory |
|
| 5374 | + * |
|
| 5375 | + * @param array $csv_row Field values being exported in csv. |
|
| 5376 | + * @param array $post_info The post info. |
|
| 5377 | + */ |
|
| 5378 | + $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info);
|
|
| 5379 | 5379 | |
| 5380 | 5380 | for ( $c = 0; $c < $images_count; $c++ ) {
|
| 5381 | 5381 | $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
@@ -5408,64 +5408,64 @@ discard block |
||
| 5408 | 5408 | * @return array Array of posts data. |
| 5409 | 5409 | */ |
| 5410 | 5410 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) {
|
| 5411 | - global $wpdb, $plugin_prefix; |
|
| 5411 | + global $wpdb, $plugin_prefix; |
|
| 5412 | 5412 | |
| 5413 | - if ( ! post_type_exists( $post_type ) ) |
|
| 5414 | - return new stdClass; |
|
| 5413 | + if ( ! post_type_exists( $post_type ) ) |
|
| 5414 | + return new stdClass; |
|
| 5415 | 5415 | |
| 5416 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5416 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5417 | 5417 | |
| 5418 | - $limit = ''; |
|
| 5419 | - if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5420 | - $offset = ( $page_no - 1 ) * $per_page; |
|
| 5418 | + $limit = ''; |
|
| 5419 | + if ( $per_page > 0 && $page_no > 0 ) {
|
|
| 5420 | + $offset = ( $page_no - 1 ) * $per_page; |
|
| 5421 | 5421 | |
| 5422 | - if ( $offset > 0 ) {
|
|
| 5423 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5424 | - } else {
|
|
| 5425 | - $limit = " LIMIT " . $per_page; |
|
| 5426 | - } |
|
| 5427 | - } |
|
| 5422 | + if ( $offset > 0 ) {
|
|
| 5423 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
| 5424 | + } else {
|
|
| 5425 | + $limit = " LIMIT " . $per_page; |
|
| 5426 | + } |
|
| 5427 | + } |
|
| 5428 | 5428 | |
| 5429 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5430 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5431 | - $where_statuses = ''; |
|
| 5432 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5433 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5434 | - } |
|
| 5429 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5430 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5431 | + $where_statuses = ''; |
|
| 5432 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5433 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5434 | + } |
|
| 5435 | 5435 | |
| 5436 | - /** |
|
| 5437 | - * Filter the SQL where clause part to filter posts in import/export. |
|
| 5438 | - * |
|
| 5439 | - * @since 1.6.4 |
|
| 5440 | - * @package GeoDirectory |
|
| 5441 | - * |
|
| 5442 | - * @param string $where SQL where clause part. |
|
| 5443 | - */ |
|
| 5444 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5445 | - |
|
| 5446 | - $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 );
|
|
| 5447 | - /** |
|
| 5448 | - * Modify returned posts SQL query for the current post type. |
|
| 5449 | - * |
|
| 5450 | - * @since 1.4.6 |
|
| 5451 | - * @package GeoDirectory |
|
| 5452 | - * |
|
| 5453 | - * @param int $query The SQL query. |
|
| 5454 | - * @param string $post_type Post type. |
|
| 5455 | - */ |
|
| 5456 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5457 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5458 | - |
|
| 5459 | - /** |
|
| 5460 | - * Modify returned post results for the current post type. |
|
| 5461 | - * |
|
| 5462 | - * @since 1.4.6 |
|
| 5463 | - * @package GeoDirectory |
|
| 5464 | - * |
|
| 5465 | - * @param object $results An object containing all post ids. |
|
| 5466 | - * @param string $post_type Post type. |
|
| 5467 | - */ |
|
| 5468 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5436 | + /** |
|
| 5437 | + * Filter the SQL where clause part to filter posts in import/export. |
|
| 5438 | + * |
|
| 5439 | + * @since 1.6.4 |
|
| 5440 | + * @package GeoDirectory |
|
| 5441 | + * |
|
| 5442 | + * @param string $where SQL where clause part. |
|
| 5443 | + */ |
|
| 5444 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5445 | + |
|
| 5446 | + $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 );
|
|
| 5447 | + /** |
|
| 5448 | + * Modify returned posts SQL query for the current post type. |
|
| 5449 | + * |
|
| 5450 | + * @since 1.4.6 |
|
| 5451 | + * @package GeoDirectory |
|
| 5452 | + * |
|
| 5453 | + * @param int $query The SQL query. |
|
| 5454 | + * @param string $post_type Post type. |
|
| 5455 | + */ |
|
| 5456 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
| 5457 | + $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
| 5458 | + |
|
| 5459 | + /** |
|
| 5460 | + * Modify returned post results for the current post type. |
|
| 5461 | + * |
|
| 5462 | + * @since 1.4.6 |
|
| 5463 | + * @package GeoDirectory |
|
| 5464 | + * |
|
| 5465 | + * @param object $results An object containing all post ids. |
|
| 5466 | + * @param string $post_type Post type. |
|
| 5467 | + */ |
|
| 5468 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
| 5469 | 5469 | } |
| 5470 | 5470 | |
| 5471 | 5471 | /** |
@@ -5484,26 +5484,26 @@ discard block |
||
| 5484 | 5484 | * @return string The SQL query. |
| 5485 | 5485 | */ |
| 5486 | 5486 | function geodir_imex_get_events_query( $query, $post_type ) {
|
| 5487 | - if ( $post_type == 'gd_event' ) {
|
|
| 5488 | - global $wpdb, $plugin_prefix; |
|
| 5487 | + if ( $post_type == 'gd_event' ) {
|
|
| 5488 | + global $wpdb, $plugin_prefix; |
|
| 5489 | 5489 | |
| 5490 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5491 | - $schedule_table = EVENT_SCHEDULE; |
|
| 5490 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 5491 | + $schedule_table = EVENT_SCHEDULE; |
|
| 5492 | 5492 | |
| 5493 | - // Skip listing with statuses trash, auto-draft etc... |
|
| 5494 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5495 | - $where_statuses = ''; |
|
| 5496 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5497 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5498 | - } |
|
| 5493 | + // Skip listing with statuses trash, auto-draft etc... |
|
| 5494 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
| 5495 | + $where_statuses = ''; |
|
| 5496 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) {
|
|
| 5497 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')";
|
|
| 5498 | + } |
|
| 5499 | 5499 | |
| 5500 | - /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
| 5501 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5500 | + /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
| 5501 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
| 5502 | 5502 | |
| 5503 | - $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 );
|
|
| 5504 | - } |
|
| 5503 | + $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 );
|
|
| 5504 | + } |
|
| 5505 | 5505 | |
| 5506 | - return $query; |
|
| 5506 | + return $query; |
|
| 5507 | 5507 | } |
| 5508 | 5508 | |
| 5509 | 5509 | /** |
@@ -5525,36 +5525,36 @@ discard block |
||
| 5525 | 5525 | * @return int Total terms count. |
| 5526 | 5526 | */ |
| 5527 | 5527 | function geodir_get_terms_count( $post_type ) {
|
| 5528 | - $args = array( 'hide_empty' => 0 ); |
|
| 5528 | + $args = array( 'hide_empty' => 0 ); |
|
| 5529 | 5529 | |
| 5530 | - remove_all_filters( 'get_terms' ); |
|
| 5530 | + remove_all_filters( 'get_terms' ); |
|
| 5531 | 5531 | |
| 5532 | - $taxonomy = $post_type . 'category'; |
|
| 5532 | + $taxonomy = $post_type . 'category'; |
|
| 5533 | 5533 | |
| 5534 | - // WPML |
|
| 5535 | - $is_wpml = geodir_is_wpml(); |
|
| 5536 | - $active_lang = 'all'; |
|
| 5537 | - if ( $is_wpml ) {
|
|
| 5538 | - global $sitepress; |
|
| 5539 | - $active_lang = $sitepress->get_current_language(); |
|
| 5534 | + // WPML |
|
| 5535 | + $is_wpml = geodir_is_wpml(); |
|
| 5536 | + $active_lang = 'all'; |
|
| 5537 | + if ( $is_wpml ) {
|
|
| 5538 | + global $sitepress; |
|
| 5539 | + $active_lang = $sitepress->get_current_language(); |
|
| 5540 | 5540 | |
| 5541 | - if ( $active_lang != 'all' ) {
|
|
| 5542 | - $sitepress->switch_lang( 'all', true ); |
|
| 5543 | - } |
|
| 5544 | - } |
|
| 5545 | - // WPML |
|
| 5541 | + if ( $active_lang != 'all' ) {
|
|
| 5542 | + $sitepress->switch_lang( 'all', true ); |
|
| 5543 | + } |
|
| 5544 | + } |
|
| 5545 | + // WPML |
|
| 5546 | 5546 | |
| 5547 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5547 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
| 5548 | 5548 | |
| 5549 | - // WPML |
|
| 5550 | - if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5551 | - global $sitepress; |
|
| 5552 | - $sitepress->switch_lang( $active_lang, true ); |
|
| 5553 | - } |
|
| 5554 | - // WPML |
|
| 5555 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5549 | + // WPML |
|
| 5550 | + if ( $is_wpml && $active_lang !== 'all' ) {
|
|
| 5551 | + global $sitepress; |
|
| 5552 | + $sitepress->switch_lang( $active_lang, true ); |
|
| 5553 | + } |
|
| 5554 | + // WPML |
|
| 5555 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
| 5556 | 5556 | |
| 5557 | - return $count_terms; |
|
| 5557 | + return $count_terms; |
|
| 5558 | 5558 | } |
| 5559 | 5559 | |
| 5560 | 5560 | /** |
@@ -5593,11 +5593,11 @@ discard block |
||
| 5593 | 5593 | $csv_row[] = 'cat_posttype'; |
| 5594 | 5594 | $csv_row[] = 'cat_parent'; |
| 5595 | 5595 | $csv_row[] = 'cat_schema'; |
| 5596 | - // WPML |
|
| 5596 | + // WPML |
|
| 5597 | 5597 | $is_wpml = geodir_is_wpml(); |
| 5598 | 5598 | if ($is_wpml) {
|
| 5599 | 5599 | $csv_row[] = 'cat_language'; |
| 5600 | - $csv_row[] = 'cat_id_original'; |
|
| 5600 | + $csv_row[] = 'cat_id_original'; |
|
| 5601 | 5601 | } |
| 5602 | 5602 | // WPML |
| 5603 | 5603 | $csv_row[] = 'cat_description'; |
@@ -5627,10 +5627,10 @@ discard block |
||
| 5627 | 5627 | $csv_row[] = $post_type; |
| 5628 | 5628 | $csv_row[] = $cat_parent; |
| 5629 | 5629 | $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
| 5630 | - // WPML |
|
| 5630 | + // WPML |
|
| 5631 | 5631 | if ($is_wpml) {
|
| 5632 | 5632 | $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
| 5633 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5633 | + $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
| 5634 | 5634 | } |
| 5635 | 5635 | // WPML |
| 5636 | 5636 | $csv_row[] = $term->description; |
@@ -6048,43 +6048,43 @@ discard block |
||
| 6048 | 6048 | * @param string $status Post status. |
| 6049 | 6049 | */ |
| 6050 | 6050 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') {
|
| 6051 | - global $wpdb, $current_user; |
|
| 6052 | - |
|
| 6053 | - $option_value = get_option($option); |
|
| 6054 | - |
|
| 6055 | - if ($option_value > 0) : |
|
| 6056 | - if (get_post($option_value)) : |
|
| 6057 | - // Page exists |
|
| 6058 | - return; |
|
| 6059 | - endif; |
|
| 6060 | - endif; |
|
| 6061 | - |
|
| 6062 | - $page_found = $wpdb->get_var( |
|
| 6063 | - $wpdb->prepare( |
|
| 6064 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6065 | - array($slug) |
|
| 6066 | - ) |
|
| 6067 | - ); |
|
| 6068 | - |
|
| 6069 | - if ($page_found) : |
|
| 6070 | - // Page exists |
|
| 6071 | - if (!$option_value) update_option($option, $page_found); |
|
| 6072 | - return; |
|
| 6073 | - endif; |
|
| 6074 | - |
|
| 6075 | - $page_data = array( |
|
| 6076 | - 'post_status' => $status, |
|
| 6077 | - 'post_type' => 'page', |
|
| 6078 | - 'post_author' => $current_user->ID, |
|
| 6079 | - 'post_name' => $slug, |
|
| 6080 | - 'post_title' => $page_title, |
|
| 6081 | - 'post_content' => $page_content, |
|
| 6082 | - 'post_parent' => $post_parent, |
|
| 6083 | - 'comment_status' => 'closed' |
|
| 6084 | - ); |
|
| 6085 | - $page_id = wp_insert_post($page_data); |
|
| 6086 | - |
|
| 6087 | - add_option($option, $page_id); |
|
| 6051 | + global $wpdb, $current_user; |
|
| 6052 | + |
|
| 6053 | + $option_value = get_option($option); |
|
| 6054 | + |
|
| 6055 | + if ($option_value > 0) : |
|
| 6056 | + if (get_post($option_value)) : |
|
| 6057 | + // Page exists |
|
| 6058 | + return; |
|
| 6059 | + endif; |
|
| 6060 | + endif; |
|
| 6061 | + |
|
| 6062 | + $page_found = $wpdb->get_var( |
|
| 6063 | + $wpdb->prepare( |
|
| 6064 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 6065 | + array($slug) |
|
| 6066 | + ) |
|
| 6067 | + ); |
|
| 6068 | + |
|
| 6069 | + if ($page_found) : |
|
| 6070 | + // Page exists |
|
| 6071 | + if (!$option_value) update_option($option, $page_found); |
|
| 6072 | + return; |
|
| 6073 | + endif; |
|
| 6074 | + |
|
| 6075 | + $page_data = array( |
|
| 6076 | + 'post_status' => $status, |
|
| 6077 | + 'post_type' => 'page', |
|
| 6078 | + 'post_author' => $current_user->ID, |
|
| 6079 | + 'post_name' => $slug, |
|
| 6080 | + 'post_title' => $page_title, |
|
| 6081 | + 'post_content' => $page_content, |
|
| 6082 | + 'post_parent' => $post_parent, |
|
| 6083 | + 'comment_status' => 'closed' |
|
| 6084 | + ); |
|
| 6085 | + $page_id = wp_insert_post($page_data); |
|
| 6086 | + |
|
| 6087 | + add_option($option, $page_id); |
|
| 6088 | 6088 | |
| 6089 | 6089 | } |
| 6090 | 6090 | |
@@ -6115,9 +6115,9 @@ discard block |
||
| 6115 | 6115 | * @package GeoDirectory |
| 6116 | 6116 | */ |
| 6117 | 6117 | function geodir_admin_upgrade_notice() {
|
| 6118 | - $class = "error"; |
|
| 6119 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6120 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6118 | + $class = "error"; |
|
| 6119 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory");
|
|
| 6120 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
| 6121 | 6121 | } |
| 6122 | 6122 | |
| 6123 | 6123 | /** |
@@ -6130,18 +6130,18 @@ discard block |
||
| 6130 | 6130 | */ |
| 6131 | 6131 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
| 6132 | 6132 | {
|
| 6133 | - // readme contents |
|
| 6134 | - $args = array( |
|
| 6135 | - 'timeout' => 15, |
|
| 6136 | - 'redirection' => 5 |
|
| 6137 | - ); |
|
| 6138 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6139 | - $data = wp_remote_get( $url, $args ); |
|
| 6133 | + // readme contents |
|
| 6134 | + $args = array( |
|
| 6135 | + 'timeout' => 15, |
|
| 6136 | + 'redirection' => 5 |
|
| 6137 | + ); |
|
| 6138 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
| 6139 | + $data = wp_remote_get( $url, $args ); |
|
| 6140 | 6140 | |
| 6141 | - if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6141 | + if (!is_wp_error($data) && $data['response']['code'] == 200) {
|
|
| 6142 | 6142 | |
| 6143 | - geodir_in_plugin_update_message($data['body']); |
|
| 6144 | - } |
|
| 6143 | + geodir_in_plugin_update_message($data['body']); |
|
| 6144 | + } |
|
| 6145 | 6145 | } |
| 6146 | 6146 | |
| 6147 | 6147 | |
@@ -6149,28 +6149,28 @@ discard block |
||
| 6149 | 6149 | * @param string $content http response body |
| 6150 | 6150 | */ |
| 6151 | 6151 | function geodir_in_plugin_update_message($content) {
|
| 6152 | - // Output Upgrade Notice |
|
| 6153 | - $matches = null; |
|
| 6154 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6155 | - $upgrade_notice = ''; |
|
| 6156 | - if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6157 | - if(empty($matches)){return;}
|
|
| 6158 | - |
|
| 6159 | - $version = trim( $matches[1] ); |
|
| 6160 | - if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6161 | - |
|
| 6162 | - |
|
| 6163 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6164 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6165 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6166 | - foreach ( $notices as $index => $line ) {
|
|
| 6167 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6168 | - } |
|
| 6169 | - $upgrade_notice .= '</div> '; |
|
| 6170 | - } |
|
| 6171 | - } |
|
| 6172 | - } |
|
| 6173 | - echo $upgrade_notice; |
|
| 6152 | + // Output Upgrade Notice |
|
| 6153 | + $matches = null; |
|
| 6154 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
| 6155 | + $upgrade_notice = ''; |
|
| 6156 | + if ( preg_match( $regexp, $content, $matches ) ) {
|
|
| 6157 | + if(empty($matches)){return;}
|
|
| 6158 | + |
|
| 6159 | + $version = trim( $matches[1] ); |
|
| 6160 | + if($version && $version>GEODIRECTORY_VERSION){
|
|
| 6161 | + |
|
| 6162 | + |
|
| 6163 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) );
|
|
| 6164 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) {
|
|
| 6165 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
| 6166 | + foreach ( $notices as $index => $line ) {
|
|
| 6167 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) );
|
|
| 6168 | + } |
|
| 6169 | + $upgrade_notice .= '</div> '; |
|
| 6170 | + } |
|
| 6171 | + } |
|
| 6172 | + } |
|
| 6173 | + echo $upgrade_notice; |
|
| 6174 | 6174 | } |
| 6175 | 6175 | |
| 6176 | 6176 | /** |
@@ -6203,19 +6203,19 @@ discard block |
||
| 6203 | 6203 | * @param array Listing statuses to be skipped. |
| 6204 | 6204 | */ |
| 6205 | 6205 | function geodir_imex_export_skip_statuses() {
|
| 6206 | - $statuses = array( 'trash', 'auto-draft' ); |
|
| 6206 | + $statuses = array( 'trash', 'auto-draft' ); |
|
| 6207 | 6207 | |
| 6208 | - /** |
|
| 6209 | - * Filter the statuses to skip during GD export listings. |
|
| 6210 | - * |
|
| 6211 | - * @since 1.6.0 |
|
| 6212 | - * @package GeoDirectory |
|
| 6213 | - * |
|
| 6214 | - * @param array $statuses Listing statuses to be skipped. |
|
| 6215 | - */ |
|
| 6216 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6208 | + /** |
|
| 6209 | + * Filter the statuses to skip during GD export listings. |
|
| 6210 | + * |
|
| 6211 | + * @since 1.6.0 |
|
| 6212 | + * @package GeoDirectory |
|
| 6213 | + * |
|
| 6214 | + * @param array $statuses Listing statuses to be skipped. |
|
| 6215 | + */ |
|
| 6216 | + $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
| 6217 | 6217 | |
| 6218 | - return $statuses; |
|
| 6218 | + return $statuses; |
|
| 6219 | 6219 | } |
| 6220 | 6220 | |
| 6221 | 6221 | /** |
@@ -6231,37 +6231,37 @@ discard block |
||
| 6231 | 6231 | * @global string $typenow Current post type. |
| 6232 | 6232 | */ |
| 6233 | 6233 | function geodir_admin_dequeue_scripts() {
|
| 6234 | - global $typenow; |
|
| 6234 | + global $typenow; |
|
| 6235 | 6235 | |
| 6236 | - // EDD |
|
| 6237 | - if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6238 | - wp_dequeue_script('jquery-chosen');
|
|
| 6239 | - } |
|
| 6236 | + // EDD |
|
| 6237 | + if (wp_script_is('jquery-chosen', 'enqueued')) {
|
|
| 6238 | + wp_dequeue_script('jquery-chosen');
|
|
| 6239 | + } |
|
| 6240 | 6240 | |
| 6241 | - // Ultimate Addons for Visual Composer |
|
| 6242 | - if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6243 | - wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6244 | - } |
|
| 6241 | + // Ultimate Addons for Visual Composer |
|
| 6242 | + if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) {
|
|
| 6243 | + wp_dequeue_script('ultimate-vc-backend-script');
|
|
| 6244 | + } |
|
| 6245 | 6245 | |
| 6246 | - // VC editor conflicts |
|
| 6247 | - if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
|
|
| 6248 | - wp_dequeue_script('dfd_vc_damin_scripts');
|
|
| 6249 | - } |
|
| 6246 | + // VC editor conflicts |
|
| 6247 | + if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) {
|
|
| 6248 | + wp_dequeue_script('dfd_vc_damin_scripts');
|
|
| 6249 | + } |
|
| 6250 | 6250 | |
| 6251 | - // Ultimate chosen |
|
| 6252 | - if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
|
|
| 6253 | - wp_dequeue_script('ultimate-chosen-script');
|
|
| 6254 | - } |
|
| 6251 | + // Ultimate chosen |
|
| 6252 | + if (wp_script_is('ultimate-chosen-script', 'enqueued')) {
|
|
| 6253 | + wp_dequeue_script('ultimate-chosen-script');
|
|
| 6254 | + } |
|
| 6255 | 6255 | |
| 6256 | - // Crum composer choosen |
|
| 6257 | - if (wp_script_is('crum-composer-choosen', 'enqueued')) {
|
|
| 6258 | - wp_dequeue_script('crum-composer-choosen');
|
|
| 6259 | - } |
|
| 6256 | + // Crum composer choosen |
|
| 6257 | + if (wp_script_is('crum-composer-choosen', 'enqueued')) {
|
|
| 6258 | + wp_dequeue_script('crum-composer-choosen');
|
|
| 6259 | + } |
|
| 6260 | 6260 | |
| 6261 | - // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
| 6262 | - if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
|
|
| 6263 | - wp_dequeue_script('fusion_builder_chosen_js');
|
|
| 6264 | - } |
|
| 6261 | + // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
| 6262 | + if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) {
|
|
| 6263 | + wp_dequeue_script('fusion_builder_chosen_js');
|
|
| 6264 | + } |
|
| 6265 | 6265 | } |
| 6266 | 6266 | |
| 6267 | 6267 | /** |
@@ -6277,48 +6277,48 @@ discard block |
||
| 6277 | 6277 | * @return string SQL where clause part. |
| 6278 | 6278 | */ |
| 6279 | 6279 | function geodir_imex_get_filter_where($where = '', $post_type = '') {
|
| 6280 | - global $wpdb; |
|
| 6280 | + global $wpdb; |
|
| 6281 | 6281 | |
| 6282 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 6282 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
| 6283 | 6283 | |
| 6284 | - if ( !empty( $filters ) ) {
|
|
| 6285 | - foreach ( $filters as $field => $value ) {
|
|
| 6286 | - switch ($field) {
|
|
| 6287 | - case 'start_date': |
|
| 6288 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
| 6289 | - break; |
|
| 6290 | - case 'end_date': |
|
| 6291 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
| 6292 | - break; |
|
| 6293 | - } |
|
| 6294 | - } |
|
| 6295 | - } |
|
| 6284 | + if ( !empty( $filters ) ) {
|
|
| 6285 | + foreach ( $filters as $field => $value ) {
|
|
| 6286 | + switch ($field) {
|
|
| 6287 | + case 'start_date': |
|
| 6288 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
| 6289 | + break; |
|
| 6290 | + case 'end_date': |
|
| 6291 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
| 6292 | + break; |
|
| 6293 | + } |
|
| 6294 | + } |
|
| 6295 | + } |
|
| 6296 | 6296 | |
| 6297 | - return $where; |
|
| 6297 | + return $where; |
|
| 6298 | 6298 | } |
| 6299 | 6299 | add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2);
|
| 6300 | 6300 | add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2);
|
| 6301 | 6301 | |
| 6302 | 6302 | |
| 6303 | 6303 | function geodir_fix_for_primer_theme(){
|
| 6304 | - if(!defined( 'PRIMER_VERSION' )){return;}
|
|
| 6305 | - global $pagenow; |
|
| 6304 | + if(!defined( 'PRIMER_VERSION' )){return;}
|
|
| 6305 | + global $pagenow; |
|
| 6306 | 6306 | |
| 6307 | - if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){
|
|
| 6307 | + if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){
|
|
| 6308 | 6308 | |
| 6309 | - $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
| 6309 | + $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
| 6310 | 6310 | |
| 6311 | - $post_types = geodir_get_posttypes(); |
|
| 6312 | - if ($post_type && in_array($post_type, $post_types) ) {
|
|
| 6313 | - global $primer_customizer_layouts; |
|
| 6314 | - remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
| 6315 | - } |
|
| 6316 | - } |
|
| 6311 | + $post_types = geodir_get_posttypes(); |
|
| 6312 | + if ($post_type && in_array($post_type, $post_types) ) {
|
|
| 6313 | + global $primer_customizer_layouts; |
|
| 6314 | + remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
| 6315 | + } |
|
| 6316 | + } |
|
| 6317 | 6317 | |
| 6318 | 6318 | } |
| 6319 | 6319 | |
| 6320 | 6320 | if(is_admin()){
|
| 6321 | - add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);
|
|
| 6321 | + add_action('add_meta_boxes','geodir_fix_for_primer_theme',0);
|
|
| 6322 | 6322 | } |
| 6323 | 6323 | |
| 6324 | 6324 | |
@@ -6451,94 +6451,94 @@ discard block |
||
| 6451 | 6451 | |
| 6452 | 6452 | function geodir_ga_activation_url() {
|
| 6453 | 6453 | |
| 6454 | - return add_query_arg( array( |
|
| 6455 | - 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
|
|
| 6456 | - 'scope' => GEODIR_GA_SCOPE, |
|
| 6457 | - 'response_type' => 'code', |
|
| 6458 | - 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
| 6459 | - 'client_id' => GEODIR_GA_CLIENTID, |
|
| 6460 | - ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
| 6454 | + return add_query_arg( array( |
|
| 6455 | + 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"),
|
|
| 6456 | + 'scope' => GEODIR_GA_SCOPE, |
|
| 6457 | + 'response_type' => 'code', |
|
| 6458 | + 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
| 6459 | + 'client_id' => GEODIR_GA_CLIENTID, |
|
| 6460 | + ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
| 6461 | 6461 | |
| 6462 | - return $url; |
|
| 6462 | + return $url; |
|
| 6463 | 6463 | } |
| 6464 | 6464 | |
| 6465 | 6465 | function geodir_gd_accounts(){
|
| 6466 | - $accounts = array(); |
|
| 6467 | - $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
| 6468 | - if($useAuth){
|
|
| 6469 | - try {
|
|
| 6470 | - $accounts = geodir_ga_get_analytics_accounts(); |
|
| 6471 | - } catch (Exception $e) {
|
|
| 6472 | - geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
| 6473 | - } |
|
| 6466 | + $accounts = array(); |
|
| 6467 | + $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
| 6468 | + if($useAuth){
|
|
| 6469 | + try {
|
|
| 6470 | + $accounts = geodir_ga_get_analytics_accounts(); |
|
| 6471 | + } catch (Exception $e) {
|
|
| 6472 | + geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
| 6473 | + } |
|
| 6474 | 6474 | |
| 6475 | - if(is_array($accounts)){
|
|
| 6476 | - $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
|
|
| 6477 | - }elseif(get_option('geodir_ga_account_id')){
|
|
| 6478 | - $accounts = array(); |
|
| 6479 | - $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
|
|
| 6480 | - } |
|
| 6481 | - } |
|
| 6482 | - return $accounts; |
|
| 6475 | + if(is_array($accounts)){
|
|
| 6476 | + $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts);
|
|
| 6477 | + }elseif(get_option('geodir_ga_account_id')){
|
|
| 6478 | + $accounts = array(); |
|
| 6479 | + $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')';
|
|
| 6480 | + } |
|
| 6481 | + } |
|
| 6482 | + return $accounts; |
|
| 6483 | 6483 | } |
| 6484 | 6484 | |
| 6485 | 6485 | function geodir_ga_get_analytics_accounts() |
| 6486 | 6486 | {
|
| 6487 | - global $gd_ga_errors; |
|
| 6488 | - $accounts = array(); |
|
| 6487 | + global $gd_ga_errors; |
|
| 6488 | + $accounts = array(); |
|
| 6489 | 6489 | |
| 6490 | - if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
|
|
| 6490 | + if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');}
|
|
| 6491 | 6491 | |
| 6492 | 6492 | |
| 6493 | - if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
|
|
| 6494 | - return get_option('geodir_gd_uids');
|
|
| 6495 | - } |
|
| 6493 | + if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){
|
|
| 6494 | + return get_option('geodir_gd_uids');
|
|
| 6495 | + } |
|
| 6496 | 6496 | |
| 6497 | - # Create a new Gdata call |
|
| 6498 | - if ( trim(get_option('geodir_ga_auth_code')) != '' )
|
|
| 6499 | - $stats = new GDGoogleAnalyticsStats(); |
|
| 6500 | - else |
|
| 6501 | - return false; |
|
| 6497 | + # Create a new Gdata call |
|
| 6498 | + if ( trim(get_option('geodir_ga_auth_code')) != '' )
|
|
| 6499 | + $stats = new GDGoogleAnalyticsStats(); |
|
| 6500 | + else |
|
| 6501 | + return false; |
|
| 6502 | 6502 | |
| 6503 | - # Check if Google sucessfully logged in |
|
| 6504 | - if ( ! $stats->checkLogin() ) |
|
| 6505 | - return false; |
|
| 6503 | + # Check if Google sucessfully logged in |
|
| 6504 | + if ( ! $stats->checkLogin() ) |
|
| 6505 | + return false; |
|
| 6506 | 6506 | |
| 6507 | - # Get a list of accounts |
|
| 6508 | - try {
|
|
| 6509 | - $accounts = $stats->getAllProfiles(); |
|
| 6510 | - } catch (Exception $e) {
|
|
| 6511 | - $gd_ga_errors[] = $e->getMessage(); |
|
| 6512 | - return false; |
|
| 6513 | - } |
|
| 6507 | + # Get a list of accounts |
|
| 6508 | + try {
|
|
| 6509 | + $accounts = $stats->getAllProfiles(); |
|
| 6510 | + } catch (Exception $e) {
|
|
| 6511 | + $gd_ga_errors[] = $e->getMessage(); |
|
| 6512 | + return false; |
|
| 6513 | + } |
|
| 6514 | 6514 | |
| 6515 | 6515 | |
| 6516 | - natcasesort ($accounts); |
|
| 6516 | + natcasesort ($accounts); |
|
| 6517 | 6517 | |
| 6518 | - # Return the account array if there are accounts |
|
| 6519 | - if ( count($accounts) > 0 ){
|
|
| 6520 | - update_option('geodir_gd_uids',$accounts);
|
|
| 6521 | - return $accounts; |
|
| 6522 | - } |
|
| 6523 | - else |
|
| 6524 | - return false; |
|
| 6518 | + # Return the account array if there are accounts |
|
| 6519 | + if ( count($accounts) > 0 ){
|
|
| 6520 | + update_option('geodir_gd_uids',$accounts);
|
|
| 6521 | + return $accounts; |
|
| 6522 | + } |
|
| 6523 | + else |
|
| 6524 | + return false; |
|
| 6525 | 6525 | } |
| 6526 | 6526 | |
| 6527 | 6527 | add_action( 'wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize' ); |
| 6528 | 6528 | function geodir_ga_deauthorize(){
|
| 6529 | 6529 | |
| 6530 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
|
|
| 6530 | + if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) {
|
|
| 6531 | 6531 | |
| 6532 | - die( 'Security check' ); |
|
| 6532 | + die( 'Security check' ); |
|
| 6533 | 6533 | |
| 6534 | - } else {
|
|
| 6535 | - update_option('geodir_ga_auth_token','');
|
|
| 6536 | - update_option('geodir_ga_auth_code','');
|
|
| 6537 | - update_option('geodir_gd_uids','');
|
|
| 6534 | + } else {
|
|
| 6535 | + update_option('geodir_ga_auth_token','');
|
|
| 6536 | + update_option('geodir_ga_auth_code','');
|
|
| 6537 | + update_option('geodir_gd_uids','');
|
|
| 6538 | 6538 | |
| 6539 | 6539 | |
| 6540 | - echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
|
|
| 6541 | - } |
|
| 6540 | + echo admin_url('?page=geodirectory&active_tab=google_analytic_settings');
|
|
| 6541 | + } |
|
| 6542 | 6542 | |
| 6543 | - die(); |
|
| 6543 | + die(); |
|
| 6544 | 6544 | } |
| 6545 | 6545 | \ No newline at end of file |
@@ -10,33 +10,33 @@ discard block |
||
| 10 | 10 | |
| 11 | 11 | add_action('admin_init', 'geodir_admin_init');
|
| 12 | 12 | if (!function_exists('geodir_admin_init')) {
|
| 13 | - /** |
|
| 14 | - * Adds GD setting pages in admin. |
|
| 15 | - * |
|
| 16 | - * @since 1.0.0 |
|
| 17 | - * @package GeoDirectory |
|
| 18 | - * @global string $current_tab The current settings tab name. |
|
| 19 | - */ |
|
| 20 | - function geodir_admin_init() |
|
| 21 | - {
|
|
| 22 | - |
|
| 23 | - if (is_admin()): |
|
| 24 | - global $current_tab; |
|
| 25 | - geodir_redirect_to_admin_panel_on_installed(); |
|
| 26 | - $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; |
|
| 27 | - if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests |
|
| 28 | - geodir_handle_option_form_submit($current_tab); // located in admin function.php |
|
| 29 | - /** |
|
| 30 | - * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. |
|
| 31 | - * |
|
| 32 | - * @since 1.0.0 |
|
| 33 | - */ |
|
| 34 | - do_action('admin_panel_init');
|
|
| 35 | - add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
|
|
| 36 | - |
|
| 37 | - |
|
| 38 | - endif; |
|
| 39 | - } |
|
| 13 | + /** |
|
| 14 | + * Adds GD setting pages in admin. |
|
| 15 | + * |
|
| 16 | + * @since 1.0.0 |
|
| 17 | + * @package GeoDirectory |
|
| 18 | + * @global string $current_tab The current settings tab name. |
|
| 19 | + */ |
|
| 20 | + function geodir_admin_init() |
|
| 21 | + {
|
|
| 22 | + |
|
| 23 | + if (is_admin()): |
|
| 24 | + global $current_tab; |
|
| 25 | + geodir_redirect_to_admin_panel_on_installed(); |
|
| 26 | + $current_tab = (isset($_GET['tab']) && $_GET['tab'] != '') ? $_GET['tab'] : 'general_settings'; |
|
| 27 | + if (!(isset($_REQUEST['action']))) // this will avoid Ajax requests |
|
| 28 | + geodir_handle_option_form_submit($current_tab); // located in admin function.php |
|
| 29 | + /** |
|
| 30 | + * Called on the WordPress 'admin_init' hook this hookis used to call everything for the GD settings pages in the admin area. |
|
| 31 | + * |
|
| 32 | + * @since 1.0.0 |
|
| 33 | + */ |
|
| 34 | + do_action('admin_panel_init');
|
|
| 35 | + add_action('geodir_admin_option_form', 'geodir_get_admin_option_form', 1);
|
|
| 36 | + |
|
| 37 | + |
|
| 38 | + endif; |
|
| 39 | + } |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
@@ -47,10 +47,10 @@ discard block |
||
| 47 | 47 | */ |
| 48 | 48 | function geodir_redirect_to_admin_panel_on_installed() |
| 49 | 49 | {
|
| 50 | - if (get_option('geodir_installation_redirect', false)) {
|
|
| 51 | - delete_option('geodir_installation_redirect');
|
|
| 52 | - wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
|
|
| 53 | - } |
|
| 50 | + if (get_option('geodir_installation_redirect', false)) {
|
|
| 51 | + delete_option('geodir_installation_redirect');
|
|
| 52 | + wp_redirect(admin_url('admin.php?page=geodirectory&installed=yes'));
|
|
| 53 | + } |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | function geodir_get_admin_option_form($current_tab) |
| 64 | 64 | {
|
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php |
|
| 65 | + geodir_admin_option_form($current_tab);// defined in admin template tags.php |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -86,24 +86,24 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | function geodir_conditional_admin_script_load() |
| 88 | 88 | {
|
| 89 | - global $pagenow; |
|
| 89 | + global $pagenow; |
|
| 90 | 90 | |
| 91 | 91 | // Get the current post type |
| 92 | 92 | $post_type = geodir_admin_current_post_type(); |
| 93 | 93 | $geodir_post_types = geodir_get_posttypes(); |
| 94 | 94 | |
| 95 | 95 | if ((isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') || (($pagenow == 'post.php' || $pagenow == 'post-new.php' || $pagenow == 'edit.php') && $post_type && in_array($post_type, $geodir_post_types)) || ($pagenow == 'edit-tags.php' || $pagenow == 'term.php' || $pagenow == 'edit-comments.php' || $pagenow == 'comment.php')) {
|
| 96 | - add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
|
|
| 97 | - add_action('admin_enqueue_scripts', 'geodir_admin_styles');
|
|
| 98 | - add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
|
|
| 96 | + add_action('admin_enqueue_scripts', 'geodir_admin_scripts');
|
|
| 97 | + add_action('admin_enqueue_scripts', 'geodir_admin_styles');
|
|
| 98 | + add_action('admin_enqueue_scripts', 'geodir_admin_dequeue_scripts', 100);
|
|
| 99 | 99 | |
| 100 | - // Disable VC editor for GD post types. |
|
| 101 | - if (class_exists('Vc_Role_Access_Controller')) {
|
|
| 102 | - add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 ); |
|
| 103 | - } |
|
| 104 | - } |
|
| 100 | + // Disable VC editor for GD post types. |
|
| 101 | + if (class_exists('Vc_Role_Access_Controller')) {
|
|
| 102 | + add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 ); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | 105 | |
| 106 | - add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
|
|
| 106 | + add_action('admin_enqueue_scripts', 'geodir_admin_styles_req');
|
|
| 107 | 107 | |
| 108 | 108 | } |
| 109 | 109 | |
@@ -138,12 +138,12 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | function create_default_admin_main_nav() |
| 140 | 140 | {
|
| 141 | - add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
|
|
| 142 | - add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
|
|
| 143 | - add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
|
|
| 144 | - add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
|
|
| 145 | - add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
|
|
| 146 | - //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
|
|
| 141 | + add_filter('geodir_settings_tabs_array', 'geodir_default_admin_main_tabs', 1);
|
|
| 142 | + add_filter('geodir_settings_tabs_array', 'places_custom_fields_tab', 2);
|
|
| 143 | + add_filter('geodir_settings_tabs_array', 'geodir_compatibility_setting_tab', 90);
|
|
| 144 | + add_filter('geodir_settings_tabs_array', 'geodir_tools_setting_tab', 95);
|
|
| 145 | + add_filter('geodir_settings_tabs_array', 'geodir_extend_geodirectory_setting_tab', 100);
|
|
| 146 | + //add_filter('geodir_settings_tabs_array', 'geodir_hide_set_location_default',3);
|
|
| 147 | 147 | |
| 148 | 148 | } |
| 149 | 149 | |
@@ -156,16 +156,16 @@ discard block |
||
| 156 | 156 | */ |
| 157 | 157 | function geodir_admin_list_columns() |
| 158 | 158 | {
|
| 159 | - if ($post_types = geodir_get_posttypes()) {
|
|
| 159 | + if ($post_types = geodir_get_posttypes()) {
|
|
| 160 | 160 | |
| 161 | - foreach ($post_types as $post_type): |
|
| 162 | - add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
|
|
| 163 | - //Filter-Payment-Manager to show Package |
|
| 164 | - add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
|
|
| 161 | + foreach ($post_types as $post_type): |
|
| 162 | + add_filter("manage_edit-{$post_type}_columns", 'geodir_edit_post_columns', 100);
|
|
| 163 | + //Filter-Payment-Manager to show Package |
|
| 164 | + add_action("manage_{$post_type}_posts_custom_column", 'geodir_manage_post_columns', 10, 2);
|
|
| 165 | 165 | |
| 166 | - add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
|
|
| 167 | - endforeach; |
|
| 168 | - } |
|
| 166 | + add_filter("manage_edit-{$post_type}_sortable_columns", 'geodir_post_sortable_columns');
|
|
| 167 | + endforeach; |
|
| 168 | + } |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -178,15 +178,15 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | function geodir_default_admin_main_tabs($tabs) |
| 180 | 180 | {
|
| 181 | - return $tabs = array( |
|
| 182 | - 'general_settings' => array('label' => __('General', 'geodirectory')),
|
|
| 183 | - 'design_settings' => array('label' => __('Design', 'geodirectory')),
|
|
| 184 | - 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
|
|
| 185 | - 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
|
|
| 186 | - 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
|
|
| 187 | - 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
|
|
| 188 | - |
|
| 189 | - ); |
|
| 181 | + return $tabs = array( |
|
| 182 | + 'general_settings' => array('label' => __('General', 'geodirectory')),
|
|
| 183 | + 'design_settings' => array('label' => __('Design', 'geodirectory')),
|
|
| 184 | + 'permalink_settings' => array('label' => __('Permalinks', 'geodirectory')),
|
|
| 185 | + 'title_meta_settings' => array('label' => __('Titles & Metas', 'geodirectory')),
|
|
| 186 | + 'notifications_settings' => array('label' => __('Notifications', 'geodirectory')),
|
|
| 187 | + 'default_location_settings' => array('label' => __('Set Default Location', 'geodirectory')),
|
|
| 188 | + |
|
| 189 | + ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | add_action('do_meta_boxes', 'geodir_remove_image_box');
|
@@ -199,16 +199,16 @@ discard block |
||
| 199 | 199 | */ |
| 200 | 200 | function geodir_remove_image_box() |
| 201 | 201 | {
|
| 202 | - global $post; |
|
| 202 | + global $post; |
|
| 203 | 203 | |
| 204 | - $geodir_posttypes = geodir_get_posttypes(); |
|
| 204 | + $geodir_posttypes = geodir_get_posttypes(); |
|
| 205 | 205 | |
| 206 | - if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
| 206 | + if (isset($post) && in_array($post->post_type, $geodir_posttypes)): |
|
| 207 | 207 | |
| 208 | - remove_meta_box('postimagediv', $post->post_type, 'side');
|
|
| 209 | - remove_meta_box('revisionsdiv', $post->post_type, 'normal');
|
|
| 208 | + remove_meta_box('postimagediv', $post->post_type, 'side');
|
|
| 209 | + remove_meta_box('revisionsdiv', $post->post_type, 'normal');
|
|
| 210 | 210 | |
| 211 | - endif; |
|
| 211 | + endif; |
|
| 212 | 212 | |
| 213 | 213 | } |
| 214 | 214 | |
@@ -223,27 +223,27 @@ discard block |
||
| 223 | 223 | */ |
| 224 | 224 | function geodir_meta_box_add() |
| 225 | 225 | {
|
| 226 | - global $post; |
|
| 226 | + global $post; |
|
| 227 | 227 | |
| 228 | - $geodir_post_types = geodir_get_posttypes('array');
|
|
| 229 | - $geodir_posttypes = array_keys($geodir_post_types); |
|
| 228 | + $geodir_post_types = geodir_get_posttypes('array');
|
|
| 229 | + $geodir_posttypes = array_keys($geodir_post_types); |
|
| 230 | 230 | |
| 231 | - if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
| 231 | + if (isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)): |
|
| 232 | 232 | |
| 233 | - $geodir_posttype = $post->post_type; |
|
| 234 | - $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory'); |
|
| 235 | - $post_typename = geodir_ucwords($post_typename); |
|
| 233 | + $geodir_posttype = $post->post_type; |
|
| 234 | + $post_typename = __($geodir_post_types[$geodir_posttype]['labels']['singular_name'], 'geodirectory'); |
|
| 235 | + $post_typename = geodir_ucwords($post_typename); |
|
| 236 | 236 | |
| 237 | - // Filter-Payment-Manager |
|
| 237 | + // Filter-Payment-Manager |
|
| 238 | 238 | |
| 239 | - add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
|
|
| 239 | + add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
|
|
| 240 | 240 | |
| 241 | - add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
|
|
| 241 | + add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
|
|
| 242 | 242 | |
| 243 | - // no need of this box as all fields moved to main information box |
|
| 244 | - //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
|
|
| 243 | + // no need of this box as all fields moved to main information box |
|
| 244 | + //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
|
|
| 245 | 245 | |
| 246 | - endif; |
|
| 246 | + endif; |
|
| 247 | 247 | |
| 248 | 248 | } |
| 249 | 249 | |
@@ -267,23 +267,23 @@ discard block |
||
| 267 | 267 | function geodir_hide_post_taxonomy_meta_boxes() |
| 268 | 268 | {
|
| 269 | 269 | |
| 270 | - $geodir_post_types = get_option('geodir_post_types');
|
|
| 270 | + $geodir_post_types = get_option('geodir_post_types');
|
|
| 271 | 271 | |
| 272 | - if (!empty($geodir_post_types)) {
|
|
| 273 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
|
|
| 272 | + if (!empty($geodir_post_types)) {
|
|
| 273 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info) {
|
|
| 274 | 274 | |
| 275 | - $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 275 | + $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
|
| 276 | 276 | |
| 277 | - if(!empty($gd_taxonomy)) {
|
|
| 278 | - foreach ($gd_taxonomy as $tax) {
|
|
| 277 | + if(!empty($gd_taxonomy)) {
|
|
| 278 | + foreach ($gd_taxonomy as $tax) {
|
|
| 279 | 279 | |
| 280 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
| 280 | + remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
| 281 | 281 | |
| 282 | - } |
|
| 283 | - } |
|
| 282 | + } |
|
| 283 | + } |
|
| 284 | 284 | |
| 285 | - } |
|
| 286 | - } |
|
| 285 | + } |
|
| 286 | + } |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | add_filter('geodir_add_listing_map_restrict', 'geodir_add_listing_map_restrict');
|
@@ -297,12 +297,12 @@ discard block |
||
| 297 | 297 | */ |
| 298 | 298 | function geodir_add_listing_map_restrict($map_restirct) |
| 299 | 299 | {
|
| 300 | - if (is_admin()) {
|
|
| 301 | - if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
|
|
| 302 | - $map_restirct = false; |
|
| 303 | - } |
|
| 304 | - } |
|
| 305 | - return $map_restirct; |
|
| 300 | + if (is_admin()) {
|
|
| 301 | + if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'default_location_settings') {
|
|
| 302 | + $map_restirct = false; |
|
| 303 | + } |
|
| 304 | + } |
|
| 305 | + return $map_restirct; |
|
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | |
@@ -321,16 +321,16 @@ discard block |
||
| 321 | 321 | function geodir_enable_editor_on_notifications($notification) |
| 322 | 322 | {
|
| 323 | 323 | |
| 324 | - if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
|
|
| 324 | + if (!empty($notification) && get_option('geodir_tiny_editor') == '1') {
|
|
| 325 | 325 | |
| 326 | - foreach ($notification as $key => $value) {
|
|
| 327 | - if ($value['type'] == 'textarea') |
|
| 328 | - $notification[$key]['type'] = 'editor'; |
|
| 329 | - } |
|
| 326 | + foreach ($notification as $key => $value) {
|
|
| 327 | + if ($value['type'] == 'textarea') |
|
| 328 | + $notification[$key]['type'] = 'editor'; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | - } |
|
| 331 | + } |
|
| 332 | 332 | |
| 333 | - return $notification; |
|
| 333 | + return $notification; |
|
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | |
@@ -347,16 +347,16 @@ discard block |
||
| 347 | 347 | function geodir_enable_editor_on_design_settings($design_setting) |
| 348 | 348 | {
|
| 349 | 349 | |
| 350 | - if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
|
|
| 350 | + if (!empty($design_setting) && get_option('geodir_tiny_editor') == '1') {
|
|
| 351 | 351 | |
| 352 | - foreach ($design_setting as $key => $value) {
|
|
| 353 | - if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
| 354 | - $design_setting[$key]['type'] = 'editor'; |
|
| 355 | - } |
|
| 352 | + foreach ($design_setting as $key => $value) {
|
|
| 353 | + if ($value['type'] == 'textarea' && $value['id'] == 'geodir_term_condition_content') |
|
| 354 | + $design_setting[$key]['type'] = 'editor'; |
|
| 355 | + } |
|
| 356 | 356 | |
| 357 | - } |
|
| 357 | + } |
|
| 358 | 358 | |
| 359 | - return $design_setting; |
|
| 359 | + return $design_setting; |
|
| 360 | 360 | } |
| 361 | 361 | |
| 362 | 362 | /* ----------- START MANAGE CUSTOM FIELDS ---------------- */ |
@@ -364,15 +364,15 @@ discard block |
||
| 364 | 364 | add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
|
| 365 | 365 | |
| 366 | 366 | function geodir_manage_available_fields_predefined($sub_tab){
|
| 367 | - if($sub_tab=='custom_fields'){
|
|
| 368 | - geodir_custom_available_fields('predefined');
|
|
| 369 | - } |
|
| 367 | + if($sub_tab=='custom_fields'){
|
|
| 368 | + geodir_custom_available_fields('predefined');
|
|
| 369 | + } |
|
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | function geodir_manage_available_fields_custom($sub_tab){
|
| 373 | - if($sub_tab=='custom_fields'){
|
|
| 374 | - geodir_custom_available_fields('custom');
|
|
| 375 | - } |
|
| 373 | + if($sub_tab=='custom_fields'){
|
|
| 374 | + geodir_custom_available_fields('custom');
|
|
| 375 | + } |
|
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
@@ -391,16 +391,16 @@ discard block |
||
| 391 | 391 | function geodir_manage_available_fields($sub_tab) |
| 392 | 392 | {
|
| 393 | 393 | |
| 394 | - switch ($sub_tab) {
|
|
| 395 | - case 'custom_fields': |
|
| 396 | - geodir_custom_available_fields(); |
|
| 397 | - break; |
|
| 394 | + switch ($sub_tab) {
|
|
| 395 | + case 'custom_fields': |
|
| 396 | + geodir_custom_available_fields(); |
|
| 397 | + break; |
|
| 398 | 398 | |
| 399 | - case 'sorting_options': |
|
| 400 | - geodir_sorting_options_available_fields(); |
|
| 401 | - break; |
|
| 399 | + case 'sorting_options': |
|
| 400 | + geodir_sorting_options_available_fields(); |
|
| 401 | + break; |
|
| 402 | 402 | |
| 403 | - } |
|
| 403 | + } |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | |
@@ -416,16 +416,16 @@ discard block |
||
| 416 | 416 | function geodir_manage_selected_fields($sub_tab) |
| 417 | 417 | {
|
| 418 | 418 | |
| 419 | - switch ($sub_tab) {
|
|
| 420 | - case 'custom_fields': |
|
| 421 | - geodir_custom_selected_fields(); |
|
| 422 | - break; |
|
| 419 | + switch ($sub_tab) {
|
|
| 420 | + case 'custom_fields': |
|
| 421 | + geodir_custom_selected_fields(); |
|
| 422 | + break; |
|
| 423 | 423 | |
| 424 | - case 'sorting_options': |
|
| 425 | - geodir_sorting_options_selected_fields(); |
|
| 426 | - break; |
|
| 424 | + case 'sorting_options': |
|
| 425 | + geodir_sorting_options_selected_fields(); |
|
| 426 | + break; |
|
| 427 | 427 | |
| 428 | - } |
|
| 428 | + } |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -437,52 +437,52 @@ discard block |
||
| 437 | 437 | */ |
| 438 | 438 | function geodir_sorting_options_available_fields() |
| 439 | 439 | {
|
| 440 | - global $wpdb; |
|
| 441 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 442 | - ?> |
|
| 440 | + global $wpdb; |
|
| 441 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 442 | + ?> |
|
| 443 | 443 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
| 444 | 444 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 445 | 445 | <ul> |
| 446 | 446 | <?php |
| 447 | - $sort_options = geodir_get_custom_sort_options($listing_type); |
|
| 447 | + $sort_options = geodir_get_custom_sort_options($listing_type); |
|
| 448 | 448 | |
| 449 | - foreach ($sort_options as $key => $val) {
|
|
| 450 | - $val = stripslashes_deep($val); // strip slashes |
|
| 451 | - |
|
| 452 | - $check_html_variable = $wpdb->get_var( |
|
| 453 | - $wpdb->prepare( |
|
| 454 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
| 455 | - array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
| 456 | - ) |
|
| 457 | - ); |
|
| 449 | + foreach ($sort_options as $key => $val) {
|
|
| 450 | + $val = stripslashes_deep($val); // strip slashes |
|
| 451 | + |
|
| 452 | + $check_html_variable = $wpdb->get_var( |
|
| 453 | + $wpdb->prepare( |
|
| 454 | + "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
| 455 | + array($val['htmlvar_name'], $listing_type, $val['field_type']) |
|
| 456 | + ) |
|
| 457 | + ); |
|
| 458 | 458 | |
| 459 | - $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
| 460 | - ?> |
|
| 459 | + $display = $check_html_variable ? ' style="display:none;"' : ''; |
|
| 460 | + ?> |
|
| 461 | 461 | |
| 462 | 462 | <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> |
| 463 | 463 | <?php |
| 464 | - if(isset($val['description']) && $val['description']){
|
|
| 465 | - echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
|
| 466 | - }?> |
|
| 464 | + if(isset($val['description']) && $val['description']){
|
|
| 465 | + echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
|
| 466 | + }?> |
|
| 467 | 467 | |
| 468 | 468 | <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>" data-field-type="<?php echo $val['field_type'];?>" |
| 469 | 469 | title="<?php echo $val['site_title'];?>" |
| 470 | 470 | class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> |
| 471 | 471 | <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
|
| 472 | - echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
|
| 473 | - }elseif(isset($val['field_icon']) && $val['field_icon'] ){
|
|
| 474 | - echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
|
|
| 475 | - }else{
|
|
| 476 | - echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
| 477 | - }?> |
|
| 472 | + echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
|
| 473 | + }elseif(isset($val['field_icon']) && $val['field_icon'] ){
|
|
| 474 | + echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
|
|
| 475 | + }else{
|
|
| 476 | + echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
| 477 | + }?> |
|
| 478 | 478 | <?php echo $val['site_title'];?> |
| 479 | 479 | </a> |
| 480 | 480 | </li> |
| 481 | 481 | |
| 482 | 482 | |
| 483 | 483 | <?php |
| 484 | - } |
|
| 485 | - ?> |
|
| 484 | + } |
|
| 485 | + ?> |
|
| 486 | 486 | </ul> |
| 487 | 487 | <?php |
| 488 | 488 | } |
@@ -496,28 +496,28 @@ discard block |
||
| 496 | 496 | */ |
| 497 | 497 | function geodir_sorting_options_selected_fields() |
| 498 | 498 | {
|
| 499 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 500 | - ?> |
|
| 499 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 500 | + ?> |
|
| 501 | 501 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 502 | 502 | <ul class="core"> |
| 503 | 503 | <?php |
| 504 | - global $wpdb; |
|
| 504 | + global $wpdb; |
|
| 505 | 505 | |
| 506 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
|
|
| 506 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
|
|
| 507 | 507 | |
| 508 | - if (!empty($fields)) {
|
|
| 509 | - foreach ($fields as $field) {
|
|
| 510 | - //$result_str = $field->id; |
|
| 511 | - $result_str = $field; |
|
| 512 | - $field_type = $field->field_type; |
|
| 513 | - $field_ins_upd = 'display'; |
|
| 508 | + if (!empty($fields)) {
|
|
| 509 | + foreach ($fields as $field) {
|
|
| 510 | + //$result_str = $field->id; |
|
| 511 | + $result_str = $field; |
|
| 512 | + $field_type = $field->field_type; |
|
| 513 | + $field_ins_upd = 'display'; |
|
| 514 | 514 | |
| 515 | - $default = false; |
|
| 515 | + $default = false; |
|
| 516 | 516 | |
| 517 | - geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
| 518 | - } |
|
| 519 | - } |
|
| 520 | - ?> |
|
| 517 | + geodir_custom_sort_field_adminhtml($field_type, $result_str, $field_ins_upd, $default); |
|
| 518 | + } |
|
| 519 | + } |
|
| 520 | + ?> |
|
| 521 | 521 | </ul> |
| 522 | 522 | <?php |
| 523 | 523 | } |
@@ -530,12 +530,12 @@ discard block |
||
| 530 | 530 | */ |
| 531 | 531 | function geodir_custom_fields_custom($post_type=''){
|
| 532 | 532 | |
| 533 | - $custom_fields = array(); |
|
| 533 | + $custom_fields = array(); |
|
| 534 | 534 | |
| 535 | - /** |
|
| 536 | - * @see `geodir_custom_fields` |
|
| 537 | - */ |
|
| 538 | - return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
|
|
| 535 | + /** |
|
| 536 | + * @see `geodir_custom_fields` |
|
| 537 | + */ |
|
| 538 | + return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
|
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | |
@@ -548,140 +548,140 @@ discard block |
||
| 548 | 548 | */ |
| 549 | 549 | function geodir_custom_fields($post_type=''){
|
| 550 | 550 | |
| 551 | - $custom_fields = array( |
|
| 552 | - 'text' => array( |
|
| 553 | - 'field_type' => 'text', |
|
| 554 | - 'class' => 'gd-text', |
|
| 555 | - 'icon' => 'fa fa-minus', |
|
| 556 | - 'name' => __('Text', 'geodirectory'),
|
|
| 557 | - 'description' => __('Add any sort of text field, text or numbers', 'geodirectory')
|
|
| 558 | - ), |
|
| 559 | - 'datepicker' => array( |
|
| 560 | - 'field_type' => 'datepicker', |
|
| 561 | - 'class' => 'gd-datepicker', |
|
| 562 | - 'icon' => 'fa fa-calendar', |
|
| 563 | - 'name' => __('Date', 'geodirectory'),
|
|
| 564 | - 'description' => __('Adds a date picker.', 'geodirectory')
|
|
| 565 | - ), |
|
| 566 | - 'textarea' => array( |
|
| 567 | - 'field_type' => 'textarea', |
|
| 568 | - 'class' => 'gd-textarea', |
|
| 569 | - 'icon' => 'fa fa-bars', |
|
| 570 | - 'name' => __('Textarea', 'geodirectory'),
|
|
| 571 | - 'description' => __('Adds a textarea', 'geodirectory')
|
|
| 572 | - ), |
|
| 573 | - 'time' => array( |
|
| 574 | - 'field_type' => 'time', |
|
| 575 | - 'class' => 'gd-time', |
|
| 576 | - 'icon' => 'fa fa-clock-o', |
|
| 577 | - 'name' => __('Time', 'geodirectory'),
|
|
| 578 | - 'description' => __('Adds a time picker', 'geodirectory')
|
|
| 579 | - ), |
|
| 580 | - 'checkbox' => array( |
|
| 581 | - 'field_type' => 'checkbox', |
|
| 582 | - 'class' => 'gd-checkbox', |
|
| 583 | - 'icon' => 'fa fa-check-square-o', |
|
| 584 | - 'name' => __('Checkbox', 'geodirectory'),
|
|
| 585 | - 'description' => __('Adds a checkbox', 'geodirectory')
|
|
| 586 | - ), |
|
| 587 | - 'phone' => array( |
|
| 588 | - 'field_type' => 'phone', |
|
| 589 | - 'class' => 'gd-phone', |
|
| 590 | - 'icon' => 'fa fa-phone', |
|
| 591 | - 'name' => __('Phone', 'geodirectory'),
|
|
| 592 | - 'description' => __('Adds a phone input', 'geodirectory')
|
|
| 593 | - ), |
|
| 594 | - 'radio' => array( |
|
| 595 | - 'field_type' => 'radio', |
|
| 596 | - 'class' => 'gd-radio', |
|
| 597 | - 'icon' => 'fa fa-dot-circle-o', |
|
| 598 | - 'name' => __('Radio', 'geodirectory'),
|
|
| 599 | - 'description' => __('Adds a radio input', 'geodirectory')
|
|
| 600 | - ), |
|
| 601 | - 'email' => array( |
|
| 602 | - 'field_type' => 'email', |
|
| 603 | - 'class' => 'gd-email', |
|
| 604 | - 'icon' => 'fa fa-envelope-o', |
|
| 605 | - 'name' => __('Email', 'geodirectory'),
|
|
| 606 | - 'description' => __('Adds a email input', 'geodirectory')
|
|
| 607 | - ), |
|
| 608 | - 'select' => array( |
|
| 609 | - 'field_type' => 'select', |
|
| 610 | - 'class' => 'gd-select', |
|
| 611 | - 'icon' => 'fa fa-caret-square-o-down', |
|
| 612 | - 'name' => __('Select', 'geodirectory'),
|
|
| 613 | - 'description' => __('Adds a select input', 'geodirectory')
|
|
| 614 | - ), |
|
| 615 | - 'multiselect' => array( |
|
| 616 | - 'field_type' => 'multiselect', |
|
| 617 | - 'class' => 'gd-multiselect', |
|
| 618 | - 'icon' => 'fa fa-caret-square-o-down', |
|
| 619 | - 'name' => __('Multi Select', 'geodirectory'),
|
|
| 620 | - 'description' => __('Adds a multiselect input', 'geodirectory')
|
|
| 621 | - ), |
|
| 622 | - 'url' => array( |
|
| 623 | - 'field_type' => 'url', |
|
| 624 | - 'class' => 'gd-url', |
|
| 625 | - 'icon' => 'fa fa-link', |
|
| 626 | - 'name' => __('URL', 'geodirectory'),
|
|
| 627 | - 'description' => __('Adds a url input', 'geodirectory')
|
|
| 628 | - ), |
|
| 629 | - 'html' => array( |
|
| 630 | - 'field_type' => 'html', |
|
| 631 | - 'class' => 'gd-html', |
|
| 632 | - 'icon' => 'fa fa-code', |
|
| 633 | - 'name' => __('HTML', 'geodirectory'),
|
|
| 634 | - 'description' => __('Adds a html input textarea', 'geodirectory')
|
|
| 635 | - ), |
|
| 636 | - 'file' => array( |
|
| 637 | - 'field_type' => 'file', |
|
| 638 | - 'class' => 'gd-file', |
|
| 639 | - 'icon' => 'fa fa-file', |
|
| 640 | - 'name' => __('File Upload', 'geodirectory'),
|
|
| 641 | - 'description' => __('Adds a file input', 'geodirectory')
|
|
| 642 | - ) |
|
| 643 | - ); |
|
| 644 | - |
|
| 645 | - /** |
|
| 646 | - * Filter the custom fields array to be able to add or remove items. |
|
| 647 | - * |
|
| 648 | - * @since 1.6.6 |
|
| 649 | - * |
|
| 650 | - * @param array $custom_fields {
|
|
| 651 | - * The custom fields array to be filtered. |
|
| 652 | - * |
|
| 653 | - * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. |
|
| 654 | - * @type string $class The class for the field in backend. |
|
| 655 | - * @type string $icon Can be font-awesome class name or icon image url. |
|
| 656 | - * @type string $name The name of the field. |
|
| 657 | - * @type string $description A short description about the field. |
|
| 658 | - * @type array $defaults {
|
|
| 659 | - * Optional. Used to set the default value of the field. |
|
| 660 | - * |
|
| 661 | - * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE |
|
| 662 | - * @type int decimal_point limit if using FLOAT data_type |
|
| 663 | - * @type string admin_title The admin title for the field. |
|
| 664 | - * @type string site_title This will be the title for the field on the frontend. |
|
| 665 | - * @type string admin_desc This will be shown below the field on the add listing form. |
|
| 666 | - * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. |
|
| 667 | - * @type bool is_active If false the field will not be displayed anywhere. |
|
| 668 | - * @type bool for_admin_use If true then only site admin can see and edit this field. |
|
| 669 | - * @type string default_value The default value for the input on the add listing page. |
|
| 670 | - * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] |
|
| 671 | - * @type bool is_required If true the field will be required on the add listing page. |
|
| 672 | - * @type string option_values The option values for select and multiselect only |
|
| 673 | - * @type string validation_pattern HTML5 validation pattern (text input only by default). |
|
| 674 | - * @type string validation_msg HTML5 validation message (text input only by default). |
|
| 675 | - * @type string required_msg Required warning message. |
|
| 676 | - * @type string field_icon Icon url or font awesome class. |
|
| 677 | - * @type string css_class Field custom css class for field custom style. |
|
| 678 | - * @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option. |
|
| 679 | - * @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required) |
|
| 680 | - * } |
|
| 681 | - * } |
|
| 682 | - * @param string $post_type The post type requested. |
|
| 683 | - */ |
|
| 684 | - return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
|
|
| 551 | + $custom_fields = array( |
|
| 552 | + 'text' => array( |
|
| 553 | + 'field_type' => 'text', |
|
| 554 | + 'class' => 'gd-text', |
|
| 555 | + 'icon' => 'fa fa-minus', |
|
| 556 | + 'name' => __('Text', 'geodirectory'),
|
|
| 557 | + 'description' => __('Add any sort of text field, text or numbers', 'geodirectory')
|
|
| 558 | + ), |
|
| 559 | + 'datepicker' => array( |
|
| 560 | + 'field_type' => 'datepicker', |
|
| 561 | + 'class' => 'gd-datepicker', |
|
| 562 | + 'icon' => 'fa fa-calendar', |
|
| 563 | + 'name' => __('Date', 'geodirectory'),
|
|
| 564 | + 'description' => __('Adds a date picker.', 'geodirectory')
|
|
| 565 | + ), |
|
| 566 | + 'textarea' => array( |
|
| 567 | + 'field_type' => 'textarea', |
|
| 568 | + 'class' => 'gd-textarea', |
|
| 569 | + 'icon' => 'fa fa-bars', |
|
| 570 | + 'name' => __('Textarea', 'geodirectory'),
|
|
| 571 | + 'description' => __('Adds a textarea', 'geodirectory')
|
|
| 572 | + ), |
|
| 573 | + 'time' => array( |
|
| 574 | + 'field_type' => 'time', |
|
| 575 | + 'class' => 'gd-time', |
|
| 576 | + 'icon' => 'fa fa-clock-o', |
|
| 577 | + 'name' => __('Time', 'geodirectory'),
|
|
| 578 | + 'description' => __('Adds a time picker', 'geodirectory')
|
|
| 579 | + ), |
|
| 580 | + 'checkbox' => array( |
|
| 581 | + 'field_type' => 'checkbox', |
|
| 582 | + 'class' => 'gd-checkbox', |
|
| 583 | + 'icon' => 'fa fa-check-square-o', |
|
| 584 | + 'name' => __('Checkbox', 'geodirectory'),
|
|
| 585 | + 'description' => __('Adds a checkbox', 'geodirectory')
|
|
| 586 | + ), |
|
| 587 | + 'phone' => array( |
|
| 588 | + 'field_type' => 'phone', |
|
| 589 | + 'class' => 'gd-phone', |
|
| 590 | + 'icon' => 'fa fa-phone', |
|
| 591 | + 'name' => __('Phone', 'geodirectory'),
|
|
| 592 | + 'description' => __('Adds a phone input', 'geodirectory')
|
|
| 593 | + ), |
|
| 594 | + 'radio' => array( |
|
| 595 | + 'field_type' => 'radio', |
|
| 596 | + 'class' => 'gd-radio', |
|
| 597 | + 'icon' => 'fa fa-dot-circle-o', |
|
| 598 | + 'name' => __('Radio', 'geodirectory'),
|
|
| 599 | + 'description' => __('Adds a radio input', 'geodirectory')
|
|
| 600 | + ), |
|
| 601 | + 'email' => array( |
|
| 602 | + 'field_type' => 'email', |
|
| 603 | + 'class' => 'gd-email', |
|
| 604 | + 'icon' => 'fa fa-envelope-o', |
|
| 605 | + 'name' => __('Email', 'geodirectory'),
|
|
| 606 | + 'description' => __('Adds a email input', 'geodirectory')
|
|
| 607 | + ), |
|
| 608 | + 'select' => array( |
|
| 609 | + 'field_type' => 'select', |
|
| 610 | + 'class' => 'gd-select', |
|
| 611 | + 'icon' => 'fa fa-caret-square-o-down', |
|
| 612 | + 'name' => __('Select', 'geodirectory'),
|
|
| 613 | + 'description' => __('Adds a select input', 'geodirectory')
|
|
| 614 | + ), |
|
| 615 | + 'multiselect' => array( |
|
| 616 | + 'field_type' => 'multiselect', |
|
| 617 | + 'class' => 'gd-multiselect', |
|
| 618 | + 'icon' => 'fa fa-caret-square-o-down', |
|
| 619 | + 'name' => __('Multi Select', 'geodirectory'),
|
|
| 620 | + 'description' => __('Adds a multiselect input', 'geodirectory')
|
|
| 621 | + ), |
|
| 622 | + 'url' => array( |
|
| 623 | + 'field_type' => 'url', |
|
| 624 | + 'class' => 'gd-url', |
|
| 625 | + 'icon' => 'fa fa-link', |
|
| 626 | + 'name' => __('URL', 'geodirectory'),
|
|
| 627 | + 'description' => __('Adds a url input', 'geodirectory')
|
|
| 628 | + ), |
|
| 629 | + 'html' => array( |
|
| 630 | + 'field_type' => 'html', |
|
| 631 | + 'class' => 'gd-html', |
|
| 632 | + 'icon' => 'fa fa-code', |
|
| 633 | + 'name' => __('HTML', 'geodirectory'),
|
|
| 634 | + 'description' => __('Adds a html input textarea', 'geodirectory')
|
|
| 635 | + ), |
|
| 636 | + 'file' => array( |
|
| 637 | + 'field_type' => 'file', |
|
| 638 | + 'class' => 'gd-file', |
|
| 639 | + 'icon' => 'fa fa-file', |
|
| 640 | + 'name' => __('File Upload', 'geodirectory'),
|
|
| 641 | + 'description' => __('Adds a file input', 'geodirectory')
|
|
| 642 | + ) |
|
| 643 | + ); |
|
| 644 | + |
|
| 645 | + /** |
|
| 646 | + * Filter the custom fields array to be able to add or remove items. |
|
| 647 | + * |
|
| 648 | + * @since 1.6.6 |
|
| 649 | + * |
|
| 650 | + * @param array $custom_fields {
|
|
| 651 | + * The custom fields array to be filtered. |
|
| 652 | + * |
|
| 653 | + * @type string $field_type The type of field, eg: text, datepicker, textarea, time, checkbox, phone, radio, email, select, multiselect, url, html, file. |
|
| 654 | + * @type string $class The class for the field in backend. |
|
| 655 | + * @type string $icon Can be font-awesome class name or icon image url. |
|
| 656 | + * @type string $name The name of the field. |
|
| 657 | + * @type string $description A short description about the field. |
|
| 658 | + * @type array $defaults {
|
|
| 659 | + * Optional. Used to set the default value of the field. |
|
| 660 | + * |
|
| 661 | + * @type string data_type The SQL data type for the field. VARCHAR, TEXT, TIME, TINYINT, INT, FLOAT, DATE |
|
| 662 | + * @type int decimal_point limit if using FLOAT data_type |
|
| 663 | + * @type string admin_title The admin title for the field. |
|
| 664 | + * @type string site_title This will be the title for the field on the frontend. |
|
| 665 | + * @type string admin_desc This will be shown below the field on the add listing form. |
|
| 666 | + * @type string htmlvar_name This is a unique identifier used in the HTML, it MUST NOT contain spaces or special characters. |
|
| 667 | + * @type bool is_active If false the field will not be displayed anywhere. |
|
| 668 | + * @type bool for_admin_use If true then only site admin can see and edit this field. |
|
| 669 | + * @type string default_value The default value for the input on the add listing page. |
|
| 670 | + * @type string show_in The locations to show in. [detail],[moreinfo],[listing],[owntab],[mapbubble] |
|
| 671 | + * @type bool is_required If true the field will be required on the add listing page. |
|
| 672 | + * @type string option_values The option values for select and multiselect only |
|
| 673 | + * @type string validation_pattern HTML5 validation pattern (text input only by default). |
|
| 674 | + * @type string validation_msg HTML5 validation message (text input only by default). |
|
| 675 | + * @type string required_msg Required warning message. |
|
| 676 | + * @type string field_icon Icon url or font awesome class. |
|
| 677 | + * @type string css_class Field custom css class for field custom style. |
|
| 678 | + * @type bool cat_sort If true the field will appear in the category sort options, if false the field will be hidden, leave blank to show option. |
|
| 679 | + * @type bool cat_sort If true the field will appear in the advanced search sort options, if false the field will be hidden, leave blank to show option. (advanced search addon required) |
|
| 680 | + * } |
|
| 681 | + * } |
|
| 682 | + * @param string $post_type The post type requested. |
|
| 683 | + */ |
|
| 684 | + return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
|
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -694,19 +694,19 @@ discard block |
||
| 694 | 694 | */ |
| 695 | 695 | function geodir_custom_available_fields($type='') |
| 696 | 696 | {
|
| 697 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 698 | - ?> |
|
| 697 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 698 | + ?> |
|
| 699 | 699 | <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
| 700 | 700 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> |
| 701 | 701 | |
| 702 | 702 | <?php |
| 703 | - if($type=='predefined'){
|
|
| 704 | - $cfs = geodir_custom_fields_predefined($listing_type); |
|
| 705 | - }elseif($type=='custom'){
|
|
| 706 | - $cfs = geodir_custom_fields_custom($listing_type); |
|
| 707 | - }else{
|
|
| 708 | - $cfs = geodir_custom_fields($listing_type); |
|
| 709 | - ?> |
|
| 703 | + if($type=='predefined'){
|
|
| 704 | + $cfs = geodir_custom_fields_predefined($listing_type); |
|
| 705 | + }elseif($type=='custom'){
|
|
| 706 | + $cfs = geodir_custom_fields_custom($listing_type); |
|
| 707 | + }else{
|
|
| 708 | + $cfs = geodir_custom_fields($listing_type); |
|
| 709 | + ?> |
|
| 710 | 710 | <ul class="full gd-cf-tooltip-wrap"> |
| 711 | 711 | <li> |
| 712 | 712 | <div class="gdcf-tooltip"> |
@@ -727,18 +727,18 @@ discard block |
||
| 727 | 727 | </ul> |
| 728 | 728 | |
| 729 | 729 | <?php |
| 730 | - } |
|
| 730 | + } |
|
| 731 | 731 | |
| 732 | - if(!empty($cfs)) {
|
|
| 733 | - echo '<ul>'; |
|
| 734 | - foreach ( $cfs as $id => $cf ) {
|
|
| 735 | - ?> |
|
| 732 | + if(!empty($cfs)) {
|
|
| 733 | + echo '<ul>'; |
|
| 734 | + foreach ( $cfs as $id => $cf ) {
|
|
| 735 | + ?> |
|
| 736 | 736 | |
| 737 | 737 | <li class="gd-cf-tooltip-wrap"> |
| 738 | 738 | <?php |
| 739 | - if ( isset( $cf['description'] ) && $cf['description'] ) {
|
|
| 740 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
| 741 | - } ?> |
|
| 739 | + if ( isset( $cf['description'] ) && $cf['description'] ) {
|
|
| 740 | + echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
| 741 | + } ?> |
|
| 742 | 742 | |
| 743 | 743 | <a id="gd-<?php echo $id; ?>" |
| 744 | 744 | data-field-custom-type="<?php echo $type; ?>" |
@@ -748,21 +748,21 @@ discard block |
||
| 748 | 748 | href="javascript:void(0);"> |
| 749 | 749 | |
| 750 | 750 | <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
|
| 751 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
| 752 | - } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
|
|
| 753 | - echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
|
|
| 754 | - } else {
|
|
| 755 | - echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
| 756 | - } ?> |
|
| 751 | + echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
| 752 | + } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
|
|
| 753 | + echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
|
|
| 754 | + } else {
|
|
| 755 | + echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
|
| 756 | + } ?> |
|
| 757 | 757 | <?php echo $cf['name']; ?> |
| 758 | 758 | </a> |
| 759 | 759 | </li> |
| 760 | 760 | <?php |
| 761 | - } |
|
| 762 | - }else{
|
|
| 763 | - _e('There are no custom fields here yet.', 'geodirectory');
|
|
| 764 | - } |
|
| 765 | - ?> |
|
| 761 | + } |
|
| 762 | + }else{
|
|
| 763 | + _e('There are no custom fields here yet.', 'geodirectory');
|
|
| 764 | + } |
|
| 765 | + ?> |
|
| 766 | 766 | |
| 767 | 767 | |
| 768 | 768 | </ul> |
@@ -781,26 +781,26 @@ discard block |
||
| 781 | 781 | */ |
| 782 | 782 | function geodir_custom_selected_fields() |
| 783 | 783 | {
|
| 784 | - $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 785 | - ?> |
|
| 784 | + $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
|
| 785 | + ?> |
|
| 786 | 786 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 787 | 787 | <ul class="core"> |
| 788 | 788 | <?php |
| 789 | - global $wpdb; |
|
| 790 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
|
|
| 791 | - |
|
| 792 | - if (!empty($fields)) {
|
|
| 793 | - foreach ($fields as $field) {
|
|
| 794 | - //$result_str = $field->id; |
|
| 795 | - $result_str = $field; |
|
| 796 | - $field_type = $field->field_type; |
|
| 797 | - $field_type_key = $field->field_type_key; |
|
| 798 | - $field_ins_upd = 'display'; |
|
| 799 | - |
|
| 800 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
| 801 | - } |
|
| 802 | - } |
|
| 803 | - ?></ul> |
|
| 789 | + global $wpdb; |
|
| 790 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
|
|
| 791 | + |
|
| 792 | + if (!empty($fields)) {
|
|
| 793 | + foreach ($fields as $field) {
|
|
| 794 | + //$result_str = $field->id; |
|
| 795 | + $result_str = $field; |
|
| 796 | + $field_type = $field->field_type; |
|
| 797 | + $field_type_key = $field->field_type_key; |
|
| 798 | + $field_ins_upd = 'display'; |
|
| 799 | + |
|
| 800 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
| 801 | + } |
|
| 802 | + } |
|
| 803 | + ?></ul> |
|
| 804 | 804 | <?php |
| 805 | 805 | |
| 806 | 806 | } |
@@ -819,16 +819,16 @@ discard block |
||
| 819 | 819 | function geodir_custom_fields_panel_head($heading, $sub_tab, $listing_type) |
| 820 | 820 | {
|
| 821 | 821 | |
| 822 | - switch ($sub_tab) {
|
|
| 823 | - case 'custom_fields': |
|
| 824 | - $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 825 | - break; |
|
| 822 | + switch ($sub_tab) {
|
|
| 823 | + case 'custom_fields': |
|
| 824 | + $heading = sprintf(__('Manage %s Custom Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 825 | + break; |
|
| 826 | 826 | |
| 827 | - case 'sorting_options': |
|
| 828 | - $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 829 | - break; |
|
| 830 | - } |
|
| 831 | - return $heading; |
|
| 827 | + case 'sorting_options': |
|
| 828 | + $heading = sprintf(__('Manage %s Listing Sorting Options Fields', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 829 | + break; |
|
| 830 | + } |
|
| 831 | + return $heading; |
|
| 832 | 832 | } |
| 833 | 833 | |
| 834 | 834 | |
@@ -846,16 +846,16 @@ discard block |
||
| 846 | 846 | function geodir_cf_panel_available_fields_head($heading, $sub_tab, $listing_type) |
| 847 | 847 | {
|
| 848 | 848 | |
| 849 | - switch ($sub_tab) {
|
|
| 850 | - case 'custom_fields': |
|
| 851 | - $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 852 | - break; |
|
| 849 | + switch ($sub_tab) {
|
|
| 850 | + case 'custom_fields': |
|
| 851 | + $heading = sprintf(__('Add new %s form field', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 852 | + break; |
|
| 853 | 853 | |
| 854 | - case 'sorting_options': |
|
| 855 | - $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 856 | - break; |
|
| 857 | - } |
|
| 858 | - return $heading; |
|
| 854 | + case 'sorting_options': |
|
| 855 | + $heading = sprintf(__('Available sorting options for %s listing and search results', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 856 | + break; |
|
| 857 | + } |
|
| 858 | + return $heading; |
|
| 859 | 859 | } |
| 860 | 860 | |
| 861 | 861 | |
@@ -873,16 +873,16 @@ discard block |
||
| 873 | 873 | function geodir_cf_panel_available_fields_note($note, $sub_tab, $listing_type) |
| 874 | 874 | {
|
| 875 | 875 | |
| 876 | - switch ($sub_tab) {
|
|
| 877 | - case 'custom_fields': |
|
| 878 | - $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 879 | - break; |
|
| 876 | + switch ($sub_tab) {
|
|
| 877 | + case 'custom_fields': |
|
| 878 | + $note = sprintf(__('Click on any box below to add a field of that type to the add %s listing form. You can use a fieldset to group your fields.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 879 | + break; |
|
| 880 | 880 | |
| 881 | - case 'sorting_options': |
|
| 882 | - $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 883 | - break; |
|
| 884 | - } |
|
| 885 | - return $note; |
|
| 881 | + case 'sorting_options': |
|
| 882 | + $note = sprintf(__('Click on any box below to make it appear in the sorting option dropdown on %s listing and search results.<br />To make a field available here, go to custom fields tab and expand any field from selected fields panel and tick the checkbox saying \'Include this field in sort option\'.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 883 | + break; |
|
| 884 | + } |
|
| 885 | + return $note; |
|
| 886 | 886 | } |
| 887 | 887 | |
| 888 | 888 | |
@@ -900,16 +900,16 @@ discard block |
||
| 900 | 900 | function geodir_cf_panel_selected_fields_head($heading, $sub_tab, $listing_type) |
| 901 | 901 | {
|
| 902 | 902 | |
| 903 | - switch ($sub_tab) {
|
|
| 904 | - case 'custom_fields': |
|
| 905 | - $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 906 | - break; |
|
| 903 | + switch ($sub_tab) {
|
|
| 904 | + case 'custom_fields': |
|
| 905 | + $heading = sprintf(__('List of fields that will appear on add new %s listing form', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 906 | + break; |
|
| 907 | 907 | |
| 908 | - case 'sorting_options': |
|
| 909 | - $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 910 | - break; |
|
| 911 | - } |
|
| 912 | - return $heading; |
|
| 908 | + case 'sorting_options': |
|
| 909 | + $heading = sprintf(__('List of fields that will appear in %s listing and search results sorting option dropdown box.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 910 | + break; |
|
| 911 | + } |
|
| 912 | + return $heading; |
|
| 913 | 913 | } |
| 914 | 914 | |
| 915 | 915 | |
@@ -927,16 +927,16 @@ discard block |
||
| 927 | 927 | function geodir_cf_panel_selected_fields_note($note, $sub_tab, $listing_type) |
| 928 | 928 | {
|
| 929 | 929 | |
| 930 | - switch ($sub_tab) {
|
|
| 931 | - case 'custom_fields': |
|
| 932 | - $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 933 | - break; |
|
| 930 | + switch ($sub_tab) {
|
|
| 931 | + case 'custom_fields': |
|
| 932 | + $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order on add %s listing form too.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 933 | + break; |
|
| 934 | 934 | |
| 935 | - case 'sorting_options': |
|
| 936 | - $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 937 | - break; |
|
| 938 | - } |
|
| 939 | - return $note; |
|
| 935 | + case 'sorting_options': |
|
| 936 | + $note = sprintf(__('Click to expand and view field related settings. You may drag and drop to arrange fields order in sorting option dropdown box on %s listing and search results page.', 'geodirectory'), get_post_type_singular_label($listing_type, false, true));
|
|
| 937 | + break; |
|
| 938 | + } |
|
| 939 | + return $note; |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | |
@@ -952,16 +952,16 @@ discard block |
||
| 952 | 952 | */ |
| 953 | 953 | function geodir_remove_unnecessary_fields() |
| 954 | 954 | {
|
| 955 | - global $wpdb, $plugin_prefix; |
|
| 955 | + global $wpdb, $plugin_prefix; |
|
| 956 | 956 | |
| 957 | - if (!get_option('geodir_remove_unnecessary_fields')) {
|
|
| 957 | + if (!get_option('geodir_remove_unnecessary_fields')) {
|
|
| 958 | 958 | |
| 959 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
|
|
| 960 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
|
|
| 959 | + if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
|
|
| 960 | + $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
|
|
| 961 | 961 | |
| 962 | - update_option('geodir_remove_unnecessary_fields', '1');
|
|
| 962 | + update_option('geodir_remove_unnecessary_fields', '1');
|
|
| 963 | 963 | |
| 964 | - } |
|
| 964 | + } |
|
| 965 | 965 | |
| 966 | 966 | } |
| 967 | 967 | |
@@ -979,25 +979,25 @@ discard block |
||
| 979 | 979 | */ |
| 980 | 980 | function geodir_admin_ajax_handler() |
| 981 | 981 | {
|
| 982 | - if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
|
|
| 983 | - $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
| 984 | - switch ($geodir_admin_ajax_action) {
|
|
| 985 | - case 'diagnosis' : |
|
| 986 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 987 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 988 | - call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 989 | - exit(); |
|
| 990 | - break; |
|
| 991 | - |
|
| 992 | - case 'diagnosis-fix' : |
|
| 993 | - if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 994 | - $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 995 | - call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 996 | - exit(); |
|
| 997 | - break; |
|
| 998 | - } |
|
| 999 | - } |
|
| 1000 | - exit(); |
|
| 982 | + if (isset($_REQUEST['geodir_admin_ajax_action']) && $_REQUEST['geodir_admin_ajax_action'] != '') {
|
|
| 983 | + $geodir_admin_ajax_action = $_REQUEST['geodir_admin_ajax_action']; |
|
| 984 | + switch ($geodir_admin_ajax_action) {
|
|
| 985 | + case 'diagnosis' : |
|
| 986 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 987 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 988 | + call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 989 | + exit(); |
|
| 990 | + break; |
|
| 991 | + |
|
| 992 | + case 'diagnosis-fix' : |
|
| 993 | + if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
|
| 994 | + $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
|
| 995 | + call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 996 | + exit(); |
|
| 997 | + break; |
|
| 998 | + } |
|
| 999 | + } |
|
| 1000 | + exit(); |
|
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | 1003 | |
@@ -1015,127 +1015,127 @@ discard block |
||
| 1015 | 1015 | */ |
| 1016 | 1016 | function geodir_diagnose_multisite_table($filter_arr, $table, $tabel_name, $fix) |
| 1017 | 1017 | {
|
| 1018 | - global $wpdb; |
|
| 1019 | - //$filter_arr['output_str'] .='###'.$table.'###'; |
|
| 1020 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
|
|
| 1021 | - $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
|
|
| 1022 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 1023 | - |
|
| 1024 | - } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 1025 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1026 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 1027 | - $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
|
|
| 1028 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 1029 | - |
|
| 1030 | - if ($fix) {
|
|
| 1031 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
|
|
| 1032 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
|
|
| 1033 | - |
|
| 1034 | - if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
|
|
| 1035 | - //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
|
|
| 1036 | - |
|
| 1037 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
|
|
| 1038 | - |
|
| 1039 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 1040 | - $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
|
|
| 1041 | - } else {
|
|
| 1042 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1043 | - } |
|
| 1044 | - |
|
| 1045 | - } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
|
|
| 1046 | - |
|
| 1047 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
|
|
| 1048 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
|
|
| 1049 | - |
|
| 1050 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1051 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
|
|
| 1052 | - } else {
|
|
| 1053 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1054 | - } |
|
| 1055 | - |
|
| 1056 | - } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
|
|
| 1057 | - |
|
| 1058 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
|
|
| 1059 | - |
|
| 1060 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 1061 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
|
|
| 1062 | - } else {
|
|
| 1063 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1064 | - } |
|
| 1065 | - |
|
| 1066 | - } |
|
| 1067 | - |
|
| 1068 | - } |
|
| 1069 | - |
|
| 1070 | - |
|
| 1071 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 1072 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1073 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 1074 | - |
|
| 1075 | - if ($fix) {
|
|
| 1076 | - if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
|
|
| 1077 | - if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
|
|
| 1078 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
|
|
| 1079 | - } else {
|
|
| 1080 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
|
|
| 1081 | - } |
|
| 1082 | - |
|
| 1083 | - } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
|
|
| 1084 | - if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
|
|
| 1085 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 1086 | - } else {
|
|
| 1087 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 1088 | - } |
|
| 1089 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1090 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1091 | - } else {
|
|
| 1092 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1093 | - } |
|
| 1094 | - } else {// else rename the original table to _ms_bak
|
|
| 1095 | - if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1096 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 1097 | - } else {
|
|
| 1098 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 1099 | - } |
|
| 1100 | - } |
|
| 1101 | - } |
|
| 1102 | - |
|
| 1103 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 1104 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1105 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 1106 | - |
|
| 1107 | - if ($fix) {
|
|
| 1108 | - // if original table exists but new does not, rename |
|
| 1109 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1110 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1111 | - } else {
|
|
| 1112 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1113 | - } |
|
| 1114 | - |
|
| 1115 | - } |
|
| 1116 | - |
|
| 1117 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 1118 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1119 | - $filter_arr['is_error_during_diagnose'] = true; |
|
| 1120 | - |
|
| 1121 | - if ($fix) {
|
|
| 1122 | - // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
| 1123 | - delete_option('geodirlocation_db_version');
|
|
| 1124 | - delete_option('geodirevents_db_version');
|
|
| 1125 | - delete_option('geodir_reviewrating_db_version');
|
|
| 1126 | - delete_option('gdevents_db_version');
|
|
| 1127 | - delete_option('geodirectory_db_version');
|
|
| 1128 | - delete_option('geodirclaim_db_version');
|
|
| 1129 | - delete_option('geodir_custom_posts_db_version');
|
|
| 1130 | - delete_option('geodir_reviewratings_db_version');
|
|
| 1131 | - delete_option('geodiradvancesearch_db_version');
|
|
| 1132 | - $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
|
|
| 1133 | - } |
|
| 1134 | - |
|
| 1135 | - } else {
|
|
| 1136 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1137 | - } |
|
| 1138 | - return $filter_arr; |
|
| 1018 | + global $wpdb; |
|
| 1019 | + //$filter_arr['output_str'] .='###'.$table.'###'; |
|
| 1020 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
|
|
| 1021 | + $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
|
|
| 1022 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 1023 | + |
|
| 1024 | + } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 1025 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1026 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 1027 | + $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
|
|
| 1028 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 1029 | + |
|
| 1030 | + if ($fix) {
|
|
| 1031 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
|
|
| 1032 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
|
|
| 1033 | + |
|
| 1034 | + if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
|
|
| 1035 | + //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
|
|
| 1036 | + |
|
| 1037 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
|
|
| 1038 | + |
|
| 1039 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 1040 | + $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
|
|
| 1041 | + } else {
|
|
| 1042 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1043 | + } |
|
| 1044 | + |
|
| 1045 | + } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
|
|
| 1046 | + |
|
| 1047 | + $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
|
|
| 1048 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
|
|
| 1049 | + |
|
| 1050 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1051 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
|
|
| 1052 | + } else {
|
|
| 1053 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1054 | + } |
|
| 1055 | + |
|
| 1056 | + } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
|
|
| 1057 | + |
|
| 1058 | + $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
|
|
| 1059 | + |
|
| 1060 | + if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 1061 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
|
|
| 1062 | + } else {
|
|
| 1063 | + $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1064 | + } |
|
| 1065 | + |
|
| 1066 | + } |
|
| 1067 | + |
|
| 1068 | + } |
|
| 1069 | + |
|
| 1070 | + |
|
| 1071 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 1072 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1073 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 1074 | + |
|
| 1075 | + if ($fix) {
|
|
| 1076 | + if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
|
|
| 1077 | + if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
|
|
| 1078 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
|
|
| 1079 | + } else {
|
|
| 1080 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
|
|
| 1081 | + } |
|
| 1082 | + |
|
| 1083 | + } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
|
|
| 1084 | + if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
|
|
| 1085 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 1086 | + } else {
|
|
| 1087 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 1088 | + } |
|
| 1089 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1090 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1091 | + } else {
|
|
| 1092 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1093 | + } |
|
| 1094 | + } else {// else rename the original table to _ms_bak
|
|
| 1095 | + if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1096 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 1097 | + } else {
|
|
| 1098 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 1099 | + } |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1102 | + |
|
| 1103 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 1104 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1105 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 1106 | + |
|
| 1107 | + if ($fix) {
|
|
| 1108 | + // if original table exists but new does not, rename |
|
| 1109 | + if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1110 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1111 | + } else {
|
|
| 1112 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1113 | + } |
|
| 1114 | + |
|
| 1115 | + } |
|
| 1116 | + |
|
| 1117 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 1118 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1119 | + $filter_arr['is_error_during_diagnose'] = true; |
|
| 1120 | + |
|
| 1121 | + if ($fix) {
|
|
| 1122 | + // if original table does not exist try deleting db_vers of all addons so the initial db_install scripts run; |
|
| 1123 | + delete_option('geodirlocation_db_version');
|
|
| 1124 | + delete_option('geodirevents_db_version');
|
|
| 1125 | + delete_option('geodir_reviewrating_db_version');
|
|
| 1126 | + delete_option('gdevents_db_version');
|
|
| 1127 | + delete_option('geodirectory_db_version');
|
|
| 1128 | + delete_option('geodirclaim_db_version');
|
|
| 1129 | + delete_option('geodir_custom_posts_db_version');
|
|
| 1130 | + delete_option('geodir_reviewratings_db_version');
|
|
| 1131 | + delete_option('geodiradvancesearch_db_version');
|
|
| 1132 | + $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
|
|
| 1133 | + } |
|
| 1134 | + |
|
| 1135 | + } else {
|
|
| 1136 | + $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1137 | + } |
|
| 1138 | + return $filter_arr; |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | |
@@ -1149,53 +1149,53 @@ discard block |
||
| 1149 | 1149 | */ |
| 1150 | 1150 | function geodir_diagnose_tags_sync() |
| 1151 | 1151 | {
|
| 1152 | - global $wpdb, $plugin_prefix; |
|
| 1153 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1154 | - |
|
| 1155 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1156 | - $is_error_during_diagnose = false; |
|
| 1157 | - $output_str = ''; |
|
| 1158 | - |
|
| 1159 | - |
|
| 1160 | - $all_postypes = geodir_get_posttypes(); |
|
| 1161 | - |
|
| 1162 | - if (!empty($all_postypes)) {
|
|
| 1163 | - foreach ($all_postypes as $key) {
|
|
| 1164 | - // update each GD CPT |
|
| 1165 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
|
|
| 1166 | - |
|
| 1167 | - if (!empty($posts)) {
|
|
| 1168 | - |
|
| 1169 | - foreach ($posts as $p) {
|
|
| 1170 | - $p->post_type = $key; |
|
| 1171 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
|
|
| 1172 | - if (empty($raw_tags)) {
|
|
| 1173 | - $post_tags = ''; |
|
| 1174 | - } else {
|
|
| 1175 | - $post_tags = implode(",", $raw_tags);
|
|
| 1176 | - } |
|
| 1177 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1178 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
|
|
| 1179 | - |
|
| 1180 | - } |
|
| 1181 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1182 | - } |
|
| 1183 | - |
|
| 1184 | - } |
|
| 1185 | - |
|
| 1186 | - } |
|
| 1187 | - |
|
| 1188 | - if ($is_error_during_diagnose) {
|
|
| 1189 | - $info_div_class = "geodir_problem_info"; |
|
| 1190 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1191 | - } else {
|
|
| 1192 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1193 | - $fix_button_txt = ''; |
|
| 1194 | - } |
|
| 1195 | - echo "<ul class='$info_div_class'>"; |
|
| 1196 | - echo $output_str; |
|
| 1197 | - echo $fix_button_txt; |
|
| 1198 | - echo "</ul>"; |
|
| 1152 | + global $wpdb, $plugin_prefix; |
|
| 1153 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1154 | + |
|
| 1155 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1156 | + $is_error_during_diagnose = false; |
|
| 1157 | + $output_str = ''; |
|
| 1158 | + |
|
| 1159 | + |
|
| 1160 | + $all_postypes = geodir_get_posttypes(); |
|
| 1161 | + |
|
| 1162 | + if (!empty($all_postypes)) {
|
|
| 1163 | + foreach ($all_postypes as $key) {
|
|
| 1164 | + // update each GD CPT |
|
| 1165 | + $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
|
|
| 1166 | + |
|
| 1167 | + if (!empty($posts)) {
|
|
| 1168 | + |
|
| 1169 | + foreach ($posts as $p) {
|
|
| 1170 | + $p->post_type = $key; |
|
| 1171 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
|
|
| 1172 | + if (empty($raw_tags)) {
|
|
| 1173 | + $post_tags = ''; |
|
| 1174 | + } else {
|
|
| 1175 | + $post_tags = implode(",", $raw_tags);
|
|
| 1176 | + } |
|
| 1177 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1178 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
|
|
| 1179 | + |
|
| 1180 | + } |
|
| 1181 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1182 | + } |
|
| 1183 | + |
|
| 1184 | + } |
|
| 1185 | + |
|
| 1186 | + } |
|
| 1187 | + |
|
| 1188 | + if ($is_error_during_diagnose) {
|
|
| 1189 | + $info_div_class = "geodir_problem_info"; |
|
| 1190 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1191 | + } else {
|
|
| 1192 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1193 | + $fix_button_txt = ''; |
|
| 1194 | + } |
|
| 1195 | + echo "<ul class='$info_div_class'>"; |
|
| 1196 | + echo $output_str; |
|
| 1197 | + echo $fix_button_txt; |
|
| 1198 | + echo "</ul>"; |
|
| 1199 | 1199 | |
| 1200 | 1200 | } |
| 1201 | 1201 | |
@@ -1211,75 +1211,75 @@ discard block |
||
| 1211 | 1211 | */ |
| 1212 | 1212 | function geodir_diagnose_cats_sync() |
| 1213 | 1213 | {
|
| 1214 | - global $wpdb, $plugin_prefix; |
|
| 1215 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1214 | + global $wpdb, $plugin_prefix; |
|
| 1215 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1216 | 1216 | |
| 1217 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1218 | - $is_error_during_diagnose = false; |
|
| 1219 | - $output_str = ''; |
|
| 1217 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1218 | + $is_error_during_diagnose = false; |
|
| 1219 | + $output_str = ''; |
|
| 1220 | 1220 | |
| 1221 | 1221 | |
| 1222 | - $all_postypes = geodir_get_posttypes(); |
|
| 1222 | + $all_postypes = geodir_get_posttypes(); |
|
| 1223 | 1223 | |
| 1224 | - if (!empty($all_postypes)) {
|
|
| 1225 | - foreach ($all_postypes as $key) {
|
|
| 1226 | - // update each GD CTP |
|
| 1227 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
|
|
| 1224 | + if (!empty($all_postypes)) {
|
|
| 1225 | + foreach ($all_postypes as $key) {
|
|
| 1226 | + // update each GD CTP |
|
| 1227 | + $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
|
|
| 1228 | 1228 | |
| 1229 | - if (!empty($posts)) {
|
|
| 1229 | + if (!empty($posts)) {
|
|
| 1230 | 1230 | |
| 1231 | - foreach ($posts as $p) {
|
|
| 1232 | - $p->post_type = $key; |
|
| 1233 | - $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
|
|
| 1231 | + foreach ($posts as $p) {
|
|
| 1232 | + $p->post_type = $key; |
|
| 1233 | + $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
|
|
| 1234 | 1234 | |
| 1235 | - if (empty($raw_cats)) {
|
|
| 1236 | - $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
| 1235 | + if (empty($raw_cats)) {
|
|
| 1236 | + $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
|
| 1237 | 1237 | |
| 1238 | - if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
|
|
| 1239 | - $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
|
|
| 1240 | - foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
|
|
| 1241 | - if (is_numeric($cat_part)) {
|
|
| 1242 | - $raw_cats[] = (int)$cat_part; |
|
| 1243 | - } |
|
| 1244 | - } |
|
| 1238 | + if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
|
|
| 1239 | + $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
|
|
| 1240 | + foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
|
|
| 1241 | + if (is_numeric($cat_part)) {
|
|
| 1242 | + $raw_cats[] = (int)$cat_part; |
|
| 1243 | + } |
|
| 1244 | + } |
|
| 1245 | 1245 | |
| 1246 | - } |
|
| 1246 | + } |
|
| 1247 | 1247 | |
| 1248 | - if (!empty($raw_cats)) {
|
|
| 1249 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
| 1248 | + if (!empty($raw_cats)) {
|
|
| 1249 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
| 1250 | 1250 | |
| 1251 | - } |
|
| 1251 | + } |
|
| 1252 | 1252 | |
| 1253 | - } |
|
| 1253 | + } |
|
| 1254 | 1254 | |
| 1255 | 1255 | |
| 1256 | - if (empty($raw_cats)) {
|
|
| 1257 | - $post_cats = ''; |
|
| 1258 | - } else {
|
|
| 1259 | - $post_cats = ',' . implode(",", $raw_cats) . ',';
|
|
| 1260 | - } |
|
| 1261 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1262 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
|
|
| 1263 | - } |
|
| 1256 | + if (empty($raw_cats)) {
|
|
| 1257 | + $post_cats = ''; |
|
| 1258 | + } else {
|
|
| 1259 | + $post_cats = ',' . implode(",", $raw_cats) . ',';
|
|
| 1260 | + } |
|
| 1261 | + $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1262 | + $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
|
|
| 1263 | + } |
|
| 1264 | 1264 | |
| 1265 | - } |
|
| 1266 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1265 | + } |
|
| 1266 | + $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1267 | 1267 | |
| 1268 | - } |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | - } |
|
| 1270 | + } |
|
| 1271 | 1271 | |
| 1272 | - if ($is_error_during_diagnose) {
|
|
| 1273 | - $info_div_class = "geodir_problem_info"; |
|
| 1274 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1275 | - } else {
|
|
| 1276 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1277 | - $fix_button_txt = ''; |
|
| 1278 | - } |
|
| 1279 | - echo "<ul class='$info_div_class'>"; |
|
| 1280 | - echo $output_str; |
|
| 1281 | - echo $fix_button_txt; |
|
| 1282 | - echo "</ul>"; |
|
| 1272 | + if ($is_error_during_diagnose) {
|
|
| 1273 | + $info_div_class = "geodir_problem_info"; |
|
| 1274 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1275 | + } else {
|
|
| 1276 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1277 | + $fix_button_txt = ''; |
|
| 1278 | + } |
|
| 1279 | + echo "<ul class='$info_div_class'>"; |
|
| 1280 | + echo $output_str; |
|
| 1281 | + echo $fix_button_txt; |
|
| 1282 | + echo "</ul>"; |
|
| 1283 | 1283 | |
| 1284 | 1284 | } |
| 1285 | 1285 | |
@@ -1293,61 +1293,61 @@ discard block |
||
| 1293 | 1293 | */ |
| 1294 | 1294 | function geodir_diagnose_version_clear() |
| 1295 | 1295 | {
|
| 1296 | - global $wpdb, $plugin_prefix; |
|
| 1297 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1298 | - |
|
| 1299 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1300 | - $is_error_during_diagnose = false; |
|
| 1301 | - $output_str = ''; |
|
| 1302 | - |
|
| 1303 | - |
|
| 1304 | - $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
|
|
| 1305 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1306 | - 'GeoDirectory Framework' => 'gdf_db_version', |
|
| 1307 | - 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
| 1308 | - 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
| 1309 | - 'Claim Manager' => 'geodirclaim_db_version', |
|
| 1310 | - 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
| 1311 | - 'Location Manager' => 'geodirlocation_db_version', |
|
| 1312 | - 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1313 | - 'Events Manager' => 'geodirevents_db_version', |
|
| 1314 | - ); |
|
| 1315 | - |
|
| 1316 | - /** |
|
| 1317 | - * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
| 1318 | - * |
|
| 1319 | - * @since 1.0.0 |
|
| 1320 | - * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
|
|
| 1321 | - */ |
|
| 1322 | - $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
|
|
| 1323 | - |
|
| 1324 | - if (!empty($ver_arr)) {
|
|
| 1325 | - foreach ($ver_arr as $key => $val) {
|
|
| 1326 | - if (delete_option($val)) {
|
|
| 1327 | - $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
|
|
| 1328 | - } else {
|
|
| 1329 | - $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
|
|
| 1330 | - } |
|
| 1331 | - |
|
| 1332 | - } |
|
| 1333 | - |
|
| 1334 | - if ($output_str) {
|
|
| 1335 | - $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
|
|
| 1336 | - } |
|
| 1337 | - |
|
| 1338 | - } |
|
| 1339 | - |
|
| 1340 | - if ($is_error_during_diagnose) {
|
|
| 1341 | - $info_div_class = "geodir_problem_info"; |
|
| 1342 | - $fix_button_txt = ""; |
|
| 1343 | - } else {
|
|
| 1344 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1345 | - $fix_button_txt = ''; |
|
| 1346 | - } |
|
| 1347 | - echo "<ul class='$info_div_class'>"; |
|
| 1348 | - echo $output_str; |
|
| 1349 | - echo $fix_button_txt; |
|
| 1350 | - echo "</ul>"; |
|
| 1296 | + global $wpdb, $plugin_prefix; |
|
| 1297 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1298 | + |
|
| 1299 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1300 | + $is_error_during_diagnose = false; |
|
| 1301 | + $output_str = ''; |
|
| 1302 | + |
|
| 1303 | + |
|
| 1304 | + $gd_arr = array('GeoDirectory' => 'geodirectory_db_version',
|
|
| 1305 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1306 | + 'GeoDirectory Framework' => 'gdf_db_version', |
|
| 1307 | + 'Advanced Search' => 'geodiradvancesearch_db_version', |
|
| 1308 | + 'Review Rating Manager' => 'geodir_reviewratings_db_version', |
|
| 1309 | + 'Claim Manager' => 'geodirclaim_db_version', |
|
| 1310 | + 'CPT Manager' => 'geodir_custom_posts_db_version', |
|
| 1311 | + 'Location Manager' => 'geodirlocation_db_version', |
|
| 1312 | + 'Payment Manager' => 'geodir_payments_db_version', |
|
| 1313 | + 'Events Manager' => 'geodirevents_db_version', |
|
| 1314 | + ); |
|
| 1315 | + |
|
| 1316 | + /** |
|
| 1317 | + * Filter the array of plugins to clear the version numbers for in the GD >Tools : clear all version numbers. |
|
| 1318 | + * |
|
| 1319 | + * @since 1.0.0 |
|
| 1320 | + * @param array $gd_arr The array or addons to clear, array('GeoDirectory' => 'geodirectory_db_version',...
|
|
| 1321 | + */ |
|
| 1322 | + $ver_arr = apply_filters('geodir_db_version_name', $gd_arr);
|
|
| 1323 | + |
|
| 1324 | + if (!empty($ver_arr)) {
|
|
| 1325 | + foreach ($ver_arr as $key => $val) {
|
|
| 1326 | + if (delete_option($val)) {
|
|
| 1327 | + $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
|
|
| 1328 | + } else {
|
|
| 1329 | + $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
|
|
| 1330 | + } |
|
| 1331 | + |
|
| 1332 | + } |
|
| 1333 | + |
|
| 1334 | + if ($output_str) {
|
|
| 1335 | + $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
|
|
| 1336 | + } |
|
| 1337 | + |
|
| 1338 | + } |
|
| 1339 | + |
|
| 1340 | + if ($is_error_during_diagnose) {
|
|
| 1341 | + $info_div_class = "geodir_problem_info"; |
|
| 1342 | + $fix_button_txt = ""; |
|
| 1343 | + } else {
|
|
| 1344 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1345 | + $fix_button_txt = ''; |
|
| 1346 | + } |
|
| 1347 | + echo "<ul class='$info_div_class'>"; |
|
| 1348 | + echo $output_str; |
|
| 1349 | + echo $fix_button_txt; |
|
| 1350 | + echo "</ul>"; |
|
| 1351 | 1351 | |
| 1352 | 1352 | } |
| 1353 | 1353 | |
@@ -1361,59 +1361,59 @@ discard block |
||
| 1361 | 1361 | */ |
| 1362 | 1362 | function geodir_diagnose_ratings() |
| 1363 | 1363 | {
|
| 1364 | - global $wpdb; |
|
| 1365 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1366 | - |
|
| 1367 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1368 | - $is_error_during_diagnose = false; |
|
| 1369 | - $output_str = ''; |
|
| 1370 | - |
|
| 1371 | - // check review locations |
|
| 1372 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
|
|
| 1373 | - $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
|
|
| 1374 | - $is_error_during_diagnose = true; |
|
| 1375 | - |
|
| 1376 | - if ($fix) {
|
|
| 1377 | - if (geodir_fix_review_location()) {
|
|
| 1378 | - $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
|
|
| 1379 | - } else {
|
|
| 1380 | - $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1381 | - } |
|
| 1382 | - } |
|
| 1383 | - |
|
| 1384 | - } else {
|
|
| 1385 | - $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
|
|
| 1386 | - } |
|
| 1387 | - |
|
| 1388 | - // check review content |
|
| 1389 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
|
|
| 1390 | - $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
|
|
| 1391 | - $is_error_during_diagnose = true; |
|
| 1392 | - |
|
| 1393 | - if ($fix) {
|
|
| 1394 | - if (geodir_fix_review_content()) {
|
|
| 1395 | - $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
|
|
| 1396 | - } else {
|
|
| 1397 | - $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1398 | - } |
|
| 1399 | - } |
|
| 1400 | - |
|
| 1401 | - } else {
|
|
| 1402 | - $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
|
|
| 1403 | - } |
|
| 1404 | - |
|
| 1405 | - |
|
| 1406 | - if ($is_error_during_diagnose) {
|
|
| 1407 | - $info_div_class = "geodir_problem_info"; |
|
| 1408 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1409 | - } else {
|
|
| 1410 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1411 | - $fix_button_txt = ''; |
|
| 1412 | - } |
|
| 1413 | - echo "<ul class='$info_div_class'>"; |
|
| 1414 | - echo $output_str; |
|
| 1415 | - echo $fix_button_txt; |
|
| 1416 | - echo "</ul>"; |
|
| 1364 | + global $wpdb; |
|
| 1365 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1366 | + |
|
| 1367 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1368 | + $is_error_during_diagnose = false; |
|
| 1369 | + $output_str = ''; |
|
| 1370 | + |
|
| 1371 | + // check review locations |
|
| 1372 | + if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
|
|
| 1373 | + $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
|
|
| 1374 | + $is_error_during_diagnose = true; |
|
| 1375 | + |
|
| 1376 | + if ($fix) {
|
|
| 1377 | + if (geodir_fix_review_location()) {
|
|
| 1378 | + $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
|
|
| 1379 | + } else {
|
|
| 1380 | + $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1381 | + } |
|
| 1382 | + } |
|
| 1383 | + |
|
| 1384 | + } else {
|
|
| 1385 | + $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
|
|
| 1386 | + } |
|
| 1387 | + |
|
| 1388 | + // check review content |
|
| 1389 | + if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
|
|
| 1390 | + $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
|
|
| 1391 | + $is_error_during_diagnose = true; |
|
| 1392 | + |
|
| 1393 | + if ($fix) {
|
|
| 1394 | + if (geodir_fix_review_content()) {
|
|
| 1395 | + $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
|
|
| 1396 | + } else {
|
|
| 1397 | + $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1398 | + } |
|
| 1399 | + } |
|
| 1400 | + |
|
| 1401 | + } else {
|
|
| 1402 | + $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
|
|
| 1403 | + } |
|
| 1404 | + |
|
| 1405 | + |
|
| 1406 | + if ($is_error_during_diagnose) {
|
|
| 1407 | + $info_div_class = "geodir_problem_info"; |
|
| 1408 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1409 | + } else {
|
|
| 1410 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1411 | + $fix_button_txt = ''; |
|
| 1412 | + } |
|
| 1413 | + echo "<ul class='$info_div_class'>"; |
|
| 1414 | + echo $output_str; |
|
| 1415 | + echo $fix_button_txt; |
|
| 1416 | + echo "</ul>"; |
|
| 1417 | 1417 | |
| 1418 | 1418 | } |
| 1419 | 1419 | |
@@ -1427,57 +1427,57 @@ discard block |
||
| 1427 | 1427 | */ |
| 1428 | 1428 | function geodir_diagnose_multisite_conversion() |
| 1429 | 1429 | {
|
| 1430 | - global $wpdb; |
|
| 1431 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1432 | - //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1433 | - $is_error_during_diagnose = false; |
|
| 1434 | - $output_str = ''; |
|
| 1435 | - |
|
| 1436 | - $filter_arr = array(); |
|
| 1437 | - $filter_arr['output_str'] = $output_str; |
|
| 1438 | - $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
| 1439 | - $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
|
|
| 1440 | - 'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
|
|
| 1441 | - 'geodir_post_icon' => __('Post icon', 'geodirectory'),
|
|
| 1442 | - 'geodir_attachments' => __('Attachments', 'geodirectory'),
|
|
| 1443 | - 'geodir_post_review' => __('Reviews', 'geodirectory'),
|
|
| 1444 | - 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
|
|
| 1445 | - 'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
|
|
| 1446 | - ); |
|
| 1447 | - |
|
| 1448 | - // allow other addons to hook in and add their checks |
|
| 1449 | - |
|
| 1450 | - /** |
|
| 1451 | - * Filter the array of tables. |
|
| 1452 | - * |
|
| 1453 | - * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. |
|
| 1454 | - * |
|
| 1455 | - * @since 1.0.0 |
|
| 1456 | - * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
|
|
| 1457 | - */ |
|
| 1458 | - $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
|
|
| 1459 | - |
|
| 1460 | - foreach ($table_arr as $table => $table_name) {
|
|
| 1461 | - // Diagnose table |
|
| 1462 | - $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
| 1463 | - } |
|
| 1464 | - |
|
| 1465 | - |
|
| 1466 | - $output_str = $filter_arr['output_str']; |
|
| 1467 | - $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
| 1468 | - |
|
| 1469 | - |
|
| 1470 | - if ($is_error_during_diagnose) {
|
|
| 1471 | - $info_div_class = "geodir_problem_info"; |
|
| 1472 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
|
|
| 1473 | - } else {
|
|
| 1474 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1475 | - $fix_button_txt = ''; |
|
| 1476 | - } |
|
| 1477 | - echo "<ul class='$info_div_class'>"; |
|
| 1478 | - echo $output_str; |
|
| 1479 | - echo $fix_button_txt; |
|
| 1480 | - echo "</ul>"; |
|
| 1430 | + global $wpdb; |
|
| 1431 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1432 | + //if($fix){echo 'true';}else{echo 'false';}
|
|
| 1433 | + $is_error_during_diagnose = false; |
|
| 1434 | + $output_str = ''; |
|
| 1435 | + |
|
| 1436 | + $filter_arr = array(); |
|
| 1437 | + $filter_arr['output_str'] = $output_str; |
|
| 1438 | + $filter_arr['is_error_during_diagnose'] = $is_error_during_diagnose; |
|
| 1439 | + $table_arr = array('geodir_countries' => __('Countries', 'geodirectory'),
|
|
| 1440 | + 'geodir_custom_fields' => __('Custom fields', 'geodirectory'),
|
|
| 1441 | + 'geodir_post_icon' => __('Post icon', 'geodirectory'),
|
|
| 1442 | + 'geodir_attachments' => __('Attachments', 'geodirectory'),
|
|
| 1443 | + 'geodir_post_review' => __('Reviews', 'geodirectory'),
|
|
| 1444 | + 'geodir_custom_sort_fields' => __('Custom sort fields', 'geodirectory'),
|
|
| 1445 | + 'geodir_gd_place_detail' => __('Place detail', 'geodirectory')
|
|
| 1446 | + ); |
|
| 1447 | + |
|
| 1448 | + // allow other addons to hook in and add their checks |
|
| 1449 | + |
|
| 1450 | + /** |
|
| 1451 | + * Filter the array of tables. |
|
| 1452 | + * |
|
| 1453 | + * Filter the array of tables to check during the GD>Tools multisite DB conversion tool check, this allows addons to add their DB tables to the checks. |
|
| 1454 | + * |
|
| 1455 | + * @since 1.0.0 |
|
| 1456 | + * @param array $table_arr The array of tables to check, array('geodir_countries' => __('Countries', 'geodirectory'),...
|
|
| 1457 | + */ |
|
| 1458 | + $table_arr = apply_filters('geodir_diagnose_multisite_conversion', $table_arr);
|
|
| 1459 | + |
|
| 1460 | + foreach ($table_arr as $table => $table_name) {
|
|
| 1461 | + // Diagnose table |
|
| 1462 | + $filter_arr = geodir_diagnose_multisite_table($filter_arr, $table, $table_name, $fix); |
|
| 1463 | + } |
|
| 1464 | + |
|
| 1465 | + |
|
| 1466 | + $output_str = $filter_arr['output_str']; |
|
| 1467 | + $is_error_during_diagnose = $filter_arr['is_error_during_diagnose']; |
|
| 1468 | + |
|
| 1469 | + |
|
| 1470 | + if ($is_error_during_diagnose) {
|
|
| 1471 | + $info_div_class = "geodir_problem_info"; |
|
| 1472 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
|
|
| 1473 | + } else {
|
|
| 1474 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1475 | + $fix_button_txt = ''; |
|
| 1476 | + } |
|
| 1477 | + echo "<ul class='$info_div_class'>"; |
|
| 1478 | + echo $output_str; |
|
| 1479 | + echo $fix_button_txt; |
|
| 1480 | + echo "</ul>"; |
|
| 1481 | 1481 | } |
| 1482 | 1482 | |
| 1483 | 1483 | /** |
@@ -1495,39 +1495,39 @@ discard block |
||
| 1495 | 1495 | */ |
| 1496 | 1496 | function geodir_fix_virtual_page($slug, $page_title, $old_id, $option) |
| 1497 | 1497 | {
|
| 1498 | - global $wpdb, $current_user; |
|
| 1499 | - |
|
| 1500 | - if (!empty($old_id)) {
|
|
| 1501 | - wp_delete_post($old_id, true); |
|
| 1502 | - }//delete post if already there |
|
| 1503 | - else {
|
|
| 1504 | - $page_found = $wpdb->get_var( |
|
| 1505 | - $wpdb->prepare( |
|
| 1506 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 1507 | - array($slug) |
|
| 1508 | - ) |
|
| 1509 | - ); |
|
| 1510 | - wp_delete_post($page_found, true); |
|
| 1511 | - |
|
| 1512 | - } |
|
| 1513 | - |
|
| 1514 | - $page_data = array( |
|
| 1515 | - 'post_status' => 'publish', |
|
| 1516 | - 'post_type' => 'page', |
|
| 1517 | - 'post_author' => $current_user->ID, |
|
| 1518 | - 'post_name' => $slug, |
|
| 1519 | - 'post_title' => $page_title, |
|
| 1520 | - 'post_content' => '', |
|
| 1521 | - 'post_parent' => 0, |
|
| 1522 | - 'comment_status' => 'closed' |
|
| 1523 | - ); |
|
| 1524 | - $page_id = wp_insert_post($page_data); |
|
| 1525 | - update_option($option, $page_id); |
|
| 1526 | - if ($page_id) {
|
|
| 1527 | - return true; |
|
| 1528 | - } else {
|
|
| 1529 | - return false; |
|
| 1530 | - } |
|
| 1498 | + global $wpdb, $current_user; |
|
| 1499 | + |
|
| 1500 | + if (!empty($old_id)) {
|
|
| 1501 | + wp_delete_post($old_id, true); |
|
| 1502 | + }//delete post if already there |
|
| 1503 | + else {
|
|
| 1504 | + $page_found = $wpdb->get_var( |
|
| 1505 | + $wpdb->prepare( |
|
| 1506 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 1507 | + array($slug) |
|
| 1508 | + ) |
|
| 1509 | + ); |
|
| 1510 | + wp_delete_post($page_found, true); |
|
| 1511 | + |
|
| 1512 | + } |
|
| 1513 | + |
|
| 1514 | + $page_data = array( |
|
| 1515 | + 'post_status' => 'publish', |
|
| 1516 | + 'post_type' => 'page', |
|
| 1517 | + 'post_author' => $current_user->ID, |
|
| 1518 | + 'post_name' => $slug, |
|
| 1519 | + 'post_title' => $page_title, |
|
| 1520 | + 'post_content' => '', |
|
| 1521 | + 'post_parent' => 0, |
|
| 1522 | + 'comment_status' => 'closed' |
|
| 1523 | + ); |
|
| 1524 | + $page_id = wp_insert_post($page_data); |
|
| 1525 | + update_option($option, $page_id); |
|
| 1526 | + if ($page_id) {
|
|
| 1527 | + return true; |
|
| 1528 | + } else {
|
|
| 1529 | + return false; |
|
| 1530 | + } |
|
| 1531 | 1531 | } |
| 1532 | 1532 | |
| 1533 | 1533 | /** |
@@ -1539,212 +1539,212 @@ discard block |
||
| 1539 | 1539 | */ |
| 1540 | 1540 | function geodir_diagnose_default_pages() |
| 1541 | 1541 | {
|
| 1542 | - global $wpdb; |
|
| 1543 | - $is_error_during_diagnose = false; |
|
| 1544 | - $output_str = ''; |
|
| 1545 | - $fix = isset($_POST['fix']) ? true : false; |
|
| 1546 | - |
|
| 1547 | - ////////////////////////////////// |
|
| 1548 | - /* Diagnose GD Home Page Starts */ |
|
| 1549 | - ////////////////////////////////// |
|
| 1550 | - $option_value = get_option('geodir_home_page');
|
|
| 1551 | - $page = get_post($option_value); |
|
| 1552 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1553 | - |
|
| 1554 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1555 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1556 | - else {
|
|
| 1557 | - $is_error_during_diagnose = true; |
|
| 1558 | - $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1559 | - if ($fix) {
|
|
| 1560 | - if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
|
|
| 1561 | - $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1562 | - } else {
|
|
| 1563 | - $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1564 | - } |
|
| 1565 | - } |
|
| 1566 | - } |
|
| 1567 | - |
|
| 1568 | - //////////////////////////////// |
|
| 1569 | - /* Diagnose GD Home Page Ends */ |
|
| 1570 | - //////////////////////////////// |
|
| 1571 | - |
|
| 1572 | - ////////////////////////////////// |
|
| 1573 | - /* Diagnose Add Listing Page Starts */ |
|
| 1574 | - ////////////////////////////////// |
|
| 1575 | - $option_value = get_option('geodir_add_listing_page');
|
|
| 1576 | - $page = get_post($option_value); |
|
| 1577 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1578 | - |
|
| 1579 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1580 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1581 | - else {
|
|
| 1582 | - $is_error_during_diagnose = true; |
|
| 1583 | - $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1584 | - if ($fix) {
|
|
| 1585 | - if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
|
|
| 1586 | - $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1587 | - } else {
|
|
| 1588 | - $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1589 | - } |
|
| 1590 | - } |
|
| 1591 | - } |
|
| 1592 | - |
|
| 1593 | - //////////////////////////////// |
|
| 1594 | - /* Diagnose Add Listing Page Ends */ |
|
| 1595 | - //////////////////////////////// |
|
| 1596 | - |
|
| 1597 | - |
|
| 1598 | - ////////////////////////////////// |
|
| 1599 | - /* Diagnose Listing Preview Page Starts */ |
|
| 1600 | - ////////////////////////////////// |
|
| 1601 | - $option_value = get_option('geodir_preview_page');
|
|
| 1602 | - $page = get_post($option_value); |
|
| 1603 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1604 | - |
|
| 1605 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1606 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1607 | - else {
|
|
| 1608 | - $is_error_during_diagnose = true; |
|
| 1609 | - $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1610 | - if ($fix) {
|
|
| 1611 | - if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
|
|
| 1612 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1613 | - } else {
|
|
| 1614 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1615 | - } |
|
| 1616 | - } |
|
| 1617 | - } |
|
| 1618 | - |
|
| 1619 | - //////////////////////////////// |
|
| 1620 | - /* Diagnose Listing Preview Page Ends */ |
|
| 1621 | - //////////////////////////////// |
|
| 1622 | - |
|
| 1623 | - ////////////////////////////////// |
|
| 1624 | - /* Diagnose Listing Success Page Starts */ |
|
| 1625 | - ////////////////////////////////// |
|
| 1626 | - $option_value = get_option('geodir_success_page');
|
|
| 1627 | - $page = get_post($option_value); |
|
| 1628 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1629 | - |
|
| 1630 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1631 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1632 | - else {
|
|
| 1633 | - $is_error_during_diagnose = true; |
|
| 1634 | - $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1635 | - if ($fix) {
|
|
| 1636 | - if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
|
|
| 1637 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1638 | - } else {
|
|
| 1639 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1640 | - } |
|
| 1641 | - } |
|
| 1642 | - } |
|
| 1643 | - |
|
| 1644 | - //////////////////////////////// |
|
| 1645 | - /* Diagnose Listing Sucess Page Ends */ |
|
| 1646 | - //////////////////////////////// |
|
| 1647 | - |
|
| 1648 | - ////////////////////////////////// |
|
| 1649 | - /* Diagnose Info Page Starts */ |
|
| 1650 | - ////////////////////////////////// |
|
| 1651 | - $option_value = get_option('geodir_info_page');
|
|
| 1652 | - $page = get_post($option_value); |
|
| 1653 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1654 | - |
|
| 1655 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1656 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1657 | - else {
|
|
| 1658 | - $is_error_during_diagnose = true; |
|
| 1659 | - $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1660 | - if ($fix) {
|
|
| 1661 | - if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
|
|
| 1662 | - $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1663 | - } else {
|
|
| 1664 | - $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1665 | - } |
|
| 1666 | - } |
|
| 1667 | - } |
|
| 1668 | - |
|
| 1669 | - //////////////////////////////// |
|
| 1670 | - /* Diagnose Info Page Ends */ |
|
| 1671 | - //////////////////////////////// |
|
| 1672 | - |
|
| 1673 | - ////////////////////////////////// |
|
| 1674 | - /* Diagnose Login Page Starts */ |
|
| 1675 | - ////////////////////////////////// |
|
| 1676 | - $option_value = get_option('geodir_login_page');
|
|
| 1677 | - $page = get_post($option_value); |
|
| 1678 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1679 | - |
|
| 1680 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1681 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1682 | - else {
|
|
| 1683 | - $is_error_during_diagnose = true; |
|
| 1684 | - $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1685 | - if ($fix) {
|
|
| 1686 | - if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
|
|
| 1687 | - $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1688 | - } else {
|
|
| 1689 | - $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1690 | - } |
|
| 1691 | - } |
|
| 1692 | - } |
|
| 1693 | - |
|
| 1694 | - //////////////////////////////// |
|
| 1695 | - /* Diagnose Info Page Ends */ |
|
| 1696 | - //////////////////////////////// |
|
| 1697 | - |
|
| 1698 | - ////////////////////////////////// |
|
| 1699 | - /* Diagnose Location Page Starts */ |
|
| 1700 | - ////////////////////////////////// |
|
| 1701 | - $option_value = get_option('geodir_location_page');
|
|
| 1702 | - $page = get_post($option_value); |
|
| 1703 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1704 | - |
|
| 1705 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1706 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1707 | - else {
|
|
| 1708 | - $is_error_during_diagnose = true; |
|
| 1709 | - $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1710 | - if ($fix) {
|
|
| 1711 | - if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
|
|
| 1712 | - $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1713 | - } else {
|
|
| 1714 | - $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1715 | - } |
|
| 1716 | - } |
|
| 1717 | - } |
|
| 1718 | - |
|
| 1719 | - //////////////////////////////// |
|
| 1720 | - /* Diagnose Location Page Ends */ |
|
| 1721 | - //////////////////////////////// |
|
| 1722 | - |
|
| 1723 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
|
|
| 1724 | - /** |
|
| 1725 | - * This action is called at the end of the GD Tools page check function. |
|
| 1726 | - * |
|
| 1727 | - * @since 1.5.2 |
|
| 1728 | - */ |
|
| 1729 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
|
|
| 1730 | - |
|
| 1731 | - $output_str = $page_chk_arr['output_str']; |
|
| 1732 | - $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
| 1733 | - |
|
| 1734 | - if ($is_error_during_diagnose) {
|
|
| 1735 | - if ($fix) {
|
|
| 1736 | - flush_rewrite_rules(); |
|
| 1737 | - } |
|
| 1738 | - $info_div_class = "geodir_problem_info"; |
|
| 1739 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
|
|
| 1740 | - } else {
|
|
| 1741 | - $info_div_class = "geodir_noproblem_info"; |
|
| 1742 | - $fix_button_txt = ''; |
|
| 1743 | - } |
|
| 1744 | - echo "<ul class='$info_div_class'>"; |
|
| 1745 | - echo $output_str; |
|
| 1746 | - echo $fix_button_txt; |
|
| 1747 | - echo "</ul>"; |
|
| 1542 | + global $wpdb; |
|
| 1543 | + $is_error_during_diagnose = false; |
|
| 1544 | + $output_str = ''; |
|
| 1545 | + $fix = isset($_POST['fix']) ? true : false; |
|
| 1546 | + |
|
| 1547 | + ////////////////////////////////// |
|
| 1548 | + /* Diagnose GD Home Page Starts */ |
|
| 1549 | + ////////////////////////////////// |
|
| 1550 | + $option_value = get_option('geodir_home_page');
|
|
| 1551 | + $page = get_post($option_value); |
|
| 1552 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1553 | + |
|
| 1554 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1555 | + $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1556 | + else {
|
|
| 1557 | + $is_error_during_diagnose = true; |
|
| 1558 | + $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1559 | + if ($fix) {
|
|
| 1560 | + if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
|
|
| 1561 | + $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1562 | + } else {
|
|
| 1563 | + $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1564 | + } |
|
| 1565 | + } |
|
| 1566 | + } |
|
| 1567 | + |
|
| 1568 | + //////////////////////////////// |
|
| 1569 | + /* Diagnose GD Home Page Ends */ |
|
| 1570 | + //////////////////////////////// |
|
| 1571 | + |
|
| 1572 | + ////////////////////////////////// |
|
| 1573 | + /* Diagnose Add Listing Page Starts */ |
|
| 1574 | + ////////////////////////////////// |
|
| 1575 | + $option_value = get_option('geodir_add_listing_page');
|
|
| 1576 | + $page = get_post($option_value); |
|
| 1577 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1578 | + |
|
| 1579 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1580 | + $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1581 | + else {
|
|
| 1582 | + $is_error_during_diagnose = true; |
|
| 1583 | + $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1584 | + if ($fix) {
|
|
| 1585 | + if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
|
|
| 1586 | + $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1587 | + } else {
|
|
| 1588 | + $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1589 | + } |
|
| 1590 | + } |
|
| 1591 | + } |
|
| 1592 | + |
|
| 1593 | + //////////////////////////////// |
|
| 1594 | + /* Diagnose Add Listing Page Ends */ |
|
| 1595 | + //////////////////////////////// |
|
| 1596 | + |
|
| 1597 | + |
|
| 1598 | + ////////////////////////////////// |
|
| 1599 | + /* Diagnose Listing Preview Page Starts */ |
|
| 1600 | + ////////////////////////////////// |
|
| 1601 | + $option_value = get_option('geodir_preview_page');
|
|
| 1602 | + $page = get_post($option_value); |
|
| 1603 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1604 | + |
|
| 1605 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1606 | + $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1607 | + else {
|
|
| 1608 | + $is_error_during_diagnose = true; |
|
| 1609 | + $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1610 | + if ($fix) {
|
|
| 1611 | + if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
|
|
| 1612 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1613 | + } else {
|
|
| 1614 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1615 | + } |
|
| 1616 | + } |
|
| 1617 | + } |
|
| 1618 | + |
|
| 1619 | + //////////////////////////////// |
|
| 1620 | + /* Diagnose Listing Preview Page Ends */ |
|
| 1621 | + //////////////////////////////// |
|
| 1622 | + |
|
| 1623 | + ////////////////////////////////// |
|
| 1624 | + /* Diagnose Listing Success Page Starts */ |
|
| 1625 | + ////////////////////////////////// |
|
| 1626 | + $option_value = get_option('geodir_success_page');
|
|
| 1627 | + $page = get_post($option_value); |
|
| 1628 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1629 | + |
|
| 1630 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1631 | + $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1632 | + else {
|
|
| 1633 | + $is_error_during_diagnose = true; |
|
| 1634 | + $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1635 | + if ($fix) {
|
|
| 1636 | + if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
|
|
| 1637 | + $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1638 | + } else {
|
|
| 1639 | + $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1640 | + } |
|
| 1641 | + } |
|
| 1642 | + } |
|
| 1643 | + |
|
| 1644 | + //////////////////////////////// |
|
| 1645 | + /* Diagnose Listing Sucess Page Ends */ |
|
| 1646 | + //////////////////////////////// |
|
| 1647 | + |
|
| 1648 | + ////////////////////////////////// |
|
| 1649 | + /* Diagnose Info Page Starts */ |
|
| 1650 | + ////////////////////////////////// |
|
| 1651 | + $option_value = get_option('geodir_info_page');
|
|
| 1652 | + $page = get_post($option_value); |
|
| 1653 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1654 | + |
|
| 1655 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1656 | + $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1657 | + else {
|
|
| 1658 | + $is_error_during_diagnose = true; |
|
| 1659 | + $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1660 | + if ($fix) {
|
|
| 1661 | + if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
|
|
| 1662 | + $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1663 | + } else {
|
|
| 1664 | + $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1665 | + } |
|
| 1666 | + } |
|
| 1667 | + } |
|
| 1668 | + |
|
| 1669 | + //////////////////////////////// |
|
| 1670 | + /* Diagnose Info Page Ends */ |
|
| 1671 | + //////////////////////////////// |
|
| 1672 | + |
|
| 1673 | + ////////////////////////////////// |
|
| 1674 | + /* Diagnose Login Page Starts */ |
|
| 1675 | + ////////////////////////////////// |
|
| 1676 | + $option_value = get_option('geodir_login_page');
|
|
| 1677 | + $page = get_post($option_value); |
|
| 1678 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1679 | + |
|
| 1680 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1681 | + $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1682 | + else {
|
|
| 1683 | + $is_error_during_diagnose = true; |
|
| 1684 | + $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1685 | + if ($fix) {
|
|
| 1686 | + if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
|
|
| 1687 | + $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1688 | + } else {
|
|
| 1689 | + $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1690 | + } |
|
| 1691 | + } |
|
| 1692 | + } |
|
| 1693 | + |
|
| 1694 | + //////////////////////////////// |
|
| 1695 | + /* Diagnose Info Page Ends */ |
|
| 1696 | + //////////////////////////////// |
|
| 1697 | + |
|
| 1698 | + ////////////////////////////////// |
|
| 1699 | + /* Diagnose Location Page Starts */ |
|
| 1700 | + ////////////////////////////////// |
|
| 1701 | + $option_value = get_option('geodir_location_page');
|
|
| 1702 | + $page = get_post($option_value); |
|
| 1703 | + if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1704 | + |
|
| 1705 | + if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1706 | + $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1707 | + else {
|
|
| 1708 | + $is_error_during_diagnose = true; |
|
| 1709 | + $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1710 | + if ($fix) {
|
|
| 1711 | + if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
|
|
| 1712 | + $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1713 | + } else {
|
|
| 1714 | + $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1715 | + } |
|
| 1716 | + } |
|
| 1717 | + } |
|
| 1718 | + |
|
| 1719 | + //////////////////////////////// |
|
| 1720 | + /* Diagnose Location Page Ends */ |
|
| 1721 | + //////////////////////////////// |
|
| 1722 | + |
|
| 1723 | + $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
|
|
| 1724 | + /** |
|
| 1725 | + * This action is called at the end of the GD Tools page check function. |
|
| 1726 | + * |
|
| 1727 | + * @since 1.5.2 |
|
| 1728 | + */ |
|
| 1729 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
|
|
| 1730 | + |
|
| 1731 | + $output_str = $page_chk_arr['output_str']; |
|
| 1732 | + $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
|
| 1733 | + |
|
| 1734 | + if ($is_error_during_diagnose) {
|
|
| 1735 | + if ($fix) {
|
|
| 1736 | + flush_rewrite_rules(); |
|
| 1737 | + } |
|
| 1738 | + $info_div_class = "geodir_problem_info"; |
|
| 1739 | + $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
|
|
| 1740 | + } else {
|
|
| 1741 | + $info_div_class = "geodir_noproblem_info"; |
|
| 1742 | + $fix_button_txt = ''; |
|
| 1743 | + } |
|
| 1744 | + echo "<ul class='$info_div_class'>"; |
|
| 1745 | + echo $output_str; |
|
| 1746 | + echo $fix_button_txt; |
|
| 1747 | + echo "</ul>"; |
|
| 1748 | 1748 | |
| 1749 | 1749 | } |
| 1750 | 1750 | |
@@ -1756,26 +1756,26 @@ discard block |
||
| 1756 | 1756 | * @global object $wpdb WordPress Database object. |
| 1757 | 1757 | */ |
| 1758 | 1758 | function geodir_diagnose_load_db_language() {
|
| 1759 | - global $wpdb; |
|
| 1759 | + global $wpdb; |
|
| 1760 | 1760 | |
| 1761 | 1761 | $is_error_during_diagnose = geodirectory_load_db_language(); |
| 1762 | 1762 | |
| 1763 | - $output_str = ''; |
|
| 1764 | - $fix_button_txt = ''; |
|
| 1763 | + $output_str = ''; |
|
| 1764 | + $fix_button_txt = ''; |
|
| 1765 | 1765 | |
| 1766 | - if ($is_error_during_diagnose) {
|
|
| 1767 | - $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
|
|
| 1766 | + if ($is_error_during_diagnose) {
|
|
| 1767 | + $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
|
|
| 1768 | 1768 | $info_div_class = "geodir_problem_info"; |
| 1769 | - } else {
|
|
| 1770 | - $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
|
|
| 1769 | + } else {
|
|
| 1770 | + $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
|
|
| 1771 | 1771 | $info_div_class = "geodir_noproblem_info"; |
| 1772 | - $fix_button_txt = ''; |
|
| 1773 | - } |
|
| 1772 | + $fix_button_txt = ''; |
|
| 1773 | + } |
|
| 1774 | 1774 | |
| 1775 | 1775 | echo "<ul class='$info_div_class'>"; |
| 1776 | - echo $output_str; |
|
| 1777 | - echo $fix_button_txt; |
|
| 1778 | - echo "</ul>"; |
|
| 1776 | + echo $output_str; |
|
| 1777 | + echo $fix_button_txt; |
|
| 1778 | + echo "</ul>"; |
|
| 1779 | 1779 | |
| 1780 | 1780 | } |
| 1781 | 1781 | |
@@ -1806,23 +1806,23 @@ discard block |
||
| 1806 | 1806 | */ |
| 1807 | 1807 | function geodir_posts_clauses_request($clauses) |
| 1808 | 1808 | {
|
| 1809 | - global $wpdb, $wp_query, $plugin_prefix; |
|
| 1809 | + global $wpdb, $wp_query, $plugin_prefix; |
|
| 1810 | 1810 | |
| 1811 | - if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
|
|
| 1812 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
| 1811 | + if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
|
|
| 1812 | + $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
| 1813 | 1813 | |
| 1814 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
| 1815 | - $clauses['join'] = $join; |
|
| 1814 | + $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
| 1815 | + $clauses['join'] = $join; |
|
| 1816 | 1816 | |
| 1817 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
| 1818 | - $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; |
|
| 1819 | - $clauses['fields'] = $fields; |
|
| 1817 | + $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
| 1818 | + $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; |
|
| 1819 | + $clauses['fields'] = $fields; |
|
| 1820 | 1820 | |
| 1821 | - $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
| 1822 | - $orderby = 'gd_expire ' . $order; |
|
| 1823 | - $clauses['orderby'] = $orderby; |
|
| 1824 | - } |
|
| 1825 | - return $clauses; |
|
| 1821 | + $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
|
| 1822 | + $orderby = 'gd_expire ' . $order; |
|
| 1823 | + $clauses['orderby'] = $orderby; |
|
| 1824 | + } |
|
| 1825 | + return $clauses; |
|
| 1826 | 1826 | } |
| 1827 | 1827 | |
| 1828 | 1828 | |
@@ -1843,7 +1843,7 @@ discard block |
||
| 1843 | 1843 | */ |
| 1844 | 1844 | function gd_theme_switch_compat_check() |
| 1845 | 1845 | {
|
| 1846 | - gd_set_theme_compat(); |
|
| 1846 | + gd_set_theme_compat(); |
|
| 1847 | 1847 | } |
| 1848 | 1848 | |
| 1849 | 1849 | /** |
@@ -1856,27 +1856,27 @@ discard block |
||
| 1856 | 1856 | */ |
| 1857 | 1857 | function geodir_str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") |
| 1858 | 1858 | {
|
| 1859 | - if (function_exists('str_getcsv')) {
|
|
| 1860 | - $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
| 1861 | - } else {
|
|
| 1862 | - global $current_user; |
|
| 1863 | - $upload_dir = wp_upload_dir(); |
|
| 1864 | - |
|
| 1865 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
| 1866 | - $handle = fopen($file, 'w'); |
|
| 1867 | - |
|
| 1868 | - fwrite($handle, $input); |
|
| 1869 | - fclose($handle); |
|
| 1870 | - |
|
| 1871 | - $handle = fopen($file, 'rt'); |
|
| 1872 | - if (PHP_VERSION >= '5.3.0') {
|
|
| 1873 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
| 1874 | - } else {
|
|
| 1875 | - $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
| 1876 | - } |
|
| 1877 | - fclose($handle); |
|
| 1878 | - } |
|
| 1879 | - return $fgetcsv; |
|
| 1859 | + if (function_exists('str_getcsv')) {
|
|
| 1860 | + $fgetcsv = str_getcsv($input, $delimiter, $enclosure, $escape); |
|
| 1861 | + } else {
|
|
| 1862 | + global $current_user; |
|
| 1863 | + $upload_dir = wp_upload_dir(); |
|
| 1864 | + |
|
| 1865 | + $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
| 1866 | + $handle = fopen($file, 'w'); |
|
| 1867 | + |
|
| 1868 | + fwrite($handle, $input); |
|
| 1869 | + fclose($handle); |
|
| 1870 | + |
|
| 1871 | + $handle = fopen($file, 'rt'); |
|
| 1872 | + if (PHP_VERSION >= '5.3.0') {
|
|
| 1873 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure, $escape); |
|
| 1874 | + } else {
|
|
| 1875 | + $fgetcsv = fgetcsv($handle, 0, $delimiter, $enclosure); |
|
| 1876 | + } |
|
| 1877 | + fclose($handle); |
|
| 1878 | + } |
|
| 1879 | + return $fgetcsv; |
|
| 1880 | 1880 | } |
| 1881 | 1881 | |
| 1882 | 1882 | add_action('wp_ajax_gdImportCsv', 'geodir_ajax_import_csv');
|
@@ -1891,375 +1891,375 @@ discard block |
||
| 1891 | 1891 | */ |
| 1892 | 1892 | function geodir_ajax_import_csv() |
| 1893 | 1893 | {
|
| 1894 | - error_reporting(0); // hide error to get clean json response |
|
| 1894 | + error_reporting(0); // hide error to get clean json response |
|
| 1895 | 1895 | |
| 1896 | - global $wpdb, $plugin_prefix, $current_user; |
|
| 1897 | - $uploads = wp_upload_dir(); |
|
| 1898 | - ini_set('auto_detect_line_endings', true);
|
|
| 1896 | + global $wpdb, $plugin_prefix, $current_user; |
|
| 1897 | + $uploads = wp_upload_dir(); |
|
| 1898 | + ini_set('auto_detect_line_endings', true);
|
|
| 1899 | 1899 | |
| 1900 | 1900 | $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
| 1901 | 1901 | |
| 1902 | - $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
| 1903 | - $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
| 1904 | - $filename = $uploadedFile; |
|
| 1905 | - |
|
| 1906 | - $uploads = wp_upload_dir(); |
|
| 1907 | - $uploads_dir = $uploads['path']; |
|
| 1908 | - $image_name_arr = explode('/', $filename);
|
|
| 1909 | - $filename = end($image_name_arr); |
|
| 1910 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1911 | - $return = array(); |
|
| 1912 | - $return['file'] = $uploadedFile; |
|
| 1913 | - $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
|
| 1914 | - |
|
| 1915 | - if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
|
|
| 1916 | - $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
| 1917 | - |
|
| 1918 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 1919 | - $return['error'] = NULL; |
|
| 1920 | - |
|
| 1921 | - $return['rows'] = 0; |
|
| 1922 | - |
|
| 1923 | - |
|
| 1924 | - |
|
| 1925 | - if (($handle = fopen($target_path, "r")) !== FALSE) {
|
|
| 1926 | - while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
|
|
| 1927 | - if(is_array($data) && !empty($data)) {
|
|
| 1928 | - $file[] = '"' . implode('","', $data) . '"';
|
|
| 1929 | - } |
|
| 1930 | - } |
|
| 1931 | - fclose($handle); |
|
| 1932 | - $file = $file; |
|
| 1933 | - } |
|
| 1934 | - |
|
| 1935 | - |
|
| 1936 | - |
|
| 1937 | - $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 1938 | - |
|
| 1939 | - |
|
| 1940 | - if (!$return['rows'] > 0) {
|
|
| 1941 | - $return['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 1942 | - } |
|
| 1943 | - } |
|
| 1944 | - } |
|
| 1945 | - if ($task == 'prepare' || !empty($return['error'])) {
|
|
| 1946 | - echo json_encode($return); |
|
| 1947 | - exit; |
|
| 1948 | - } |
|
| 1949 | - |
|
| 1950 | - $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
| 1951 | - $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
| 1952 | - $count = $importlimit; |
|
| 1953 | - $requested_limit = $importlimit; |
|
| 1954 | - $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
| 1955 | - |
|
| 1956 | - if ($count < $totRecords) {
|
|
| 1957 | - $count = $tmpCnt + $count; |
|
| 1958 | - if ($count > $totRecords) {
|
|
| 1959 | - $count = $totRecords; |
|
| 1960 | - } |
|
| 1961 | - } else {
|
|
| 1962 | - $count = $totRecords; |
|
| 1963 | - } |
|
| 1964 | - |
|
| 1965 | - $total_records = 0; |
|
| 1966 | - $rowcount = 0; |
|
| 1967 | - $address_invalid = 0; |
|
| 1968 | - $blank_address = 0; |
|
| 1969 | - $upload_files = 0; |
|
| 1970 | - $invalid_post_type = 0; |
|
| 1971 | - $invalid_title = 0; |
|
| 1972 | - $customKeyarray = array(); |
|
| 1973 | - $gd_post_info = array(); |
|
| 1974 | - $post_location = array(); |
|
| 1975 | - $countpost = 0; |
|
| 1976 | - |
|
| 1977 | - if (!empty($file)) {
|
|
| 1978 | - $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
| 1979 | - $customKeyarray = $columns; |
|
| 1980 | - |
|
| 1981 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 1982 | - $return['error'] = CSV_INVAILD_FILE; |
|
| 1983 | - echo json_encode($return); |
|
| 1984 | - exit; |
|
| 1985 | - } |
|
| 1986 | - |
|
| 1987 | - for ($i = 1; $i <= $importlimit; $i++) {
|
|
| 1988 | - $current_index = $tmpCnt + $i; |
|
| 1989 | - if (isset($file[$current_index])) {
|
|
| 1990 | - $total_records++; |
|
| 1991 | - |
|
| 1992 | - $buffer = geodir_str_getcsv($file[$current_index]); |
|
| 1993 | - $post_title = addslashes($buffer[0]); |
|
| 1994 | - $current_post_author = $buffer[1]; |
|
| 1995 | - $post_desc = addslashes($buffer[2]); |
|
| 1996 | - $post_cat = array(); |
|
| 1997 | - $catids_arr = array(); |
|
| 1998 | - $post_cat = trim($buffer[3]); // comma seperated category name |
|
| 1999 | - |
|
| 2000 | - if ($post_cat) {
|
|
| 2001 | - $post_cat_arr = explode(',', $post_cat);
|
|
| 2002 | - |
|
| 2003 | - for ($c = 0; $c < count($post_cat_arr); $c++) {
|
|
| 2004 | - $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
| 2005 | - |
|
| 2006 | - if (!empty($buffer[5])) {
|
|
| 2007 | - if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2008 | - |
|
| 2009 | - $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
| 2010 | - |
|
| 2011 | - if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 2012 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 2013 | - $catids_arr[] = $cat->slug; |
|
| 2014 | - } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 2015 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 2016 | - $catids_arr[] = $cat->slug; |
|
| 2017 | - } else {
|
|
| 2018 | - $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
| 2019 | - if ($ret && !is_wp_error($ret)) {
|
|
| 2020 | - if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 2021 | - $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 2022 | - $catids_arr[] = $cat->slug; |
|
| 2023 | - } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 2024 | - $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 2025 | - $catids_arr[] = $cat->slug; |
|
| 2026 | - } |
|
| 2027 | - } |
|
| 2028 | - } |
|
| 2029 | - } |
|
| 2030 | - } |
|
| 2031 | - } |
|
| 2032 | - } |
|
| 2033 | - |
|
| 2034 | - if (!$catids_arr) {
|
|
| 2035 | - $catids_arr[] = 1; |
|
| 2036 | - } |
|
| 2037 | - |
|
| 2038 | - $post_tags = trim($buffer[4]); // comma seperated tags |
|
| 2039 | - |
|
| 2040 | - $tag_arr = ''; |
|
| 2041 | - if ($post_tags) {
|
|
| 2042 | - $tag_arr = explode(',', $post_tags);
|
|
| 2043 | - } |
|
| 2044 | - |
|
| 2045 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
| 2046 | - |
|
| 2047 | - $error = ''; |
|
| 2048 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
|
|
| 2049 | - $invalid_post_type++; |
|
| 2050 | - continue; |
|
| 2051 | - } |
|
| 2052 | - |
|
| 2053 | - if ($post_title != '') {
|
|
| 2054 | - $menu_order = 0; |
|
| 2055 | - $image_folder_name = 'uplaod/'; |
|
| 2056 | - |
|
| 2057 | - $image_names = array(); |
|
| 2058 | - |
|
| 2059 | - for ($c = 5; $c < count($customKeyarray); $c++) {
|
|
| 2060 | - $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
| 2061 | - |
|
| 2062 | - if ($customKeyarray[$c] == 'IMAGE') {
|
|
| 2063 | - $buffer[$c] = trim($buffer[$c]); |
|
| 2064 | - |
|
| 2065 | - if (!empty($buffer[$c])) {
|
|
| 2066 | - $image_names[] = $buffer[$c]; |
|
| 2067 | - } |
|
| 2068 | - } |
|
| 2069 | - |
|
| 2070 | - if ($customKeyarray[$c] == 'alive_days') {
|
|
| 2071 | - if ($buffer[$c] != '0' && $buffer[$c] != '') {
|
|
| 2072 | - $submitdata = date('Y-m-d');
|
|
| 2073 | - |
|
| 2074 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
|
|
| 2075 | - } else {
|
|
| 2076 | - $gd_post_info['expire_date'] = 'Never'; |
|
| 2077 | - } |
|
| 2078 | - } |
|
| 2079 | - |
|
| 2080 | - if ($customKeyarray[$c] == 'post_city') {
|
|
| 2081 | - $post_city = addslashes($buffer[$c]); |
|
| 2082 | - } |
|
| 2083 | - |
|
| 2084 | - if ($customKeyarray[$c] == 'post_region') {
|
|
| 2085 | - $post_region = addslashes($buffer[$c]); |
|
| 2086 | - } |
|
| 2087 | - |
|
| 2088 | - if ($customKeyarray[$c] == 'post_country') {
|
|
| 2089 | - $post_country = addslashes($buffer[$c]); |
|
| 2090 | - } |
|
| 2091 | - |
|
| 2092 | - if ($customKeyarray[$c] == 'post_latitude') {
|
|
| 2093 | - $post_latitude = addslashes($buffer[$c]); |
|
| 2094 | - } |
|
| 2095 | - |
|
| 2096 | - if ($customKeyarray[$c] == 'post_longitude') {
|
|
| 2097 | - $post_longitude = addslashes($buffer[$c]); |
|
| 2098 | - } |
|
| 1902 | + $task = isset($_POST['task']) ? $_POST['task'] : ''; |
|
| 1903 | + $uploadedFile = isset($_POST['gddata']['uploadedFile']) ? $_POST['gddata']['uploadedFile'] : NULL; |
|
| 1904 | + $filename = $uploadedFile; |
|
| 1905 | + |
|
| 1906 | + $uploads = wp_upload_dir(); |
|
| 1907 | + $uploads_dir = $uploads['path']; |
|
| 1908 | + $image_name_arr = explode('/', $filename);
|
|
| 1909 | + $filename = end($image_name_arr); |
|
| 1910 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1911 | + $return = array(); |
|
| 1912 | + $return['file'] = $uploadedFile; |
|
| 1913 | + $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
|
| 1914 | + |
|
| 1915 | + if (is_file($target_path) && file_exists($target_path) && $uploadedFile) {
|
|
| 1916 | + $wp_filetype = wp_check_filetype_and_ext($target_path, $filename); |
|
| 1917 | + |
|
| 1918 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') {
|
|
| 1919 | + $return['error'] = NULL; |
|
| 1920 | + |
|
| 1921 | + $return['rows'] = 0; |
|
| 1922 | + |
|
| 1923 | + |
|
| 1924 | + |
|
| 1925 | + if (($handle = fopen($target_path, "r")) !== FALSE) {
|
|
| 1926 | + while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
|
|
| 1927 | + if(is_array($data) && !empty($data)) {
|
|
| 1928 | + $file[] = '"' . implode('","', $data) . '"';
|
|
| 1929 | + } |
|
| 1930 | + } |
|
| 1931 | + fclose($handle); |
|
| 1932 | + $file = $file; |
|
| 1933 | + } |
|
| 1934 | + |
|
| 1935 | + |
|
| 1936 | + |
|
| 1937 | + $return['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
| 1938 | + |
|
| 1939 | + |
|
| 1940 | + if (!$return['rows'] > 0) {
|
|
| 1941 | + $return['error'] = __('No data found in csv file.', 'geodirectory');
|
|
| 1942 | + } |
|
| 1943 | + } |
|
| 1944 | + } |
|
| 1945 | + if ($task == 'prepare' || !empty($return['error'])) {
|
|
| 1946 | + echo json_encode($return); |
|
| 1947 | + exit; |
|
| 1948 | + } |
|
| 1949 | + |
|
| 1950 | + $totRecords = isset($_POST['gddata']['totRecords']) ? $_POST['gddata']['totRecords'] : NULL; |
|
| 1951 | + $importlimit = isset($_POST['gddata']['importlimit']) ? $_POST['gddata']['importlimit'] : 1; |
|
| 1952 | + $count = $importlimit; |
|
| 1953 | + $requested_limit = $importlimit; |
|
| 1954 | + $tmpCnt = isset($_POST['gddata']['tmpcount']) ? $_POST['gddata']['tmpcount'] : 0; |
|
| 1955 | + |
|
| 1956 | + if ($count < $totRecords) {
|
|
| 1957 | + $count = $tmpCnt + $count; |
|
| 1958 | + if ($count > $totRecords) {
|
|
| 1959 | + $count = $totRecords; |
|
| 1960 | + } |
|
| 1961 | + } else {
|
|
| 1962 | + $count = $totRecords; |
|
| 1963 | + } |
|
| 1964 | + |
|
| 1965 | + $total_records = 0; |
|
| 1966 | + $rowcount = 0; |
|
| 1967 | + $address_invalid = 0; |
|
| 1968 | + $blank_address = 0; |
|
| 1969 | + $upload_files = 0; |
|
| 1970 | + $invalid_post_type = 0; |
|
| 1971 | + $invalid_title = 0; |
|
| 1972 | + $customKeyarray = array(); |
|
| 1973 | + $gd_post_info = array(); |
|
| 1974 | + $post_location = array(); |
|
| 1975 | + $countpost = 0; |
|
| 1976 | + |
|
| 1977 | + if (!empty($file)) {
|
|
| 1978 | + $columns = isset($file[0]) ? geodir_str_getcsv($file[0]) : NULL; |
|
| 1979 | + $customKeyarray = $columns; |
|
| 1980 | + |
|
| 1981 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) {
|
|
| 1982 | + $return['error'] = CSV_INVAILD_FILE; |
|
| 1983 | + echo json_encode($return); |
|
| 1984 | + exit; |
|
| 1985 | + } |
|
| 1986 | + |
|
| 1987 | + for ($i = 1; $i <= $importlimit; $i++) {
|
|
| 1988 | + $current_index = $tmpCnt + $i; |
|
| 1989 | + if (isset($file[$current_index])) {
|
|
| 1990 | + $total_records++; |
|
| 1991 | + |
|
| 1992 | + $buffer = geodir_str_getcsv($file[$current_index]); |
|
| 1993 | + $post_title = addslashes($buffer[0]); |
|
| 1994 | + $current_post_author = $buffer[1]; |
|
| 1995 | + $post_desc = addslashes($buffer[2]); |
|
| 1996 | + $post_cat = array(); |
|
| 1997 | + $catids_arr = array(); |
|
| 1998 | + $post_cat = trim($buffer[3]); // comma seperated category name |
|
| 1999 | + |
|
| 2000 | + if ($post_cat) {
|
|
| 2001 | + $post_cat_arr = explode(',', $post_cat);
|
|
| 2002 | + |
|
| 2003 | + for ($c = 0; $c < count($post_cat_arr); $c++) {
|
|
| 2004 | + $catid = wp_kses_normalize_entities(trim($post_cat_arr[$c])); |
|
| 2005 | + |
|
| 2006 | + if (!empty($buffer[5])) {
|
|
| 2007 | + if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2008 | + |
|
| 2009 | + $p_taxonomy = geodir_get_taxonomies(addslashes($buffer[5])); |
|
| 2010 | + |
|
| 2011 | + if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 2012 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 2013 | + $catids_arr[] = $cat->slug; |
|
| 2014 | + } else if (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 2015 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 2016 | + $catids_arr[] = $cat->slug; |
|
| 2017 | + } else {
|
|
| 2018 | + $ret = wp_insert_term($catid, $p_taxonomy[0]); |
|
| 2019 | + if ($ret && !is_wp_error($ret)) {
|
|
| 2020 | + if (get_term_by('name', $catid, $p_taxonomy[0])) {
|
|
| 2021 | + $cat = get_term_by('name', $catid, $p_taxonomy[0]);
|
|
| 2022 | + $catids_arr[] = $cat->slug; |
|
| 2023 | + } elseif (get_term_by('slug', $catid, $p_taxonomy[0])) {
|
|
| 2024 | + $cat = get_term_by('slug', $catid, $p_taxonomy[0]);
|
|
| 2025 | + $catids_arr[] = $cat->slug; |
|
| 2026 | + } |
|
| 2027 | + } |
|
| 2028 | + } |
|
| 2029 | + } |
|
| 2030 | + } |
|
| 2031 | + } |
|
| 2032 | + } |
|
| 2033 | + |
|
| 2034 | + if (!$catids_arr) {
|
|
| 2035 | + $catids_arr[] = 1; |
|
| 2036 | + } |
|
| 2037 | + |
|
| 2038 | + $post_tags = trim($buffer[4]); // comma seperated tags |
|
| 2039 | + |
|
| 2040 | + $tag_arr = ''; |
|
| 2041 | + if ($post_tags) {
|
|
| 2042 | + $tag_arr = explode(',', $post_tags);
|
|
| 2043 | + } |
|
| 2044 | + |
|
| 2045 | + $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
| 2046 | + |
|
| 2047 | + $error = ''; |
|
| 2048 | + if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
|
|
| 2049 | + $invalid_post_type++; |
|
| 2050 | + continue; |
|
| 2051 | + } |
|
| 2052 | + |
|
| 2053 | + if ($post_title != '') {
|
|
| 2054 | + $menu_order = 0; |
|
| 2055 | + $image_folder_name = 'uplaod/'; |
|
| 2056 | + |
|
| 2057 | + $image_names = array(); |
|
| 2058 | + |
|
| 2059 | + for ($c = 5; $c < count($customKeyarray); $c++) {
|
|
| 2060 | + $gd_post_info[$customKeyarray[$c]] = addslashes($buffer[$c]); |
|
| 2061 | + |
|
| 2062 | + if ($customKeyarray[$c] == 'IMAGE') {
|
|
| 2063 | + $buffer[$c] = trim($buffer[$c]); |
|
| 2064 | + |
|
| 2065 | + if (!empty($buffer[$c])) {
|
|
| 2066 | + $image_names[] = $buffer[$c]; |
|
| 2067 | + } |
|
| 2068 | + } |
|
| 2069 | + |
|
| 2070 | + if ($customKeyarray[$c] == 'alive_days') {
|
|
| 2071 | + if ($buffer[$c] != '0' && $buffer[$c] != '') {
|
|
| 2072 | + $submitdata = date('Y-m-d');
|
|
| 2073 | + |
|
| 2074 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
|
|
| 2075 | + } else {
|
|
| 2076 | + $gd_post_info['expire_date'] = 'Never'; |
|
| 2077 | + } |
|
| 2078 | + } |
|
| 2079 | + |
|
| 2080 | + if ($customKeyarray[$c] == 'post_city') {
|
|
| 2081 | + $post_city = addslashes($buffer[$c]); |
|
| 2082 | + } |
|
| 2083 | + |
|
| 2084 | + if ($customKeyarray[$c] == 'post_region') {
|
|
| 2085 | + $post_region = addslashes($buffer[$c]); |
|
| 2086 | + } |
|
| 2087 | + |
|
| 2088 | + if ($customKeyarray[$c] == 'post_country') {
|
|
| 2089 | + $post_country = addslashes($buffer[$c]); |
|
| 2090 | + } |
|
| 2091 | + |
|
| 2092 | + if ($customKeyarray[$c] == 'post_latitude') {
|
|
| 2093 | + $post_latitude = addslashes($buffer[$c]); |
|
| 2094 | + } |
|
| 2095 | + |
|
| 2096 | + if ($customKeyarray[$c] == 'post_longitude') {
|
|
| 2097 | + $post_longitude = addslashes($buffer[$c]); |
|
| 2098 | + } |
|
| 2099 | 2099 | |
| 2100 | 2100 | // Post status |
| 2101 | 2101 | if ($customKeyarray[$c] == 'post_status') {
|
| 2102 | - $post_status = sanitize_key( $buffer[$c] ); |
|
| 2103 | - } |
|
| 2104 | - } |
|
| 2105 | - |
|
| 2106 | - /* ================ before array create ============== */ |
|
| 2107 | - $location_result = geodir_get_default_location(); |
|
| 2108 | - if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
|
|
| 2109 | - $blank_address++; |
|
| 2110 | - continue; |
|
| 2111 | - } else if ($location_result->location_id == 0) {
|
|
| 2112 | - if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
|
|
| 2113 | - $address_invalid++; |
|
| 2114 | - continue; |
|
| 2115 | - } |
|
| 2116 | - } |
|
| 2102 | + $post_status = sanitize_key( $buffer[$c] ); |
|
| 2103 | + } |
|
| 2104 | + } |
|
| 2105 | + |
|
| 2106 | + /* ================ before array create ============== */ |
|
| 2107 | + $location_result = geodir_get_default_location(); |
|
| 2108 | + if ((!isset($gd_post_info['post_city']) || $gd_post_info['post_city'] == '') || (!isset($gd_post_info['post_region']) || $gd_post_info['post_region'] == '') || (!isset($gd_post_info['post_country']) || $gd_post_info['post_country'] == '') || (!isset($gd_post_info['post_address']) || $gd_post_info['post_address'] == '') || (!isset($gd_post_info['post_latitude']) || $gd_post_info['post_latitude'] == '') || (!isset($gd_post_info['post_longitude']) || $gd_post_info['post_longitude'] == '')) {
|
|
| 2109 | + $blank_address++; |
|
| 2110 | + continue; |
|
| 2111 | + } else if ($location_result->location_id == 0) {
|
|
| 2112 | + if ((geodir_strtolower($gd_post_info['post_city']) != geodir_strtolower($location_result->city)) || (geodir_strtolower($gd_post_info['post_region']) != geodir_strtolower($location_result->region)) || (geodir_strtolower($gd_post_info['post_country']) != geodir_strtolower($location_result->country))) {
|
|
| 2113 | + $address_invalid++; |
|
| 2114 | + continue; |
|
| 2115 | + } |
|
| 2116 | + } |
|
| 2117 | 2117 | |
| 2118 | 2118 | // Default post status |
| 2119 | 2119 | $default_status = 'publish'; |
| 2120 | 2120 | $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
| 2121 | 2121 | $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
| 2122 | 2122 | |
| 2123 | - $my_post['post_title'] = $post_title; |
|
| 2124 | - $my_post['post_content'] = $post_desc; |
|
| 2125 | - $my_post['post_type'] = addslashes($buffer[5]); |
|
| 2126 | - $my_post['post_author'] = $current_post_author; |
|
| 2127 | - $my_post['post_status'] = $post_status; |
|
| 2128 | - $my_post['post_category'] = $catids_arr; |
|
| 2129 | - $my_post['post_tags'] = $tag_arr; |
|
| 2130 | - |
|
| 2131 | - $gd_post_info['post_tags'] = $tag_arr; |
|
| 2132 | - $gd_post_info['post_title'] = $post_title; |
|
| 2133 | - $gd_post_info['post_status'] = $post_status; |
|
| 2134 | - $gd_post_info['submit_time'] = time(); |
|
| 2135 | - $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 2136 | - |
|
| 2137 | - $last_postid = wp_insert_post($my_post); |
|
| 2138 | - $countpost++; |
|
| 2139 | - |
|
| 2140 | - // Check if we need to save post location as new location |
|
| 2141 | - if ($location_result->location_id > 0) {
|
|
| 2142 | - if (isset($post_city) && isset($post_region)) {
|
|
| 2143 | - $request_info['post_location'] = array( |
|
| 2144 | - 'city' => $post_city, |
|
| 2145 | - 'region' => $post_region, |
|
| 2146 | - 'country' => $post_country, |
|
| 2147 | - 'geo_lat' => $post_latitude, |
|
| 2148 | - 'geo_lng' => $post_longitude |
|
| 2149 | - ); |
|
| 2150 | - |
|
| 2151 | - $post_location_info = $request_info['post_location']; |
|
| 2152 | - if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 2153 | - $post_location_id = $location_id; |
|
| 2154 | - } else {
|
|
| 2155 | - $post_location_id = 0; |
|
| 2156 | - } |
|
| 2157 | - } else {
|
|
| 2158 | - $post_location_id = 0; |
|
| 2159 | - } |
|
| 2160 | - |
|
| 2161 | - /* ------- get default package info ----- */ |
|
| 2162 | - $payment_info = array(); |
|
| 2163 | - $package_info = array(); |
|
| 2164 | - |
|
| 2165 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2166 | - $package_id = ''; |
|
| 2167 | - if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
|
| 2168 | - $package_id = $gd_post_info['package_id']; |
|
| 2169 | - } |
|
| 2170 | - |
|
| 2171 | - if (!empty($package_info)) {
|
|
| 2172 | - $payment_info['package_id'] = $package_info['pid']; |
|
| 2173 | - |
|
| 2174 | - if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
|
|
| 2175 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
|
|
| 2176 | - } else {
|
|
| 2177 | - $payment_info['expire_date'] = 'Never'; |
|
| 2178 | - } |
|
| 2179 | - |
|
| 2180 | - $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 2181 | - } |
|
| 2182 | - |
|
| 2183 | - $gd_post_info['post_location_id'] = $post_location_id; |
|
| 2184 | - |
|
| 2185 | - $post_type = get_post_type($last_postid); |
|
| 2186 | - |
|
| 2187 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2188 | - |
|
| 2189 | - geodir_save_post_info($last_postid, $gd_post_info); |
|
| 2190 | - |
|
| 2191 | - if (!empty($image_names)) {
|
|
| 2192 | - $upload_files++; |
|
| 2193 | - $menu_order = 1; |
|
| 2194 | - |
|
| 2195 | - foreach ($image_names as $image_name) {
|
|
| 2196 | - $img_name_arr = explode('.', $image_name);
|
|
| 2197 | - |
|
| 2198 | - $uploads = wp_upload_dir(); |
|
| 2199 | - $sub_dir = $uploads['subdir']; |
|
| 2200 | - |
|
| 2201 | - $arr_file_type = wp_check_filetype($image_name); |
|
| 2202 | - $uploaded_file_type = $arr_file_type['type']; |
|
| 2203 | - |
|
| 2204 | - $attachment = array(); |
|
| 2205 | - $attachment['post_id'] = $last_postid; |
|
| 2206 | - $attachment['title'] = $img_name_arr[0]; |
|
| 2207 | - $attachment['content'] = ''; |
|
| 2208 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
| 2209 | - $attachment['mime_type'] = $uploaded_file_type; |
|
| 2210 | - $attachment['menu_order'] = $menu_order; |
|
| 2211 | - $attachment['is_featured'] = 0; |
|
| 2212 | - |
|
| 2213 | - $attachment_set = ''; |
|
| 2214 | - |
|
| 2215 | - foreach ($attachment as $key => $val) {
|
|
| 2216 | - if ($val != '') |
|
| 2217 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2218 | - } |
|
| 2219 | - $attachment_set = trim($attachment_set, ", "); |
|
| 2220 | - |
|
| 2221 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 2222 | - |
|
| 2223 | - if ($menu_order == 1) {
|
|
| 2224 | - $post_type = get_post_type($last_postid); |
|
| 2225 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
|
|
| 2226 | - } |
|
| 2227 | - $menu_order++; |
|
| 2228 | - } |
|
| 2229 | - } |
|
| 2230 | - |
|
| 2231 | - $gd_post_info['package_id'] = $package_id; |
|
| 2232 | - |
|
| 2233 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 2234 | - do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
|
|
| 2235 | - |
|
| 2236 | - if (!empty($buffer[5])) {
|
|
| 2237 | - if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2238 | - $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
| 2239 | - wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
| 2240 | - wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
| 2241 | - |
|
| 2242 | - $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
| 2243 | - $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
| 2244 | - geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
| 2245 | - } |
|
| 2246 | - } |
|
| 2247 | - } else {
|
|
| 2248 | - $invalid_title++; |
|
| 2249 | - } |
|
| 2250 | - } |
|
| 2251 | - } |
|
| 2252 | - } |
|
| 2253 | - $return['rowcount'] = $countpost; |
|
| 2254 | - $return['invalidcount'] = $address_invalid; |
|
| 2255 | - $return['blank_address'] = $blank_address; |
|
| 2256 | - $return['upload_files'] = $upload_files; |
|
| 2257 | - $return['invalid_post_type'] = $invalid_post_type; |
|
| 2258 | - $return['invalid_title'] = $invalid_title; |
|
| 2259 | - $return['total_records'] = $total_records; |
|
| 2260 | - |
|
| 2261 | - echo json_encode($return); |
|
| 2262 | - exit; |
|
| 2123 | + $my_post['post_title'] = $post_title; |
|
| 2124 | + $my_post['post_content'] = $post_desc; |
|
| 2125 | + $my_post['post_type'] = addslashes($buffer[5]); |
|
| 2126 | + $my_post['post_author'] = $current_post_author; |
|
| 2127 | + $my_post['post_status'] = $post_status; |
|
| 2128 | + $my_post['post_category'] = $catids_arr; |
|
| 2129 | + $my_post['post_tags'] = $tag_arr; |
|
| 2130 | + |
|
| 2131 | + $gd_post_info['post_tags'] = $tag_arr; |
|
| 2132 | + $gd_post_info['post_title'] = $post_title; |
|
| 2133 | + $gd_post_info['post_status'] = $post_status; |
|
| 2134 | + $gd_post_info['submit_time'] = time(); |
|
| 2135 | + $gd_post_info['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
| 2136 | + |
|
| 2137 | + $last_postid = wp_insert_post($my_post); |
|
| 2138 | + $countpost++; |
|
| 2139 | + |
|
| 2140 | + // Check if we need to save post location as new location |
|
| 2141 | + if ($location_result->location_id > 0) {
|
|
| 2142 | + if (isset($post_city) && isset($post_region)) {
|
|
| 2143 | + $request_info['post_location'] = array( |
|
| 2144 | + 'city' => $post_city, |
|
| 2145 | + 'region' => $post_region, |
|
| 2146 | + 'country' => $post_country, |
|
| 2147 | + 'geo_lat' => $post_latitude, |
|
| 2148 | + 'geo_lng' => $post_longitude |
|
| 2149 | + ); |
|
| 2150 | + |
|
| 2151 | + $post_location_info = $request_info['post_location']; |
|
| 2152 | + if ($location_id = geodir_add_new_location($post_location_info)) |
|
| 2153 | + $post_location_id = $location_id; |
|
| 2154 | + } else {
|
|
| 2155 | + $post_location_id = 0; |
|
| 2156 | + } |
|
| 2157 | + } else {
|
|
| 2158 | + $post_location_id = 0; |
|
| 2159 | + } |
|
| 2160 | + |
|
| 2161 | + /* ------- get default package info ----- */ |
|
| 2162 | + $payment_info = array(); |
|
| 2163 | + $package_info = array(); |
|
| 2164 | + |
|
| 2165 | + $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2166 | + $package_id = ''; |
|
| 2167 | + if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
|
| 2168 | + $package_id = $gd_post_info['package_id']; |
|
| 2169 | + } |
|
| 2170 | + |
|
| 2171 | + if (!empty($package_info)) {
|
|
| 2172 | + $payment_info['package_id'] = $package_info['pid']; |
|
| 2173 | + |
|
| 2174 | + if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
|
|
| 2175 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
|
|
| 2176 | + } else {
|
|
| 2177 | + $payment_info['expire_date'] = 'Never'; |
|
| 2178 | + } |
|
| 2179 | + |
|
| 2180 | + $gd_post_info = array_merge($gd_post_info, $payment_info); |
|
| 2181 | + } |
|
| 2182 | + |
|
| 2183 | + $gd_post_info['post_location_id'] = $post_location_id; |
|
| 2184 | + |
|
| 2185 | + $post_type = get_post_type($last_postid); |
|
| 2186 | + |
|
| 2187 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2188 | + |
|
| 2189 | + geodir_save_post_info($last_postid, $gd_post_info); |
|
| 2190 | + |
|
| 2191 | + if (!empty($image_names)) {
|
|
| 2192 | + $upload_files++; |
|
| 2193 | + $menu_order = 1; |
|
| 2194 | + |
|
| 2195 | + foreach ($image_names as $image_name) {
|
|
| 2196 | + $img_name_arr = explode('.', $image_name);
|
|
| 2197 | + |
|
| 2198 | + $uploads = wp_upload_dir(); |
|
| 2199 | + $sub_dir = $uploads['subdir']; |
|
| 2200 | + |
|
| 2201 | + $arr_file_type = wp_check_filetype($image_name); |
|
| 2202 | + $uploaded_file_type = $arr_file_type['type']; |
|
| 2203 | + |
|
| 2204 | + $attachment = array(); |
|
| 2205 | + $attachment['post_id'] = $last_postid; |
|
| 2206 | + $attachment['title'] = $img_name_arr[0]; |
|
| 2207 | + $attachment['content'] = ''; |
|
| 2208 | + $attachment['file'] = $sub_dir . '/' . $image_name; |
|
| 2209 | + $attachment['mime_type'] = $uploaded_file_type; |
|
| 2210 | + $attachment['menu_order'] = $menu_order; |
|
| 2211 | + $attachment['is_featured'] = 0; |
|
| 2212 | + |
|
| 2213 | + $attachment_set = ''; |
|
| 2214 | + |
|
| 2215 | + foreach ($attachment as $key => $val) {
|
|
| 2216 | + if ($val != '') |
|
| 2217 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2218 | + } |
|
| 2219 | + $attachment_set = trim($attachment_set, ", "); |
|
| 2220 | + |
|
| 2221 | + $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 2222 | + |
|
| 2223 | + if ($menu_order == 1) {
|
|
| 2224 | + $post_type = get_post_type($last_postid); |
|
| 2225 | + $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
|
|
| 2226 | + } |
|
| 2227 | + $menu_order++; |
|
| 2228 | + } |
|
| 2229 | + } |
|
| 2230 | + |
|
| 2231 | + $gd_post_info['package_id'] = $package_id; |
|
| 2232 | + |
|
| 2233 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
| 2234 | + do_action('geodir_after_save_listing', $last_postid, $gd_post_info);
|
|
| 2235 | + |
|
| 2236 | + if (!empty($buffer[5])) {
|
|
| 2237 | + if (in_array($buffer[5], geodir_get_posttypes())) {
|
|
| 2238 | + $taxonomies = geodir_get_posttype_info(addslashes($buffer[5])); |
|
| 2239 | + wp_set_object_terms($last_postid, $my_post['post_tags'], $taxonomy = $taxonomies['taxonomies'][1]); |
|
| 2240 | + wp_set_object_terms($last_postid, $my_post['post_category'], $taxonomy = $taxonomies['taxonomies'][0]); |
|
| 2241 | + |
|
| 2242 | + $post_default_category = isset($my_post['post_default_category']) ? $my_post['post_default_category'] : ''; |
|
| 2243 | + $post_category_str = isset($my_post['post_category_str']) ? $my_post['post_category_str'] : ''; |
|
| 2244 | + geodir_set_postcat_structure($last_postid, $taxonomy, $post_default_category, $post_category_str); |
|
| 2245 | + } |
|
| 2246 | + } |
|
| 2247 | + } else {
|
|
| 2248 | + $invalid_title++; |
|
| 2249 | + } |
|
| 2250 | + } |
|
| 2251 | + } |
|
| 2252 | + } |
|
| 2253 | + $return['rowcount'] = $countpost; |
|
| 2254 | + $return['invalidcount'] = $address_invalid; |
|
| 2255 | + $return['blank_address'] = $blank_address; |
|
| 2256 | + $return['upload_files'] = $upload_files; |
|
| 2257 | + $return['invalid_post_type'] = $invalid_post_type; |
|
| 2258 | + $return['invalid_title'] = $invalid_title; |
|
| 2259 | + $return['total_records'] = $total_records; |
|
| 2260 | + |
|
| 2261 | + echo json_encode($return); |
|
| 2262 | + exit; |
|
| 2263 | 2263 | } |
| 2264 | 2264 | |
| 2265 | 2265 | // Add the tab in left sidebar menu fro import & export page. |
@@ -2279,9 +2279,9 @@ discard block |
||
| 2279 | 2279 | * @param $post object $post The post object of the post being saved. |
| 2280 | 2280 | */ |
| 2281 | 2281 | function geodir_update_location_prefix($post_id,$post){
|
| 2282 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
|
|
| 2283 | - update_option('geodir_location_prefix',$post->post_name);
|
|
| 2284 | - } |
|
| 2282 | + if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
|
|
| 2283 | + update_option('geodir_location_prefix',$post->post_name);
|
|
| 2284 | + } |
|
| 2285 | 2285 | |
| 2286 | 2286 | } |
| 2287 | 2287 | |
@@ -2292,50 +2292,50 @@ discard block |
||
| 2292 | 2292 | function geodir_ga_callback(){
|
| 2293 | 2293 | |
| 2294 | 2294 | if(isset($_REQUEST['code']) && $_REQUEST['code']) {
|
| 2295 | - $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
| 2296 | - $code = "code=".$_REQUEST['code']; |
|
| 2297 | - $grant_type = "&grant_type=authorization_code"; |
|
| 2298 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 2299 | - $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2300 | - $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
|
|
| 2295 | + $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
|
| 2296 | + $code = "code=".$_REQUEST['code']; |
|
| 2297 | + $grant_type = "&grant_type=authorization_code"; |
|
| 2298 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 2299 | + $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
|
| 2300 | + $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
|
|
| 2301 | 2301 | |
| 2302 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
| 2302 | + $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
| 2303 | 2303 | |
| 2304 | - $response = wp_remote_post($auth_url, array('timeout' => 15));
|
|
| 2304 | + $response = wp_remote_post($auth_url, array('timeout' => 15));
|
|
| 2305 | 2305 | |
| 2306 | - //print_r($response); |
|
| 2306 | + //print_r($response); |
|
| 2307 | 2307 | |
| 2308 | - $error_msg = __('Something went wrong','geodirectory');
|
|
| 2309 | - if(!empty($response['response']['code']) && $response['response']['code']==200){
|
|
| 2308 | + $error_msg = __('Something went wrong','geodirectory');
|
|
| 2309 | + if(!empty($response['response']['code']) && $response['response']['code']==200){
|
|
| 2310 | 2310 | |
| 2311 | - $parts = json_decode($response['body']); |
|
| 2312 | - //print_r($parts); |
|
| 2313 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
|
|
| 2314 | - else{
|
|
| 2311 | + $parts = json_decode($response['body']); |
|
| 2312 | + //print_r($parts); |
|
| 2313 | + if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
|
|
| 2314 | + else{
|
|
| 2315 | 2315 | |
| 2316 | - update_option('gd_ga_access_token', $parts->access_token);
|
|
| 2317 | - update_option('gd_ga_refresh_token', $parts->refresh_token);
|
|
| 2318 | - ?><script>window.close();</script><?php |
|
| 2319 | - } |
|
| 2316 | + update_option('gd_ga_access_token', $parts->access_token);
|
|
| 2317 | + update_option('gd_ga_refresh_token', $parts->refresh_token);
|
|
| 2318 | + ?><script>window.close();</script><?php |
|
| 2319 | + } |
|
| 2320 | 2320 | |
| 2321 | 2321 | |
| 2322 | - } |
|
| 2323 | - elseif(!empty($response['response']['code'])) {
|
|
| 2324 | - $parts = json_decode($response['body']); |
|
| 2322 | + } |
|
| 2323 | + elseif(!empty($response['response']['code'])) {
|
|
| 2324 | + $parts = json_decode($response['body']); |
|
| 2325 | 2325 | |
| 2326 | - if(isset($parts->error)){
|
|
| 2327 | - echo $parts->error.": ".$parts->error_description;exit; |
|
| 2328 | - }else{
|
|
| 2329 | - echo $error_msg." - #2";exit; |
|
| 2330 | - } |
|
| 2326 | + if(isset($parts->error)){
|
|
| 2327 | + echo $parts->error.": ".$parts->error_description;exit; |
|
| 2328 | + }else{
|
|
| 2329 | + echo $error_msg." - #2";exit; |
|
| 2330 | + } |
|
| 2331 | 2331 | |
| 2332 | - }else{
|
|
| 2332 | + }else{
|
|
| 2333 | 2333 | |
| 2334 | - echo $error_msg." - #3";exit; |
|
| 2334 | + echo $error_msg." - #3";exit; |
|
| 2335 | 2335 | |
| 2336 | - } |
|
| 2336 | + } |
|
| 2337 | 2337 | } |
| 2338 | - exit; |
|
| 2338 | + exit; |
|
| 2339 | 2339 | } |
| 2340 | 2340 | |
| 2341 | 2341 | if (isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') {
|
@@ -2351,45 +2351,45 @@ discard block |
||
| 2351 | 2351 | * @return array Array of settings. |
| 2352 | 2352 | */ |
| 2353 | 2353 | function geodir_uninstall_settings($general_settings) {
|
| 2354 | - $settings = array(); |
|
| 2355 | - $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
|
|
| 2356 | - $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
|
|
| 2354 | + $settings = array(); |
|
| 2355 | + $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
|
|
| 2356 | + $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
|
|
| 2357 | 2357 | |
| 2358 | - $plugins = get_plugins(); |
|
| 2359 | - $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
|
|
| 2358 | + $plugins = get_plugins(); |
|
| 2359 | + $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
|
|
| 2360 | 2360 | |
| 2361 | - if (!empty($plugins) && !empty($un_plugins)) {
|
|
| 2362 | - foreach ($plugins as $plugin => $data) {
|
|
| 2363 | - $plugin_name = plugin_basename(dirname($plugin)); |
|
| 2361 | + if (!empty($plugins) && !empty($un_plugins)) {
|
|
| 2362 | + foreach ($plugins as $plugin => $data) {
|
|
| 2363 | + $plugin_name = plugin_basename(dirname($plugin)); |
|
| 2364 | 2364 | |
| 2365 | - if (in_array($plugin_name, $un_plugins)) {
|
|
| 2366 | - $settings[] = array( |
|
| 2367 | - 'type' => 'checkbox', |
|
| 2368 | - 'id' => 'geodir_un_' . $plugin_name, |
|
| 2369 | - 'name' => $data['Name'], |
|
| 2370 | - 'desc' => __('Remove all data when deleted?', 'geodirectory'),
|
|
| 2371 | - 'std' => '0' |
|
| 2372 | - ); |
|
| 2373 | - } |
|
| 2374 | - } |
|
| 2375 | - } |
|
| 2365 | + if (in_array($plugin_name, $un_plugins)) {
|
|
| 2366 | + $settings[] = array( |
|
| 2367 | + 'type' => 'checkbox', |
|
| 2368 | + 'id' => 'geodir_un_' . $plugin_name, |
|
| 2369 | + 'name' => $data['Name'], |
|
| 2370 | + 'desc' => __('Remove all data when deleted?', 'geodirectory'),
|
|
| 2371 | + 'std' => '0' |
|
| 2372 | + ); |
|
| 2373 | + } |
|
| 2374 | + } |
|
| 2375 | + } |
|
| 2376 | 2376 | |
| 2377 | - $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
|
|
| 2377 | + $settings[] = array('type' => 'sectionend', 'id' => 'uninstall_settings_main');
|
|
| 2378 | 2378 | |
| 2379 | - /** |
|
| 2380 | - * Filter the uninstall settings array. |
|
| 2381 | - * |
|
| 2382 | - * @since 1.6.9 |
|
| 2383 | - * |
|
| 2384 | - * @param array $settings The settings array. |
|
| 2385 | - */ |
|
| 2386 | - $settings = apply_filters('geodir_uninstall_settings', $settings);
|
|
| 2379 | + /** |
|
| 2380 | + * Filter the uninstall settings array. |
|
| 2381 | + * |
|
| 2382 | + * @since 1.6.9 |
|
| 2383 | + * |
|
| 2384 | + * @param array $settings The settings array. |
|
| 2385 | + */ |
|
| 2386 | + $settings = apply_filters('geodir_uninstall_settings', $settings);
|
|
| 2387 | 2387 | |
| 2388 | - if (!empty($settings) && count($settings) > 3) {
|
|
| 2389 | - return array_merge($general_settings, $settings); |
|
| 2390 | - } |
|
| 2388 | + if (!empty($settings) && count($settings) > 3) {
|
|
| 2389 | + return array_merge($general_settings, $settings); |
|
| 2390 | + } |
|
| 2391 | 2391 | |
| 2392 | - return $general_settings; |
|
| 2392 | + return $general_settings; |
|
| 2393 | 2393 | } |
| 2394 | 2394 | add_filter('geodir_general_settings', 'geodir_uninstall_settings', 100, 1);
|
| 2395 | 2395 | |
@@ -2399,7 +2399,7 @@ discard block |
||
| 2399 | 2399 | * @since 1.6.9 |
| 2400 | 2400 | */ |
| 2401 | 2401 | function geodir_uninstall_settings_desc() {
|
| 2402 | - echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
|
|
| 2402 | + echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
|
|
| 2403 | 2403 | } |
| 2404 | 2404 | add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
|
| 2405 | 2405 | |
@@ -2415,18 +2415,18 @@ discard block |
||
| 2415 | 2415 | * @return array The settings array. |
| 2416 | 2416 | */ |
| 2417 | 2417 | function geodir_resave_settings($settings = array()) {
|
| 2418 | - if (!empty($settings) && is_array($settings)) {
|
|
| 2419 | - $c = 0; |
|
| 2418 | + if (!empty($settings) && is_array($settings)) {
|
|
| 2419 | + $c = 0; |
|
| 2420 | 2420 | |
| 2421 | - foreach ($settings as $setting) {
|
|
| 2422 | - if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
|
|
| 2423 | - $settings[$c]['std'] = $value; |
|
| 2424 | - } |
|
| 2425 | - $c++; |
|
| 2426 | - } |
|
| 2427 | - } |
|
| 2428 | - |
|
| 2429 | - return $settings; |
|
| 2421 | + foreach ($settings as $setting) {
|
|
| 2422 | + if (!empty($setting['id']) && false !== ($value = get_option($setting['id']))) {
|
|
| 2423 | + $settings[$c]['std'] = $value; |
|
| 2424 | + } |
|
| 2425 | + $c++; |
|
| 2426 | + } |
|
| 2427 | + } |
|
| 2428 | + |
|
| 2429 | + return $settings; |
|
| 2430 | 2430 | } |
| 2431 | 2431 | |
| 2432 | 2432 | /** |
@@ -2438,8 +2438,8 @@ discard block |
||
| 2438 | 2438 | * @return array The modified settings. |
| 2439 | 2439 | */ |
| 2440 | 2440 | function geodir_core_uninstall_settings($settings) {
|
| 2441 | - $settings[] = plugin_basename(dirname(dirname(__FILE__))); |
|
| 2441 | + $settings[] = plugin_basename(dirname(dirname(__FILE__))); |
|
| 2442 | 2442 | |
| 2443 | - return $settings; |
|
| 2443 | + return $settings; |
|
| 2444 | 2444 | } |
| 2445 | 2445 | add_filter('geodir_plugins_uninstall_settings', 'geodir_core_uninstall_settings', 10, 1); |
| 2446 | 2446 | \ No newline at end of file |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | */ |
| 63 | 63 | function geodir_get_admin_option_form($current_tab) |
| 64 | 64 | {
|
| 65 | - geodir_admin_option_form($current_tab);// defined in admin template tags.php |
|
| 65 | + geodir_admin_option_form($current_tab); // defined in admin template tags.php |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | add_action('geodir_update_options_compatibility_settings', 'geodir_update_options_compatibility_settings');
|
| 71 | 71 | add_action('geodir_update_options_default_location_settings', 'geodir_location_form_submit');
|
| 72 | 72 | add_action('geodir_before_admin_panel', 'geodir_before_admin_panel'); // this function is in admin_functions.php
|
| 73 | -add_action('geodir_before_update_options', 'geodir_before_update_options',10,2);
|
|
| 73 | +add_action('geodir_before_update_options', 'geodir_before_update_options', 10, 2);
|
|
| 74 | 74 | |
| 75 | 75 | //add_action('geodir_before_admin_panel', 'geodir_autoinstall_admin_header');
|
| 76 | 76 | |
@@ -99,7 +99,7 @@ discard block |
||
| 99 | 99 | |
| 100 | 100 | // Disable VC editor for GD post types. |
| 101 | 101 | if (class_exists('Vc_Role_Access_Controller')) {
|
| 102 | - add_filter( 'vc_role_access_with_post_types_can', '__return_false', 100 ); |
|
| 102 | + add_filter('vc_role_access_with_post_types_can', '__return_false', 100);
|
|
| 103 | 103 | } |
| 104 | 104 | } |
| 105 | 105 | |
@@ -126,8 +126,8 @@ discard block |
||
| 126 | 126 | add_action('admin_panel_init', 'geodir_admin_list_columns', 2);
|
| 127 | 127 | |
| 128 | 128 | /* --- insert dummy post action ---*/ |
| 129 | -add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1,3);
|
|
| 130 | -add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1,3);
|
|
| 129 | +add_action('geodir_insert_dummy_posts', 'geodir_insert_dummy_posts', 1, 3);
|
|
| 130 | +add_action('geodir_delete_dummy_posts', 'geodir_delete_dummy_posts', 1, 3);
|
|
| 131 | 131 | |
| 132 | 132 | |
| 133 | 133 | /** |
@@ -236,9 +236,9 @@ discard block |
||
| 236 | 236 | |
| 237 | 237 | // Filter-Payment-Manager |
| 238 | 238 | |
| 239 | - add_meta_box('geodir_post_images', $post_typename . ' ' . __('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
|
|
| 239 | + add_meta_box('geodir_post_images', $post_typename.' '.__('Attachments', 'geodirectory'), 'geodir_post_attachments', $geodir_posttype, 'side');
|
|
| 240 | 240 | |
| 241 | - add_meta_box('geodir_post_info', $post_typename . ' ' . __('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
|
|
| 241 | + add_meta_box('geodir_post_info', $post_typename.' '.__('Information', 'geodirectory'), 'geodir_post_info_setting', $geodir_posttype, 'normal', 'high');
|
|
| 242 | 242 | |
| 243 | 243 | // no need of this box as all fields moved to main information box |
| 244 | 244 | //add_meta_box( 'geodir_post_addinfo', $post_typename. ' ' .__('Additional Information' , 'geodirectory'), 'geodir_post_addinfo_setting', $geodir_posttype,'normal', 'high' );
|
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | -add_action('save_post', 'geodir_post_information_save',10,2);
|
|
| 250 | +add_action('save_post', 'geodir_post_information_save', 10, 2);
|
|
| 251 | 251 | |
| 252 | 252 | |
| 253 | 253 | |
@@ -274,10 +274,10 @@ discard block |
||
| 274 | 274 | |
| 275 | 275 | $gd_taxonomy = geodir_get_taxonomies($geodir_post_type); |
| 276 | 276 | |
| 277 | - if(!empty($gd_taxonomy)) {
|
|
| 277 | + if (!empty($gd_taxonomy)) {
|
|
| 278 | 278 | foreach ($gd_taxonomy as $tax) {
|
| 279 | 279 | |
| 280 | - remove_meta_box($tax . 'div', $geodir_post_type, 'normal'); |
|
| 280 | + remove_meta_box($tax.'div', $geodir_post_type, 'normal'); |
|
| 281 | 281 | |
| 282 | 282 | } |
| 283 | 283 | } |
@@ -363,14 +363,14 @@ discard block |
||
| 363 | 363 | add_action('geodir_manage_available_fields_predefined', 'geodir_manage_available_fields_predefined');
|
| 364 | 364 | add_action('geodir_manage_available_fields_custom', 'geodir_manage_available_fields_custom');
|
| 365 | 365 | |
| 366 | -function geodir_manage_available_fields_predefined($sub_tab){
|
|
| 367 | - if($sub_tab=='custom_fields'){
|
|
| 366 | +function geodir_manage_available_fields_predefined($sub_tab) {
|
|
| 367 | + if ($sub_tab == 'custom_fields') {
|
|
| 368 | 368 | geodir_custom_available_fields('predefined');
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | -function geodir_manage_available_fields_custom($sub_tab){
|
|
| 373 | - if($sub_tab=='custom_fields'){
|
|
| 372 | +function geodir_manage_available_fields_custom($sub_tab) {
|
|
| 373 | + if ($sub_tab == 'custom_fields') {
|
|
| 374 | 374 | geodir_custom_available_fields('custom');
|
| 375 | 375 | } |
| 376 | 376 | } |
@@ -440,7 +440,7 @@ discard block |
||
| 440 | 440 | global $wpdb; |
| 441 | 441 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
| 442 | 442 | ?> |
| 443 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
| 443 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
| 444 | 444 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>"/> |
| 445 | 445 | <ul> |
| 446 | 446 | <?php |
@@ -451,7 +451,7 @@ discard block |
||
| 451 | 451 | |
| 452 | 452 | $check_html_variable = $wpdb->get_var( |
| 453 | 453 | $wpdb->prepare( |
| 454 | - "SELECT htmlvar_name FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
| 454 | + "SELECT htmlvar_name FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE htmlvar_name = %s AND post_type = %s AND field_type=%s", |
|
| 455 | 455 | array($val['htmlvar_name'], $listing_type, $val['field_type']) |
| 456 | 456 | ) |
| 457 | 457 | ); |
@@ -459,23 +459,23 @@ discard block |
||
| 459 | 459 | $display = $check_html_variable ? ' style="display:none;"' : ''; |
| 460 | 460 | ?> |
| 461 | 461 | |
| 462 | - <li class="gd-cf-tooltip-wrap" <?php echo $display;?>> |
|
| 462 | + <li class="gd-cf-tooltip-wrap" <?php echo $display; ?>> |
|
| 463 | 463 | <?php |
| 464 | - if(isset($val['description']) && $val['description']){
|
|
| 464 | + if (isset($val['description']) && $val['description']) {
|
|
| 465 | 465 | echo '<div class="gdcf-tooltip">'.$val['description'].'</div>'; |
| 466 | 466 | }?> |
| 467 | 467 | |
| 468 | - <a id="gd-<?php echo $val['field_type'];?>-_-<?php echo $val['htmlvar_name'];?>" data-field-type-key="<?php echo $val['htmlvar_name'];?>" data-field-type="<?php echo $val['field_type'];?>" |
|
| 469 | - title="<?php echo $val['site_title'];?>" |
|
| 470 | - class="gd-draggable-form-items gd-<?php echo $val['field_type'];?> geodir-sort-<?php echo $val['htmlvar_name'];?>" href="javascript:void(0);"> |
|
| 468 | + <a id="gd-<?php echo $val['field_type']; ?>-_-<?php echo $val['htmlvar_name']; ?>" data-field-type-key="<?php echo $val['htmlvar_name']; ?>" data-field-type="<?php echo $val['field_type']; ?>" |
|
| 469 | + title="<?php echo $val['site_title']; ?>" |
|
| 470 | + class="gd-draggable-form-items gd-<?php echo $val['field_type']; ?> geodir-sort-<?php echo $val['htmlvar_name']; ?>" href="javascript:void(0);"> |
|
| 471 | 471 | <?php if (isset($val['field_icon']) && strpos($val['field_icon'], 'fa fa-') !== false) {
|
| 472 | 472 | echo '<i class="'.$val['field_icon'].'" aria-hidden="true"></i>'; |
| 473 | - }elseif(isset($val['field_icon']) && $val['field_icon'] ){
|
|
| 473 | + }elseif (isset($val['field_icon']) && $val['field_icon']) {
|
|
| 474 | 474 | echo '<b style="background-image: url("'.$val['field_icon'].'")"></b>';
|
| 475 | - }else{
|
|
| 475 | + } else {
|
|
| 476 | 476 | echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
| 477 | 477 | }?> |
| 478 | - <?php echo $val['site_title'];?> |
|
| 478 | + <?php echo $val['site_title']; ?> |
|
| 479 | 479 | </a> |
| 480 | 480 | </li> |
| 481 | 481 | |
@@ -503,7 +503,7 @@ discard block |
||
| 503 | 503 | <?php |
| 504 | 504 | global $wpdb; |
| 505 | 505 | |
| 506 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_SORT_FIELDS_TABLE . " WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
|
|
| 506 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_SORT_FIELDS_TABLE." WHERE post_type = %s AND field_type != 'address' ORDER BY sort_order ASC", array($listing_type)));
|
|
| 507 | 507 | |
| 508 | 508 | if (!empty($fields)) {
|
| 509 | 509 | foreach ($fields as $field) {
|
@@ -528,14 +528,14 @@ discard block |
||
| 528 | 528 | * @since 1.6.9 |
| 529 | 529 | * @package GeoDirectory |
| 530 | 530 | */ |
| 531 | -function geodir_custom_fields_custom($post_type=''){
|
|
| 531 | +function geodir_custom_fields_custom($post_type = '') {
|
|
| 532 | 532 | |
| 533 | 533 | $custom_fields = array(); |
| 534 | 534 | |
| 535 | 535 | /** |
| 536 | 536 | * @see `geodir_custom_fields` |
| 537 | 537 | */ |
| 538 | - return apply_filters('geodir_custom_fields_custom',$custom_fields,$post_type);
|
|
| 538 | + return apply_filters('geodir_custom_fields_custom', $custom_fields, $post_type);
|
|
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | |
@@ -546,7 +546,7 @@ discard block |
||
| 546 | 546 | * @since 1.6.6 |
| 547 | 547 | * @package GeoDirectory |
| 548 | 548 | */ |
| 549 | -function geodir_custom_fields($post_type=''){
|
|
| 549 | +function geodir_custom_fields($post_type = '') {
|
|
| 550 | 550 | |
| 551 | 551 | $custom_fields = array( |
| 552 | 552 | 'text' => array( |
@@ -681,7 +681,7 @@ discard block |
||
| 681 | 681 | * } |
| 682 | 682 | * @param string $post_type The post type requested. |
| 683 | 683 | */ |
| 684 | - return apply_filters('geodir_custom_fields',$custom_fields,$post_type);
|
|
| 684 | + return apply_filters('geodir_custom_fields', $custom_fields, $post_type);
|
|
| 685 | 685 | } |
| 686 | 686 | |
| 687 | 687 | /** |
@@ -692,25 +692,25 @@ discard block |
||
| 692 | 692 | * @param string $type The custom field type, predefined, custom or blank for default |
| 693 | 693 | * @package GeoDirectory |
| 694 | 694 | */ |
| 695 | -function geodir_custom_available_fields($type='') |
|
| 695 | +function geodir_custom_available_fields($type = '') |
|
| 696 | 696 | {
|
| 697 | 697 | $listing_type = ($_REQUEST['listing_type'] != '') ? sanitize_text_field($_REQUEST['listing_type']) : 'gd_place'; |
| 698 | 698 | ?> |
| 699 | - <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type;?>"/> |
|
| 699 | + <input type="hidden" name="listing_type" id="new_post_type" value="<?php echo $listing_type; ?>"/> |
|
| 700 | 700 | <input type="hidden" name="manage_field_type" class="manage_field_type" value="<?php echo sanitize_text_field($_REQUEST['subtab']); ?>" /> |
| 701 | 701 | |
| 702 | 702 | <?php |
| 703 | - if($type=='predefined'){
|
|
| 703 | + if ($type == 'predefined') {
|
|
| 704 | 704 | $cfs = geodir_custom_fields_predefined($listing_type); |
| 705 | - }elseif($type=='custom'){
|
|
| 705 | + }elseif ($type == 'custom') {
|
|
| 706 | 706 | $cfs = geodir_custom_fields_custom($listing_type); |
| 707 | - }else{
|
|
| 707 | + } else {
|
|
| 708 | 708 | $cfs = geodir_custom_fields($listing_type); |
| 709 | 709 | ?> |
| 710 | 710 | <ul class="full gd-cf-tooltip-wrap"> |
| 711 | 711 | <li> |
| 712 | 712 | <div class="gdcf-tooltip"> |
| 713 | - <?php _e('This adds a section separator with a title.', 'geodirectory');?>
|
|
| 713 | + <?php _e('This adds a section separator with a title.', 'geodirectory'); ?>
|
|
| 714 | 714 | </div> |
| 715 | 715 | <a id="gt-fieldset" |
| 716 | 716 | class="gd-draggable-form-items gt-fieldset" |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | |
| 722 | 722 | <i class="fa fa-long-arrow-left " aria-hidden="true"></i> |
| 723 | 723 | <i class="fa fa-long-arrow-right " aria-hidden="true"></i> |
| 724 | - <?php _e('Fieldset (section separator)', 'geodirectory');?>
|
|
| 724 | + <?php _e('Fieldset (section separator)', 'geodirectory'); ?>
|
|
| 725 | 725 | </a> |
| 726 | 726 | </li> |
| 727 | 727 | </ul> |
@@ -729,15 +729,15 @@ discard block |
||
| 729 | 729 | <?php |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | - if(!empty($cfs)) {
|
|
| 732 | + if (!empty($cfs)) {
|
|
| 733 | 733 | echo '<ul>'; |
| 734 | - foreach ( $cfs as $id => $cf ) {
|
|
| 734 | + foreach ($cfs as $id => $cf) {
|
|
| 735 | 735 | ?> |
| 736 | 736 | |
| 737 | 737 | <li class="gd-cf-tooltip-wrap"> |
| 738 | 738 | <?php |
| 739 | - if ( isset( $cf['description'] ) && $cf['description'] ) {
|
|
| 740 | - echo '<div class="gdcf-tooltip">' . $cf['description'] . '</div>'; |
|
| 739 | + if (isset($cf['description']) && $cf['description']) {
|
|
| 740 | + echo '<div class="gdcf-tooltip">'.$cf['description'].'</div>'; |
|
| 741 | 741 | } ?> |
| 742 | 742 | |
| 743 | 743 | <a id="gd-<?php echo $id; ?>" |
@@ -747,10 +747,10 @@ discard block |
||
| 747 | 747 | class="gd-draggable-form-items <?php echo $cf['class']; ?>" |
| 748 | 748 | href="javascript:void(0);"> |
| 749 | 749 | |
| 750 | - <?php if ( isset( $cf['icon'] ) && strpos( $cf['icon'], 'fa fa-' ) !== false ) {
|
|
| 751 | - echo '<i class="' . $cf['icon'] . '" aria-hidden="true"></i>'; |
|
| 752 | - } elseif ( isset( $cf['icon'] ) && $cf['icon'] ) {
|
|
| 753 | - echo '<b style="background-image: url("' . $cf['icon'] . '")"></b>';
|
|
| 750 | + <?php if (isset($cf['icon']) && strpos($cf['icon'], 'fa fa-') !== false) {
|
|
| 751 | + echo '<i class="'.$cf['icon'].'" aria-hidden="true"></i>'; |
|
| 752 | + } elseif (isset($cf['icon']) && $cf['icon']) {
|
|
| 753 | + echo '<b style="background-image: url("'.$cf['icon'].'")"></b>';
|
|
| 754 | 754 | } else {
|
| 755 | 755 | echo '<i class="fa fa-cog" aria-hidden="true"></i>'; |
| 756 | 756 | } ?> |
@@ -759,7 +759,7 @@ discard block |
||
| 759 | 759 | </li> |
| 760 | 760 | <?php |
| 761 | 761 | } |
| 762 | - }else{
|
|
| 762 | + } else {
|
|
| 763 | 763 | _e('There are no custom fields here yet.', 'geodirectory');
|
| 764 | 764 | } |
| 765 | 765 | ?> |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | <ul class="core"> |
| 788 | 788 | <?php |
| 789 | 789 | global $wpdb; |
| 790 | - $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM " . GEODIR_CUSTOM_FIELDS_TABLE . " WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
|
|
| 790 | + $fields = $wpdb->get_results($wpdb->prepare("SELECT * FROM ".GEODIR_CUSTOM_FIELDS_TABLE." WHERE post_type = %s ORDER BY sort_order ASC", array($listing_type)));
|
|
| 791 | 791 | |
| 792 | 792 | if (!empty($fields)) {
|
| 793 | 793 | foreach ($fields as $field) {
|
@@ -797,7 +797,7 @@ discard block |
||
| 797 | 797 | $field_type_key = $field->field_type_key; |
| 798 | 798 | $field_ins_upd = 'display'; |
| 799 | 799 | |
| 800 | - geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd,$field_type_key); |
|
| 800 | + geodir_custom_field_adminhtml($field_type, $result_str, $field_ins_upd, $field_type_key); |
|
| 801 | 801 | } |
| 802 | 802 | } |
| 803 | 803 | ?></ul> |
@@ -956,8 +956,8 @@ discard block |
||
| 956 | 956 | |
| 957 | 957 | if (!get_option('geodir_remove_unnecessary_fields')) {
|
| 958 | 958 | |
| 959 | - if ($wpdb->get_var("SHOW COLUMNS FROM " . $plugin_prefix . "gd_place_detail WHERE field = 'categories'"))
|
|
| 960 | - $wpdb->query("ALTER TABLE `" . $plugin_prefix . "gd_place_detail` DROP `categories`");
|
|
| 959 | + if ($wpdb->get_var("SHOW COLUMNS FROM ".$plugin_prefix."gd_place_detail WHERE field = 'categories'"))
|
|
| 960 | + $wpdb->query("ALTER TABLE `".$plugin_prefix."gd_place_detail` DROP `categories`");
|
|
| 961 | 961 | |
| 962 | 962 | update_option('geodir_remove_unnecessary_fields', '1');
|
| 963 | 963 | |
@@ -985,14 +985,14 @@ discard block |
||
| 985 | 985 | case 'diagnosis' : |
| 986 | 986 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
| 987 | 987 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
| 988 | - call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 988 | + call_user_func('geodir_diagnose_'.$diagnose_this);
|
|
| 989 | 989 | exit(); |
| 990 | 990 | break; |
| 991 | 991 | |
| 992 | 992 | case 'diagnosis-fix' : |
| 993 | 993 | if (isset($_REQUEST['diagnose_this']) && $_REQUEST['diagnose_this'] != '') |
| 994 | 994 | $diagnose_this = sanitize_text_field($_REQUEST['diagnose_this']); |
| 995 | - call_user_func('geodir_diagnose_' . $diagnose_this);
|
|
| 995 | + call_user_func('geodir_diagnose_'.$diagnose_this);
|
|
| 996 | 996 | exit(); |
| 997 | 997 | break; |
| 998 | 998 | } |
@@ -1017,50 +1017,50 @@ discard block |
||
| 1017 | 1017 | {
|
| 1018 | 1018 | global $wpdb; |
| 1019 | 1019 | //$filter_arr['output_str'] .='###'.$table.'###'; |
| 1020 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0) {
|
|
| 1021 | - $filter_arr['output_str'] .= "<li>" . __('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory') . "</li>";
|
|
| 1020 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0) {
|
|
| 1021 | + $filter_arr['output_str'] .= "<li>".__('ERROR: You did not follow instructions! Now you will need to contact support to manually fix things.', 'geodirectory')."</li>";
|
|
| 1022 | 1022 | $filter_arr['is_error_during_diagnose'] = true; |
| 1023 | 1023 | |
| 1024 | - } elseif ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 1025 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1024 | + } elseif ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
|
|
| 1025 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s_ms_bak table found', 'geodirectory'), $tabel_name)."</li>";
|
|
| 1026 | 1026 | $filter_arr['is_error_during_diagnose'] = true; |
| 1027 | - $filter_arr['output_str'] .= "<li>" . __('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory') . "</li>";
|
|
| 1027 | + $filter_arr['output_str'] .= "<li>".__('IMPORTANT: This can be caused by out of date core or addons, please update core + addons before trying the fix OR YOU WILL HAVE A BAD TIME!', 'geodirectory')."</li>";
|
|
| 1028 | 1028 | $filter_arr['is_error_during_diagnose'] = true; |
| 1029 | 1029 | |
| 1030 | 1030 | if ($fix) {
|
| 1031 | - $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $table . "_ms_bak");// get backup table count
|
|
| 1032 | - $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table");// get new table count
|
|
| 1031 | + $ms_bak_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$table."_ms_bak"); // get backup table count
|
|
| 1032 | + $new_table_count = $wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table"); // get new table count
|
|
| 1033 | 1033 | |
| 1034 | 1034 | if ($ms_bak_count == $new_table_count) {// if they are the same count rename to bak2
|
| 1035 | 1035 | //$filter_arr['output_str'] .= "<li>".sprintf( __('-->PROBLEM: %s table count is the same as new table, contact support' , 'geodirectory'), $table )."</li>" ;
|
| 1036 | 1036 | |
| 1037 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename bak table to new table
|
|
| 1037 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename bak table to new table
|
|
| 1038 | 1038 | |
| 1039 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 1040 | - $filter_arr['output_str'] .= "<li>" . __('-->FIXED: Renamed and backed up the tables', 'geodirectory') . "</li>";
|
|
| 1039 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
|
|
| 1040 | + $filter_arr['output_str'] .= "<li>".__('-->FIXED: Renamed and backed up the tables', 'geodirectory')."</li>";
|
|
| 1041 | 1041 | } else {
|
| 1042 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1042 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
|
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | } elseif ($ms_bak_count > $new_table_count) {//if backup is greater then restore it
|
| 1046 | 1046 | |
| 1047 | - $wpdb->query("RENAME TABLE " . $wpdb->prefix . "$table TO " . $table . "_ms_bak2");// rename new table to bak2
|
|
| 1048 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $wpdb->prefix . "$table");// rename bak table to new table
|
|
| 1047 | + $wpdb->query("RENAME TABLE ".$wpdb->prefix."$table TO ".$table."_ms_bak2"); // rename new table to bak2
|
|
| 1048 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$wpdb->prefix."$table"); // rename bak table to new table
|
|
| 1049 | 1049 | |
| 1050 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1051 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table) . "</li>";
|
|
| 1050 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak2'") && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") && $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1051 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: restored largest table %s', 'geodirectory'), $table)."</li>";
|
|
| 1052 | 1052 | } else {
|
| 1053 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1053 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
|
|
| 1054 | 1054 | } |
| 1055 | 1055 | |
| 1056 | 1056 | } elseif ($new_table_count > $ms_bak_count) {// we cant do much so rename the table to stop errors
|
| 1057 | 1057 | |
| 1058 | - $wpdb->query("RENAME TABLE " . $table . "_ms_bak TO " . $table . "_ms_bak2");// rename ms_bak table to ms_bak2
|
|
| 1058 | + $wpdb->query("RENAME TABLE ".$table."_ms_bak TO ".$table."_ms_bak2"); // rename ms_bak table to ms_bak2
|
|
| 1059 | 1059 | |
| 1060 | - if ($wpdb->query("SHOW TABLES LIKE '" . $table . "_ms_bak'") == 0) {
|
|
| 1061 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table) . "</li>";
|
|
| 1060 | + if ($wpdb->query("SHOW TABLES LIKE '".$table."_ms_bak'") == 0) {
|
|
| 1061 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: table %s_ms_bak renamed and backed up', 'geodirectory'), $table)."</li>";
|
|
| 1062 | 1062 | } else {
|
| 1063 | - $filter_arr['output_str'] .= "<li>" . __('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory') . "</li>";
|
|
| 1063 | + $filter_arr['output_str'] .= "<li>".__('-->PROBLEM: Failed to rename tables, please contact support.', 'geodirectory')."</li>";
|
|
| 1064 | 1064 | } |
| 1065 | 1065 | |
| 1066 | 1066 | } |
@@ -1068,54 +1068,54 @@ discard block |
||
| 1068 | 1068 | } |
| 1069 | 1069 | |
| 1070 | 1070 | |
| 1071 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") > 0) {
|
|
| 1072 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1071 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") > 0) {
|
|
| 1072 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: Two %s tables found', 'geodirectory'), $tabel_name)."</li>";
|
|
| 1073 | 1073 | $filter_arr['is_error_during_diagnose'] = true; |
| 1074 | 1074 | |
| 1075 | 1075 | if ($fix) {
|
| 1076 | 1076 | if ($wpdb->get_var("SELECT COUNT(*) FROM $table") == 0) {// if first table is empty just delete it
|
| 1077 | 1077 | if ($wpdb->query("DROP TABLE IF EXISTS $table")) {
|
| 1078 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table) . "</li>";
|
|
| 1078 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $table)."</li>";
|
|
| 1079 | 1079 | } else {
|
| 1080 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table) . "</li>";
|
|
| 1080 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $table)."</li>";
|
|
| 1081 | 1081 | } |
| 1082 | 1082 | |
| 1083 | - } elseif ($wpdb->get_var("SELECT COUNT(*) FROM " . $wpdb->prefix . "$table") == 0) {// if main table is empty but original is not, delete main and rename original
|
|
| 1084 | - if ($wpdb->query("DROP TABLE IF EXISTS " . $wpdb->prefix . "$table")) {
|
|
| 1085 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 1083 | + } elseif ($wpdb->get_var("SELECT COUNT(*) FROM ".$wpdb->prefix."$table") == 0) {// if main table is empty but original is not, delete main and rename original
|
|
| 1084 | + if ($wpdb->query("DROP TABLE IF EXISTS ".$wpdb->prefix."$table")) {
|
|
| 1085 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Deleted table %s', 'geodirectory'), $wpdb->prefix.$table)."</li>";
|
|
| 1086 | 1086 | } else {
|
| 1087 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix . $table) . "</li>";
|
|
| 1087 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Delete table %s failed, please try manual delete from DB', 'geodirectory'), $wpdb->prefix.$table)."</li>";
|
|
| 1088 | 1088 | } |
| 1089 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1090 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1089 | + if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1090 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
|
|
| 1091 | 1091 | } else {
|
| 1092 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1092 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
|
|
| 1093 | 1093 | } |
| 1094 | 1094 | } else {// else rename the original table to _ms_bak
|
| 1095 | - if ($wpdb->query("RENAME TABLE $table TO " . $table . "_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1096 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 1095 | + if ($wpdb->query("RENAME TABLE $table TO ".$table."_ms_bak") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1096 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table contained info so we renamed %s to %s incase it is needed in future', 'geodirectory'), $table, $table."_ms_bak")."</li>";
|
|
| 1097 | 1097 | } else {
|
| 1098 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table . "_ms_bak") . "</li>";
|
|
| 1098 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Table %s could not be renamed to %s, this table has info so may need to be reviewed manually in the DB', 'geodirectory'), $table, $table."_ms_bak")."</li>";
|
|
| 1099 | 1099 | } |
| 1100 | 1100 | } |
| 1101 | 1101 | } |
| 1102 | 1102 | |
| 1103 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 1104 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1103 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") > 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
|
|
| 1104 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table not converted', 'geodirectory'), $tabel_name)."</li>";
|
|
| 1105 | 1105 | $filter_arr['is_error_during_diagnose'] = true; |
| 1106 | 1106 | |
| 1107 | 1107 | if ($fix) {
|
| 1108 | 1108 | // if original table exists but new does not, rename |
| 1109 | - if ($wpdb->query("RENAME TABLE $table TO " . $wpdb->prefix . "$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1110 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1109 | + if ($wpdb->query("RENAME TABLE $table TO ".$wpdb->prefix."$table") || $wpdb->query("SHOW TABLES LIKE '$table'") == 0) {
|
|
| 1110 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->FIXED: Table %s renamed to %s', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
|
|
| 1111 | 1111 | } else {
|
| 1112 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix . $table) . "</li>";
|
|
| 1112 | + $filter_arr['output_str'] .= "<li>".sprintf(__('-->PROBLEM: Failed to rename table %s to %s, please try manually from DB', 'geodirectory'), $table, $wpdb->prefix.$table)."</li>";
|
|
| 1113 | 1113 | } |
| 1114 | 1114 | |
| 1115 | 1115 | } |
| 1116 | 1116 | |
| 1117 | - } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '" . $wpdb->prefix . "$table'") == 0) {
|
|
| 1118 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1117 | + } elseif ($wpdb->query("SHOW TABLES LIKE '$table'") == 0 && $wpdb->query("SHOW TABLES LIKE '".$wpdb->prefix."$table'") == 0) {
|
|
| 1118 | + $filter_arr['output_str'] .= "<li>".sprintf(__('ERROR: %s table does not exist', 'geodirectory'), $tabel_name)."</li>";
|
|
| 1119 | 1119 | $filter_arr['is_error_during_diagnose'] = true; |
| 1120 | 1120 | |
| 1121 | 1121 | if ($fix) {
|
@@ -1129,11 +1129,11 @@ discard block |
||
| 1129 | 1129 | delete_option('geodir_custom_posts_db_version');
|
| 1130 | 1130 | delete_option('geodir_reviewratings_db_version');
|
| 1131 | 1131 | delete_option('geodiradvancesearch_db_version');
|
| 1132 | - $filter_arr['output_str'] .= "<li>" . __('-->TRY: Please refresh page to run table install functions', 'geodirectory') . "</li>";
|
|
| 1132 | + $filter_arr['output_str'] .= "<li>".__('-->TRY: Please refresh page to run table install functions', 'geodirectory')."</li>";
|
|
| 1133 | 1133 | } |
| 1134 | 1134 | |
| 1135 | 1135 | } else {
|
| 1136 | - $filter_arr['output_str'] .= "<li>" . sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name) . "</li>";
|
|
| 1136 | + $filter_arr['output_str'] .= "<li>".sprintf(__('%s table converted correctly', 'geodirectory'), $tabel_name)."</li>";
|
|
| 1137 | 1137 | } |
| 1138 | 1138 | return $filter_arr; |
| 1139 | 1139 | } |
@@ -1162,23 +1162,23 @@ discard block |
||
| 1162 | 1162 | if (!empty($all_postypes)) {
|
| 1163 | 1163 | foreach ($all_postypes as $key) {
|
| 1164 | 1164 | // update each GD CPT |
| 1165 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d");
|
|
| 1165 | + $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d");
|
|
| 1166 | 1166 | |
| 1167 | 1167 | if (!empty($posts)) {
|
| 1168 | 1168 | |
| 1169 | 1169 | foreach ($posts as $p) {
|
| 1170 | 1170 | $p->post_type = $key; |
| 1171 | - $raw_tags = wp_get_object_terms($p->post_id, $p->post_type . '_tags', array('fields' => 'names'));
|
|
| 1171 | + $raw_tags = wp_get_object_terms($p->post_id, $p->post_type.'_tags', array('fields' => 'names'));
|
|
| 1172 | 1172 | if (empty($raw_tags)) {
|
| 1173 | 1173 | $post_tags = ''; |
| 1174 | 1174 | } else {
|
| 1175 | 1175 | $post_tags = implode(",", $raw_tags);
|
| 1176 | 1176 | } |
| 1177 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1178 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
|
|
| 1177 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
| 1178 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET post_tags=%s WHERE post_id =%d", $post_tags, $p->post_id));
|
|
| 1179 | 1179 | |
| 1180 | 1180 | } |
| 1181 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1181 | + $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
|
|
| 1182 | 1182 | } |
| 1183 | 1183 | |
| 1184 | 1184 | } |
@@ -1187,7 +1187,7 @@ discard block |
||
| 1187 | 1187 | |
| 1188 | 1188 | if ($is_error_during_diagnose) {
|
| 1189 | 1189 | $info_div_class = "geodir_problem_info"; |
| 1190 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1190 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1191 | 1191 | } else {
|
| 1192 | 1192 | $info_div_class = "geodir_noproblem_info"; |
| 1193 | 1193 | $fix_button_txt = ''; |
@@ -1224,29 +1224,29 @@ discard block |
||
| 1224 | 1224 | if (!empty($all_postypes)) {
|
| 1225 | 1225 | foreach ($all_postypes as $key) {
|
| 1226 | 1226 | // update each GD CTP |
| 1227 | - $posts = $wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "geodir_" . $key . "_detail d WHERE d." . $key . "category='' ");
|
|
| 1227 | + $posts = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix."geodir_".$key."_detail d WHERE d.".$key."category='' ");
|
|
| 1228 | 1228 | |
| 1229 | 1229 | if (!empty($posts)) {
|
| 1230 | 1230 | |
| 1231 | 1231 | foreach ($posts as $p) {
|
| 1232 | 1232 | $p->post_type = $key; |
| 1233 | - $raw_cats = wp_get_object_terms($p->post_id, $p->post_type . 'category', array('fields' => 'ids'));
|
|
| 1233 | + $raw_cats = wp_get_object_terms($p->post_id, $p->post_type.'category', array('fields' => 'ids'));
|
|
| 1234 | 1234 | |
| 1235 | 1235 | if (empty($raw_cats)) {
|
| 1236 | 1236 | $post_categories = get_post_meta($p->post_id, 'post_categories', true); |
| 1237 | 1237 | |
| 1238 | - if (!empty($post_categories) && !empty($post_categories[$p->post_type . 'category'])) {
|
|
| 1239 | - $post_categories[$p->post_type . 'category'] = str_replace("d:", "", $post_categories[$p->post_type . 'category']);
|
|
| 1240 | - foreach (explode(",", $post_categories[$p->post_type . 'category']) as $cat_part) {
|
|
| 1238 | + if (!empty($post_categories) && !empty($post_categories[$p->post_type.'category'])) {
|
|
| 1239 | + $post_categories[$p->post_type.'category'] = str_replace("d:", "", $post_categories[$p->post_type.'category']);
|
|
| 1240 | + foreach (explode(",", $post_categories[$p->post_type.'category']) as $cat_part) {
|
|
| 1241 | 1241 | if (is_numeric($cat_part)) {
|
| 1242 | - $raw_cats[] = (int)$cat_part; |
|
| 1242 | + $raw_cats[] = (int) $cat_part; |
|
| 1243 | 1243 | } |
| 1244 | 1244 | } |
| 1245 | 1245 | |
| 1246 | 1246 | } |
| 1247 | 1247 | |
| 1248 | 1248 | if (!empty($raw_cats)) {
|
| 1249 | - $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type . 'category'); |
|
| 1249 | + $term_taxonomy_ids = wp_set_object_terms($p->post_id, $raw_cats, $p->post_type.'category'); |
|
| 1250 | 1250 | |
| 1251 | 1251 | } |
| 1252 | 1252 | |
@@ -1256,14 +1256,14 @@ discard block |
||
| 1256 | 1256 | if (empty($raw_cats)) {
|
| 1257 | 1257 | $post_cats = ''; |
| 1258 | 1258 | } else {
|
| 1259 | - $post_cats = ',' . implode(",", $raw_cats) . ',';
|
|
| 1259 | + $post_cats = ','.implode(",", $raw_cats).',';
|
|
| 1260 | 1260 | } |
| 1261 | - $tablename = $plugin_prefix . $p->post_type . '_detail'; |
|
| 1262 | - $wpdb->query($wpdb->prepare("UPDATE " . $tablename . " SET " . $p->post_type . "category=%s WHERE post_id =%d", $post_cats, $p->post_id));
|
|
| 1261 | + $tablename = $plugin_prefix.$p->post_type.'_detail'; |
|
| 1262 | + $wpdb->query($wpdb->prepare("UPDATE ".$tablename." SET ".$p->post_type."category=%s WHERE post_id =%d", $post_cats, $p->post_id));
|
|
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | 1265 | } |
| 1266 | - $output_str .= "<li>" . $key . __(': Done', 'geodirectory') . "</li>";
|
|
| 1266 | + $output_str .= "<li>".$key.__(': Done', 'geodirectory')."</li>";
|
|
| 1267 | 1267 | |
| 1268 | 1268 | } |
| 1269 | 1269 | |
@@ -1271,7 +1271,7 @@ discard block |
||
| 1271 | 1271 | |
| 1272 | 1272 | if ($is_error_during_diagnose) {
|
| 1273 | 1273 | $info_div_class = "geodir_problem_info"; |
| 1274 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1274 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1275 | 1275 | } else {
|
| 1276 | 1276 | $info_div_class = "geodir_noproblem_info"; |
| 1277 | 1277 | $fix_button_txt = ''; |
@@ -1324,15 +1324,15 @@ discard block |
||
| 1324 | 1324 | if (!empty($ver_arr)) {
|
| 1325 | 1325 | foreach ($ver_arr as $key => $val) {
|
| 1326 | 1326 | if (delete_option($val)) {
|
| 1327 | - $output_str .= "<li>" . $key . __(' Version: Deleted', 'geodirectory') . "</li>";
|
|
| 1327 | + $output_str .= "<li>".$key.__(' Version: Deleted', 'geodirectory')."</li>";
|
|
| 1328 | 1328 | } else {
|
| 1329 | - $output_str .= "<li>" . $key . __(' Version: Not Found', 'geodirectory') . "</li>";
|
|
| 1329 | + $output_str .= "<li>".$key.__(' Version: Not Found', 'geodirectory')."</li>";
|
|
| 1330 | 1330 | } |
| 1331 | 1331 | |
| 1332 | 1332 | } |
| 1333 | 1333 | |
| 1334 | 1334 | if ($output_str) {
|
| 1335 | - $output_str .= "<li><strong>" . __(' Upgrade/install scripts will run on next page reload.', 'geodirectory') . "</strong></li>";
|
|
| 1335 | + $output_str .= "<li><strong>".__(' Upgrade/install scripts will run on next page reload.', 'geodirectory')."</strong></li>";
|
|
| 1336 | 1336 | } |
| 1337 | 1337 | |
| 1338 | 1338 | } |
@@ -1369,43 +1369,43 @@ discard block |
||
| 1369 | 1369 | $output_str = ''; |
| 1370 | 1370 | |
| 1371 | 1371 | // check review locations |
| 1372 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
|
|
| 1373 | - $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>";
|
|
| 1372 | + if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) {
|
|
| 1373 | + $output_str .= "<li>".__('Review locations missing or broken', 'geodirectory')."</li>";
|
|
| 1374 | 1374 | $is_error_during_diagnose = true; |
| 1375 | 1375 | |
| 1376 | 1376 | if ($fix) {
|
| 1377 | 1377 | if (geodir_fix_review_location()) {
|
| 1378 | - $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>";
|
|
| 1378 | + $output_str .= "<li><strong>".__('-->FIXED: Review locations fixed', 'geodirectory')."</strong></li>";
|
|
| 1379 | 1379 | } else {
|
| 1380 | - $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1380 | + $output_str .= "<li><strong>".__('-->FAILED: Review locations fix failed', 'geodirectory')."</strong></li>";
|
|
| 1381 | 1381 | } |
| 1382 | 1382 | } |
| 1383 | 1383 | |
| 1384 | 1384 | } else {
|
| 1385 | - $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>";
|
|
| 1385 | + $output_str .= "<li>".__('Review locations ok', 'geodirectory')."</li>";
|
|
| 1386 | 1386 | } |
| 1387 | 1387 | |
| 1388 | 1388 | // check review content |
| 1389 | - if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) {
|
|
| 1390 | - $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>";
|
|
| 1389 | + if ($wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE comment_content IS NULL")) {
|
|
| 1390 | + $output_str .= "<li>".__('Review content missing or broken', 'geodirectory')."</li>";
|
|
| 1391 | 1391 | $is_error_during_diagnose = true; |
| 1392 | 1392 | |
| 1393 | 1393 | if ($fix) {
|
| 1394 | 1394 | if (geodir_fix_review_content()) {
|
| 1395 | - $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>";
|
|
| 1395 | + $output_str .= "<li><strong>".__('-->FIXED: Review content fixed', 'geodirectory')."</strong></li>";
|
|
| 1396 | 1396 | } else {
|
| 1397 | - $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1397 | + $output_str .= "<li><strong>".__('-->FAILED: Review content fix failed', 'geodirectory')."</strong></li>";
|
|
| 1398 | 1398 | } |
| 1399 | 1399 | } |
| 1400 | 1400 | |
| 1401 | 1401 | } else {
|
| 1402 | - $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>";
|
|
| 1402 | + $output_str .= "<li>".__('Review content ok', 'geodirectory')."</li>";
|
|
| 1403 | 1403 | } |
| 1404 | 1404 | |
| 1405 | 1405 | |
| 1406 | 1406 | if ($is_error_during_diagnose) {
|
| 1407 | 1407 | $info_div_class = "geodir_problem_info"; |
| 1408 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1408 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />";
|
|
| 1409 | 1409 | } else {
|
| 1410 | 1410 | $info_div_class = "geodir_noproblem_info"; |
| 1411 | 1411 | $fix_button_txt = ''; |
@@ -1469,7 +1469,7 @@ discard block |
||
| 1469 | 1469 | |
| 1470 | 1470 | if ($is_error_during_diagnose) {
|
| 1471 | 1471 | $info_div_class = "geodir_problem_info"; |
| 1472 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
|
|
| 1472 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='multisite_conversion' />";
|
|
| 1473 | 1473 | } else {
|
| 1474 | 1474 | $info_div_class = "geodir_noproblem_info"; |
| 1475 | 1475 | $fix_button_txt = ''; |
@@ -1503,7 +1503,7 @@ discard block |
||
| 1503 | 1503 | else {
|
| 1504 | 1504 | $page_found = $wpdb->get_var( |
| 1505 | 1505 | $wpdb->prepare( |
| 1506 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
| 1506 | + "SELECT ID FROM ".$wpdb->posts." WHERE post_name = %s LIMIT 1;", |
|
| 1507 | 1507 | array($slug) |
| 1508 | 1508 | ) |
| 1509 | 1509 | ); |
@@ -1549,18 +1549,18 @@ discard block |
||
| 1549 | 1549 | ////////////////////////////////// |
| 1550 | 1550 | $option_value = get_option('geodir_home_page');
|
| 1551 | 1551 | $page = get_post($option_value); |
| 1552 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1552 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1553 | 1553 | |
| 1554 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1555 | - $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1554 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1555 | + $output_str .= "<li>".__('GD Home page exists with proper setting.', 'geodirectory')."</li>";
|
|
| 1556 | 1556 | else {
|
| 1557 | 1557 | $is_error_during_diagnose = true; |
| 1558 | - $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1558 | + $output_str .= "<li><strong>".__('GD Home page is missing.', 'geodirectory')."</strong></li>";
|
|
| 1559 | 1559 | if ($fix) {
|
| 1560 | 1560 | if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
|
| 1561 | - $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1561 | + $output_str .= "<li><strong>".__('-->FIXED: GD Home page fixed', 'geodirectory')."</strong></li>";
|
|
| 1562 | 1562 | } else {
|
| 1563 | - $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1563 | + $output_str .= "<li><strong>".__('-->FAILED: GD Home page fix failed', 'geodirectory')."</strong></li>";
|
|
| 1564 | 1564 | } |
| 1565 | 1565 | } |
| 1566 | 1566 | } |
@@ -1574,18 +1574,18 @@ discard block |
||
| 1574 | 1574 | ////////////////////////////////// |
| 1575 | 1575 | $option_value = get_option('geodir_add_listing_page');
|
| 1576 | 1576 | $page = get_post($option_value); |
| 1577 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1577 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1578 | 1578 | |
| 1579 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1580 | - $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1579 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1580 | + $output_str .= "<li>".__('Add Listing page exists with proper setting.', 'geodirectory')."</li>";
|
|
| 1581 | 1581 | else {
|
| 1582 | 1582 | $is_error_during_diagnose = true; |
| 1583 | - $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1583 | + $output_str .= "<li><strong>".__('Add Listing page is missing.', 'geodirectory')."</strong></li>";
|
|
| 1584 | 1584 | if ($fix) {
|
| 1585 | 1585 | if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
|
| 1586 | - $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1586 | + $output_str .= "<li><strong>".__('-->FIXED: Add Listing page fixed', 'geodirectory')."</strong></li>";
|
|
| 1587 | 1587 | } else {
|
| 1588 | - $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1588 | + $output_str .= "<li><strong>".__('-->FAILED: Add Listing page fix failed', 'geodirectory')."</strong></li>";
|
|
| 1589 | 1589 | } |
| 1590 | 1590 | } |
| 1591 | 1591 | } |
@@ -1600,18 +1600,18 @@ discard block |
||
| 1600 | 1600 | ////////////////////////////////// |
| 1601 | 1601 | $option_value = get_option('geodir_preview_page');
|
| 1602 | 1602 | $page = get_post($option_value); |
| 1603 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1603 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1604 | 1604 | |
| 1605 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1606 | - $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1605 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1606 | + $output_str .= "<li>".__('Listing Preview page exists with proper setting.', 'geodirectory')."</li>";
|
|
| 1607 | 1607 | else {
|
| 1608 | 1608 | $is_error_during_diagnose = true; |
| 1609 | - $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1609 | + $output_str .= "<li><strong>".__('Listing Preview page is missing.', 'geodirectory')."</strong></li>";
|
|
| 1610 | 1610 | if ($fix) {
|
| 1611 | 1611 | if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
|
| 1612 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1612 | + $output_str .= "<li><strong>".__('-->FIXED: Listing Preview page fixed', 'geodirectory')."</strong></li>";
|
|
| 1613 | 1613 | } else {
|
| 1614 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1614 | + $output_str .= "<li><strong>".__('-->FAILED: Listing Preview page fix failed', 'geodirectory')."</strong></li>";
|
|
| 1615 | 1615 | } |
| 1616 | 1616 | } |
| 1617 | 1617 | } |
@@ -1625,18 +1625,18 @@ discard block |
||
| 1625 | 1625 | ////////////////////////////////// |
| 1626 | 1626 | $option_value = get_option('geodir_success_page');
|
| 1627 | 1627 | $page = get_post($option_value); |
| 1628 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1628 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1629 | 1629 | |
| 1630 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1631 | - $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1630 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1631 | + $output_str .= "<li>".__('Listing Success page exists with proper setting.', 'geodirectory')."</li>";
|
|
| 1632 | 1632 | else {
|
| 1633 | 1633 | $is_error_during_diagnose = true; |
| 1634 | - $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1634 | + $output_str .= "<li><strong>".__('Listing Success page is missing.', 'geodirectory')."</strong></li>";
|
|
| 1635 | 1635 | if ($fix) {
|
| 1636 | 1636 | if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
|
| 1637 | - $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1637 | + $output_str .= "<li><strong>".__('-->FIXED: Listing Success page fixed', 'geodirectory')."</strong></li>";
|
|
| 1638 | 1638 | } else {
|
| 1639 | - $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1639 | + $output_str .= "<li><strong>".__('-->FAILED: Listing Success page fix failed', 'geodirectory')."</strong></li>";
|
|
| 1640 | 1640 | } |
| 1641 | 1641 | } |
| 1642 | 1642 | } |
@@ -1650,18 +1650,18 @@ discard block |
||
| 1650 | 1650 | ////////////////////////////////// |
| 1651 | 1651 | $option_value = get_option('geodir_info_page');
|
| 1652 | 1652 | $page = get_post($option_value); |
| 1653 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1653 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1654 | 1654 | |
| 1655 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1656 | - $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1655 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1656 | + $output_str .= "<li>".__('Info page exists with proper setting.', 'geodirectory')."</li>";
|
|
| 1657 | 1657 | else {
|
| 1658 | 1658 | $is_error_during_diagnose = true; |
| 1659 | - $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1659 | + $output_str .= "<li><strong>".__('Info page is missing.', 'geodirectory')."</strong></li>";
|
|
| 1660 | 1660 | if ($fix) {
|
| 1661 | 1661 | if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
|
| 1662 | - $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1662 | + $output_str .= "<li><strong>".__('-->FIXED: Info page fixed', 'geodirectory')."</strong></li>";
|
|
| 1663 | 1663 | } else {
|
| 1664 | - $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1664 | + $output_str .= "<li><strong>".__('-->FAILED: Info page fix failed', 'geodirectory')."</strong></li>";
|
|
| 1665 | 1665 | } |
| 1666 | 1666 | } |
| 1667 | 1667 | } |
@@ -1675,18 +1675,18 @@ discard block |
||
| 1675 | 1675 | ////////////////////////////////// |
| 1676 | 1676 | $option_value = get_option('geodir_login_page');
|
| 1677 | 1677 | $page = get_post($option_value); |
| 1678 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1678 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1679 | 1679 | |
| 1680 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1681 | - $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1680 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1681 | + $output_str .= "<li>".__('Login page exists with proper setting.', 'geodirectory')."</li>";
|
|
| 1682 | 1682 | else {
|
| 1683 | 1683 | $is_error_during_diagnose = true; |
| 1684 | - $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1684 | + $output_str .= "<li><strong>".__('Login page is missing.', 'geodirectory')."</strong></li>";
|
|
| 1685 | 1685 | if ($fix) {
|
| 1686 | 1686 | if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
|
| 1687 | - $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1687 | + $output_str .= "<li><strong>".__('-->FIXED: Login page fixed', 'geodirectory')."</strong></li>";
|
|
| 1688 | 1688 | } else {
|
| 1689 | - $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1689 | + $output_str .= "<li><strong>".__('-->FAILED: Login page fix failed', 'geodirectory')."</strong></li>";
|
|
| 1690 | 1690 | } |
| 1691 | 1691 | } |
| 1692 | 1692 | } |
@@ -1700,18 +1700,18 @@ discard block |
||
| 1700 | 1700 | ////////////////////////////////// |
| 1701 | 1701 | $option_value = get_option('geodir_location_page');
|
| 1702 | 1702 | $page = get_post($option_value); |
| 1703 | - if(!empty($page)){$page_found = $page->ID;}else{$page_found = '';}
|
|
| 1703 | + if (!empty($page)) {$page_found = $page->ID; } else {$page_found = ''; }
|
|
| 1704 | 1704 | |
| 1705 | - if(!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status=='publish') |
|
| 1706 | - $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>";
|
|
| 1705 | + if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') |
|
| 1706 | + $output_str .= "<li>".__('Location page exists with proper setting.', 'geodirectory')."</li>";
|
|
| 1707 | 1707 | else {
|
| 1708 | 1708 | $is_error_during_diagnose = true; |
| 1709 | - $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>";
|
|
| 1709 | + $output_str .= "<li><strong>".__('Location page is missing.', 'geodirectory')."</strong></li>";
|
|
| 1710 | 1710 | if ($fix) {
|
| 1711 | 1711 | if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
|
| 1712 | - $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>";
|
|
| 1712 | + $output_str .= "<li><strong>".__('-->FIXED: Location page fixed', 'geodirectory')."</strong></li>";
|
|
| 1713 | 1713 | } else {
|
| 1714 | - $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>";
|
|
| 1714 | + $output_str .= "<li><strong>".__('-->FAILED: Location page fix failed', 'geodirectory')."</strong></li>";
|
|
| 1715 | 1715 | } |
| 1716 | 1716 | } |
| 1717 | 1717 | } |
@@ -1720,13 +1720,13 @@ discard block |
||
| 1720 | 1720 | /* Diagnose Location Page Ends */ |
| 1721 | 1721 | //////////////////////////////// |
| 1722 | 1722 | |
| 1723 | - $page_chk_arr = array('output_str'=>$output_str,'is_error_during_diagnose'=>$is_error_during_diagnose );
|
|
| 1723 | + $page_chk_arr = array('output_str'=>$output_str, 'is_error_during_diagnose'=>$is_error_during_diagnose);
|
|
| 1724 | 1724 | /** |
| 1725 | 1725 | * This action is called at the end of the GD Tools page check function. |
| 1726 | 1726 | * |
| 1727 | 1727 | * @since 1.5.2 |
| 1728 | 1728 | */ |
| 1729 | - $page_chk_arr = apply_filters('geodir_diagnose_default_pages',$page_chk_arr);
|
|
| 1729 | + $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr);
|
|
| 1730 | 1730 | |
| 1731 | 1731 | $output_str = $page_chk_arr['output_str']; |
| 1732 | 1732 | $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; |
@@ -1736,7 +1736,7 @@ discard block |
||
| 1736 | 1736 | flush_rewrite_rules(); |
| 1737 | 1737 | } |
| 1738 | 1738 | $info_div_class = "geodir_problem_info"; |
| 1739 | - $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
|
|
| 1739 | + $fix_button_txt = "<input type='button' value='".__('Fix', 'geodirectory')."' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />";
|
|
| 1740 | 1740 | } else {
|
| 1741 | 1741 | $info_div_class = "geodir_noproblem_info"; |
| 1742 | 1742 | $fix_button_txt = ''; |
@@ -1764,10 +1764,10 @@ discard block |
||
| 1764 | 1764 | $fix_button_txt = ''; |
| 1765 | 1765 | |
| 1766 | 1766 | if ($is_error_during_diagnose) {
|
| 1767 | - $output_str .= "<li>" . __('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory') . ' ' . geodir_plugin_path() . '/db-language.php' . "</li>";
|
|
| 1767 | + $output_str .= "<li>".__('Fail to load custom fields in to file for translation, please check file permission:', 'geodirectory').' '.geodir_plugin_path().'/db-language.php'."</li>";
|
|
| 1768 | 1768 | $info_div_class = "geodir_problem_info"; |
| 1769 | 1769 | } else {
|
| 1770 | - $output_str .= "<li>" . __('Load custom fields in to file for translation: ok', 'geodirectory') . "</li>";
|
|
| 1770 | + $output_str .= "<li>".__('Load custom fields in to file for translation: ok', 'geodirectory')."</li>";
|
|
| 1771 | 1771 | $info_div_class = "geodir_noproblem_info"; |
| 1772 | 1772 | $fix_button_txt = ''; |
| 1773 | 1773 | } |
@@ -1809,17 +1809,17 @@ discard block |
||
| 1809 | 1809 | global $wpdb, $wp_query, $plugin_prefix; |
| 1810 | 1810 | |
| 1811 | 1811 | if (is_admin() && !empty($wp_query->query_vars) && !empty($wp_query->query_vars['is_geodir_loop']) && !empty($wp_query->query_vars['orderby']) && $wp_query->query_vars['orderby'] == 'expire' && !empty($wp_query->query_vars['post_type']) && in_array($wp_query->query_vars['post_type'], geodir_get_posttypes()) && !empty($wp_query->query_vars['orderby']) && isset($clauses['join']) && isset($clauses['orderby']) && isset($clauses['fields'])) {
|
| 1812 | - $table = $plugin_prefix . $wp_query->query_vars['post_type'] . '_detail'; |
|
| 1812 | + $table = $plugin_prefix.$wp_query->query_vars['post_type'].'_detail'; |
|
| 1813 | 1813 | |
| 1814 | - $join = $clauses['join'] . ' INNER JOIN ' . $table . ' AS gd_posts ON (gd_posts.post_id = ' . $wpdb->posts . '.ID)'; |
|
| 1814 | + $join = $clauses['join'].' INNER JOIN '.$table.' AS gd_posts ON (gd_posts.post_id = '.$wpdb->posts.'.ID)'; |
|
| 1815 | 1815 | $clauses['join'] = $join; |
| 1816 | 1816 | |
| 1817 | - $fields = $clauses['fields'] != '' ? $clauses['fields'] . ', ' : ''; |
|
| 1817 | + $fields = $clauses['fields'] != '' ? $clauses['fields'].', ' : ''; |
|
| 1818 | 1818 | $fields .= 'IF(UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), UNIX_TIMESTAMP(DATE_FORMAT(gd_posts.expire_date, "%Y-%m-%d")), 253402300799) AS gd_expire'; |
| 1819 | 1819 | $clauses['fields'] = $fields; |
| 1820 | 1820 | |
| 1821 | 1821 | $order = !empty($wp_query->query_vars['order']) ? $wp_query->query_vars['order'] : 'ASC'; |
| 1822 | - $orderby = 'gd_expire ' . $order; |
|
| 1822 | + $orderby = 'gd_expire '.$order; |
|
| 1823 | 1823 | $clauses['orderby'] = $orderby; |
| 1824 | 1824 | } |
| 1825 | 1825 | return $clauses; |
@@ -1862,7 +1862,7 @@ discard block |
||
| 1862 | 1862 | global $current_user; |
| 1863 | 1863 | $upload_dir = wp_upload_dir(); |
| 1864 | 1864 | |
| 1865 | - $file = $upload_dir['path'] . '/temp_' . $current_user->data->ID . '/geodir_tmp.csv'; |
|
| 1865 | + $file = $upload_dir['path'].'/temp_'.$current_user->data->ID.'/geodir_tmp.csv'; |
|
| 1866 | 1866 | $handle = fopen($file, 'w'); |
| 1867 | 1867 | |
| 1868 | 1868 | fwrite($handle, $input); |
@@ -1907,7 +1907,7 @@ discard block |
||
| 1907 | 1907 | $uploads_dir = $uploads['path']; |
| 1908 | 1908 | $image_name_arr = explode('/', $filename);
|
| 1909 | 1909 | $filename = end($image_name_arr); |
| 1910 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $filename; |
|
| 1910 | + $target_path = $uploads_dir.'/temp_'.$current_user->data->ID.'/'.$filename; |
|
| 1911 | 1911 | $return = array(); |
| 1912 | 1912 | $return['file'] = $uploadedFile; |
| 1913 | 1913 | $return['error'] = __('The uploaded file is not a valid csv file. Please try again.', 'geodirectory');
|
@@ -1924,8 +1924,8 @@ discard block |
||
| 1924 | 1924 | |
| 1925 | 1925 | if (($handle = fopen($target_path, "r")) !== FALSE) {
|
| 1926 | 1926 | while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
|
| 1927 | - if(is_array($data) && !empty($data)) {
|
|
| 1928 | - $file[] = '"' . implode('","', $data) . '"';
|
|
| 1927 | + if (is_array($data) && !empty($data)) {
|
|
| 1928 | + $file[] = '"'.implode('","', $data).'"';
|
|
| 1929 | 1929 | } |
| 1930 | 1930 | } |
| 1931 | 1931 | fclose($handle); |
@@ -2042,10 +2042,10 @@ discard block |
||
| 2042 | 2042 | $tag_arr = explode(',', $post_tags);
|
| 2043 | 2043 | } |
| 2044 | 2044 | |
| 2045 | - $table = $plugin_prefix . $buffer[5] . '_detail'; // check table in database |
|
| 2045 | + $table = $plugin_prefix.$buffer[5].'_detail'; // check table in database |
|
| 2046 | 2046 | |
| 2047 | 2047 | $error = ''; |
| 2048 | - if ($wpdb->get_var("SHOW TABLES LIKE '" . $table . "'") != $table) {
|
|
| 2048 | + if ($wpdb->get_var("SHOW TABLES LIKE '".$table."'") != $table) {
|
|
| 2049 | 2049 | $invalid_post_type++; |
| 2050 | 2050 | continue; |
| 2051 | 2051 | } |
@@ -2071,7 +2071,7 @@ discard block |
||
| 2071 | 2071 | if ($buffer[$c] != '0' && $buffer[$c] != '') {
|
| 2072 | 2072 | $submitdata = date('Y-m-d');
|
| 2073 | 2073 | |
| 2074 | - $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata . "+" . addslashes($buffer[$c]) . " days"));
|
|
| 2074 | + $gd_post_info['expire_date'] = date('Y-m-d', strtotime($submitdata."+".addslashes($buffer[$c])." days"));
|
|
| 2075 | 2075 | } else {
|
| 2076 | 2076 | $gd_post_info['expire_date'] = 'Never'; |
| 2077 | 2077 | } |
@@ -2099,7 +2099,7 @@ discard block |
||
| 2099 | 2099 | |
| 2100 | 2100 | // Post status |
| 2101 | 2101 | if ($customKeyarray[$c] == 'post_status') {
|
| 2102 | - $post_status = sanitize_key( $buffer[$c] ); |
|
| 2102 | + $post_status = sanitize_key($buffer[$c]); |
|
| 2103 | 2103 | } |
| 2104 | 2104 | } |
| 2105 | 2105 | |
@@ -2117,8 +2117,8 @@ discard block |
||
| 2117 | 2117 | |
| 2118 | 2118 | // Default post status |
| 2119 | 2119 | $default_status = 'publish'; |
| 2120 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
| 2121 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
| 2120 | + $post_status = !empty($post_status) ? sanitize_key($post_status) : $default_status; |
|
| 2121 | + $post_status = !empty($wp_post_statuses) && !isset($wp_post_statuses[$post_status]) ? $default_status : $post_status; |
|
| 2122 | 2122 | |
| 2123 | 2123 | $my_post['post_title'] = $post_title; |
| 2124 | 2124 | $my_post['post_content'] = $post_desc; |
@@ -2162,7 +2162,7 @@ discard block |
||
| 2162 | 2162 | $payment_info = array(); |
| 2163 | 2163 | $package_info = array(); |
| 2164 | 2164 | |
| 2165 | - $package_info = (array)geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2165 | + $package_info = (array) geodir_post_package_info($package_info, '', $buffer[5]); |
|
| 2166 | 2166 | $package_id = ''; |
| 2167 | 2167 | if (isset($gd_post_info['package_id']) && $gd_post_info['package_id'] != '') {
|
| 2168 | 2168 | $package_id = $gd_post_info['package_id']; |
@@ -2172,7 +2172,7 @@ discard block |
||
| 2172 | 2172 | $payment_info['package_id'] = $package_info['pid']; |
| 2173 | 2173 | |
| 2174 | 2174 | if (isset($package_info['alive_days']) && $package_info['alive_days'] != 0) {
|
| 2175 | - $payment_info['expire_date'] = date('Y-m-d', strtotime("+" . $package_info['alive_days'] . " days"));
|
|
| 2175 | + $payment_info['expire_date'] = date('Y-m-d', strtotime("+".$package_info['alive_days']." days"));
|
|
| 2176 | 2176 | } else {
|
| 2177 | 2177 | $payment_info['expire_date'] = 'Never'; |
| 2178 | 2178 | } |
@@ -2184,7 +2184,7 @@ discard block |
||
| 2184 | 2184 | |
| 2185 | 2185 | $post_type = get_post_type($last_postid); |
| 2186 | 2186 | |
| 2187 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
| 2187 | + $table = $plugin_prefix.$post_type.'_detail'; |
|
| 2188 | 2188 | |
| 2189 | 2189 | geodir_save_post_info($last_postid, $gd_post_info); |
| 2190 | 2190 | |
@@ -2205,7 +2205,7 @@ discard block |
||
| 2205 | 2205 | $attachment['post_id'] = $last_postid; |
| 2206 | 2206 | $attachment['title'] = $img_name_arr[0]; |
| 2207 | 2207 | $attachment['content'] = ''; |
| 2208 | - $attachment['file'] = $sub_dir . '/' . $image_name; |
|
| 2208 | + $attachment['file'] = $sub_dir.'/'.$image_name; |
|
| 2209 | 2209 | $attachment['mime_type'] = $uploaded_file_type; |
| 2210 | 2210 | $attachment['menu_order'] = $menu_order; |
| 2211 | 2211 | $attachment['is_featured'] = 0; |
@@ -2214,15 +2214,15 @@ discard block |
||
| 2214 | 2214 | |
| 2215 | 2215 | foreach ($attachment as $key => $val) {
|
| 2216 | 2216 | if ($val != '') |
| 2217 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
| 2217 | + $attachment_set .= $key." = '".$val."', "; |
|
| 2218 | 2218 | } |
| 2219 | 2219 | $attachment_set = trim($attachment_set, ", "); |
| 2220 | 2220 | |
| 2221 | - $wpdb->query("INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set);
|
|
| 2221 | + $wpdb->query("INSERT INTO ".GEODIR_ATTACHMENT_TABLE." SET ".$attachment_set);
|
|
| 2222 | 2222 | |
| 2223 | 2223 | if ($menu_order == 1) {
|
| 2224 | 2224 | $post_type = get_post_type($last_postid); |
| 2225 | - $wpdb->query($wpdb->prepare("UPDATE " . $table . " SET featured_image = %s where post_id =%d", array($sub_dir . '/' . $image_name, $last_postid)));
|
|
| 2225 | + $wpdb->query($wpdb->prepare("UPDATE ".$table." SET featured_image = %s where post_id =%d", array($sub_dir.'/'.$image_name, $last_postid)));
|
|
| 2226 | 2226 | } |
| 2227 | 2227 | $menu_order++; |
| 2228 | 2228 | } |
@@ -2263,11 +2263,11 @@ discard block |
||
| 2263 | 2263 | } |
| 2264 | 2264 | |
| 2265 | 2265 | // Add the tab in left sidebar menu fro import & export page. |
| 2266 | -add_filter( 'geodir_settings_tabs_array', 'geodir_import_export_tab', 94 ); |
|
| 2266 | +add_filter('geodir_settings_tabs_array', 'geodir_import_export_tab', 94);
|
|
| 2267 | 2267 | |
| 2268 | 2268 | // Handle ajax request for import/export. |
| 2269 | -add_action( 'wp_ajax_geodir_import_export', 'geodir_ajax_import_export' ); |
|
| 2270 | -add_action( 'wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export' ); |
|
| 2269 | +add_action('wp_ajax_geodir_import_export', 'geodir_ajax_import_export');
|
|
| 2270 | +add_action('wp_ajax_nopriv_geodir_import_exportn', 'geodir_ajax_import_export');
|
|
| 2271 | 2271 | |
| 2272 | 2272 | |
| 2273 | 2273 | /** |
@@ -2278,40 +2278,40 @@ discard block |
||
| 2278 | 2278 | * @param $post_id int $post_id The post ID of the post being saved. |
| 2279 | 2279 | * @param $post object $post The post object of the post being saved. |
| 2280 | 2280 | */ |
| 2281 | -function geodir_update_location_prefix($post_id,$post){
|
|
| 2282 | - if($post->post_type=='page' && $post->post_name && $post_id==get_option('geodir_location_page')){
|
|
| 2283 | - update_option('geodir_location_prefix',$post->post_name);
|
|
| 2281 | +function geodir_update_location_prefix($post_id, $post) {
|
|
| 2282 | + if ($post->post_type == 'page' && $post->post_name && $post_id == get_option('geodir_location_page')) {
|
|
| 2283 | + update_option('geodir_location_prefix', $post->post_name);
|
|
| 2284 | 2284 | } |
| 2285 | 2285 | |
| 2286 | 2286 | } |
| 2287 | 2287 | |
| 2288 | -add_action('save_post', 'geodir_update_location_prefix',10,2);
|
|
| 2288 | +add_action('save_post', 'geodir_update_location_prefix', 10, 2);
|
|
| 2289 | 2289 | |
| 2290 | -add_action( 'wp_ajax_geodir_ga_callback', 'geodir_ga_callback' ); |
|
| 2290 | +add_action('wp_ajax_geodir_ga_callback', 'geodir_ga_callback');
|
|
| 2291 | 2291 | |
| 2292 | -function geodir_ga_callback(){
|
|
| 2292 | +function geodir_ga_callback() {
|
|
| 2293 | 2293 | |
| 2294 | -if(isset($_REQUEST['code']) && $_REQUEST['code']) {
|
|
| 2294 | +if (isset($_REQUEST['code']) && $_REQUEST['code']) {
|
|
| 2295 | 2295 | $oAuthURL = "https://www.googleapis.com/oauth2/v3/token?"; |
| 2296 | 2296 | $code = "code=".$_REQUEST['code']; |
| 2297 | 2297 | $grant_type = "&grant_type=authorization_code"; |
| 2298 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback";
|
|
| 2298 | + $redirect_uri = "&redirect_uri=".admin_url('admin-ajax.php')."?action=geodir_ga_callback";
|
|
| 2299 | 2299 | $client_id = "&client_id=".get_option('geodir_ga_client_id');
|
| 2300 | 2300 | $client_secret = "&client_secret=".get_option('geodir_ga_client_secret');
|
| 2301 | 2301 | |
| 2302 | - $auth_url = $oAuthURL . $code . $redirect_uri . $grant_type . $client_id .$client_secret; |
|
| 2302 | + $auth_url = $oAuthURL.$code.$redirect_uri.$grant_type.$client_id.$client_secret; |
|
| 2303 | 2303 | |
| 2304 | 2304 | $response = wp_remote_post($auth_url, array('timeout' => 15));
|
| 2305 | 2305 | |
| 2306 | 2306 | //print_r($response); |
| 2307 | 2307 | |
| 2308 | - $error_msg = __('Something went wrong','geodirectory');
|
|
| 2309 | - if(!empty($response['response']['code']) && $response['response']['code']==200){
|
|
| 2308 | + $error_msg = __('Something went wrong', 'geodirectory');
|
|
| 2309 | + if (!empty($response['response']['code']) && $response['response']['code'] == 200) {
|
|
| 2310 | 2310 | |
| 2311 | 2311 | $parts = json_decode($response['body']); |
| 2312 | 2312 | //print_r($parts); |
| 2313 | - if(!isset($parts->access_token)){echo $error_msg." - #1";exit;}
|
|
| 2314 | - else{
|
|
| 2313 | + if (!isset($parts->access_token)) {echo $error_msg." - #1"; exit; }
|
|
| 2314 | + else {
|
|
| 2315 | 2315 | |
| 2316 | 2316 | update_option('gd_ga_access_token', $parts->access_token);
|
| 2317 | 2317 | update_option('gd_ga_refresh_token', $parts->refresh_token);
|
@@ -2320,18 +2320,18 @@ discard block |
||
| 2320 | 2320 | |
| 2321 | 2321 | |
| 2322 | 2322 | } |
| 2323 | - elseif(!empty($response['response']['code'])) {
|
|
| 2323 | + elseif (!empty($response['response']['code'])) {
|
|
| 2324 | 2324 | $parts = json_decode($response['body']); |
| 2325 | 2325 | |
| 2326 | - if(isset($parts->error)){
|
|
| 2327 | - echo $parts->error.": ".$parts->error_description;exit; |
|
| 2328 | - }else{
|
|
| 2329 | - echo $error_msg." - #2";exit; |
|
| 2326 | + if (isset($parts->error)) {
|
|
| 2327 | + echo $parts->error.": ".$parts->error_description; exit; |
|
| 2328 | + } else {
|
|
| 2329 | + echo $error_msg." - #2"; exit; |
|
| 2330 | 2330 | } |
| 2331 | 2331 | |
| 2332 | - }else{
|
|
| 2332 | + } else {
|
|
| 2333 | 2333 | |
| 2334 | - echo $error_msg." - #3";exit; |
|
| 2334 | + echo $error_msg." - #3"; exit; |
|
| 2335 | 2335 | |
| 2336 | 2336 | } |
| 2337 | 2337 | } |
@@ -2353,7 +2353,7 @@ discard block |
||
| 2353 | 2353 | function geodir_uninstall_settings($general_settings) {
|
| 2354 | 2354 | $settings = array(); |
| 2355 | 2355 | $settings[] = array('type' => 'title', 'id' => 'uninstall_settings', 'name' => __('Uninstall Settings', 'geodirectory'));
|
| 2356 | - $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory' ));
|
|
| 2356 | + $settings[] = array('type' => 'sectionstart', 'id' => 'uninstall_settings_main', 'name' => __('Remove Data on Uninstall?', 'geodirectory'));
|
|
| 2357 | 2357 | |
| 2358 | 2358 | $plugins = get_plugins(); |
| 2359 | 2359 | $un_plugins = apply_filters('geodir_plugins_uninstall_settings', array());
|
@@ -2365,7 +2365,7 @@ discard block |
||
| 2365 | 2365 | if (in_array($plugin_name, $un_plugins)) {
|
| 2366 | 2366 | $settings[] = array( |
| 2367 | 2367 | 'type' => 'checkbox', |
| 2368 | - 'id' => 'geodir_un_' . $plugin_name, |
|
| 2368 | + 'id' => 'geodir_un_'.$plugin_name, |
|
| 2369 | 2369 | 'name' => $data['Name'], |
| 2370 | 2370 | 'desc' => __('Remove all data when deleted?', 'geodirectory'),
|
| 2371 | 2371 | 'std' => '0' |
@@ -2399,7 +2399,7 @@ discard block |
||
| 2399 | 2399 | * @since 1.6.9 |
| 2400 | 2400 | */ |
| 2401 | 2401 | function geodir_uninstall_settings_desc() {
|
| 2402 | - echo '<p class="gd-un-settings-desc">' . __('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory') . '</p>';
|
|
| 2402 | + echo '<p class="gd-un-settings-desc">'.__('Select the plugins that you would like to completely remove all of its data when the plugin is deleted.', 'geodirectory').'</p>';
|
|
| 2403 | 2403 | } |
| 2404 | 2404 | add_action('geodir_settings_uninstall_settings_main_start', 'geodir_uninstall_settings_desc');
|
| 2405 | 2405 | |