@@ -13,134 +13,134 @@ 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 | - { |
|
69 | - |
|
70 | - wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.5.0/js/all.js#faload', array('font-awesome-shim'), GEODIRECTORY_VERSION); |
|
71 | - wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.5.0/js/v4-shims.js', array(), GEODIRECTORY_VERSION); |
|
72 | - wp_enqueue_script( 'font-awesome' ); |
|
73 | - |
|
74 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION); |
|
75 | - wp_enqueue_script('geodirectory-admin'); |
|
61 | + /** |
|
62 | + * Loads stylesheets from CDN. |
|
63 | + * |
|
64 | + * @since 1.0.0 |
|
65 | + * @package GeoDirectory |
|
66 | + */ |
|
67 | + function geodir_admin_styles_req() |
|
68 | + { |
|
76 | 69 | |
77 | - } |
|
70 | + wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.5.0/js/all.js#faload', array('font-awesome-shim'), GEODIRECTORY_VERSION); |
|
71 | + wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.5.0/js/v4-shims.js', array(), GEODIRECTORY_VERSION); |
|
72 | + wp_enqueue_script( 'font-awesome' ); |
|
73 | + |
|
74 | + wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION); |
|
75 | + wp_enqueue_script('geodirectory-admin'); |
|
76 | + |
|
77 | + } |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | if (!function_exists('geodir_admin_scripts')) { |
81 | - /** |
|
82 | - * Enqueue Admin Scripts. |
|
83 | - * |
|
84 | - * @since 1.0.0 |
|
85 | - * @package GeoDirectory |
|
86 | - */ |
|
87 | - function geodir_admin_scripts() |
|
88 | - { |
|
89 | - $geodir_map_name = geodir_map_name(); |
|
81 | + /** |
|
82 | + * Enqueue Admin Scripts. |
|
83 | + * |
|
84 | + * @since 1.0.0 |
|
85 | + * @package GeoDirectory |
|
86 | + */ |
|
87 | + function geodir_admin_scripts() |
|
88 | + { |
|
89 | + $geodir_map_name = geodir_map_name(); |
|
90 | 90 | |
91 | - wp_enqueue_script('jquery'); |
|
91 | + wp_enqueue_script('jquery'); |
|
92 | 92 | |
93 | - 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 | + 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); |
|
94 | 94 | |
95 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION); |
|
96 | - wp_enqueue_script('chosen'); |
|
95 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION); |
|
96 | + wp_enqueue_script('chosen'); |
|
97 | 97 | |
98 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION); |
|
99 | - wp_enqueue_script('geodirectory-choose-ajax'); |
|
98 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION); |
|
99 | + wp_enqueue_script('geodirectory-choose-ajax'); |
|
100 | 100 | |
101 | - if (isset($_REQUEST['listing_type'])) { |
|
102 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION); |
|
103 | - } |
|
101 | + if (isset($_REQUEST['listing_type'])) { |
|
102 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION); |
|
103 | + } |
|
104 | 104 | |
105 | - wp_enqueue_script('geodirectory-custom-fields-script'); |
|
106 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
105 | + wp_enqueue_script('geodirectory-custom-fields-script'); |
|
106 | + $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
107 | 107 | |
108 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true); |
|
108 | + wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true); |
|
109 | 109 | |
110 | - if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
111 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
112 | - $map_key = "&key=" . geodir_get_map_api_key(); |
|
113 | - /** This filter is documented in geodirectory_template_tags.php */ |
|
114 | - $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
115 | - wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL); |
|
110 | + if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
111 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
112 | + $map_key = "&key=" . geodir_get_map_api_key(); |
|
113 | + /** This filter is documented in geodirectory_template_tags.php */ |
|
114 | + $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
115 | + wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL); |
|
116 | 116 | |
117 | - // Overlapping Marker Spiderfier |
|
118 | - wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION); |
|
119 | - wp_enqueue_script('geodirectory-g-overlappingmarker-script'); |
|
120 | - } |
|
117 | + // Overlapping Marker Spiderfier |
|
118 | + wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION); |
|
119 | + wp_enqueue_script('geodirectory-g-overlappingmarker-script'); |
|
120 | + } |
|
121 | 121 | |
122 | - if ($geodir_map_name == 'osm') { |
|
123 | - // Leaflet OpenStreetMap |
|
124 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
125 | - wp_enqueue_style('geodirectory-leaflet-style'); |
|
122 | + if ($geodir_map_name == 'osm') { |
|
123 | + // Leaflet OpenStreetMap |
|
124 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
125 | + wp_enqueue_style('geodirectory-leaflet-style'); |
|
126 | 126 | |
127 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
128 | - wp_enqueue_script('geodirectory-leaflet-script'); |
|
127 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
128 | + wp_enqueue_script('geodirectory-leaflet-script'); |
|
129 | 129 | |
130 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION); |
|
131 | - wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
130 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION); |
|
131 | + wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
132 | 132 | |
133 | - // Overlapping Marker Spiderfier Leaflet |
|
134 | - wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
135 | - wp_enqueue_script('geodirectory-o-overlappingmarker-script'); |
|
136 | - } |
|
137 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
133 | + // Overlapping Marker Spiderfier Leaflet |
|
134 | + wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
135 | + wp_enqueue_script('geodirectory-o-overlappingmarker-script'); |
|
136 | + } |
|
137 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
138 | 138 | |
139 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true); |
|
140 | - wp_enqueue_script('geodirectory-goMap-script'); |
|
139 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true); |
|
140 | + wp_enqueue_script('geodirectory-goMap-script'); |
|
141 | 141 | |
142 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION); |
|
143 | - wp_enqueue_script('geodirectory-goMap-script'); |
|
142 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION); |
|
143 | + wp_enqueue_script('geodirectory-goMap-script'); |
|
144 | 144 | |
145 | 145 | // font awesome rating script |
146 | 146 | if (get_option('geodir_reviewrating_enable_font_awesome')) { |
@@ -151,167 +151,167 @@ discard block |
||
151 | 151 | wp_enqueue_script('geodir-jRating-js'); |
152 | 152 | } |
153 | 153 | |
154 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION); |
|
155 | - wp_enqueue_script('geodir-on-document-load'); |
|
156 | - |
|
157 | - |
|
158 | - // SCRIPT FOR UPLOAD |
|
159 | - wp_enqueue_script('plupload-all'); |
|
160 | - wp_enqueue_script('jquery-ui-sortable'); |
|
161 | - |
|
162 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION); |
|
163 | - wp_enqueue_script('geodirectory-plupload-script'); |
|
164 | - |
|
165 | - // SCRIPT FOR UPLOAD END |
|
166 | - |
|
167 | - |
|
168 | - // place js config array for plupload |
|
169 | - $plupload_init = array( |
|
170 | - 'runtimes' => 'html5,silverlight,html4', |
|
171 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
172 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
173 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
174 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
175 | - 'multiple_queues' => true, |
|
176 | - 'max_file_size' => geodir_max_upload_size(), |
|
177 | - 'url' => admin_url('admin-ajax.php'), |
|
178 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
179 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
180 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
181 | - 'multipart' => true, |
|
182 | - 'urlstream_upload' => true, |
|
183 | - 'multi_selection' => false, // will be added per uploader |
|
184 | - // additional post data to send to our ajax hook |
|
185 | - 'multipart_params' => array( |
|
186 | - '_ajax_nonce' => "", // will be added per uploader |
|
187 | - 'action' => 'plupload_action', // the ajax action name |
|
188 | - 'imgid' => 0 // will be added per uploader |
|
189 | - ) |
|
190 | - ); |
|
191 | - $base_plupload_config = json_encode($plupload_init); |
|
192 | - |
|
193 | - |
|
194 | - $thumb_img_arr = array(); |
|
195 | - |
|
196 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
197 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
198 | - |
|
199 | - $totImg = ''; |
|
200 | - $image_limit = ''; |
|
201 | - if (!empty($thumb_img_arr)) { |
|
202 | - $totImg = count($thumb_img_arr); |
|
203 | - } |
|
154 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION); |
|
155 | + wp_enqueue_script('geodir-on-document-load'); |
|
156 | + |
|
157 | + |
|
158 | + // SCRIPT FOR UPLOAD |
|
159 | + wp_enqueue_script('plupload-all'); |
|
160 | + wp_enqueue_script('jquery-ui-sortable'); |
|
161 | + |
|
162 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION); |
|
163 | + wp_enqueue_script('geodirectory-plupload-script'); |
|
164 | + |
|
165 | + // SCRIPT FOR UPLOAD END |
|
166 | + |
|
167 | + |
|
168 | + // place js config array for plupload |
|
169 | + $plupload_init = array( |
|
170 | + 'runtimes' => 'html5,silverlight,html4', |
|
171 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
172 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
173 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
174 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
175 | + 'multiple_queues' => true, |
|
176 | + 'max_file_size' => geodir_max_upload_size(), |
|
177 | + 'url' => admin_url('admin-ajax.php'), |
|
178 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
179 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
180 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
181 | + 'multipart' => true, |
|
182 | + 'urlstream_upload' => true, |
|
183 | + 'multi_selection' => false, // will be added per uploader |
|
184 | + // additional post data to send to our ajax hook |
|
185 | + 'multipart_params' => array( |
|
186 | + '_ajax_nonce' => "", // will be added per uploader |
|
187 | + 'action' => 'plupload_action', // the ajax action name |
|
188 | + 'imgid' => 0 // will be added per uploader |
|
189 | + ) |
|
190 | + ); |
|
191 | + $base_plupload_config = json_encode($plupload_init); |
|
192 | + |
|
193 | + |
|
194 | + $thumb_img_arr = array(); |
|
195 | + |
|
196 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
197 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
198 | + |
|
199 | + $totImg = ''; |
|
200 | + $image_limit = ''; |
|
201 | + if (!empty($thumb_img_arr)) { |
|
202 | + $totImg = count($thumb_img_arr); |
|
203 | + } |
|
204 | 204 | |
205 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
206 | - 'totalImg' => $totImg, |
|
207 | - 'image_limit' => $image_limit, |
|
208 | - 'upload_img_size' => geodir_max_upload_size()); |
|
205 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
206 | + 'totalImg' => $totImg, |
|
207 | + 'image_limit' => $image_limit, |
|
208 | + 'upload_img_size' => geodir_max_upload_size()); |
|
209 | 209 | |
210 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
210 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
211 | 211 | |
212 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php'))); |
|
213 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data); |
|
212 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php'))); |
|
213 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data); |
|
214 | 214 | |
215 | 215 | |
216 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION); |
|
217 | - wp_enqueue_script('geodirectory-admin-script'); |
|
216 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION); |
|
217 | + wp_enqueue_script('geodirectory-admin-script'); |
|
218 | 218 | |
219 | - wp_enqueue_style('farbtastic'); |
|
220 | - wp_enqueue_script('farbtastic'); |
|
219 | + wp_enqueue_style('farbtastic'); |
|
220 | + wp_enqueue_script('farbtastic'); |
|
221 | 221 | |
222 | - $screen = get_current_screen(); |
|
223 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) { |
|
224 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js'); |
|
225 | - } |
|
222 | + $screen = get_current_screen(); |
|
223 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) { |
|
224 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js'); |
|
225 | + } |
|
226 | 226 | |
227 | - $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true'))); |
|
228 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data); |
|
227 | + $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true'))); |
|
228 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data); |
|
229 | 229 | |
230 | - } |
|
230 | + } |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | if (!function_exists('geodir_admin_menu')) { |
234 | - /** |
|
235 | - * Admin Menus |
|
236 | - * |
|
237 | - * Sets up the admin menus in wordpress. |
|
238 | - * |
|
239 | - * @since 1.0.0 |
|
240 | - * @package GeoDirectory |
|
241 | - * @global array $menu Menu array. |
|
242 | - * @global object $geodirectory GeoDirectory plugin object. |
|
243 | - */ |
|
244 | - function geodir_admin_menu() |
|
245 | - { |
|
246 | - global $menu, $geodirectory; |
|
234 | + /** |
|
235 | + * Admin Menus |
|
236 | + * |
|
237 | + * Sets up the admin menus in wordpress. |
|
238 | + * |
|
239 | + * @since 1.0.0 |
|
240 | + * @package GeoDirectory |
|
241 | + * @global array $menu Menu array. |
|
242 | + * @global object $geodirectory GeoDirectory plugin object. |
|
243 | + */ |
|
244 | + function geodir_admin_menu() |
|
245 | + { |
|
246 | + global $menu, $geodirectory; |
|
247 | 247 | |
248 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory'); |
|
248 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory'); |
|
249 | 249 | |
250 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984'); |
|
250 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984'); |
|
251 | 251 | |
252 | 252 | |
253 | - } |
|
253 | + } |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | if (!function_exists('geodir_admin_menu_order')) { |
257 | - /** |
|
258 | - * Order admin menus. |
|
259 | - * |
|
260 | - * @since 1.0.0 |
|
261 | - * @package GeoDirectory |
|
262 | - * @param array $menu_order Menu order array. |
|
263 | - * @return array Modified menu order array. |
|
264 | - */ |
|
265 | - function geodir_admin_menu_order($menu_order) |
|
266 | - { |
|
267 | - |
|
268 | - // Initialize our custom order array |
|
269 | - $geodir_menu_order = array(); |
|
270 | - |
|
271 | - // Get the index of our custom separator |
|
272 | - $geodir_separator = array_search('separator-geodirectory', $menu_order); |
|
273 | - |
|
274 | - // Get index of posttype menu |
|
275 | - $post_types = geodir_get_posttypes(); |
|
276 | - |
|
277 | - // Loop through menu order and do some rearranging |
|
278 | - foreach ($menu_order as $index => $item) : |
|
279 | - |
|
280 | - if ((('geodirectory') == $item)) : |
|
281 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
282 | - if (!empty($post_types)) { |
|
283 | - foreach ($post_types as $post_type) { |
|
284 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
285 | - } |
|
286 | - } |
|
287 | - $geodir_menu_order[] = $item; |
|
257 | + /** |
|
258 | + * Order admin menus. |
|
259 | + * |
|
260 | + * @since 1.0.0 |
|
261 | + * @package GeoDirectory |
|
262 | + * @param array $menu_order Menu order array. |
|
263 | + * @return array Modified menu order array. |
|
264 | + */ |
|
265 | + function geodir_admin_menu_order($menu_order) |
|
266 | + { |
|
288 | 267 | |
289 | - unset($menu_order[$geodir_separator]); |
|
290 | - //unset( $menu_order[$geodir_places] ); |
|
291 | - elseif (!in_array($item, array('separator-geodirectory'))) : |
|
292 | - $geodir_menu_order[] = $item; |
|
293 | - endif; |
|
268 | + // Initialize our custom order array |
|
269 | + $geodir_menu_order = array(); |
|
294 | 270 | |
295 | - endforeach; |
|
271 | + // Get the index of our custom separator |
|
272 | + $geodir_separator = array_search('separator-geodirectory', $menu_order); |
|
296 | 273 | |
297 | - // Return order |
|
298 | - return $geodir_menu_order; |
|
299 | - } |
|
274 | + // Get index of posttype menu |
|
275 | + $post_types = geodir_get_posttypes(); |
|
276 | + |
|
277 | + // Loop through menu order and do some rearranging |
|
278 | + foreach ($menu_order as $index => $item) : |
|
279 | + |
|
280 | + if ((('geodirectory') == $item)) : |
|
281 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
282 | + if (!empty($post_types)) { |
|
283 | + foreach ($post_types as $post_type) { |
|
284 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
285 | + } |
|
286 | + } |
|
287 | + $geodir_menu_order[] = $item; |
|
288 | + |
|
289 | + unset($menu_order[$geodir_separator]); |
|
290 | + //unset( $menu_order[$geodir_places] ); |
|
291 | + elseif (!in_array($item, array('separator-geodirectory'))) : |
|
292 | + $geodir_menu_order[] = $item; |
|
293 | + endif; |
|
294 | + |
|
295 | + endforeach; |
|
296 | + |
|
297 | + // Return order |
|
298 | + return $geodir_menu_order; |
|
299 | + } |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | if (!function_exists('geodir_admin_custom_menu_order')) { |
303 | - /** |
|
304 | - * Enables custom menu order. |
|
305 | - * |
|
306 | - * @since 1.0.0 |
|
307 | - * @package GeoDirectory |
|
308 | - * @return bool |
|
309 | - */ |
|
310 | - function geodir_admin_custom_menu_order() |
|
311 | - { |
|
312 | - if (!current_user_can('manage_options')) return false; |
|
313 | - return true; |
|
314 | - } |
|
303 | + /** |
|
304 | + * Enables custom menu order. |
|
305 | + * |
|
306 | + * @since 1.0.0 |
|
307 | + * @package GeoDirectory |
|
308 | + * @return bool |
|
309 | + */ |
|
310 | + function geodir_admin_custom_menu_order() |
|
311 | + { |
|
312 | + if (!current_user_can('manage_options')) return false; |
|
313 | + return true; |
|
314 | + } |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,51 +322,51 @@ discard block |
||
322 | 322 | */ |
323 | 323 | function geodir_before_admin_panel() |
324 | 324 | { |
325 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') { |
|
326 | - echo '<div id="message" class="updated fade"> |
|
325 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') { |
|
326 | + echo '<div id="message" class="updated fade"> |
|
327 | 327 | <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> |
328 | 328 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p> |
329 | 329 | </div>'; |
330 | 330 | |
331 | - } |
|
331 | + } |
|
332 | 332 | |
333 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') { |
|
334 | - switch ($_REQUEST['msg']) { |
|
335 | - case 'success': |
|
336 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>'; |
|
337 | - flush_rewrite_rules(false); |
|
333 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') { |
|
334 | + switch ($_REQUEST['msg']) { |
|
335 | + case 'success': |
|
336 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>'; |
|
337 | + flush_rewrite_rules(false); |
|
338 | 338 | |
339 | - break; |
|
339 | + break; |
|
340 | 340 | case 'fail': |
341 | 341 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
342 | 342 | |
343 | 343 | if ($gderr == 21) |
344 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>'; |
|
344 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>'; |
|
345 | 345 | else |
346 | 346 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>'; |
347 | - break; |
|
348 | - } |
|
349 | - } |
|
347 | + break; |
|
348 | + } |
|
349 | + } |
|
350 | 350 | |
351 | - $geodir_load_map = get_option('geodir_load_map'); |
|
352 | - $need_map_key = false; |
|
353 | - if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){ |
|
354 | - $need_map_key = true; |
|
355 | - } |
|
351 | + $geodir_load_map = get_option('geodir_load_map'); |
|
352 | + $need_map_key = false; |
|
353 | + if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){ |
|
354 | + $need_map_key = true; |
|
355 | + } |
|
356 | 356 | |
357 | - if (!geodir_get_map_api_key() && $need_map_key) { |
|
358 | - 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>'; |
|
359 | - } |
|
357 | + if (!geodir_get_map_api_key() && $need_map_key) { |
|
358 | + 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>'; |
|
359 | + } |
|
360 | 360 | |
361 | - if (!geodir_is_default_location_set()) { |
|
362 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
361 | + if (!geodir_is_default_location_set()) { |
|
362 | + 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>'; |
|
363 | 363 | |
364 | - } |
|
364 | + } |
|
365 | 365 | |
366 | - if (!function_exists('curl_init')) { |
|
367 | - echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>'; |
|
366 | + if (!function_exists('curl_init')) { |
|
367 | + 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>'; |
|
368 | 368 | |
369 | - } |
|
369 | + } |
|
370 | 370 | |
371 | 371 | |
372 | 372 | |
@@ -383,19 +383,19 @@ discard block |
||
383 | 383 | */ |
384 | 384 | function geodir_handle_option_form_submit($current_tab) |
385 | 385 | { |
386 | - global $geodir_settings; |
|
387 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) { |
|
388 | - /** |
|
389 | - * Contains settings array for current tab. |
|
390 | - * |
|
391 | - * @since 1.0.0 |
|
392 | - * @package GeoDirectory |
|
393 | - */ |
|
394 | - include_once('option-pages/' . $current_tab . '_array.php'); |
|
395 | - } |
|
396 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
397 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
398 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
386 | + global $geodir_settings; |
|
387 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) { |
|
388 | + /** |
|
389 | + * Contains settings array for current tab. |
|
390 | + * |
|
391 | + * @since 1.0.0 |
|
392 | + * @package GeoDirectory |
|
393 | + */ |
|
394 | + include_once('option-pages/' . $current_tab . '_array.php'); |
|
395 | + } |
|
396 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
397 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
398 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
399 | 399 | |
400 | 400 | /** |
401 | 401 | * Fires before updating geodirectory admin settings. |
@@ -407,38 +407,38 @@ discard block |
||
407 | 407 | */ |
408 | 408 | do_action('geodir_before_update_options', $current_tab, $geodir_settings); |
409 | 409 | |
410 | - if (!empty($geodir_settings[$current_tab])) |
|
411 | - geodir_update_options($geodir_settings[$current_tab]); |
|
410 | + if (!empty($geodir_settings[$current_tab])) |
|
411 | + geodir_update_options($geodir_settings[$current_tab]); |
|
412 | 412 | |
413 | - /** |
|
414 | - * Called after GeoDirectory options settings are updated. |
|
415 | - * |
|
416 | - * @since 1.0.0 |
|
417 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
418 | - * @see 'geodir_before_update_options' |
|
419 | - */ |
|
420 | - do_action('geodir_update_options', $geodir_settings); |
|
413 | + /** |
|
414 | + * Called after GeoDirectory options settings are updated. |
|
415 | + * |
|
416 | + * @since 1.0.0 |
|
417 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
418 | + * @see 'geodir_before_update_options' |
|
419 | + */ |
|
420 | + do_action('geodir_update_options', $geodir_settings); |
|
421 | 421 | |
422 | - /** |
|
423 | - * Called after GeoDirectory options settings are updated. |
|
424 | - * |
|
425 | - * Provides tab specific settings. |
|
426 | - * |
|
427 | - * @since 1.0.0 |
|
428 | - * @param string $current_tab The current settings tab name. |
|
429 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
430 | - */ |
|
431 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]); |
|
422 | + /** |
|
423 | + * Called after GeoDirectory options settings are updated. |
|
424 | + * |
|
425 | + * Provides tab specific settings. |
|
426 | + * |
|
427 | + * @since 1.0.0 |
|
428 | + * @param string $current_tab The current settings tab name. |
|
429 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
430 | + */ |
|
431 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]); |
|
432 | 432 | |
433 | - flush_rewrite_rules(false); |
|
433 | + flush_rewrite_rules(false); |
|
434 | 434 | |
435 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
435 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
436 | 436 | |
437 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success'); |
|
437 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success'); |
|
438 | 438 | |
439 | - wp_redirect($redirect_url); |
|
440 | - exit(); |
|
441 | - endif; |
|
439 | + wp_redirect($redirect_url); |
|
440 | + exit(); |
|
441 | + endif; |
|
442 | 442 | |
443 | 443 | |
444 | 444 | } |
@@ -456,144 +456,144 @@ discard block |
||
456 | 456 | * @return bool Returns true if saved. |
457 | 457 | */ |
458 | 458 | function geodir_update_options($options, $dummy = false) { |
459 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
459 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
460 | 460 | |
461 | - foreach ($options as $value) { |
|
462 | - if ($dummy && isset($value['std'])) |
|
463 | - $_POST[$value['id']] = $value['std']; |
|
461 | + foreach ($options as $value) { |
|
462 | + if ($dummy && isset($value['std'])) |
|
463 | + $_POST[$value['id']] = $value['std']; |
|
464 | 464 | |
465 | 465 | |
466 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
466 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
467 | 467 | |
468 | - if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
469 | - update_option($value['id'], $_POST[$value['id']]); |
|
470 | - } else { |
|
471 | - update_option($value['id'], 0); |
|
472 | - } |
|
468 | + if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
469 | + update_option($value['id'], $_POST[$value['id']]); |
|
470 | + } else { |
|
471 | + update_option($value['id'], 0); |
|
472 | + } |
|
473 | 473 | |
474 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
474 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
475 | 475 | |
476 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) { |
|
477 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
478 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
479 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
480 | - update_option($value['id'] . '_crop', 1); |
|
481 | - else : |
|
482 | - update_option($value['id'] . '_crop', 0); |
|
483 | - endif; |
|
484 | - } else { |
|
485 | - update_option($value['id'] . '_width', $value['std']); |
|
486 | - update_option($value['id'] . '_height', $value['std']); |
|
487 | - update_option($value['id'] . '_crop', 1); |
|
488 | - } |
|
476 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) { |
|
477 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
478 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
479 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
480 | + update_option($value['id'] . '_crop', 1); |
|
481 | + else : |
|
482 | + update_option($value['id'] . '_crop', 0); |
|
483 | + endif; |
|
484 | + } else { |
|
485 | + update_option($value['id'] . '_width', $value['std']); |
|
486 | + update_option($value['id'] . '_height', $value['std']); |
|
487 | + update_option($value['id'] . '_crop', 1); |
|
488 | + } |
|
489 | 489 | |
490 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
491 | - $post_types = array(); |
|
492 | - $categories = array(); |
|
490 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
491 | + $post_types = array(); |
|
492 | + $categories = array(); |
|
493 | 493 | |
494 | - if (!empty($_POST['home_map_post_types'])) : |
|
495 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
496 | - $post_types[] = $post_type; |
|
497 | - endforeach; |
|
498 | - endif; |
|
494 | + if (!empty($_POST['home_map_post_types'])) : |
|
495 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
496 | + $post_types[] = $post_type; |
|
497 | + endforeach; |
|
498 | + endif; |
|
499 | 499 | |
500 | - update_option('geodir_exclude_post_type_on_map', $post_types); |
|
500 | + update_option('geodir_exclude_post_type_on_map', $post_types); |
|
501 | 501 | |
502 | - if (!empty($_POST['post_category'])) : |
|
503 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
504 | - $categories[$texonomy] = array(); |
|
505 | - foreach ($cat_arr as $category) : |
|
506 | - $categories[$texonomy][] = $category; |
|
507 | - endforeach; |
|
508 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
509 | - endforeach; |
|
510 | - endif; |
|
511 | - update_option('geodir_exclude_cat_on_map', $categories); |
|
512 | - update_option('geodir_exclude_cat_on_map_upgrade', 1); |
|
513 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
502 | + if (!empty($_POST['post_category'])) : |
|
503 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
504 | + $categories[$texonomy] = array(); |
|
505 | + foreach ($cat_arr as $category) : |
|
506 | + $categories[$texonomy][] = $category; |
|
507 | + endforeach; |
|
508 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
509 | + endforeach; |
|
510 | + endif; |
|
511 | + update_option('geodir_exclude_cat_on_map', $categories); |
|
512 | + update_option('geodir_exclude_cat_on_map_upgrade', 1); |
|
513 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
514 | 514 | |
515 | 515 | |
516 | - if (!empty($_POST['geodir_default_map_language'])): |
|
517 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']); |
|
518 | - endif; |
|
516 | + if (!empty($_POST['geodir_default_map_language'])): |
|
517 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']); |
|
518 | + endif; |
|
519 | 519 | |
520 | 520 | |
521 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
522 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']); |
|
523 | - endif; |
|
521 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
522 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']); |
|
523 | + endif; |
|
524 | 524 | |
525 | 525 | |
526 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
526 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
527 | 527 | |
528 | 528 | |
529 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file |
|
529 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file |
|
530 | 530 | |
531 | - if (get_option($value['id'])) { |
|
532 | - $image_name_arr = explode('/', get_option($value['id'])); |
|
533 | - $noimg_name = end($image_name_arr); |
|
534 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
535 | - if (file_exists($img_path)) |
|
536 | - unlink($img_path); |
|
537 | - } |
|
531 | + if (get_option($value['id'])) { |
|
532 | + $image_name_arr = explode('/', get_option($value['id'])); |
|
533 | + $noimg_name = end($image_name_arr); |
|
534 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
535 | + if (file_exists($img_path)) |
|
536 | + unlink($img_path); |
|
537 | + } |
|
538 | 538 | |
539 | - update_option($value['id'], ''); |
|
540 | - } |
|
539 | + update_option($value['id'], ''); |
|
540 | + } |
|
541 | 541 | |
542 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
543 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
544 | - |
|
545 | - if (!empty($filename)): |
|
546 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
547 | - $uplaods = array(); |
|
548 | - |
|
549 | - foreach ($uploadedfile as $key => $uplaod): |
|
550 | - if ($key == 'name'): |
|
551 | - $uplaods[$key] = $filename; |
|
552 | - else : |
|
553 | - $uplaods[$key] = $uplaod; |
|
554 | - endif; |
|
555 | - endforeach; |
|
556 | - |
|
557 | - $uploads = wp_upload_dir(); |
|
558 | - |
|
559 | - if (get_option($value['id'])) { |
|
560 | - $image_name_arr = explode('/', get_option($value['id'])); |
|
561 | - $noimg_name = end($image_name_arr); |
|
562 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
563 | - if (file_exists($img_path)) |
|
564 | - unlink($img_path); |
|
565 | - } |
|
542 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
543 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
544 | + |
|
545 | + if (!empty($filename)): |
|
546 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
547 | + $uplaods = array(); |
|
548 | + |
|
549 | + foreach ($uploadedfile as $key => $uplaod): |
|
550 | + if ($key == 'name'): |
|
551 | + $uplaods[$key] = $filename; |
|
552 | + else : |
|
553 | + $uplaods[$key] = $uplaod; |
|
554 | + endif; |
|
555 | + endforeach; |
|
556 | + |
|
557 | + $uploads = wp_upload_dir(); |
|
558 | + |
|
559 | + if (get_option($value['id'])) { |
|
560 | + $image_name_arr = explode('/', get_option($value['id'])); |
|
561 | + $noimg_name = end($image_name_arr); |
|
562 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
563 | + if (file_exists($img_path)) |
|
564 | + unlink($img_path); |
|
565 | + } |
|
566 | 566 | |
567 | - $upload_overrides = array('test_form' => false); |
|
568 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
567 | + $upload_overrides = array('test_form' => false); |
|
568 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
569 | 569 | |
570 | - update_option($value['id'], $movefile['url']); |
|
570 | + update_option($value['id'], $movefile['url']); |
|
571 | 571 | |
572 | - endif; |
|
572 | + endif; |
|
573 | 573 | |
574 | - if (!get_option($value['id']) && isset($value['value'])): |
|
575 | - update_option($value['id'], $value['value']); |
|
576 | - endif; |
|
574 | + if (!get_option($value['id']) && isset($value['value'])): |
|
575 | + update_option($value['id'], $value['value']); |
|
576 | + endif; |
|
577 | 577 | |
578 | 578 | |
579 | - else : |
|
580 | - // same menu setting per theme. |
|
581 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) { |
|
582 | - $theme = wp_get_theme(); |
|
583 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]); |
|
584 | - } |
|
579 | + else : |
|
580 | + // same menu setting per theme. |
|
581 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) { |
|
582 | + $theme = wp_get_theme(); |
|
583 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]); |
|
584 | + } |
|
585 | 585 | |
586 | - if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
587 | - update_option($value['id'], $_POST[$value['id']]); |
|
588 | - } else { |
|
589 | - delete_option($value['id']); |
|
590 | - } |
|
586 | + if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
587 | + update_option($value['id'], $_POST[$value['id']]); |
|
588 | + } else { |
|
589 | + delete_option($value['id']); |
|
590 | + } |
|
591 | 591 | |
592 | - endif; |
|
593 | - } |
|
594 | - if ($dummy) |
|
595 | - $_POST = array(); |
|
596 | - return true; |
|
592 | + endif; |
|
593 | + } |
|
594 | + if ($dummy) |
|
595 | + $_POST = array(); |
|
596 | + return true; |
|
597 | 597 | |
598 | 598 | } |
599 | 599 | |
@@ -642,33 +642,33 @@ discard block |
||
642 | 642 | function places_custom_fields_tab($tabs) |
643 | 643 | { |
644 | 644 | |
645 | - $geodir_post_types = get_option('geodir_post_types'); |
|
645 | + $geodir_post_types = get_option('geodir_post_types'); |
|
646 | 646 | |
647 | - if (!empty($geodir_post_types)) { |
|
647 | + if (!empty($geodir_post_types)) { |
|
648 | 648 | |
649 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
649 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
650 | 650 | |
651 | - $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
651 | + $listing_slug = __($geodir_posttype_info['labels']['singular_name'], 'geodirectory'); |
|
652 | 652 | |
653 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
654 | - 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug), |
|
655 | - 'subtabs' => array( |
|
656 | - array('subtab' => 'custom_fields', |
|
657 | - 'label' => __('Custom Fields', 'geodirectory'), |
|
658 | - 'request' => array('listing_type' => $geodir_post_type)), |
|
659 | - array('subtab' => 'sorting_options', |
|
660 | - 'label' => __('Sorting Options', 'geodirectory'), |
|
661 | - 'request' => array('listing_type' => $geodir_post_type)), |
|
662 | - ), |
|
663 | - 'tab_index' => 9, |
|
664 | - 'request' => array('listing_type' => $geodir_post_type) |
|
665 | - ); |
|
653 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
654 | + 'label' => wp_sprintf(__('%s Settings', 'geodirectory'), $listing_slug), |
|
655 | + 'subtabs' => array( |
|
656 | + array('subtab' => 'custom_fields', |
|
657 | + 'label' => __('Custom Fields', 'geodirectory'), |
|
658 | + 'request' => array('listing_type' => $geodir_post_type)), |
|
659 | + array('subtab' => 'sorting_options', |
|
660 | + 'label' => __('Sorting Options', 'geodirectory'), |
|
661 | + 'request' => array('listing_type' => $geodir_post_type)), |
|
662 | + ), |
|
663 | + 'tab_index' => 9, |
|
664 | + 'request' => array('listing_type' => $geodir_post_type) |
|
665 | + ); |
|
666 | 666 | |
667 | - endforeach; |
|
667 | + endforeach; |
|
668 | 668 | |
669 | - } |
|
669 | + } |
|
670 | 670 | |
671 | - return $tabs; |
|
671 | + return $tabs; |
|
672 | 672 | } |
673 | 673 | |
674 | 674 | |
@@ -684,9 +684,9 @@ discard block |
||
684 | 684 | */ |
685 | 685 | function geodir_tools_setting_tab($tabs) |
686 | 686 | { |
687 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
688 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory')); |
|
689 | - return $tabs; |
|
687 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
688 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory')); |
|
689 | + return $tabs; |
|
690 | 690 | } |
691 | 691 | |
692 | 692 | /** |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | */ |
702 | 702 | function geodir_compatibility_setting_tab($tabs) |
703 | 703 | { |
704 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory')); |
|
705 | - return $tabs; |
|
704 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory')); |
|
705 | + return $tabs; |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | |
@@ -718,144 +718,144 @@ discard block |
||
718 | 718 | */ |
719 | 719 | function geodir_extend_geodirectory_setting_tab($tabs) |
720 | 720 | { |
721 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fas fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank'); |
|
722 | - return $tabs; |
|
721 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fas fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank'); |
|
722 | + return $tabs; |
|
723 | 723 | } |
724 | 724 | |
725 | 725 | |
726 | 726 | if (!function_exists('geodir_edit_post_columns')) { |
727 | - /** |
|
728 | - * Modify admin post listing page columns. |
|
729 | - * |
|
730 | - * @since 1.0.0 |
|
731 | - * @package GeoDirectory |
|
732 | - * @param array $columns The column array. |
|
733 | - * @return array Altered column array. |
|
734 | - */ |
|
735 | - function geodir_edit_post_columns($columns) |
|
736 | - { |
|
737 | - |
|
738 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'), |
|
739 | - 'categorys' => __('Categories', 'geodirectory')); |
|
740 | - |
|
741 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist |
|
742 | - { |
|
743 | - $offset = 0; // should we prepend $array with $data? |
|
744 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
745 | - } |
|
727 | + /** |
|
728 | + * Modify admin post listing page columns. |
|
729 | + * |
|
730 | + * @since 1.0.0 |
|
731 | + * @package GeoDirectory |
|
732 | + * @param array $columns The column array. |
|
733 | + * @return array Altered column array. |
|
734 | + */ |
|
735 | + function geodir_edit_post_columns($columns) |
|
736 | + { |
|
746 | 737 | |
747 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
738 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'), |
|
739 | + 'categorys' => __('Categories', 'geodirectory')); |
|
748 | 740 | |
749 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory'))); |
|
741 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist |
|
742 | + { |
|
743 | + $offset = 0; // should we prepend $array with $data? |
|
744 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
745 | + } |
|
750 | 746 | |
751 | - return $columns; |
|
752 | - } |
|
747 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
748 | + |
|
749 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory'))); |
|
750 | + |
|
751 | + return $columns; |
|
752 | + } |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | |
756 | 756 | if (!function_exists('geodir_manage_post_columns')) { |
757 | - /** |
|
758 | - * Adds content to our custom post listing page columns. |
|
759 | - * |
|
760 | - * @since 1.0.0 |
|
761 | - * @package GeoDirectory |
|
762 | - * @global object $wpdb WordPress Database object. |
|
763 | - * @global object $post WordPress Post object. |
|
764 | - * @param string $column The column name. |
|
765 | - * @param int $post_id The post ID. |
|
766 | - */ |
|
767 | - function geodir_manage_post_columns($column, $post_id) |
|
768 | - { |
|
769 | - global $post, $wpdb; |
|
770 | - |
|
771 | - switch ($column): |
|
772 | - /* If displaying the 'city' column. */ |
|
773 | - case 'location' : |
|
774 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
775 | - $location = geodir_get_location($location_id); |
|
776 | - /* If no city is found, output a default message. */ |
|
777 | - if (empty($location)) { |
|
778 | - _e('Unknown', 'geodirectory'); |
|
779 | - } else { |
|
780 | - /* If there is a city id, append 'city name' to the text string. */ |
|
781 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : ''; |
|
782 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
783 | - } |
|
784 | - break; |
|
785 | - |
|
786 | - /* If displaying the 'expire' column. */ |
|
787 | - case 'expire' : |
|
788 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
789 | - $d1 = $expire_date; // get expire_date |
|
790 | - $d2 = date('Y-m-d'); // get current date |
|
791 | - $state = __('days left', 'geodirectory'); |
|
792 | - $date_diff_text = ''; |
|
793 | - $expire_class = 'expire_left'; |
|
794 | - if ($expire_date != 'Never') { |
|
795 | - if (strtotime($d1) < strtotime($d2)) { |
|
796 | - $state = __('days overdue', 'geodirectory'); |
|
797 | - $expire_class = 'expire_over'; |
|
798 | - } |
|
799 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
800 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>'; |
|
801 | - } |
|
802 | - /* If no expire_date is found, output a default message. */ |
|
803 | - if (empty($expire_date)) |
|
804 | - echo __('Unknown', 'geodirectory'); |
|
805 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
806 | - else |
|
807 | - echo $expire_date . $date_diff_text; |
|
808 | - break; |
|
809 | - |
|
810 | - /* If displaying the 'categorys' column. */ |
|
811 | - case 'categorys' : |
|
812 | - |
|
813 | - /* Get the categorys for the post. */ |
|
814 | - |
|
815 | - |
|
816 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
817 | - |
|
818 | - /* If terms were found. */ |
|
819 | - if (!empty($terms)) { |
|
820 | - $out = array(); |
|
821 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
822 | - foreach ($terms as $term) { |
|
823 | - if (!strstr($term->taxonomy, 'tag')) { |
|
824 | - $out[] = sprintf('<a href="%s">%s</a>', |
|
825 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')), |
|
826 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display')) |
|
827 | - ); |
|
828 | - } |
|
829 | - } |
|
830 | - /* Join the terms, separating them with a comma. */ |
|
831 | - echo(join(', ', $out)); |
|
832 | - } /* If no terms were found, output a default message. */ |
|
833 | - else { |
|
834 | - _e('No Categories', 'geodirectory'); |
|
835 | - } |
|
836 | - break; |
|
757 | + /** |
|
758 | + * Adds content to our custom post listing page columns. |
|
759 | + * |
|
760 | + * @since 1.0.0 |
|
761 | + * @package GeoDirectory |
|
762 | + * @global object $wpdb WordPress Database object. |
|
763 | + * @global object $post WordPress Post object. |
|
764 | + * @param string $column The column name. |
|
765 | + * @param int $post_id The post ID. |
|
766 | + */ |
|
767 | + function geodir_manage_post_columns($column, $post_id) |
|
768 | + { |
|
769 | + global $post, $wpdb; |
|
770 | + |
|
771 | + switch ($column): |
|
772 | + /* If displaying the 'city' column. */ |
|
773 | + case 'location' : |
|
774 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
775 | + $location = geodir_get_location($location_id); |
|
776 | + /* If no city is found, output a default message. */ |
|
777 | + if (empty($location)) { |
|
778 | + _e('Unknown', 'geodirectory'); |
|
779 | + } else { |
|
780 | + /* If there is a city id, append 'city name' to the text string. */ |
|
781 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : ''; |
|
782 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
783 | + } |
|
784 | + break; |
|
785 | + |
|
786 | + /* If displaying the 'expire' column. */ |
|
787 | + case 'expire' : |
|
788 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
789 | + $d1 = $expire_date; // get expire_date |
|
790 | + $d2 = date('Y-m-d'); // get current date |
|
791 | + $state = __('days left', 'geodirectory'); |
|
792 | + $date_diff_text = ''; |
|
793 | + $expire_class = 'expire_left'; |
|
794 | + if ($expire_date != 'Never') { |
|
795 | + if (strtotime($d1) < strtotime($d2)) { |
|
796 | + $state = __('days overdue', 'geodirectory'); |
|
797 | + $expire_class = 'expire_over'; |
|
798 | + } |
|
799 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
800 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>'; |
|
801 | + } |
|
802 | + /* If no expire_date is found, output a default message. */ |
|
803 | + if (empty($expire_date)) |
|
804 | + echo __('Unknown', 'geodirectory'); |
|
805 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
806 | + else |
|
807 | + echo $expire_date . $date_diff_text; |
|
808 | + break; |
|
837 | 809 | |
838 | - endswitch; |
|
839 | - } |
|
810 | + /* If displaying the 'categorys' column. */ |
|
811 | + case 'categorys' : |
|
812 | + |
|
813 | + /* Get the categorys for the post. */ |
|
814 | + |
|
815 | + |
|
816 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
817 | + |
|
818 | + /* If terms were found. */ |
|
819 | + if (!empty($terms)) { |
|
820 | + $out = array(); |
|
821 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
822 | + foreach ($terms as $term) { |
|
823 | + if (!strstr($term->taxonomy, 'tag')) { |
|
824 | + $out[] = sprintf('<a href="%s">%s</a>', |
|
825 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')), |
|
826 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display')) |
|
827 | + ); |
|
828 | + } |
|
829 | + } |
|
830 | + /* Join the terms, separating them with a comma. */ |
|
831 | + echo(join(', ', $out)); |
|
832 | + } /* If no terms were found, output a default message. */ |
|
833 | + else { |
|
834 | + _e('No Categories', 'geodirectory'); |
|
835 | + } |
|
836 | + break; |
|
837 | + |
|
838 | + endswitch; |
|
839 | + } |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | |
843 | 843 | if (!function_exists('geodir_post_sortable_columns')) { |
844 | - /** |
|
845 | - * Makes admin post listing page columns sortable. |
|
846 | - * |
|
847 | - * @since 1.0.0 |
|
848 | - * @package GeoDirectory |
|
849 | - * @param array $columns The column array. |
|
850 | - * @return array Altered column array. |
|
851 | - */ |
|
852 | - function geodir_post_sortable_columns($columns) |
|
853 | - { |
|
854 | - |
|
855 | - $columns['expire'] = 'expire'; |
|
856 | - |
|
857 | - return $columns; |
|
858 | - } |
|
844 | + /** |
|
845 | + * Makes admin post listing page columns sortable. |
|
846 | + * |
|
847 | + * @since 1.0.0 |
|
848 | + * @package GeoDirectory |
|
849 | + * @param array $columns The column array. |
|
850 | + * @return array Altered column array. |
|
851 | + */ |
|
852 | + function geodir_post_sortable_columns($columns) |
|
853 | + { |
|
854 | + |
|
855 | + $columns['expire'] = 'expire'; |
|
856 | + |
|
857 | + return $columns; |
|
858 | + } |
|
859 | 859 | } |
860 | 860 | |
861 | 861 | /** |
@@ -869,32 +869,32 @@ discard block |
||
869 | 869 | * @param int $post_id The post ID. |
870 | 870 | */ |
871 | 871 | function geodir_post_information_save($post_id, $post) { |
872 | - global $wpdb, $current_user; |
|
872 | + global $wpdb, $current_user; |
|
873 | 873 | |
874 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) { |
|
875 | - return; |
|
876 | - } |
|
874 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) { |
|
875 | + return; |
|
876 | + } |
|
877 | 877 | |
878 | - $geodir_posttypes = geodir_get_posttypes(); |
|
878 | + $geodir_posttypes = geodir_get_posttypes(); |
|
879 | 879 | |
880 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
881 | - return; |
|
880 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
881 | + return; |
|
882 | 882 | |
883 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) { |
|
884 | - if (isset($_REQUEST['_status'])) |
|
885 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
883 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) { |
|
884 | + if (isset($_REQUEST['_status'])) |
|
885 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
886 | 886 | |
887 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
888 | - return; |
|
887 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
888 | + return; |
|
889 | 889 | |
890 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
891 | - return; |
|
890 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
891 | + return; |
|
892 | 892 | |
893 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
894 | - return; |
|
893 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
894 | + return; |
|
895 | 895 | |
896 | - geodir_save_listing($_REQUEST); |
|
897 | - } |
|
896 | + geodir_save_listing($_REQUEST); |
|
897 | + } |
|
898 | 898 | } |
899 | 899 | |
900 | 900 | /** |
@@ -910,102 +910,102 @@ discard block |
||
910 | 910 | */ |
911 | 911 | function geodir_admin_fields($options) |
912 | 912 | { |
913 | - global $geodirectory; |
|
914 | - |
|
915 | - $first_title = true; |
|
916 | - $tab_id = ''; |
|
917 | - $i = 0; |
|
918 | - foreach ($options as $value) : |
|
919 | - if (!isset($value['name'])) $value['name'] = ''; |
|
920 | - if (!isset($value['class'])) $value['class'] = ''; |
|
921 | - if (!isset($value['css'])) $value['css'] = ''; |
|
922 | - if (!isset($value['std'])) $value['std'] = ''; |
|
923 | - $desc = ''; |
|
924 | - switch ($value['type']) : |
|
925 | - case 'dummy_installer': |
|
926 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
927 | - geodir_autoinstall_admin_header($post_type); |
|
928 | - break; |
|
929 | - case 'title': |
|
930 | - |
|
931 | - if ($i == 0) { |
|
932 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
933 | - echo '<div class="inner_content_tab_main">'; |
|
934 | - } |
|
913 | + global $geodirectory; |
|
914 | + |
|
915 | + $first_title = true; |
|
916 | + $tab_id = ''; |
|
917 | + $i = 0; |
|
918 | + foreach ($options as $value) : |
|
919 | + if (!isset($value['name'])) $value['name'] = ''; |
|
920 | + if (!isset($value['class'])) $value['class'] = ''; |
|
921 | + if (!isset($value['css'])) $value['css'] = ''; |
|
922 | + if (!isset($value['std'])) $value['std'] = ''; |
|
923 | + $desc = ''; |
|
924 | + switch ($value['type']) : |
|
925 | + case 'dummy_installer': |
|
926 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
927 | + geodir_autoinstall_admin_header($post_type); |
|
928 | + break; |
|
929 | + case 'title': |
|
930 | + |
|
931 | + if ($i == 0) { |
|
932 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
933 | + echo '<div class="inner_content_tab_main">'; |
|
934 | + } |
|
935 | 935 | |
936 | - $i++; |
|
936 | + $i++; |
|
937 | 937 | |
938 | - if (isset($value['id']) && $value['id']) |
|
939 | - $tab_id = $value['id']; |
|
938 | + if (isset($value['id']) && $value['id']) |
|
939 | + $tab_id = $value['id']; |
|
940 | 940 | |
941 | - if (isset($value['desc']) && $value['desc']) |
|
942 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
941 | + if (isset($value['desc']) && $value['desc']) |
|
942 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
943 | 943 | |
944 | - if (isset($value['name']) && $value['name']) { |
|
945 | - if ($first_title === true) { |
|
946 | - $first_title = false; |
|
947 | - } else { |
|
948 | - echo '</div>'; |
|
949 | - } |
|
950 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
944 | + if (isset($value['name']) && $value['name']) { |
|
945 | + if ($first_title === true) { |
|
946 | + $first_title = false; |
|
947 | + } else { |
|
948 | + echo '</div>'; |
|
949 | + } |
|
950 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
951 | 951 | |
952 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
953 | - } |
|
952 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
953 | + } |
|
954 | 954 | |
955 | - /** |
|
956 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
957 | - * |
|
958 | - * The action is called dynamically geodir_settings_$value['id']. |
|
959 | - * |
|
960 | - * @since 1.0.0 |
|
961 | - */ |
|
962 | - do_action('geodir_settings_' . sanitize_title($value['id'])); |
|
963 | - break; |
|
964 | - |
|
965 | - case 'no_tabs': |
|
966 | - |
|
967 | - echo '<div class="inner_content_tab_main">'; |
|
968 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
969 | - |
|
970 | - break; |
|
971 | - |
|
972 | - case 'sectionstart': |
|
973 | - if (isset($value['desc']) && $value['desc']) |
|
974 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
975 | - if (isset($value['name']) && $value['name']) |
|
976 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
977 | - /** |
|
978 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
979 | - * |
|
980 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
981 | - * |
|
982 | - * @since 1.0.0 |
|
983 | - */ |
|
984 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start'); |
|
985 | - echo '<table class="form-table">' . "\n\n"; |
|
986 | - |
|
987 | - break; |
|
988 | - case 'sectionend': |
|
989 | - /** |
|
990 | - * Called before 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']) . '_end'); |
|
997 | - echo '</table>'; |
|
998 | - /** |
|
999 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
1000 | - * |
|
1001 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
1002 | - * |
|
1003 | - * @since 1.0.0 |
|
1004 | - */ |
|
1005 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after'); |
|
1006 | - break; |
|
1007 | - case 'text': |
|
1008 | - ?> |
|
955 | + /** |
|
956 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
957 | + * |
|
958 | + * The action is called dynamically geodir_settings_$value['id']. |
|
959 | + * |
|
960 | + * @since 1.0.0 |
|
961 | + */ |
|
962 | + do_action('geodir_settings_' . sanitize_title($value['id'])); |
|
963 | + break; |
|
964 | + |
|
965 | + case 'no_tabs': |
|
966 | + |
|
967 | + echo '<div class="inner_content_tab_main">'; |
|
968 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
969 | + |
|
970 | + break; |
|
971 | + |
|
972 | + case 'sectionstart': |
|
973 | + if (isset($value['desc']) && $value['desc']) |
|
974 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
975 | + if (isset($value['name']) && $value['name']) |
|
976 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
977 | + /** |
|
978 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
979 | + * |
|
980 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
981 | + * |
|
982 | + * @since 1.0.0 |
|
983 | + */ |
|
984 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start'); |
|
985 | + echo '<table class="form-table">' . "\n\n"; |
|
986 | + |
|
987 | + break; |
|
988 | + case 'sectionend': |
|
989 | + /** |
|
990 | + * Called before 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']) . '_end'); |
|
997 | + echo '</table>'; |
|
998 | + /** |
|
999 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
1000 | + * |
|
1001 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
1002 | + * |
|
1003 | + * @since 1.0.0 |
|
1004 | + */ |
|
1005 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after'); |
|
1006 | + break; |
|
1007 | + case 'text': |
|
1008 | + ?> |
|
1009 | 1009 | <tr valign="top"> |
1010 | 1010 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1011 | 1011 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1014,15 +1014,15 @@ discard block |
||
1014 | 1014 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?> |
1015 | 1015 | style=" <?php echo esc_attr($value['css']); ?>" |
1016 | 1016 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { |
1017 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
1018 | - } else { |
|
1019 | - echo esc_attr($value['std']); |
|
1020 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1017 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
1018 | + } else { |
|
1019 | + echo esc_attr($value['std']); |
|
1020 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1021 | 1021 | </tr><?php |
1022 | - break; |
|
1022 | + break; |
|
1023 | 1023 | |
1024 | - case 'map-key': |
|
1025 | - ?> |
|
1024 | + case 'map-key': |
|
1025 | + ?> |
|
1026 | 1026 | <tr valign="top"> |
1027 | 1027 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1028 | 1028 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1031,18 +1031,18 @@ discard block |
||
1031 | 1031 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?> |
1032 | 1032 | style=" <?php echo esc_attr($value['css']); ?>" |
1033 | 1033 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { |
1034 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
1035 | - } else { |
|
1036 | - echo esc_attr($value['std']); |
|
1037 | - } ?>"/> |
|
1034 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
1035 | + } else { |
|
1036 | + echo esc_attr($value['std']); |
|
1037 | + } ?>"/> |
|
1038 | 1038 | <?php $gm_api_url = '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]';?> |
1039 | 1039 | <a id="gd-api-key" onclick='window.open("<?php echo wp_slash($gm_api_url);?>", "newwindow", "width=600, height=400"); return false;' href='<?php echo $gm_api_url;?>' class="button-primary" name="<?php _e('Generate API Key - ( MUST be logged in to your Google account )','geodirectory');?>" ><?php _e('Generate API Key','geodirectory');?></a> |
1040 | 1040 | <span class="description"><?php echo $value['desc']; ?></span></td> |
1041 | 1041 | </tr><?php |
1042 | - break; |
|
1042 | + break; |
|
1043 | 1043 | |
1044 | - case 'password': |
|
1045 | - ?> |
|
1044 | + case 'password': |
|
1045 | + ?> |
|
1046 | 1046 | <tr valign="top"> |
1047 | 1047 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1048 | 1048 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1051,42 +1051,42 @@ discard block |
||
1051 | 1051 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?> |
1052 | 1052 | style="<?php echo esc_attr($value['css']); ?>" |
1053 | 1053 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { |
1054 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
1055 | - } else { |
|
1056 | - echo esc_attr($value['std']); |
|
1057 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1054 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
1055 | + } else { |
|
1056 | + echo esc_attr($value['std']); |
|
1057 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1058 | 1058 | </tr><?php |
1059 | - break; |
|
1059 | + break; |
|
1060 | 1060 | |
1061 | - case 'html_content': |
|
1062 | - ?> |
|
1061 | + case 'html_content': |
|
1062 | + ?> |
|
1063 | 1063 | <tr valign="top"> |
1064 | 1064 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1065 | 1065 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
1066 | 1066 | </tr><?php |
1067 | - break; |
|
1067 | + break; |
|
1068 | 1068 | |
1069 | - case 'color' : |
|
1070 | - ?> |
|
1069 | + case 'color' : |
|
1070 | + ?> |
|
1071 | 1071 | <tr valign="top"> |
1072 | 1072 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1073 | 1073 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
1074 | 1074 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
1075 | 1075 | style="<?php echo esc_attr($value['css']); ?>" |
1076 | 1076 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { |
1077 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
1078 | - } else { |
|
1079 | - echo esc_attr($value['std']); |
|
1080 | - } ?>" class="colorpick"/> <span |
|
1077 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
1078 | + } else { |
|
1079 | + echo esc_attr($value['std']); |
|
1080 | + } ?>" class="colorpick"/> <span |
|
1081 | 1081 | class="description"><?php echo $value['desc']; ?></span> |
1082 | 1082 | |
1083 | 1083 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
1084 | 1084 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
1085 | 1085 | </td> |
1086 | 1086 | </tr><?php |
1087 | - break; |
|
1088 | - case 'image_width' : |
|
1089 | - ?> |
|
1087 | + break; |
|
1088 | + case 'image_width' : |
|
1089 | + ?> |
|
1090 | 1090 | <tr valign="top"> |
1091 | 1091 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1092 | 1092 | <td class="forminp"> |
@@ -1108,11 +1108,11 @@ discard block |
||
1108 | 1108 | |
1109 | 1109 | <span class="description"><?php echo $value['desc'] ?></span></td> |
1110 | 1110 | </tr><?php |
1111 | - break; |
|
1112 | - case 'select': |
|
1113 | - $option_value = get_option($value['id']); |
|
1114 | - $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
1115 | - ?> |
|
1111 | + break; |
|
1112 | + case 'select': |
|
1113 | + $option_value = get_option($value['id']); |
|
1114 | + $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
1115 | + ?> |
|
1116 | 1116 | <tr valign="top"> |
1117 | 1117 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1118 | 1118 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1121,33 +1121,33 @@ discard block |
||
1121 | 1121 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
1122 | 1122 | option-ajaxchosen="false"> |
1123 | 1123 | <?php |
1124 | - foreach ($value['options'] as $key => $val) { |
|
1125 | - $geodir_select_value = ''; |
|
1126 | - if ($option_value != '') { |
|
1127 | - if ($option_value != '' && $option_value == $key) |
|
1128 | - $geodir_select_value = ' selected="selected" '; |
|
1129 | - } else { |
|
1130 | - if ($value['std'] == $key) |
|
1131 | - $geodir_select_value = ' selected="selected" '; |
|
1132 | - } |
|
1133 | - ?> |
|
1124 | + foreach ($value['options'] as $key => $val) { |
|
1125 | + $geodir_select_value = ''; |
|
1126 | + if ($option_value != '') { |
|
1127 | + if ($option_value != '' && $option_value == $key) |
|
1128 | + $geodir_select_value = ' selected="selected" '; |
|
1129 | + } else { |
|
1130 | + if ($value['std'] == $key) |
|
1131 | + $geodir_select_value = ' selected="selected" '; |
|
1132 | + } |
|
1133 | + ?> |
|
1134 | 1134 | <option |
1135 | 1135 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo geodir_utf8_ucfirst($val) ?></option> |
1136 | 1136 | <?php |
1137 | - } |
|
1138 | - ?> |
|
1137 | + } |
|
1138 | + ?> |
|
1139 | 1139 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
1140 | 1140 | </td> |
1141 | 1141 | </tr><?php |
1142 | - break; |
|
1142 | + break; |
|
1143 | 1143 | |
1144 | - case 'multiselect': |
|
1145 | - $option_values = get_option($value['id']); |
|
1146 | - if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) { |
|
1147 | - $option_values = $value['std']; |
|
1148 | - } |
|
1149 | - $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
1150 | - ?> |
|
1144 | + case 'multiselect': |
|
1145 | + $option_values = get_option($value['id']); |
|
1146 | + if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) { |
|
1147 | + $option_values = $value['std']; |
|
1148 | + } |
|
1149 | + $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
1150 | + ?> |
|
1151 | 1151 | <tr valign="top"> |
1152 | 1152 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1153 | 1153 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -1157,26 +1157,26 @@ discard block |
||
1157 | 1157 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
1158 | 1158 | option-ajaxchosen="false"> |
1159 | 1159 | <?php |
1160 | - foreach ($value['options'] as $key => $val) { |
|
1161 | - if (strpos($key, 'optgroup_start-') === 0) { |
|
1162 | - ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php |
|
1163 | - } else if (strpos($key, 'optgroup_end-') === 0) { |
|
1164 | - ?></optgroup><?php |
|
1165 | - } else { |
|
1166 | - ?> |
|
1160 | + foreach ($value['options'] as $key => $val) { |
|
1161 | + if (strpos($key, 'optgroup_start-') === 0) { |
|
1162 | + ?><optgroup label="<?php echo geodir_utf8_ucfirst($val); ?>"><?php |
|
1163 | + } else if (strpos($key, 'optgroup_end-') === 0) { |
|
1164 | + ?></optgroup><?php |
|
1165 | + } else { |
|
1166 | + ?> |
|
1167 | 1167 | <option value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>> |
1168 | 1168 | <?php echo geodir_utf8_ucfirst($val) ?> |
1169 | 1169 | </option> |
1170 | 1170 | <?php |
1171 | - } |
|
1172 | - } |
|
1173 | - ?> |
|
1171 | + } |
|
1172 | + } |
|
1173 | + ?> |
|
1174 | 1174 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
1175 | 1175 | </td> |
1176 | 1176 | </tr><?php |
1177 | - break; |
|
1178 | - case 'file': |
|
1179 | - ?> |
|
1177 | + break; |
|
1178 | + case 'file': |
|
1179 | + ?> |
|
1180 | 1180 | <tr valign="top"> |
1181 | 1181 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1182 | 1182 | <td class="forminp"> |
@@ -1196,87 +1196,87 @@ discard block |
||
1196 | 1196 | <?php } ?> |
1197 | 1197 | </td> |
1198 | 1198 | </tr><?php |
1199 | - break; |
|
1200 | - case 'map_default_settings' : |
|
1201 | - ?> |
|
1199 | + break; |
|
1200 | + case 'map_default_settings' : |
|
1201 | + ?> |
|
1202 | 1202 | |
1203 | 1203 | <tr valign="top"> |
1204 | 1204 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th> |
1205 | 1205 | <td width="60%"> |
1206 | 1206 | <select name="geodir_default_map_language" style="width:60%"> |
1207 | 1207 | <?php |
1208 | - $arr_map_langages = array( |
|
1209 | - 'ar' => __('ARABIC', 'geodirectory'), |
|
1210 | - 'eu' => __('BASQUE', 'geodirectory'), |
|
1211 | - 'bg' => __('BULGARIAN', 'geodirectory'), |
|
1212 | - 'bn' => __('BENGALI', 'geodirectory'), |
|
1213 | - 'ca' => __('CATALAN', 'geodirectory'), |
|
1214 | - 'cs' => __('CZECH', 'geodirectory'), |
|
1215 | - 'da' => __('DANISH', 'geodirectory'), |
|
1216 | - 'de' => __('GERMAN', 'geodirectory'), |
|
1217 | - 'el' => __('GREEK', 'geodirectory'), |
|
1218 | - 'en' => __('ENGLISH', 'geodirectory'), |
|
1219 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'), |
|
1220 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'), |
|
1221 | - 'es' => __('SPANISH', 'geodirectory'), |
|
1222 | - 'eu' => __('BASQUE', 'geodirectory'), |
|
1223 | - 'fa' => __('FARSI', 'geodirectory'), |
|
1224 | - 'fi' => __('FINNISH', 'geodirectory'), |
|
1225 | - 'fil' => __('FILIPINO', 'geodirectory'), |
|
1226 | - 'fr' => __('FRENCH', 'geodirectory'), |
|
1227 | - 'gl' => __('GALICIAN', 'geodirectory'), |
|
1228 | - 'gu' => __('GUJARATI', 'geodirectory'), |
|
1229 | - 'hi' => __('HINDI', 'geodirectory'), |
|
1230 | - 'hr' => __('CROATIAN', 'geodirectory'), |
|
1231 | - 'hu' => __('HUNGARIAN', 'geodirectory'), |
|
1232 | - 'id' => __('INDONESIAN', 'geodirectory'), |
|
1233 | - 'it' => __('ITALIAN', 'geodirectory'), |
|
1234 | - 'iw' => __('HEBREW', 'geodirectory'), |
|
1235 | - 'ja' => __('JAPANESE', 'geodirectory'), |
|
1236 | - 'kn' => __('KANNADA', 'geodirectory'), |
|
1237 | - 'ko' => __('KOREAN', 'geodirectory'), |
|
1238 | - 'lt' => __('LITHUANIAN', 'geodirectory'), |
|
1239 | - 'lv' => __('LATVIAN', 'geodirectory'), |
|
1240 | - 'ml' => __('MALAYALAM', 'geodirectory'), |
|
1241 | - 'mr' => __('MARATHI', 'geodirectory'), |
|
1242 | - 'nl' => __('DUTCH', 'geodirectory'), |
|
1243 | - 'no' => __('NORWEGIAN', 'geodirectory'), |
|
1244 | - 'pl' => __('POLISH', 'geodirectory'), |
|
1245 | - 'pt' => __('PORTUGUESE', 'geodirectory'), |
|
1246 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'), |
|
1247 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'), |
|
1248 | - 'ro' => __('ROMANIAN', 'geodirectory'), |
|
1249 | - 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1250 | - 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1251 | - 'sk' => __('SLOVAK', 'geodirectory'), |
|
1252 | - 'sl' => __('SLOVENIAN', 'geodirectory'), |
|
1253 | - 'sr' => __('SERBIAN', 'geodirectory'), |
|
1254 | - 'sv' => __(' SWEDISH', 'geodirectory'), |
|
1255 | - 'tl' => __('TAGALOG', 'geodirectory'), |
|
1256 | - 'ta' => __('TAMIL', 'geodirectory'), |
|
1257 | - 'te' => __('TELUGU', 'geodirectory'), |
|
1258 | - 'th' => __('THAI', 'geodirectory'), |
|
1259 | - 'tr' => __('TURKISH', 'geodirectory'), |
|
1260 | - 'uk' => __('UKRAINIAN', 'geodirectory'), |
|
1261 | - 'vi' => __('VIETNAMESE', 'geodirectory'), |
|
1262 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'), |
|
1263 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'), |
|
1264 | - ); |
|
1265 | - $geodir_default_map_language = get_option('geodir_default_map_language'); |
|
1266 | - if (empty($geodir_default_map_language)) |
|
1267 | - $geodir_default_map_language = 'en'; |
|
1268 | - foreach ($arr_map_langages as $language_key => $language_txt) { |
|
1269 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
1270 | - $geodir_default_language_selected = "selected='selected'"; |
|
1271 | - else |
|
1272 | - $geodir_default_language_selected = ''; |
|
1273 | - |
|
1274 | - ?> |
|
1208 | + $arr_map_langages = array( |
|
1209 | + 'ar' => __('ARABIC', 'geodirectory'), |
|
1210 | + 'eu' => __('BASQUE', 'geodirectory'), |
|
1211 | + 'bg' => __('BULGARIAN', 'geodirectory'), |
|
1212 | + 'bn' => __('BENGALI', 'geodirectory'), |
|
1213 | + 'ca' => __('CATALAN', 'geodirectory'), |
|
1214 | + 'cs' => __('CZECH', 'geodirectory'), |
|
1215 | + 'da' => __('DANISH', 'geodirectory'), |
|
1216 | + 'de' => __('GERMAN', 'geodirectory'), |
|
1217 | + 'el' => __('GREEK', 'geodirectory'), |
|
1218 | + 'en' => __('ENGLISH', 'geodirectory'), |
|
1219 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'), |
|
1220 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'), |
|
1221 | + 'es' => __('SPANISH', 'geodirectory'), |
|
1222 | + 'eu' => __('BASQUE', 'geodirectory'), |
|
1223 | + 'fa' => __('FARSI', 'geodirectory'), |
|
1224 | + 'fi' => __('FINNISH', 'geodirectory'), |
|
1225 | + 'fil' => __('FILIPINO', 'geodirectory'), |
|
1226 | + 'fr' => __('FRENCH', 'geodirectory'), |
|
1227 | + 'gl' => __('GALICIAN', 'geodirectory'), |
|
1228 | + 'gu' => __('GUJARATI', 'geodirectory'), |
|
1229 | + 'hi' => __('HINDI', 'geodirectory'), |
|
1230 | + 'hr' => __('CROATIAN', 'geodirectory'), |
|
1231 | + 'hu' => __('HUNGARIAN', 'geodirectory'), |
|
1232 | + 'id' => __('INDONESIAN', 'geodirectory'), |
|
1233 | + 'it' => __('ITALIAN', 'geodirectory'), |
|
1234 | + 'iw' => __('HEBREW', 'geodirectory'), |
|
1235 | + 'ja' => __('JAPANESE', 'geodirectory'), |
|
1236 | + 'kn' => __('KANNADA', 'geodirectory'), |
|
1237 | + 'ko' => __('KOREAN', 'geodirectory'), |
|
1238 | + 'lt' => __('LITHUANIAN', 'geodirectory'), |
|
1239 | + 'lv' => __('LATVIAN', 'geodirectory'), |
|
1240 | + 'ml' => __('MALAYALAM', 'geodirectory'), |
|
1241 | + 'mr' => __('MARATHI', 'geodirectory'), |
|
1242 | + 'nl' => __('DUTCH', 'geodirectory'), |
|
1243 | + 'no' => __('NORWEGIAN', 'geodirectory'), |
|
1244 | + 'pl' => __('POLISH', 'geodirectory'), |
|
1245 | + 'pt' => __('PORTUGUESE', 'geodirectory'), |
|
1246 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'), |
|
1247 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'), |
|
1248 | + 'ro' => __('ROMANIAN', 'geodirectory'), |
|
1249 | + 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1250 | + 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1251 | + 'sk' => __('SLOVAK', 'geodirectory'), |
|
1252 | + 'sl' => __('SLOVENIAN', 'geodirectory'), |
|
1253 | + 'sr' => __('SERBIAN', 'geodirectory'), |
|
1254 | + 'sv' => __(' SWEDISH', 'geodirectory'), |
|
1255 | + 'tl' => __('TAGALOG', 'geodirectory'), |
|
1256 | + 'ta' => __('TAMIL', 'geodirectory'), |
|
1257 | + 'te' => __('TELUGU', 'geodirectory'), |
|
1258 | + 'th' => __('THAI', 'geodirectory'), |
|
1259 | + 'tr' => __('TURKISH', 'geodirectory'), |
|
1260 | + 'uk' => __('UKRAINIAN', 'geodirectory'), |
|
1261 | + 'vi' => __('VIETNAMESE', 'geodirectory'), |
|
1262 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'), |
|
1263 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'), |
|
1264 | + ); |
|
1265 | + $geodir_default_map_language = get_option('geodir_default_map_language'); |
|
1266 | + if (empty($geodir_default_map_language)) |
|
1267 | + $geodir_default_map_language = 'en'; |
|
1268 | + foreach ($arr_map_langages as $language_key => $language_txt) { |
|
1269 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
1270 | + $geodir_default_language_selected = "selected='selected'"; |
|
1271 | + else |
|
1272 | + $geodir_default_language_selected = ''; |
|
1273 | + |
|
1274 | + ?> |
|
1275 | 1275 | <option |
1276 | 1276 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
1277 | 1277 | |
1278 | 1278 | <?php } |
1279 | - ?> |
|
1279 | + ?> |
|
1280 | 1280 | </select> |
1281 | 1281 | </td> |
1282 | 1282 | </tr> |
@@ -1287,46 +1287,46 @@ discard block |
||
1287 | 1287 | <td width="60%"> |
1288 | 1288 | <select name="geodir_default_map_search_pt" style="width:60%"> |
1289 | 1289 | <?php |
1290 | - $post_types = geodir_get_posttypes('array'); |
|
1291 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt'); |
|
1292 | - if (empty($geodir_default_map_search_pt)) |
|
1293 | - $geodir_default_map_search_pt = 'gd_place'; |
|
1294 | - if (is_array($post_types)) { |
|
1295 | - foreach ($post_types as $key => $post_types_obj) { |
|
1296 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
1297 | - $geodir_search_pt_selected = "selected='selected'"; |
|
1298 | - else |
|
1299 | - $geodir_search_pt_selected = ''; |
|
1300 | - |
|
1301 | - ?> |
|
1290 | + $post_types = geodir_get_posttypes('array'); |
|
1291 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt'); |
|
1292 | + if (empty($geodir_default_map_search_pt)) |
|
1293 | + $geodir_default_map_search_pt = 'gd_place'; |
|
1294 | + if (is_array($post_types)) { |
|
1295 | + foreach ($post_types as $key => $post_types_obj) { |
|
1296 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
1297 | + $geodir_search_pt_selected = "selected='selected'"; |
|
1298 | + else |
|
1299 | + $geodir_search_pt_selected = ''; |
|
1300 | + |
|
1301 | + ?> |
|
1302 | 1302 | <option |
1303 | 1303 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo __($post_types_obj['labels']['singular_name'], 'geodirectory'); ?></option> |
1304 | 1304 | |
1305 | 1305 | <?php } |
1306 | 1306 | |
1307 | - } |
|
1307 | + } |
|
1308 | 1308 | |
1309 | - ?> |
|
1309 | + ?> |
|
1310 | 1310 | </select> |
1311 | 1311 | </td> |
1312 | 1312 | </tr> |
1313 | 1313 | |
1314 | 1314 | <?php |
1315 | - break; |
|
1315 | + break; |
|
1316 | 1316 | |
1317 | - case 'map': |
|
1318 | - ?> |
|
1317 | + case 'map': |
|
1318 | + ?> |
|
1319 | 1319 | <tr valign="top"> |
1320 | 1320 | <td class="forminp"> |
1321 | 1321 | <?php |
1322 | - global $post_cat, $cat_display; |
|
1323 | - $post_types = geodir_get_posttypes('object'); |
|
1324 | - $cat_display = 'checkbox'; |
|
1325 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map'); |
|
1326 | - $gd_cats = get_option('geodir_exclude_cat_on_map'); |
|
1327 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade'); |
|
1328 | - $count = 1; |
|
1329 | - ?> |
|
1322 | + global $post_cat, $cat_display; |
|
1323 | + $post_types = geodir_get_posttypes('object'); |
|
1324 | + $cat_display = 'checkbox'; |
|
1325 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map'); |
|
1326 | + $gd_cats = get_option('geodir_exclude_cat_on_map'); |
|
1327 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade'); |
|
1328 | + $count = 1; |
|
1329 | + ?> |
|
1330 | 1330 | <table width="70%" class="widefat"> |
1331 | 1331 | <thead> |
1332 | 1332 | <tr> |
@@ -1335,18 +1335,18 @@ discard block |
||
1335 | 1335 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
1336 | 1336 | </tr> |
1337 | 1337 | <?php |
1338 | - $gd_categs = $gd_cats; |
|
1339 | - foreach ($post_types as $key => $post_types_obj) : |
|
1340 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
1341 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
1342 | - if ($gd_cats_upgrade) { |
|
1343 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
1344 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
1345 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
1346 | - } |
|
1347 | - $post_cat = implode(',', $gd_cats); |
|
1348 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
1349 | - ?> |
|
1338 | + $gd_categs = $gd_cats; |
|
1339 | + foreach ($post_types as $key => $post_types_obj) : |
|
1340 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
1341 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
1342 | + if ($gd_cats_upgrade) { |
|
1343 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
1344 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
1345 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
1346 | + } |
|
1347 | + $post_cat = implode(',', $gd_cats); |
|
1348 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
1349 | + ?> |
|
1350 | 1350 | <tr> |
1351 | 1351 | <td valign="top" width="5%"><?php echo $count; ?></td> |
1352 | 1352 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -1367,19 +1367,19 @@ discard block |
||
1367 | 1367 | </td> |
1368 | 1368 | </tr> |
1369 | 1369 | <?php |
1370 | - break; |
|
1370 | + break; |
|
1371 | 1371 | |
1372 | - case 'checkbox' : |
|
1372 | + case 'checkbox' : |
|
1373 | 1373 | |
1374 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
1375 | - ?> |
|
1374 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
1375 | + ?> |
|
1376 | 1376 | <tr valign="top"> |
1377 | 1377 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1378 | 1378 | <td class="forminp"> |
1379 | 1379 | <?php |
1380 | - endif; |
|
1380 | + endif; |
|
1381 | 1381 | |
1382 | - ?> |
|
1382 | + ?> |
|
1383 | 1383 | <fieldset> |
1384 | 1384 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
1385 | 1385 | <label for="<?php echo $value['id'] ?>"> |
@@ -1389,49 +1389,49 @@ discard block |
||
1389 | 1389 | </fieldset> |
1390 | 1390 | <?php |
1391 | 1391 | |
1392 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
1393 | - ?> |
|
1392 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
1393 | + ?> |
|
1394 | 1394 | </td> |
1395 | 1395 | </tr> |
1396 | 1396 | <?php |
1397 | - endif; |
|
1397 | + endif; |
|
1398 | 1398 | |
1399 | - break; |
|
1399 | + break; |
|
1400 | 1400 | |
1401 | - case 'radio' : |
|
1401 | + case 'radio' : |
|
1402 | 1402 | |
1403 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
1404 | - ?> |
|
1403 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
1404 | + ?> |
|
1405 | 1405 | <tr valign="top"> |
1406 | 1406 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1407 | 1407 | <td class="forminp"> |
1408 | 1408 | <?php |
1409 | - endif; |
|
1409 | + endif; |
|
1410 | 1410 | |
1411 | - ?> |
|
1411 | + ?> |
|
1412 | 1412 | <fieldset> |
1413 | 1413 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
1414 | 1414 | <label for="<?php echo $value['id'];?>"> |
1415 | 1415 | <input name="<?php echo esc_attr($value['id']); ?>" |
1416 | 1416 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
1417 | 1417 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) { |
1418 | - echo 'checked="checked"'; |
|
1419 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> /> |
|
1418 | + echo 'checked="checked"'; |
|
1419 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> /> |
|
1420 | 1420 | <?php echo $value['desc']; ?></label><br> |
1421 | 1421 | </fieldset> |
1422 | 1422 | <?php |
1423 | 1423 | |
1424 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
1425 | - ?> |
|
1424 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
1425 | + ?> |
|
1426 | 1426 | </td> |
1427 | 1427 | </tr> |
1428 | 1428 | <?php |
1429 | - endif; |
|
1429 | + endif; |
|
1430 | 1430 | |
1431 | - break; |
|
1431 | + break; |
|
1432 | 1432 | |
1433 | - case 'textarea': |
|
1434 | - ?> |
|
1433 | + case 'textarea': |
|
1434 | + ?> |
|
1435 | 1435 | <tr valign="top"> |
1436 | 1436 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1437 | 1437 | <td class="forminp"> |
@@ -1444,30 +1444,30 @@ discard block |
||
1444 | 1444 | |
1445 | 1445 | </td> |
1446 | 1446 | </tr><?php |
1447 | - break; |
|
1447 | + break; |
|
1448 | 1448 | |
1449 | - case 'editor': |
|
1450 | - ?> |
|
1449 | + case 'editor': |
|
1450 | + ?> |
|
1451 | 1451 | <tr valign="top"> |
1452 | 1452 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1453 | 1453 | <td class="forminp"><?php |
1454 | - if (get_option($value['id'])) |
|
1455 | - $content = stripslashes(get_option($value['id'])); |
|
1456 | - else |
|
1457 | - $content = $value['std']; |
|
1454 | + if (get_option($value['id'])) |
|
1455 | + $content = stripslashes(get_option($value['id'])); |
|
1456 | + else |
|
1457 | + $content = $value['std']; |
|
1458 | 1458 | |
1459 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); |
|
1459 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); |
|
1460 | 1460 | |
1461 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
1461 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
1462 | 1462 | |
1463 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
1463 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
1464 | 1464 | |
1465 | 1465 | </td> |
1466 | 1466 | </tr><?php |
1467 | - break; |
|
1467 | + break; |
|
1468 | 1468 | |
1469 | - case 'single_select_page' : |
|
1470 | - // WPML |
|
1469 | + case 'single_select_page' : |
|
1470 | + // WPML |
|
1471 | 1471 | $switch_lang = false; |
1472 | 1472 | $disabled = ''; |
1473 | 1473 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') { |
@@ -1485,18 +1485,18 @@ discard block |
||
1485 | 1485 | // |
1486 | 1486 | $page_setting = (int)get_option($value['id']); |
1487 | 1487 | |
1488 | - $args = array('name' => $value['id'], |
|
1489 | - 'id' => $value['id'], |
|
1490 | - 'sort_column' => 'menu_order', |
|
1491 | - 'sort_order' => 'ASC', |
|
1492 | - 'show_option_none' => ' ', |
|
1493 | - 'class' => $value['class'], |
|
1494 | - 'echo' => false, |
|
1495 | - 'selected' => $page_setting); |
|
1488 | + $args = array('name' => $value['id'], |
|
1489 | + 'id' => $value['id'], |
|
1490 | + 'sort_column' => 'menu_order', |
|
1491 | + 'sort_order' => 'ASC', |
|
1492 | + 'show_option_none' => ' ', |
|
1493 | + 'class' => $value['class'], |
|
1494 | + 'echo' => false, |
|
1495 | + 'selected' => $page_setting); |
|
1496 | 1496 | |
1497 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
1497 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
1498 | 1498 | |
1499 | - ?> |
|
1499 | + ?> |
|
1500 | 1500 | <tr valign="top" class="single_select_page"> |
1501 | 1501 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1502 | 1502 | <td class="forminp"> |
@@ -1507,17 +1507,17 @@ discard block |
||
1507 | 1507 | if ($switch_lang) { |
1508 | 1508 | $sitepress->switch_lang($switch_lang, true); |
1509 | 1509 | } |
1510 | - break; |
|
1511 | - case 'single_select_country' : |
|
1512 | - $country_setting = (string)get_option($value['id']); |
|
1513 | - if (strstr($country_setting, ':')) : |
|
1514 | - $country = current(explode(':', $country_setting)); |
|
1515 | - $state = end(explode(':', $country_setting)); |
|
1516 | - else : |
|
1517 | - $country = $country_setting; |
|
1518 | - $state = '*'; |
|
1519 | - endif; |
|
1520 | - ?> |
|
1510 | + break; |
|
1511 | + case 'single_select_country' : |
|
1512 | + $country_setting = (string)get_option($value['id']); |
|
1513 | + if (strstr($country_setting, ':')) : |
|
1514 | + $country = current(explode(':', $country_setting)); |
|
1515 | + $state = end(explode(':', $country_setting)); |
|
1516 | + else : |
|
1517 | + $country = $country_setting; |
|
1518 | + $state = '*'; |
|
1519 | + endif; |
|
1520 | + ?> |
|
1521 | 1521 | <tr valign="top"> |
1522 | 1522 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
1523 | 1523 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1528,12 +1528,12 @@ discard block |
||
1528 | 1528 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
1529 | 1529 | </td> |
1530 | 1530 | </tr><?php |
1531 | - break; |
|
1532 | - case 'multi_select_countries' : |
|
1533 | - $countries = $geodirectory->countries->countries; |
|
1534 | - asort($countries); |
|
1535 | - $selections = (array)get_option($value['id']); |
|
1536 | - ?> |
|
1531 | + break; |
|
1532 | + case 'multi_select_countries' : |
|
1533 | + $countries = $geodirectory->countries->countries; |
|
1534 | + asort($countries); |
|
1535 | + $selections = (array)get_option($value['id']); |
|
1536 | + ?> |
|
1537 | 1537 | <tr valign="top"> |
1538 | 1538 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1539 | 1539 | <td class="forminp"> |
@@ -1541,21 +1541,21 @@ discard block |
||
1541 | 1541 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>" |
1542 | 1542 | title="Country" class="chosen_select"> |
1543 | 1543 | <?php |
1544 | - if ($countries) foreach ($countries as $key => $val) : |
|
1545 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
1546 | - endforeach; |
|
1547 | - ?> |
|
1544 | + if ($countries) foreach ($countries as $key => $val) : |
|
1545 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
1546 | + endforeach; |
|
1547 | + ?> |
|
1548 | 1548 | </select> |
1549 | 1549 | </td> |
1550 | 1550 | </tr> |
1551 | 1551 | |
1552 | 1552 | <?php |
1553 | 1553 | |
1554 | - break; |
|
1554 | + break; |
|
1555 | 1555 | |
1556 | - case 'google_analytics' : |
|
1557 | - $selections = (array)get_option($value['id']); |
|
1558 | - ?> |
|
1556 | + case 'google_analytics' : |
|
1557 | + $selections = (array)get_option($value['id']); |
|
1558 | + ?> |
|
1559 | 1559 | <tr valign="top"> |
1560 | 1560 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1561 | 1561 | <td class="forminp"> |
@@ -1563,62 +1563,62 @@ discard block |
||
1563 | 1563 | |
1564 | 1564 | <?php |
1565 | 1565 | |
1566 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
1567 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
1568 | - $state = "&state=123";//any string |
|
1569 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
1570 | - $response_type = "&response_type=code"; |
|
1571 | - $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
1572 | - $access_type = "&access_type=offline"; |
|
1573 | - $approval_prompt = "&approval_prompt=force"; |
|
1566 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
1567 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
1568 | + $state = "&state=123";//any string |
|
1569 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
1570 | + $response_type = "&response_type=code"; |
|
1571 | + $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
1572 | + $access_type = "&access_type=offline"; |
|
1573 | + $approval_prompt = "&approval_prompt=force"; |
|
1574 | 1574 | |
1575 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
1575 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
1576 | 1576 | |
1577 | 1577 | |
1578 | - if (get_option('geodir_ga_auth_token')) { |
|
1579 | - ?> |
|
1578 | + if (get_option('geodir_ga_auth_token')) { |
|
1579 | + ?> |
|
1580 | 1580 | <span class="button-primary" |
1581 | 1581 | onclick="gd_GA_Deauthorize('<?php echo wp_create_nonce('gd_ga_deauthorize');?>');"><?php _e('Deauthorize', 'geodirectory'); ?></span> |
1582 | 1582 | <span style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span> |
1583 | 1583 | <?php |
1584 | - global $gd_ga_errors; |
|
1585 | - if(!empty($gd_ga_errors)){ |
|
1586 | - print_r($gd_ga_errors); |
|
1587 | - } |
|
1588 | - } else { |
|
1589 | - ?> |
|
1584 | + global $gd_ga_errors; |
|
1585 | + if(!empty($gd_ga_errors)){ |
|
1586 | + print_r($gd_ga_errors); |
|
1587 | + } |
|
1588 | + } else { |
|
1589 | + ?> |
|
1590 | 1590 | <span class="button-primary" |
1591 | 1591 | 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> |
1592 | 1592 | <?php |
1593 | - } |
|
1594 | - ?> |
|
1593 | + } |
|
1594 | + ?> |
|
1595 | 1595 | </td> |
1596 | 1596 | </tr> |
1597 | 1597 | |
1598 | 1598 | <?php |
1599 | 1599 | |
1600 | 1600 | |
1601 | - break; |
|
1601 | + break; |
|
1602 | 1602 | |
1603 | - case 'field_seperator' : |
|
1603 | + case 'field_seperator' : |
|
1604 | 1604 | |
1605 | - ?> |
|
1605 | + ?> |
|
1606 | 1606 | <tr valign="top"> |
1607 | 1607 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
1608 | 1608 | </tr> |
1609 | 1609 | <?php |
1610 | 1610 | |
1611 | - break; |
|
1611 | + break; |
|
1612 | 1612 | |
1613 | - endswitch; |
|
1613 | + endswitch; |
|
1614 | 1614 | |
1615 | - endforeach; |
|
1615 | + endforeach; |
|
1616 | 1616 | |
1617 | - if ($first_title === false) { |
|
1618 | - echo "</div>"; |
|
1619 | - } |
|
1617 | + if ($first_title === false) { |
|
1618 | + echo "</div>"; |
|
1619 | + } |
|
1620 | 1620 | |
1621 | - ?> |
|
1621 | + ?> |
|
1622 | 1622 | |
1623 | 1623 | <script type="text/javascript"> |
1624 | 1624 | |
@@ -1678,33 +1678,33 @@ discard block |
||
1678 | 1678 | */ |
1679 | 1679 | function geodir_post_info_setting() |
1680 | 1680 | { |
1681 | - global $post, $post_id; |
|
1682 | - |
|
1683 | - $post_type = get_post_type(); |
|
1684 | - |
|
1685 | - $package_info = array(); |
|
1686 | - |
|
1687 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1688 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
1689 | - echo '<div id="geodir_wrapper">'; |
|
1690 | - /** |
|
1691 | - * Called before the GD custom fields are output in the wp-admin area. |
|
1692 | - * |
|
1693 | - * @since 1.0.0 |
|
1694 | - * @see 'geodir_after_default_field_in_meta_box' |
|
1695 | - */ |
|
1696 | - do_action('geodir_before_default_field_in_meta_box'); |
|
1697 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
1698 | - // to display all fields in one information box |
|
1699 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
1700 | - /** |
|
1701 | - * Called after the GD custom fields are output in the wp-admin area. |
|
1702 | - * |
|
1703 | - * @since 1.0.0 |
|
1704 | - * @see 'geodir_before_default_field_in_meta_box' |
|
1705 | - */ |
|
1706 | - do_action('geodir_after_default_field_in_meta_box'); |
|
1707 | - echo '</div>'; |
|
1681 | + global $post, $post_id; |
|
1682 | + |
|
1683 | + $post_type = get_post_type(); |
|
1684 | + |
|
1685 | + $package_info = array(); |
|
1686 | + |
|
1687 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1688 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
1689 | + echo '<div id="geodir_wrapper">'; |
|
1690 | + /** |
|
1691 | + * Called before the GD custom fields are output in the wp-admin area. |
|
1692 | + * |
|
1693 | + * @since 1.0.0 |
|
1694 | + * @see 'geodir_after_default_field_in_meta_box' |
|
1695 | + */ |
|
1696 | + do_action('geodir_before_default_field_in_meta_box'); |
|
1697 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
1698 | + // to display all fields in one information box |
|
1699 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
1700 | + /** |
|
1701 | + * Called after the GD custom fields are output in the wp-admin area. |
|
1702 | + * |
|
1703 | + * @since 1.0.0 |
|
1704 | + * @see 'geodir_before_default_field_in_meta_box' |
|
1705 | + */ |
|
1706 | + do_action('geodir_after_default_field_in_meta_box'); |
|
1707 | + echo '</div>'; |
|
1708 | 1708 | } |
1709 | 1709 | |
1710 | 1710 | /** |
@@ -1717,18 +1717,18 @@ discard block |
||
1717 | 1717 | */ |
1718 | 1718 | function geodir_post_addinfo_setting() |
1719 | 1719 | { |
1720 | - global $post, $post_id; |
|
1720 | + global $post, $post_id; |
|
1721 | 1721 | |
1722 | - $post_type = get_post_type(); |
|
1722 | + $post_type = get_post_type(); |
|
1723 | 1723 | |
1724 | - $package_info = array(); |
|
1724 | + $package_info = array(); |
|
1725 | 1725 | |
1726 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1726 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1727 | 1727 | |
1728 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
1729 | - echo '<div id="geodir_wrapper">'; |
|
1730 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
1731 | - echo '</div>'; |
|
1728 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
1729 | + echo '<div id="geodir_wrapper">'; |
|
1730 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
1731 | + echo '</div>'; |
|
1732 | 1732 | |
1733 | 1733 | } |
1734 | 1734 | |
@@ -1742,60 +1742,60 @@ discard block |
||
1742 | 1742 | */ |
1743 | 1743 | function geodir_post_attachments() |
1744 | 1744 | { |
1745 | - global $post, $post_id; |
|
1745 | + global $post, $post_id; |
|
1746 | 1746 | |
1747 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
1747 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
1748 | 1748 | |
1749 | - if (geodir_get_featured_image($post_id, 'thumbnail')) { |
|
1750 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>'; |
|
1751 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
1752 | - } |
|
1749 | + if (geodir_get_featured_image($post_id, 'thumbnail')) { |
|
1750 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>'; |
|
1751 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
1752 | + } |
|
1753 | 1753 | |
1754 | - $image_limit = 0; |
|
1754 | + $image_limit = 0; |
|
1755 | 1755 | |
1756 | - ?> |
|
1756 | + ?> |
|
1757 | 1757 | |
1758 | 1758 | |
1759 | 1759 | <h5 class="form_title"> |
1760 | 1760 | <?php if ($image_limit != 0 && $image_limit == 1) { |
1761 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>'; |
|
1762 | - } ?> |
|
1761 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>'; |
|
1762 | + } ?> |
|
1763 | 1763 | <?php if ($image_limit != 0 && $image_limit > 1) { |
1764 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>'; |
|
1765 | - } ?> |
|
1764 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>'; |
|
1765 | + } ?> |
|
1766 | 1766 | <?php if ($image_limit == 0) { |
1767 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>'; |
|
1768 | - } ?> |
|
1767 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>'; |
|
1768 | + } ?> |
|
1769 | 1769 | </h5> |
1770 | 1770 | |
1771 | 1771 | |
1772 | 1772 | <?php |
1773 | 1773 | |
1774 | - $curImages = geodir_get_images($post_id); |
|
1775 | - $place_img_array = array(); |
|
1774 | + $curImages = geodir_get_images($post_id); |
|
1775 | + $place_img_array = array(); |
|
1776 | 1776 | |
1777 | - if (!empty($curImages)): |
|
1778 | - foreach ($curImages as $p_img): |
|
1779 | - $place_img_array[] = $p_img->src; |
|
1780 | - endforeach; |
|
1781 | - endif; |
|
1777 | + if (!empty($curImages)): |
|
1778 | + foreach ($curImages as $p_img): |
|
1779 | + $place_img_array[] = $p_img->src; |
|
1780 | + endforeach; |
|
1781 | + endif; |
|
1782 | 1782 | |
1783 | - if (!empty($place_img_array)) |
|
1784 | - $curImages = implode(',', $place_img_array); |
|
1783 | + if (!empty($place_img_array)) |
|
1784 | + $curImages = implode(',', $place_img_array); |
|
1785 | 1785 | |
1786 | 1786 | |
1787 | - // adjust values here |
|
1788 | - $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 |
|
1787 | + // adjust values here |
|
1788 | + $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 |
|
1789 | 1789 | |
1790 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
1790 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
1791 | 1791 | |
1792 | - $multiple = true; // allow multiple files upload |
|
1792 | + $multiple = true; // allow multiple files upload |
|
1793 | 1793 | |
1794 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
1794 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
1795 | 1795 | |
1796 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
1796 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
1797 | 1797 | |
1798 | - ?> |
|
1798 | + ?> |
|
1799 | 1799 | |
1800 | 1800 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
1801 | 1801 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -1837,13 +1837,13 @@ discard block |
||
1837 | 1837 | */ |
1838 | 1838 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
1839 | 1839 | { |
1840 | - $post_type = get_post_type($post_ID); |
|
1840 | + $post_type = get_post_type($post_ID); |
|
1841 | 1841 | |
1842 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { |
|
1843 | - 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) { |
|
1844 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
1845 | - } |
|
1846 | - } |
|
1842 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { |
|
1843 | + 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) { |
|
1844 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
1845 | + } |
|
1846 | + } |
|
1847 | 1847 | } |
1848 | 1848 | |
1849 | 1849 | /** |
@@ -1858,39 +1858,39 @@ discard block |
||
1858 | 1858 | */ |
1859 | 1859 | function geodir_notification_add_bcc_option($settings) |
1860 | 1860 | { |
1861 | - if (!empty($settings)) { |
|
1862 | - $new_settings = array(); |
|
1863 | - foreach ($settings as $setting) { |
|
1864 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') { |
|
1865 | - $geodir_bcc_listing_published_yes = array( |
|
1866 | - 'name' => __('Listing published', 'geodirectory'), |
|
1867 | - 'desc' => __('Yes', 'geodirectory'), |
|
1868 | - 'id' => 'geodir_bcc_listing_published', |
|
1869 | - 'std' => 'yes', |
|
1870 | - 'type' => 'radio', |
|
1871 | - 'value' => '1', |
|
1872 | - 'radiogroup' => 'start' |
|
1873 | - ); |
|
1874 | - |
|
1875 | - $geodir_bcc_listing_published_no = array( |
|
1876 | - 'name' => __('Listing published', 'geodirectory'), |
|
1877 | - 'desc' => __('No', 'geodirectory'), |
|
1878 | - 'id' => 'geodir_bcc_listing_published', |
|
1879 | - 'std' => 'yes', |
|
1880 | - 'type' => 'radio', |
|
1881 | - 'value' => '0', |
|
1882 | - 'radiogroup' => 'end' |
|
1883 | - ); |
|
1884 | - |
|
1885 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
1886 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
1887 | - } |
|
1888 | - $new_settings[] = $setting; |
|
1889 | - } |
|
1890 | - $settings = $new_settings; |
|
1891 | - } |
|
1861 | + if (!empty($settings)) { |
|
1862 | + $new_settings = array(); |
|
1863 | + foreach ($settings as $setting) { |
|
1864 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') { |
|
1865 | + $geodir_bcc_listing_published_yes = array( |
|
1866 | + 'name' => __('Listing published', 'geodirectory'), |
|
1867 | + 'desc' => __('Yes', 'geodirectory'), |
|
1868 | + 'id' => 'geodir_bcc_listing_published', |
|
1869 | + 'std' => 'yes', |
|
1870 | + 'type' => 'radio', |
|
1871 | + 'value' => '1', |
|
1872 | + 'radiogroup' => 'start' |
|
1873 | + ); |
|
1874 | + |
|
1875 | + $geodir_bcc_listing_published_no = array( |
|
1876 | + 'name' => __('Listing published', 'geodirectory'), |
|
1877 | + 'desc' => __('No', 'geodirectory'), |
|
1878 | + 'id' => 'geodir_bcc_listing_published', |
|
1879 | + 'std' => 'yes', |
|
1880 | + 'type' => 'radio', |
|
1881 | + 'value' => '0', |
|
1882 | + 'radiogroup' => 'end' |
|
1883 | + ); |
|
1884 | + |
|
1885 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
1886 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
1887 | + } |
|
1888 | + $new_settings[] = $setting; |
|
1889 | + } |
|
1890 | + $settings = $new_settings; |
|
1891 | + } |
|
1892 | 1892 | |
1893 | - return $settings; |
|
1893 | + return $settings; |
|
1894 | 1894 | } |
1895 | 1895 | |
1896 | 1896 | |
@@ -1905,19 +1905,19 @@ discard block |
||
1905 | 1905 | */ |
1906 | 1906 | function get_gd_theme_compat_callback() |
1907 | 1907 | { |
1908 | - global $wpdb; |
|
1909 | - $themes = get_option('gd_theme_compats'); |
|
1910 | - |
|
1911 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) { |
|
1912 | - if (isset($_POST['export'])) { |
|
1913 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
1914 | - } else { |
|
1915 | - echo json_encode($themes[$_POST['theme']]); |
|
1916 | - } |
|
1908 | + global $wpdb; |
|
1909 | + $themes = get_option('gd_theme_compats'); |
|
1917 | 1910 | |
1918 | - } |
|
1911 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) { |
|
1912 | + if (isset($_POST['export'])) { |
|
1913 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
1914 | + } else { |
|
1915 | + echo json_encode($themes[$_POST['theme']]); |
|
1916 | + } |
|
1919 | 1917 | |
1920 | - die(); |
|
1918 | + } |
|
1919 | + |
|
1920 | + die(); |
|
1921 | 1921 | } |
1922 | 1922 | |
1923 | 1923 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback'); |
@@ -1931,20 +1931,20 @@ discard block |
||
1931 | 1931 | */ |
1932 | 1932 | function get_gd_theme_compat_import_callback() |
1933 | 1933 | { |
1934 | - global $wpdb; |
|
1935 | - $themes = get_option('gd_theme_compats'); |
|
1936 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) { |
|
1937 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
1938 | - if (!empty($json) && is_array($json)) { |
|
1939 | - $key = sanitize_text_field(key($json)); |
|
1940 | - $themes[$key] = $json[$key]; |
|
1941 | - update_option('gd_theme_compats', $themes); |
|
1942 | - echo $key; |
|
1943 | - die(); |
|
1944 | - } |
|
1945 | - } |
|
1946 | - echo '0'; |
|
1947 | - die(); |
|
1934 | + global $wpdb; |
|
1935 | + $themes = get_option('gd_theme_compats'); |
|
1936 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) { |
|
1937 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
1938 | + if (!empty($json) && is_array($json)) { |
|
1939 | + $key = sanitize_text_field(key($json)); |
|
1940 | + $themes[$key] = $json[$key]; |
|
1941 | + update_option('gd_theme_compats', $themes); |
|
1942 | + echo $key; |
|
1943 | + die(); |
|
1944 | + } |
|
1945 | + } |
|
1946 | + echo '0'; |
|
1947 | + die(); |
|
1948 | 1948 | } |
1949 | 1949 | |
1950 | 1950 | |
@@ -1957,39 +1957,39 @@ discard block |
||
1957 | 1957 | */ |
1958 | 1958 | function gd_set_theme_compat() |
1959 | 1959 | { |
1960 | - global $wpdb; |
|
1961 | - $theme = wp_get_theme(); |
|
1960 | + global $wpdb; |
|
1961 | + $theme = wp_get_theme(); |
|
1962 | 1962 | |
1963 | - if ($theme->parent()) { |
|
1964 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name')); |
|
1965 | - } else { |
|
1966 | - $theme_name = str_replace(" ", "_", $theme->get('Name')); |
|
1967 | - } |
|
1963 | + if ($theme->parent()) { |
|
1964 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name')); |
|
1965 | + } else { |
|
1966 | + $theme_name = str_replace(" ", "_", $theme->get('Name')); |
|
1967 | + } |
|
1968 | 1968 | |
1969 | - $theme_compats = get_option('gd_theme_compats'); |
|
1970 | - $current_compat = get_option('gd_theme_compat'); |
|
1971 | - $current_compat = str_replace("_custom", "", $current_compat); |
|
1969 | + $theme_compats = get_option('gd_theme_compats'); |
|
1970 | + $current_compat = get_option('gd_theme_compat'); |
|
1971 | + $current_compat = str_replace("_custom", "", $current_compat); |
|
1972 | 1972 | |
1973 | - if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) { |
|
1974 | - return; |
|
1975 | - }// if already running correct compat then bail |
|
1973 | + if ($current_compat == $theme_name && strpos(get_option('gd_theme_compat'), "_custom") !== false) { |
|
1974 | + return; |
|
1975 | + }// if already running correct compat then bail |
|
1976 | 1976 | |
1977 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it |
|
1978 | - update_option('gd_theme_compat', $theme_name); |
|
1979 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]); |
|
1977 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it |
|
1978 | + update_option('gd_theme_compat', $theme_name); |
|
1979 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]); |
|
1980 | 1980 | |
1981 | - // if there are default options to set then set them |
|
1982 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) { |
|
1981 | + // if there are default options to set then set them |
|
1982 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) { |
|
1983 | 1983 | |
1984 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) { |
|
1985 | - update_option($key, $val); |
|
1986 | - } |
|
1987 | - } |
|
1984 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) { |
|
1985 | + update_option($key, $val); |
|
1986 | + } |
|
1987 | + } |
|
1988 | 1988 | |
1989 | - } else { |
|
1990 | - update_option('gd_theme_compat', ''); |
|
1991 | - update_option('theme_compatibility_setting', ''); |
|
1992 | - } |
|
1989 | + } else { |
|
1990 | + update_option('gd_theme_compat', ''); |
|
1991 | + update_option('theme_compatibility_setting', ''); |
|
1992 | + } |
|
1993 | 1993 | |
1994 | 1994 | |
1995 | 1995 | } |
@@ -2004,9 +2004,9 @@ discard block |
||
2004 | 2004 | */ |
2005 | 2005 | function gd_check_avada_compat() |
2006 | 2006 | { |
2007 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) { |
|
2008 | - add_action('admin_notices', 'gd_avada_compat_warning'); |
|
2009 | - } |
|
2007 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) { |
|
2008 | + add_action('admin_notices', 'gd_avada_compat_warning'); |
|
2009 | + } |
|
2010 | 2010 | } |
2011 | 2011 | |
2012 | 2012 | |
@@ -2019,22 +2019,22 @@ discard block |
||
2019 | 2019 | function gd_avada_compat_warning() |
2020 | 2020 | { |
2021 | 2021 | |
2022 | - /* |
|
2022 | + /* |
|
2023 | 2023 | $msg_type = error |
2024 | 2024 | $msg_type = updated fade |
2025 | 2025 | $msg_type = update-nag |
2026 | 2026 | */ |
2027 | 2027 | |
2028 | - $plugin = 'avada-nag'; |
|
2029 | - $timestamp = 'avada-nag1234'; |
|
2030 | - $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'); |
|
2031 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
2032 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fas fa-times"></i></span>'; |
|
2033 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > "; |
|
2034 | - echo "<p>$message</p>"; |
|
2035 | - echo "</div>"; |
|
2028 | + $plugin = 'avada-nag'; |
|
2029 | + $timestamp = 'avada-nag1234'; |
|
2030 | + $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'); |
|
2031 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
2032 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fas fa-times"></i></span>'; |
|
2033 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > "; |
|
2034 | + echo "<p>$message</p>"; |
|
2035 | + echo "</div>"; |
|
2036 | 2036 | |
2037 | - ?> |
|
2037 | + ?> |
|
2038 | 2038 | <script> |
2039 | 2039 | function gdRemoveANotification($plugin, $timestamp) { |
2040 | 2040 | |
@@ -2102,10 +2102,10 @@ discard block |
||
2102 | 2102 | */ |
2103 | 2103 | function geodir_avada_remove_notification() |
2104 | 2104 | { |
2105 | - update_option('avada_nag', TRUE); |
|
2105 | + update_option('avada_nag', TRUE); |
|
2106 | 2106 | |
2107 | - // Always die in functions echoing ajax content |
|
2108 | - die(); |
|
2107 | + // Always die in functions echoing ajax content |
|
2108 | + die(); |
|
2109 | 2109 | } |
2110 | 2110 | |
2111 | 2111 | |
@@ -2127,11 +2127,11 @@ discard block |
||
2127 | 2127 | global $post, $typenow, $current_screen; |
2128 | 2128 | |
2129 | 2129 | $post_type = NULL; |
2130 | - if (isset($_REQUEST['post_type'])) |
|
2130 | + if (isset($_REQUEST['post_type'])) |
|
2131 | 2131 | $post_type = sanitize_key($_REQUEST['post_type']); |
2132 | - elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
2132 | + elseif (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
2133 | 2133 | $post_type = get_post_type($_REQUEST['post']); |
2134 | - elseif ($post && isset($post->post_type)) |
|
2134 | + elseif ($post && isset($post->post_type)) |
|
2135 | 2135 | $post_type = $post->post_type; |
2136 | 2136 | elseif ($typenow) |
2137 | 2137 | $post_type = $typenow; |
@@ -2165,7 +2165,7 @@ discard block |
||
2165 | 2165 | // Don't allow same slug url for listing and location |
2166 | 2166 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) { |
2167 | 2167 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21'); |
2168 | - wp_redirect($redirect_url); |
|
2168 | + wp_redirect($redirect_url); |
|
2169 | 2169 | exit; |
2170 | 2170 | } |
2171 | 2171 | |
@@ -2195,10 +2195,10 @@ discard block |
||
2195 | 2195 | * @package GeoDirectory |
2196 | 2196 | */ |
2197 | 2197 | function geodir_hide_admin_preview_button() { |
2198 | - global $post_type; |
|
2199 | - $post_types = geodir_get_posttypes(); |
|
2200 | - if(in_array($post_type, $post_types)) |
|
2201 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>'; |
|
2198 | + global $post_type; |
|
2199 | + $post_types = geodir_get_posttypes(); |
|
2200 | + if(in_array($post_type, $post_types)) |
|
2201 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>'; |
|
2202 | 2202 | } |
2203 | 2203 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
2204 | 2204 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -2213,7 +2213,7 @@ discard block |
||
2213 | 2213 | */ |
2214 | 2214 | function geodir_import_export_tab( $tabs ) { |
2215 | 2215 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
2216 | - return $tabs; |
|
2216 | + return $tabs; |
|
2217 | 2217 | } |
2218 | 2218 | |
2219 | 2219 | /** |
@@ -2228,26 +2228,26 @@ discard block |
||
2228 | 2228 | function geodir_import_export_page() { |
2229 | 2229 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
2230 | 2230 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
2231 | - /** |
|
2232 | - * Filter sample category data csv file url. |
|
2233 | - * |
|
2234 | - * @since 1.0.0 |
|
2235 | - * @package GeoDirectory |
|
2236 | - * |
|
2237 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
2238 | - */ |
|
2231 | + /** |
|
2232 | + * Filter sample category data csv file url. |
|
2233 | + * |
|
2234 | + * @since 1.0.0 |
|
2235 | + * @package GeoDirectory |
|
2236 | + * |
|
2237 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
2238 | + */ |
|
2239 | 2239 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
2240 | 2240 | |
2241 | 2241 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
2242 | - /** |
|
2243 | - * Filter sample post data csv file url. |
|
2244 | - * |
|
2245 | - * @since 1.0.0 |
|
2246 | - * @package GeoDirectory |
|
2247 | - * |
|
2248 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
2249 | - */ |
|
2250 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
2242 | + /** |
|
2243 | + * Filter sample post data csv file url. |
|
2244 | + * |
|
2245 | + * @since 1.0.0 |
|
2246 | + * @package GeoDirectory |
|
2247 | + * |
|
2248 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
2249 | + */ |
|
2250 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
2251 | 2251 | |
2252 | 2252 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
2253 | 2253 | |
@@ -2270,14 +2270,14 @@ discard block |
||
2270 | 2270 | $gd_chunksize_options[100000] = 100000; |
2271 | 2271 | |
2272 | 2272 | /** |
2273 | - * Filter max entries per export csv file. |
|
2274 | - * |
|
2275 | - * @since 1.5.6 |
|
2276 | - * @package GeoDirectory |
|
2277 | - * |
|
2278 | - * @param string $gd_chunksize_options Entries options. |
|
2279 | - */ |
|
2280 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
2273 | + * Filter max entries per export csv file. |
|
2274 | + * |
|
2275 | + * @since 1.5.6 |
|
2276 | + * @package GeoDirectory |
|
2277 | + * |
|
2278 | + * @param string $gd_chunksize_options Entries options. |
|
2279 | + */ |
|
2280 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
2281 | 2281 | |
2282 | 2282 | $gd_chunksize_option = ''; |
2283 | 2283 | foreach ($gd_chunksize_options as $value => $title) { |
@@ -2294,12 +2294,12 @@ discard block |
||
2294 | 2294 | <div class="gd-content-heading"> |
2295 | 2295 | |
2296 | 2296 | <?php |
2297 | - @ini_set('max_execution_time', 999999); |
|
2298 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
2299 | - @ini_restore('max_execution_time'); |
|
2297 | + @ini_set('max_execution_time', 999999); |
|
2298 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
2299 | + @ini_restore('max_execution_time'); |
|
2300 | 2300 | |
2301 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting |
|
2302 | - ?> |
|
2301 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting |
|
2302 | + ?> |
|
2303 | 2303 | <div id="gd_ie_reqs" class="metabox-holder"> |
2304 | 2304 | <div class="meta-box-sortables ui-sortable"> |
2305 | 2305 | <div class="postbox"> |
@@ -2474,7 +2474,7 @@ discard block |
||
2474 | 2474 | * Called just after the sample CSV download link. |
2475 | 2475 | * |
2476 | 2476 | * @since 1.0.0 |
2477 | - * @package GeoDirectory |
|
2477 | + * @package GeoDirectory |
|
2478 | 2478 | */ |
2479 | 2479 | do_action('geodir_sample_cats_csv_download_link'); |
2480 | 2480 | ?> |
@@ -2559,11 +2559,11 @@ discard block |
||
2559 | 2559 | * |
2560 | 2560 | * Called after the last setting on the GD > Import & Export page. |
2561 | 2561 | * @since 1.4.6 |
2562 | - * @package GeoDirectory |
|
2562 | + * @package GeoDirectory |
|
2563 | 2563 | * |
2564 | 2564 | * @param array $gd_posttypes GD post types. |
2565 | - * @param array $gd_chunksize_options File chunk size options. |
|
2566 | - * @param string $nonce Wordpress security token for GD import & export. |
|
2565 | + * @param array $gd_chunksize_options File chunk size options. |
|
2566 | + * @param string $nonce Wordpress security token for GD import & export. |
|
2567 | 2567 | */ |
2568 | 2568 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
2569 | 2569 | ?> |
@@ -3250,44 +3250,44 @@ discard block |
||
3250 | 3250 | function geodir_init_filesystem() |
3251 | 3251 | { |
3252 | 3252 | |
3253 | - if(!function_exists('get_filesystem_method')){ |
|
3254 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
3255 | - } |
|
3256 | - $access_type = get_filesystem_method(); |
|
3257 | - if ($access_type === 'direct') { |
|
3258 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
3259 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3260 | - |
|
3261 | - /* initialize the API */ |
|
3262 | - if (!WP_Filesystem($creds)) { |
|
3263 | - /* any problems and we exit */ |
|
3264 | - //return '@@@3'; |
|
3265 | - return false; |
|
3266 | - } |
|
3267 | - |
|
3268 | - global $wp_filesystem; |
|
3269 | - return $wp_filesystem; |
|
3270 | - /* do our file manipulations below */ |
|
3271 | - } elseif (defined('FTP_USER')) { |
|
3272 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3253 | + if(!function_exists('get_filesystem_method')){ |
|
3254 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
3255 | + } |
|
3256 | + $access_type = get_filesystem_method(); |
|
3257 | + if ($access_type === 'direct') { |
|
3258 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
3259 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3260 | + |
|
3261 | + /* initialize the API */ |
|
3262 | + if (!WP_Filesystem($creds)) { |
|
3263 | + /* any problems and we exit */ |
|
3264 | + //return '@@@3'; |
|
3265 | + return false; |
|
3266 | + } |
|
3273 | 3267 | |
3274 | - /* initialize the API */ |
|
3275 | - if (!WP_Filesystem($creds)) { |
|
3276 | - /* any problems and we exit */ |
|
3277 | - //return '@@@33'; |
|
3278 | - return false; |
|
3279 | - } |
|
3268 | + global $wp_filesystem; |
|
3269 | + return $wp_filesystem; |
|
3270 | + /* do our file manipulations below */ |
|
3271 | + } elseif (defined('FTP_USER')) { |
|
3272 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3273 | + |
|
3274 | + /* initialize the API */ |
|
3275 | + if (!WP_Filesystem($creds)) { |
|
3276 | + /* any problems and we exit */ |
|
3277 | + //return '@@@33'; |
|
3278 | + return false; |
|
3279 | + } |
|
3280 | 3280 | |
3281 | - global $wp_filesystem; |
|
3282 | - //return '@@@1'; |
|
3283 | - return $wp_filesystem; |
|
3281 | + global $wp_filesystem; |
|
3282 | + //return '@@@1'; |
|
3283 | + return $wp_filesystem; |
|
3284 | 3284 | |
3285 | - } else { |
|
3286 | - //return '@@@2'; |
|
3287 | - /* don't have direct write access. Prompt user with our notice */ |
|
3288 | - add_action('admin_notice', 'geodir_filesystem_notice'); |
|
3289 | - return false; |
|
3290 | - } |
|
3285 | + } else { |
|
3286 | + //return '@@@2'; |
|
3287 | + /* don't have direct write access. Prompt user with our notice */ |
|
3288 | + add_action('admin_notice', 'geodir_filesystem_notice'); |
|
3289 | + return false; |
|
3290 | + } |
|
3291 | 3291 | |
3292 | 3292 | } |
3293 | 3293 | |
@@ -3305,10 +3305,10 @@ discard block |
||
3305 | 3305 | */ |
3306 | 3306 | function geodir_filesystem_notice() |
3307 | 3307 | { if ( defined( 'DOING_AJAX' ) ){return;} |
3308 | - $access_type = get_filesystem_method(); |
|
3309 | - if ($access_type === 'direct') { |
|
3310 | - } elseif (!defined('FTP_USER')) { |
|
3311 | - ?> |
|
3308 | + $access_type = get_filesystem_method(); |
|
3309 | + if ($access_type === 'direct') { |
|
3310 | + } elseif (!defined('FTP_USER')) { |
|
3311 | + ?> |
|
3312 | 3312 | <div class="error"> |
3313 | 3313 | <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'); ?> |
3314 | 3314 | <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> |
@@ -3336,1280 +3336,1280 @@ discard block |
||
3336 | 3336 | * @return string Json data. |
3337 | 3337 | */ |
3338 | 3338 | function geodir_ajax_import_export() { |
3339 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
3339 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
3340 | 3340 | |
3341 | - error_reporting(0); |
|
3341 | + error_reporting(0); |
|
3342 | 3342 | |
3343 | - $xstart = microtime(true); |
|
3343 | + $xstart = microtime(true); |
|
3344 | 3344 | |
3345 | - // try to set higher limits for import |
|
3346 | - $max_input_time = ini_get('max_input_time'); |
|
3347 | - $max_execution_time = ini_get('max_execution_time'); |
|
3348 | - $memory_limit= ini_get('memory_limit'); |
|
3345 | + // try to set higher limits for import |
|
3346 | + $max_input_time = ini_get('max_input_time'); |
|
3347 | + $max_execution_time = ini_get('max_execution_time'); |
|
3348 | + $memory_limit= ini_get('memory_limit'); |
|
3349 | 3349 | |
3350 | - if(!$max_input_time || $max_input_time<3000){ |
|
3351 | - @ini_set('max_input_time', 3000); |
|
3352 | - } |
|
3350 | + if(!$max_input_time || $max_input_time<3000){ |
|
3351 | + @ini_set('max_input_time', 3000); |
|
3352 | + } |
|
3353 | 3353 | |
3354 | - if(!$max_execution_time || $max_execution_time<3000){ |
|
3355 | - @ini_set('max_execution_time', 3000); |
|
3356 | - } |
|
3354 | + if(!$max_execution_time || $max_execution_time<3000){ |
|
3355 | + @ini_set('max_execution_time', 3000); |
|
3356 | + } |
|
3357 | 3357 | |
3358 | - if($memory_limit && str_replace('M','',$memory_limit)){ |
|
3359 | - if(str_replace('M','',$memory_limit)<256){ |
|
3360 | - @ini_set('memory_limit', '256M'); |
|
3361 | - } |
|
3362 | - } |
|
3358 | + if($memory_limit && str_replace('M','',$memory_limit)){ |
|
3359 | + if(str_replace('M','',$memory_limit)<256){ |
|
3360 | + @ini_set('memory_limit', '256M'); |
|
3361 | + } |
|
3362 | + } |
|
3363 | 3363 | |
3364 | - $json = array(); |
|
3364 | + $json = array(); |
|
3365 | 3365 | |
3366 | - if ( !current_user_can( 'manage_options' ) ) { |
|
3367 | - wp_send_json( $json ); |
|
3368 | - } |
|
3366 | + if ( !current_user_can( 'manage_options' ) ) { |
|
3367 | + wp_send_json( $json ); |
|
3368 | + } |
|
3369 | 3369 | |
3370 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
3371 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
3372 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
3370 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
3371 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
3372 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
3373 | 3373 | |
3374 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) { |
|
3375 | - wp_send_json( $json ); |
|
3376 | - } |
|
3374 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) { |
|
3375 | + wp_send_json( $json ); |
|
3376 | + } |
|
3377 | 3377 | |
3378 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
3379 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
3380 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
3381 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
3378 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
3379 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
3380 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
3381 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
3382 | 3382 | |
3383 | - $wp_filesystem = geodir_init_filesystem(); |
|
3384 | - if (!$wp_filesystem) { |
|
3385 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
3386 | - wp_send_json( $json ); |
|
3387 | - } |
|
3383 | + $wp_filesystem = geodir_init_filesystem(); |
|
3384 | + if (!$wp_filesystem) { |
|
3385 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
3386 | + wp_send_json( $json ); |
|
3387 | + } |
|
3388 | 3388 | |
3389 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
3390 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
3391 | - wp_send_json( $json ); |
|
3392 | - } |
|
3389 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
3390 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
3391 | + wp_send_json( $json ); |
|
3392 | + } |
|
3393 | 3393 | |
3394 | - $csv_file_dir = geodir_path_import_export( false ); |
|
3395 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) { |
|
3396 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) { |
|
3397 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3398 | - wp_send_json( $json ); |
|
3399 | - } |
|
3400 | - } |
|
3394 | + $csv_file_dir = geodir_path_import_export( false ); |
|
3395 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) { |
|
3396 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) { |
|
3397 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3398 | + wp_send_json( $json ); |
|
3399 | + } |
|
3400 | + } |
|
3401 | 3401 | |
3402 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active. |
|
3403 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
3404 | - |
|
3405 | - switch ( $task ) { |
|
3406 | - case 'export_posts': { |
|
3407 | - // WPML |
|
3408 | - $is_wpml = geodir_is_wpml(); |
|
3409 | - if ($is_wpml) { |
|
3410 | - global $sitepress; |
|
3411 | - $active_lang = ICL_LANGUAGE_CODE; |
|
3402 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active. |
|
3403 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
3404 | + |
|
3405 | + switch ( $task ) { |
|
3406 | + case 'export_posts': { |
|
3407 | + // WPML |
|
3408 | + $is_wpml = geodir_is_wpml(); |
|
3409 | + if ($is_wpml) { |
|
3410 | + global $sitepress; |
|
3411 | + $active_lang = ICL_LANGUAGE_CODE; |
|
3412 | 3412 | |
3413 | - $sitepress->switch_lang('all', true); |
|
3414 | - } |
|
3415 | - // WPML |
|
3416 | - if ( $post_type == 'gd_event' ) { |
|
3417 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
3418 | - } |
|
3419 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
3413 | + $sitepress->switch_lang('all', true); |
|
3414 | + } |
|
3415 | + // WPML |
|
3416 | + if ( $post_type == 'gd_event' ) { |
|
3417 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
3418 | + } |
|
3419 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
3420 | 3420 | |
3421 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
3422 | - if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) { |
|
3423 | - $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
3424 | - } |
|
3425 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
3426 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3427 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3428 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3429 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
3421 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
3422 | + if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) { |
|
3423 | + $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
3424 | + } |
|
3425 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
3426 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3427 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3428 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3429 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
3430 | 3430 | |
3431 | - $chunk_file_paths = array(); |
|
3431 | + $chunk_file_paths = array(); |
|
3432 | 3432 | |
3433 | - if ( isset( $_REQUEST['_c'] ) ) { |
|
3434 | - $json['total'] = $posts_count; |
|
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 if ( isset( $_REQUEST['_st'] ) ) { |
|
3443 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3444 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
3445 | - $percentage = min( $percentage, 100 ); |
|
3433 | + if ( isset( $_REQUEST['_c'] ) ) { |
|
3434 | + $json['total'] = $posts_count; |
|
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 if ( isset( $_REQUEST['_st'] ) ) { |
|
3443 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3444 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
3445 | + $percentage = min( $percentage, 100 ); |
|
3446 | 3446 | |
3447 | - $json['percentage'] = $percentage; |
|
3448 | - // WPML |
|
3449 | - if ($is_wpml) { |
|
3450 | - $sitepress->switch_lang($active_lang, true); |
|
3451 | - } |
|
3452 | - // WPML |
|
3453 | - wp_send_json( $json ); |
|
3454 | - gd_die(); |
|
3455 | - } else { |
|
3456 | - if ( !$posts_count > 0 ) { |
|
3457 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3458 | - } else { |
|
3459 | - $total_posts = $posts_count; |
|
3460 | - if ($chunk_per_page > $total_posts) { |
|
3461 | - $chunk_per_page = $total_posts; |
|
3462 | - } |
|
3463 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
3447 | + $json['percentage'] = $percentage; |
|
3448 | + // WPML |
|
3449 | + if ($is_wpml) { |
|
3450 | + $sitepress->switch_lang($active_lang, true); |
|
3451 | + } |
|
3452 | + // WPML |
|
3453 | + wp_send_json( $json ); |
|
3454 | + gd_die(); |
|
3455 | + } else { |
|
3456 | + if ( !$posts_count > 0 ) { |
|
3457 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3458 | + } else { |
|
3459 | + $total_posts = $posts_count; |
|
3460 | + if ($chunk_per_page > $total_posts) { |
|
3461 | + $chunk_per_page = $total_posts; |
|
3462 | + } |
|
3463 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
3464 | 3464 | |
3465 | - $j = $chunk_page_no; |
|
3466 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
3465 | + $j = $chunk_page_no; |
|
3466 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
3467 | 3467 | |
3468 | - $per_page = 500; |
|
3469 | - if ($per_page > $chunk_per_page) { |
|
3470 | - $per_page = $chunk_per_page; |
|
3471 | - } |
|
3472 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3468 | + $per_page = 500; |
|
3469 | + if ($per_page > $chunk_per_page) { |
|
3470 | + $per_page = $chunk_per_page; |
|
3471 | + } |
|
3472 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3473 | 3473 | |
3474 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3475 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
3474 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3475 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
3476 | 3476 | |
3477 | - $clear = $i == 0 ? true : false; |
|
3478 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
3479 | - } |
|
3477 | + $clear = $i == 0 ? true : false; |
|
3478 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
3479 | + } |
|
3480 | 3480 | |
3481 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3482 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3483 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3484 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3485 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3481 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3482 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3483 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3484 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3485 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3486 | 3486 | |
3487 | - $file_url = $file_url_base . $chunk_file_name; |
|
3488 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3489 | - } |
|
3487 | + $file_url = $file_url_base . $chunk_file_name; |
|
3488 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3489 | + } |
|
3490 | 3490 | |
3491 | - if ( !empty($chunk_file_paths) ) { |
|
3492 | - $json['total'] = $posts_count; |
|
3493 | - $json['files'] = $chunk_file_paths; |
|
3494 | - } else { |
|
3495 | - if ($j > 1) { |
|
3496 | - $json['total'] = $posts_count; |
|
3497 | - $json['files'] = array(); |
|
3498 | - } else { |
|
3499 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3500 | - } |
|
3501 | - } |
|
3502 | - } |
|
3503 | - // WPML |
|
3504 | - if ($is_wpml) { |
|
3505 | - $sitepress->switch_lang($active_lang, true); |
|
3506 | - } |
|
3507 | - // WPML |
|
3508 | - wp_send_json( $json ); |
|
3509 | - } |
|
3510 | - } |
|
3511 | - break; |
|
3512 | - case 'export_cats': { |
|
3513 | - // WPML |
|
3514 | - $is_wpml = geodir_is_wpml(); |
|
3515 | - if ($is_wpml) { |
|
3516 | - global $sitepress; |
|
3517 | - $active_lang = ICL_LANGUAGE_CODE; |
|
3491 | + if ( !empty($chunk_file_paths) ) { |
|
3492 | + $json['total'] = $posts_count; |
|
3493 | + $json['files'] = $chunk_file_paths; |
|
3494 | + } else { |
|
3495 | + if ($j > 1) { |
|
3496 | + $json['total'] = $posts_count; |
|
3497 | + $json['files'] = array(); |
|
3498 | + } else { |
|
3499 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3500 | + } |
|
3501 | + } |
|
3502 | + } |
|
3503 | + // WPML |
|
3504 | + if ($is_wpml) { |
|
3505 | + $sitepress->switch_lang($active_lang, true); |
|
3506 | + } |
|
3507 | + // WPML |
|
3508 | + wp_send_json( $json ); |
|
3509 | + } |
|
3510 | + } |
|
3511 | + break; |
|
3512 | + case 'export_cats': { |
|
3513 | + // WPML |
|
3514 | + $is_wpml = geodir_is_wpml(); |
|
3515 | + if ($is_wpml) { |
|
3516 | + global $sitepress; |
|
3517 | + $active_lang = ICL_LANGUAGE_CODE; |
|
3518 | 3518 | |
3519 | - $sitepress->switch_lang('all', true); |
|
3520 | - } |
|
3521 | - // WPML |
|
3522 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
3519 | + $sitepress->switch_lang('all', true); |
|
3520 | + } |
|
3521 | + // WPML |
|
3522 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
3523 | 3523 | |
3524 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
3525 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3526 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3527 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3528 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
3524 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
3525 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3526 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3527 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3528 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
3529 | 3529 | |
3530 | - $chunk_file_paths = array(); |
|
3530 | + $chunk_file_paths = array(); |
|
3531 | 3531 | |
3532 | - if ( isset( $_REQUEST['_st'] ) ) { |
|
3533 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3534 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
3535 | - $percentage = min( $percentage, 100 ); |
|
3532 | + if ( isset( $_REQUEST['_st'] ) ) { |
|
3533 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3534 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
3535 | + $percentage = min( $percentage, 100 ); |
|
3536 | 3536 | |
3537 | - $json['percentage'] = $percentage; |
|
3538 | - // WPML |
|
3539 | - if ($is_wpml) { |
|
3540 | - $sitepress->switch_lang($active_lang, true); |
|
3541 | - } |
|
3542 | - // WPML |
|
3543 | - wp_send_json( $json ); |
|
3544 | - } else { |
|
3545 | - if ( !$terms_count > 0 ) { |
|
3546 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3547 | - } else { |
|
3548 | - $total_terms = $terms_count; |
|
3549 | - if ($chunk_per_page > $terms_count) { |
|
3550 | - $chunk_per_page = $terms_count; |
|
3551 | - } |
|
3552 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
3537 | + $json['percentage'] = $percentage; |
|
3538 | + // WPML |
|
3539 | + if ($is_wpml) { |
|
3540 | + $sitepress->switch_lang($active_lang, true); |
|
3541 | + } |
|
3542 | + // WPML |
|
3543 | + wp_send_json( $json ); |
|
3544 | + } else { |
|
3545 | + if ( !$terms_count > 0 ) { |
|
3546 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3547 | + } else { |
|
3548 | + $total_terms = $terms_count; |
|
3549 | + if ($chunk_per_page > $terms_count) { |
|
3550 | + $chunk_per_page = $terms_count; |
|
3551 | + } |
|
3552 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
3553 | 3553 | |
3554 | - $j = $chunk_page_no; |
|
3555 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
3554 | + $j = $chunk_page_no; |
|
3555 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
3556 | 3556 | |
3557 | - $per_page = 500; |
|
3558 | - if ($per_page > $chunk_per_page) { |
|
3559 | - $per_page = $chunk_per_page; |
|
3560 | - } |
|
3561 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3557 | + $per_page = 500; |
|
3558 | + if ($per_page > $chunk_per_page) { |
|
3559 | + $per_page = $chunk_per_page; |
|
3560 | + } |
|
3561 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3562 | 3562 | |
3563 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3564 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
3563 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3564 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
3565 | 3565 | |
3566 | - $clear = $i == 0 ? true : false; |
|
3567 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
3568 | - } |
|
3566 | + $clear = $i == 0 ? true : false; |
|
3567 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
3568 | + } |
|
3569 | 3569 | |
3570 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3571 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3572 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3573 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3574 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3570 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3571 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3572 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3573 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3574 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3575 | 3575 | |
3576 | - $file_url = $file_url_base . $chunk_file_name; |
|
3577 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3578 | - } |
|
3576 | + $file_url = $file_url_base . $chunk_file_name; |
|
3577 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3578 | + } |
|
3579 | 3579 | |
3580 | - if ( !empty($chunk_file_paths) ) { |
|
3581 | - $json['total'] = $terms_count; |
|
3582 | - $json['files'] = $chunk_file_paths; |
|
3583 | - } else { |
|
3584 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3585 | - } |
|
3586 | - } |
|
3587 | - // WPML |
|
3588 | - if ($is_wpml) { |
|
3589 | - $sitepress->switch_lang($active_lang, true); |
|
3590 | - } |
|
3591 | - // WPML |
|
3592 | - wp_send_json( $json ); |
|
3593 | - } |
|
3594 | - } |
|
3595 | - break; |
|
3596 | - case 'export_locations': { |
|
3597 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3598 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
3599 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3600 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3601 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
3580 | + if ( !empty($chunk_file_paths) ) { |
|
3581 | + $json['total'] = $terms_count; |
|
3582 | + $json['files'] = $chunk_file_paths; |
|
3583 | + } else { |
|
3584 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3585 | + } |
|
3586 | + } |
|
3587 | + // WPML |
|
3588 | + if ($is_wpml) { |
|
3589 | + $sitepress->switch_lang($active_lang, true); |
|
3590 | + } |
|
3591 | + // WPML |
|
3592 | + wp_send_json( $json ); |
|
3593 | + } |
|
3594 | + } |
|
3595 | + break; |
|
3596 | + case 'export_locations': { |
|
3597 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3598 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
3599 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3600 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3601 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
3602 | 3602 | |
3603 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
3603 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
3604 | 3604 | |
3605 | - if ( isset( $_REQUEST['_st'] ) ) { |
|
3606 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3607 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3608 | - $percentage = min( $percentage, 100 ); |
|
3605 | + if ( isset( $_REQUEST['_st'] ) ) { |
|
3606 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3607 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3608 | + $percentage = min( $percentage, 100 ); |
|
3609 | 3609 | |
3610 | - $json['percentage'] = $percentage; |
|
3611 | - wp_send_json( $json ); |
|
3612 | - } else { |
|
3613 | - $chunk_file_paths = array(); |
|
3610 | + $json['percentage'] = $percentage; |
|
3611 | + wp_send_json( $json ); |
|
3612 | + } else { |
|
3613 | + $chunk_file_paths = array(); |
|
3614 | 3614 | |
3615 | - if ( !$items_count > 0 ) { |
|
3616 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3617 | - } else { |
|
3618 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3619 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3615 | + if ( !$items_count > 0 ) { |
|
3616 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3617 | + } else { |
|
3618 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3619 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3620 | 3620 | |
3621 | - $j = $chunk_page_no; |
|
3622 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
3621 | + $j = $chunk_page_no; |
|
3622 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
3623 | 3623 | |
3624 | - $per_page = 500; |
|
3625 | - $per_page = min( $per_page, $chunk_per_page ); |
|
3626 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3624 | + $per_page = 500; |
|
3625 | + $per_page = min( $per_page, $chunk_per_page ); |
|
3626 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3627 | 3627 | |
3628 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3629 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3628 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3629 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3630 | 3630 | |
3631 | - $clear = $i == 0 ? true : false; |
|
3632 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3633 | - } |
|
3631 | + $clear = $i == 0 ? true : false; |
|
3632 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3633 | + } |
|
3634 | 3634 | |
3635 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3636 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3637 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3638 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3639 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3635 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3636 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3637 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3638 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3639 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3640 | 3640 | |
3641 | - $file_url = $file_url_base . $chunk_file_name; |
|
3642 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3643 | - } |
|
3641 | + $file_url = $file_url_base . $chunk_file_name; |
|
3642 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3643 | + } |
|
3644 | 3644 | |
3645 | - if ( !empty($chunk_file_paths) ) { |
|
3646 | - $json['total'] = $items_count; |
|
3647 | - $json['files'] = $chunk_file_paths; |
|
3648 | - } else { |
|
3649 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3650 | - } |
|
3651 | - } |
|
3652 | - wp_send_json( $json ); |
|
3653 | - } |
|
3654 | - } |
|
3655 | - break; |
|
3656 | - case 'export_hoods': { |
|
3657 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3658 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
3659 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3660 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3661 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
3645 | + if ( !empty($chunk_file_paths) ) { |
|
3646 | + $json['total'] = $items_count; |
|
3647 | + $json['files'] = $chunk_file_paths; |
|
3648 | + } else { |
|
3649 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3650 | + } |
|
3651 | + } |
|
3652 | + wp_send_json( $json ); |
|
3653 | + } |
|
3654 | + } |
|
3655 | + break; |
|
3656 | + case 'export_hoods': { |
|
3657 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3658 | + $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
3659 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3660 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3661 | + $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
3662 | 3662 | |
3663 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
3663 | + $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
3664 | 3664 | |
3665 | - if ( isset( $_REQUEST['_st'] ) ) { |
|
3666 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3667 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3668 | - $percentage = min( $percentage, 100 ); |
|
3665 | + if ( isset( $_REQUEST['_st'] ) ) { |
|
3666 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3667 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3668 | + $percentage = min( $percentage, 100 ); |
|
3669 | 3669 | |
3670 | - $json['percentage'] = $percentage; |
|
3671 | - wp_send_json( $json ); |
|
3672 | - } else { |
|
3673 | - $chunk_file_paths = array(); |
|
3670 | + $json['percentage'] = $percentage; |
|
3671 | + wp_send_json( $json ); |
|
3672 | + } else { |
|
3673 | + $chunk_file_paths = array(); |
|
3674 | 3674 | |
3675 | - if ( !$items_count > 0 ) { |
|
3676 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3677 | - } else { |
|
3678 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3679 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3675 | + if ( !$items_count > 0 ) { |
|
3676 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3677 | + } else { |
|
3678 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3679 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3680 | 3680 | |
3681 | - $j = $chunk_page_no; |
|
3682 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
3681 | + $j = $chunk_page_no; |
|
3682 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
3683 | 3683 | |
3684 | - $per_page = 500; |
|
3685 | - $per_page = min( $per_page, $chunk_per_page ); |
|
3686 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3684 | + $per_page = 500; |
|
3685 | + $per_page = min( $per_page, $chunk_per_page ); |
|
3686 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3687 | 3687 | |
3688 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3689 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3688 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3689 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3690 | 3690 | |
3691 | - $clear = $i == 0 ? true : false; |
|
3692 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3693 | - } |
|
3691 | + $clear = $i == 0 ? true : false; |
|
3692 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3693 | + } |
|
3694 | 3694 | |
3695 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3696 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3697 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3698 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3699 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3695 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3696 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3697 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3698 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3699 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3700 | 3700 | |
3701 | - $file_url = $file_url_base . $chunk_file_name; |
|
3702 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3703 | - } |
|
3701 | + $file_url = $file_url_base . $chunk_file_name; |
|
3702 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3703 | + } |
|
3704 | 3704 | |
3705 | - if ( !empty($chunk_file_paths) ) { |
|
3706 | - $json['total'] = $items_count; |
|
3707 | - $json['files'] = $chunk_file_paths; |
|
3708 | - } else { |
|
3709 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3710 | - } |
|
3711 | - } |
|
3712 | - wp_send_json( $json ); |
|
3713 | - } |
|
3714 | - } |
|
3715 | - break; |
|
3716 | - case 'prepare_import': |
|
3717 | - case 'import_cat': |
|
3718 | - case 'import_post': |
|
3719 | - case 'import_loc': |
|
3720 | - case 'import_hood': { |
|
3721 | - // WPML |
|
3722 | - $is_wpml = geodir_is_wpml(); |
|
3723 | - if ($is_wpml) { |
|
3724 | - global $sitepress; |
|
3725 | - $active_lang = ICL_LANGUAGE_CODE; |
|
3726 | - } |
|
3727 | - // WPML |
|
3705 | + if ( !empty($chunk_file_paths) ) { |
|
3706 | + $json['total'] = $items_count; |
|
3707 | + $json['files'] = $chunk_file_paths; |
|
3708 | + } else { |
|
3709 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3710 | + } |
|
3711 | + } |
|
3712 | + wp_send_json( $json ); |
|
3713 | + } |
|
3714 | + } |
|
3715 | + break; |
|
3716 | + case 'prepare_import': |
|
3717 | + case 'import_cat': |
|
3718 | + case 'import_post': |
|
3719 | + case 'import_loc': |
|
3720 | + case 'import_hood': { |
|
3721 | + // WPML |
|
3722 | + $is_wpml = geodir_is_wpml(); |
|
3723 | + if ($is_wpml) { |
|
3724 | + global $sitepress; |
|
3725 | + $active_lang = ICL_LANGUAGE_CODE; |
|
3726 | + } |
|
3727 | + // WPML |
|
3728 | 3728 | |
3729 | - @ini_set( 'auto_detect_line_endings', true ); |
|
3729 | + @ini_set( 'auto_detect_line_endings', true ); |
|
3730 | 3730 | |
3731 | - $uploads = wp_upload_dir(); |
|
3732 | - $uploads_dir = $uploads['path']; |
|
3733 | - $uploads_subdir = $uploads['subdir']; |
|
3731 | + $uploads = wp_upload_dir(); |
|
3732 | + $uploads_dir = $uploads['path']; |
|
3733 | + $uploads_subdir = $uploads['subdir']; |
|
3734 | 3734 | |
3735 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
3736 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
3735 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
3736 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
3737 | 3737 | |
3738 | - $csv_file_arr = explode( '/', $csv_file ); |
|
3739 | - $csv_filename = end( $csv_file_arr ); |
|
3740 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
3738 | + $csv_file_arr = explode( '/', $csv_file ); |
|
3739 | + $csv_filename = end( $csv_file_arr ); |
|
3740 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
3741 | 3741 | |
3742 | - $json['file'] = $csv_file; |
|
3743 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
3744 | - $file = array(); |
|
3745 | - |
|
3746 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) { |
|
3747 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
3748 | - |
|
3749 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
3750 | - $json['error'] = NULL; |
|
3751 | - |
|
3752 | - $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
3753 | - setlocale(LC_ALL, 'en_US.UTF-8'); |
|
3754 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) { |
|
3755 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) { |
|
3756 | - if ( !empty( $data ) ) { |
|
3757 | - $file[] = $data; |
|
3758 | - } |
|
3759 | - } |
|
3760 | - fclose($handle); |
|
3761 | - } |
|
3762 | - setlocale(LC_ALL, $lc_all); |
|
3742 | + $json['file'] = $csv_file; |
|
3743 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
3744 | + $file = array(); |
|
3745 | + |
|
3746 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) { |
|
3747 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
3748 | + |
|
3749 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
3750 | + $json['error'] = NULL; |
|
3751 | + |
|
3752 | + $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
3753 | + setlocale(LC_ALL, 'en_US.UTF-8'); |
|
3754 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) { |
|
3755 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) { |
|
3756 | + if ( !empty( $data ) ) { |
|
3757 | + $file[] = $data; |
|
3758 | + } |
|
3759 | + } |
|
3760 | + fclose($handle); |
|
3761 | + } |
|
3762 | + setlocale(LC_ALL, $lc_all); |
|
3763 | 3763 | |
3764 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
3764 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
3765 | 3765 | |
3766 | - if (!$json['rows'] > 0) { |
|
3767 | - $json['error'] = __('No data found in csv file.', 'geodirectory'); |
|
3768 | - } |
|
3769 | - } else { |
|
3770 | - wp_send_json( $json ); |
|
3771 | - } |
|
3772 | - } else { |
|
3773 | - wp_send_json( $json ); |
|
3774 | - } |
|
3766 | + if (!$json['rows'] > 0) { |
|
3767 | + $json['error'] = __('No data found in csv file.', 'geodirectory'); |
|
3768 | + } |
|
3769 | + } else { |
|
3770 | + wp_send_json( $json ); |
|
3771 | + } |
|
3772 | + } else { |
|
3773 | + wp_send_json( $json ); |
|
3774 | + } |
|
3775 | 3775 | |
3776 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) { |
|
3777 | - wp_send_json( $json ); |
|
3778 | - } |
|
3776 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) { |
|
3777 | + wp_send_json( $json ); |
|
3778 | + } |
|
3779 | 3779 | |
3780 | - $total = $json['rows']; |
|
3781 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
3782 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
3780 | + $total = $json['rows']; |
|
3781 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
3782 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
3783 | 3783 | |
3784 | - $count = $limit; |
|
3784 | + $count = $limit; |
|
3785 | 3785 | |
3786 | - if ($count < $total) { |
|
3787 | - $count = $processed + $count; |
|
3788 | - if ($count > $total) { |
|
3789 | - $count = $total; |
|
3790 | - } |
|
3791 | - } else { |
|
3792 | - $count = $total; |
|
3793 | - } |
|
3786 | + if ($count < $total) { |
|
3787 | + $count = $processed + $count; |
|
3788 | + if ($count > $total) { |
|
3789 | + $count = $total; |
|
3790 | + } |
|
3791 | + } else { |
|
3792 | + $count = $total; |
|
3793 | + } |
|
3794 | 3794 | |
3795 | - $created = 0; |
|
3796 | - $updated = 0; |
|
3797 | - $skipped = 0; |
|
3798 | - $invalid = 0; |
|
3799 | - $invalid_addr = 0; |
|
3800 | - $images = 0; |
|
3795 | + $created = 0; |
|
3796 | + $updated = 0; |
|
3797 | + $skipped = 0; |
|
3798 | + $invalid = 0; |
|
3799 | + $invalid_addr = 0; |
|
3800 | + $images = 0; |
|
3801 | 3801 | |
3802 | - $gd_post_info = array(); |
|
3803 | - $countpost = 0; |
|
3802 | + $gd_post_info = array(); |
|
3803 | + $countpost = 0; |
|
3804 | 3804 | |
3805 | - $post_types = geodir_get_posttypes(); |
|
3805 | + $post_types = geodir_get_posttypes(); |
|
3806 | 3806 | |
3807 | - if ( $task == 'import_cat' ) { |
|
3808 | - if (!empty($file)) { |
|
3809 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
3807 | + if ( $task == 'import_cat' ) { |
|
3808 | + if (!empty($file)) { |
|
3809 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
3810 | 3810 | |
3811 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
3812 | - $json['error'] = CSV_INVAILD_FILE; |
|
3813 | - wp_send_json( $json ); |
|
3814 | - exit; |
|
3815 | - } |
|
3811 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
3812 | + $json['error'] = CSV_INVAILD_FILE; |
|
3813 | + wp_send_json( $json ); |
|
3814 | + exit; |
|
3815 | + } |
|
3816 | 3816 | |
3817 | - $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory'); |
|
3817 | + $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory'); |
|
3818 | 3818 | |
3819 | - for ($i = 1; $i <= $limit; $i++) { |
|
3820 | - $index = $processed + $i; |
|
3819 | + for ($i = 1; $i <= $limit; $i++) { |
|
3820 | + $index = $processed + $i; |
|
3821 | 3821 | |
3822 | - if (isset($file[$index])) { |
|
3823 | - $row = $file[$index]; |
|
3824 | - $row = array_map( 'trim', $row ); |
|
3825 | - //$row = array_map( 'utf8_encode', $row ); |
|
3822 | + if (isset($file[$index])) { |
|
3823 | + $row = $file[$index]; |
|
3824 | + $row = array_map( 'trim', $row ); |
|
3825 | + //$row = array_map( 'utf8_encode', $row ); |
|
3826 | 3826 | |
3827 | - $cat_id = ''; |
|
3828 | - $cat_name = ''; |
|
3829 | - $cat_slug = ''; |
|
3830 | - $cat_posttype = ''; |
|
3831 | - $cat_parent = ''; |
|
3832 | - $cat_description = ''; |
|
3833 | - $cat_schema = ''; |
|
3834 | - $cat_top_description = ''; |
|
3835 | - $cat_image = ''; |
|
3836 | - $cat_icon = ''; |
|
3837 | - $cat_language = ''; |
|
3838 | - $cat_id_original = ''; |
|
3827 | + $cat_id = ''; |
|
3828 | + $cat_name = ''; |
|
3829 | + $cat_slug = ''; |
|
3830 | + $cat_posttype = ''; |
|
3831 | + $cat_parent = ''; |
|
3832 | + $cat_description = ''; |
|
3833 | + $cat_schema = ''; |
|
3834 | + $cat_top_description = ''; |
|
3835 | + $cat_image = ''; |
|
3836 | + $cat_icon = ''; |
|
3837 | + $cat_language = ''; |
|
3838 | + $cat_id_original = ''; |
|
3839 | 3839 | |
3840 | - $c = 0; |
|
3841 | - foreach ($columns as $column ) { |
|
3842 | - if ( $column == 'cat_id' ) { |
|
3843 | - $cat_id = (int)$row[$c]; |
|
3844 | - } else if ( $column == 'cat_name' ) { |
|
3845 | - $cat_name = $row[$c]; |
|
3846 | - } else if ( $column == 'cat_slug' ) { |
|
3847 | - $cat_slug = $row[$c]; |
|
3848 | - } else if ( $column == 'cat_posttype' ) { |
|
3849 | - $cat_posttype = $row[$c]; |
|
3850 | - } else if ( $column == 'cat_parent' ) { |
|
3851 | - $cat_parent = trim($row[$c]); |
|
3852 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) { |
|
3853 | - $cat_schema = $row[$c]; |
|
3854 | - } else if ( $column == 'cat_description' ) { |
|
3855 | - $cat_description = $row[$c]; |
|
3856 | - } else if ( $column == 'cat_top_description' ) { |
|
3857 | - $cat_top_description = $row[$c]; |
|
3858 | - } else if ( $column == 'cat_image' ) { |
|
3859 | - $cat_image = $row[$c]; |
|
3860 | - } else if ( $column == 'cat_icon' ) { |
|
3861 | - $cat_icon = $row[$c]; |
|
3862 | - } |
|
3863 | - // WPML |
|
3864 | - if ( $is_wpml ) { |
|
3865 | - if ( $column == 'cat_language' ) { |
|
3866 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
3867 | - } else if ( $column == 'cat_id_original' ) { |
|
3868 | - $cat_id_original = (int)$row[$c]; |
|
3869 | - } |
|
3870 | - } |
|
3871 | - // WPML |
|
3872 | - $c++; |
|
3873 | - } |
|
3840 | + $c = 0; |
|
3841 | + foreach ($columns as $column ) { |
|
3842 | + if ( $column == 'cat_id' ) { |
|
3843 | + $cat_id = (int)$row[$c]; |
|
3844 | + } else if ( $column == 'cat_name' ) { |
|
3845 | + $cat_name = $row[$c]; |
|
3846 | + } else if ( $column == 'cat_slug' ) { |
|
3847 | + $cat_slug = $row[$c]; |
|
3848 | + } else if ( $column == 'cat_posttype' ) { |
|
3849 | + $cat_posttype = $row[$c]; |
|
3850 | + } else if ( $column == 'cat_parent' ) { |
|
3851 | + $cat_parent = trim($row[$c]); |
|
3852 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) { |
|
3853 | + $cat_schema = $row[$c]; |
|
3854 | + } else if ( $column == 'cat_description' ) { |
|
3855 | + $cat_description = $row[$c]; |
|
3856 | + } else if ( $column == 'cat_top_description' ) { |
|
3857 | + $cat_top_description = $row[$c]; |
|
3858 | + } else if ( $column == 'cat_image' ) { |
|
3859 | + $cat_image = $row[$c]; |
|
3860 | + } else if ( $column == 'cat_icon' ) { |
|
3861 | + $cat_icon = $row[$c]; |
|
3862 | + } |
|
3863 | + // WPML |
|
3864 | + if ( $is_wpml ) { |
|
3865 | + if ( $column == 'cat_language' ) { |
|
3866 | + $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
3867 | + } else if ( $column == 'cat_id_original' ) { |
|
3868 | + $cat_id_original = (int)$row[$c]; |
|
3869 | + } |
|
3870 | + } |
|
3871 | + // WPML |
|
3872 | + $c++; |
|
3873 | + } |
|
3874 | 3874 | |
3875 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) { |
|
3876 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
3875 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) { |
|
3876 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
3877 | 3877 | |
3878 | - $invalid++; |
|
3879 | - continue; |
|
3880 | - } |
|
3878 | + $invalid++; |
|
3879 | + continue; |
|
3880 | + } |
|
3881 | 3881 | |
3882 | - // WPML |
|
3883 | - if ($is_wpml && $cat_language != '') { |
|
3884 | - $sitepress->switch_lang($cat_language, true); |
|
3885 | - } |
|
3886 | - // WPML |
|
3882 | + // WPML |
|
3883 | + if ($is_wpml && $cat_language != '') { |
|
3884 | + $sitepress->switch_lang($cat_language, true); |
|
3885 | + } |
|
3886 | + // WPML |
|
3887 | 3887 | |
3888 | - $term_data = array(); |
|
3889 | - $term_data['name'] = $cat_name; |
|
3890 | - $term_data['slug'] = $cat_slug; |
|
3891 | - $term_data['description'] = $cat_description; |
|
3892 | - $term_data['cat_schema'] = $cat_schema; |
|
3893 | - $term_data['top_description'] = $cat_top_description; |
|
3894 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
3895 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
3888 | + $term_data = array(); |
|
3889 | + $term_data['name'] = $cat_name; |
|
3890 | + $term_data['slug'] = $cat_slug; |
|
3891 | + $term_data['description'] = $cat_description; |
|
3892 | + $term_data['cat_schema'] = $cat_schema; |
|
3893 | + $term_data['top_description'] = $cat_top_description; |
|
3894 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
3895 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
3896 | 3896 | |
3897 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
3897 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
3898 | 3898 | |
3899 | - $taxonomy = $cat_posttype . 'category'; |
|
3899 | + $taxonomy = $cat_posttype . 'category'; |
|
3900 | 3900 | |
3901 | - $term_data['taxonomy'] = $taxonomy; |
|
3901 | + $term_data['taxonomy'] = $taxonomy; |
|
3902 | 3902 | |
3903 | - $term_parent_id = 0; |
|
3904 | - if ($cat_parent != "" || (int)$cat_parent > 0) { |
|
3905 | - $term_parent = ''; |
|
3903 | + $term_parent_id = 0; |
|
3904 | + if ($cat_parent != "" || (int)$cat_parent > 0) { |
|
3905 | + $term_parent = ''; |
|
3906 | 3906 | |
3907 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) { |
|
3908 | - // |
|
3909 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) { |
|
3910 | - // |
|
3911 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) { |
|
3912 | - // |
|
3913 | - } else { |
|
3914 | - $term_parent_data = array(); |
|
3915 | - $term_parent_data['name'] = $cat_parent; |
|
3916 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
3917 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
3907 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) { |
|
3908 | + // |
|
3909 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) { |
|
3910 | + // |
|
3911 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) { |
|
3912 | + // |
|
3913 | + } else { |
|
3914 | + $term_parent_data = array(); |
|
3915 | + $term_parent_data['name'] = $cat_parent; |
|
3916 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
3917 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
3918 | 3918 | |
3919 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
3920 | - } |
|
3919 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
3920 | + } |
|
3921 | 3921 | |
3922 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) { |
|
3923 | - $term_parent_id = (int)$term_parent->term_id; |
|
3924 | - } |
|
3925 | - } |
|
3926 | - $term_data['parent'] = (int)$term_parent_id; |
|
3922 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) { |
|
3923 | + $term_parent_id = (int)$term_parent->term_id; |
|
3924 | + } |
|
3925 | + } |
|
3926 | + $term_data['parent'] = (int)$term_parent_id; |
|
3927 | 3927 | |
3928 | - $term_id = NULL; |
|
3929 | - if ( $import_choice == 'update' ) { |
|
3930 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3931 | - $term_data['term_id'] = $term['term_id']; |
|
3928 | + $term_id = NULL; |
|
3929 | + if ( $import_choice == 'update' ) { |
|
3930 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3931 | + $term_data['term_id'] = $term['term_id']; |
|
3932 | 3932 | |
3933 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3934 | - $updated++; |
|
3935 | - } else { |
|
3936 | - $invalid++; |
|
3937 | - 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' ) ); |
|
3938 | - } |
|
3939 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3940 | - $term_data['term_id'] = $term['term_id']; |
|
3933 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3934 | + $updated++; |
|
3935 | + } else { |
|
3936 | + $invalid++; |
|
3937 | + 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' ) ); |
|
3938 | + } |
|
3939 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3940 | + $term_data['term_id'] = $term['term_id']; |
|
3941 | 3941 | |
3942 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3943 | - $updated++; |
|
3944 | - } else { |
|
3945 | - $invalid++; |
|
3946 | - 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' ) ); |
|
3947 | - } |
|
3948 | - } else { |
|
3949 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3950 | - $created++; |
|
3951 | - } else { |
|
3952 | - $invalid++; |
|
3953 | - 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' ) ); |
|
3954 | - } |
|
3955 | - } |
|
3956 | - } else if ( $import_choice == 'skip' ) { |
|
3957 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3958 | - $skipped++; |
|
3959 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3960 | - $skipped++; |
|
3961 | - } else { |
|
3962 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3963 | - $created++; |
|
3964 | - } else { |
|
3965 | - $invalid++; |
|
3966 | - 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' ) ); |
|
3967 | - } |
|
3968 | - } |
|
3969 | - } else { |
|
3970 | - $invalid++; |
|
3971 | - 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' ) ); |
|
3972 | - } |
|
3942 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3943 | + $updated++; |
|
3944 | + } else { |
|
3945 | + $invalid++; |
|
3946 | + 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' ) ); |
|
3947 | + } |
|
3948 | + } else { |
|
3949 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3950 | + $created++; |
|
3951 | + } else { |
|
3952 | + $invalid++; |
|
3953 | + 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' ) ); |
|
3954 | + } |
|
3955 | + } |
|
3956 | + } else if ( $import_choice == 'skip' ) { |
|
3957 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3958 | + $skipped++; |
|
3959 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3960 | + $skipped++; |
|
3961 | + } else { |
|
3962 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3963 | + $created++; |
|
3964 | + } else { |
|
3965 | + $invalid++; |
|
3966 | + 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' ) ); |
|
3967 | + } |
|
3968 | + } |
|
3969 | + } else { |
|
3970 | + $invalid++; |
|
3971 | + 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' ) ); |
|
3972 | + } |
|
3973 | 3973 | |
3974 | - if ( $term_id ) { |
|
3975 | - // WPML |
|
3976 | - if ($is_wpml && geodir_wpml_is_taxonomy_translated($taxonomy) && $cat_id_original > 0 && $cat_language != '') { |
|
3977 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
3978 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
3979 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
3980 | - |
|
3981 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
3974 | + if ( $term_id ) { |
|
3975 | + // WPML |
|
3976 | + if ($is_wpml && geodir_wpml_is_taxonomy_translated($taxonomy) && $cat_id_original > 0 && $cat_language != '') { |
|
3977 | + $wpml_element_type = 'tax_' . $taxonomy; |
|
3978 | + $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
3979 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
3980 | + |
|
3981 | + $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
3982 | 3982 | |
3983 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
3984 | - } |
|
3985 | - // WPML |
|
3983 | + $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
3984 | + } |
|
3985 | + // WPML |
|
3986 | 3986 | |
3987 | - if ( isset( $term_data['top_description'] ) ) { |
|
3988 | - geodir_update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
3989 | - } |
|
3987 | + if ( isset( $term_data['top_description'] ) ) { |
|
3988 | + geodir_update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
3989 | + } |
|
3990 | 3990 | |
3991 | - if ( isset( $term_data['cat_schema'] ) ) { |
|
3992 | - geodir_update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
3993 | - } |
|
3991 | + if ( isset( $term_data['cat_schema'] ) ) { |
|
3992 | + geodir_update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
3993 | + } |
|
3994 | 3994 | |
3995 | - $attachment = false; |
|
3996 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) { |
|
3997 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
3998 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
3995 | + $attachment = false; |
|
3996 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) { |
|
3997 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
3998 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
3999 | 3999 | |
4000 | - if ( basename($cat_image) != $term_data['image'] ) { |
|
4001 | - $attachment = true; |
|
4002 | - geodir_update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
4003 | - } |
|
4004 | - } |
|
4000 | + if ( basename($cat_image) != $term_data['image'] ) { |
|
4001 | + $attachment = true; |
|
4002 | + geodir_update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
4003 | + } |
|
4004 | + } |
|
4005 | 4005 | |
4006 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) { |
|
4007 | - $cat_icon = geodir_get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
4008 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
4009 | - |
|
4010 | - if ( basename($cat_icon) != $term_data['icon'] ) { |
|
4011 | - $attachment = true; |
|
4012 | - geodir_update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
4013 | - } |
|
4014 | - } |
|
4006 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) { |
|
4007 | + $cat_icon = geodir_get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
4008 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
4009 | + |
|
4010 | + if ( basename($cat_icon) != $term_data['icon'] ) { |
|
4011 | + $attachment = true; |
|
4012 | + geodir_update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
4013 | + } |
|
4014 | + } |
|
4015 | 4015 | |
4016 | - if ( $attachment ) { |
|
4017 | - $images++; |
|
4018 | - } |
|
4019 | - } |
|
4016 | + if ( $attachment ) { |
|
4017 | + $images++; |
|
4018 | + } |
|
4019 | + } |
|
4020 | 4020 | |
4021 | - // WPML |
|
4022 | - if ($is_wpml && $cat_language != '') { |
|
4023 | - $sitepress->switch_lang($active_lang, true); |
|
4024 | - } |
|
4025 | - // WPML |
|
4026 | - } |
|
4027 | - } |
|
4028 | - } |
|
4021 | + // WPML |
|
4022 | + if ($is_wpml && $cat_language != '') { |
|
4023 | + $sitepress->switch_lang($active_lang, true); |
|
4024 | + } |
|
4025 | + // WPML |
|
4026 | + } |
|
4027 | + } |
|
4028 | + } |
|
4029 | 4029 | |
4030 | - $json = array(); |
|
4031 | - $json['processed'] = $limit; |
|
4032 | - $json['created'] = $created; |
|
4033 | - $json['updated'] = $updated; |
|
4034 | - $json['skipped'] = $skipped; |
|
4035 | - $json['invalid'] = $invalid; |
|
4036 | - $json['images'] = $images; |
|
4030 | + $json = array(); |
|
4031 | + $json['processed'] = $limit; |
|
4032 | + $json['created'] = $created; |
|
4033 | + $json['updated'] = $updated; |
|
4034 | + $json['skipped'] = $skipped; |
|
4035 | + $json['invalid'] = $invalid; |
|
4036 | + $json['images'] = $images; |
|
4037 | 4037 | |
4038 | - wp_send_json( $json ); |
|
4039 | - exit; |
|
4040 | - } else if ( $task == 'import_post' ) { |
|
4041 | - $xtimings['###1'] = microtime(true)-$xstart; |
|
4042 | - //run some stuff to make the import quicker |
|
4043 | - wp_defer_term_counting( true ); |
|
4044 | - wp_defer_comment_counting( true ); |
|
4045 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
4038 | + wp_send_json( $json ); |
|
4039 | + exit; |
|
4040 | + } else if ( $task == 'import_post' ) { |
|
4041 | + $xtimings['###1'] = microtime(true)-$xstart; |
|
4042 | + //run some stuff to make the import quicker |
|
4043 | + wp_defer_term_counting( true ); |
|
4044 | + wp_defer_comment_counting( true ); |
|
4045 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
4046 | 4046 | // |
4047 | 4047 | // remove_all_actions('publish_post'); |
4048 | 4048 | // remove_all_actions('transition_post_status'); |
4049 | 4049 | // remove_all_actions('publish_future_post'); |
4050 | 4050 | |
4051 | - if (!empty($file)) { |
|
4052 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false; |
|
4053 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
4054 | - $default_status = 'publish'; |
|
4055 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
4051 | + if (!empty($file)) { |
|
4052 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false; |
|
4053 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
4054 | + $default_status = 'publish'; |
|
4055 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
4056 | 4056 | |
4057 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
4057 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
4058 | 4058 | |
4059 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4060 | - $json['error'] = CSV_INVAILD_FILE; |
|
4061 | - wp_send_json( $json ); |
|
4062 | - exit; |
|
4063 | - } |
|
4064 | - $xtimings['###2'] = microtime(true)-$xstart; |
|
4065 | - $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory'); |
|
4066 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
4067 | - $processed_actual = 0; |
|
4068 | - for ($i = 1; $i <= $limit; $i++) { |
|
4069 | - $index = $processed + $i; |
|
4070 | - $gd_post = array(); |
|
4059 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4060 | + $json['error'] = CSV_INVAILD_FILE; |
|
4061 | + wp_send_json( $json ); |
|
4062 | + exit; |
|
4063 | + } |
|
4064 | + $xtimings['###2'] = microtime(true)-$xstart; |
|
4065 | + $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory'); |
|
4066 | + $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
4067 | + $processed_actual = 0; |
|
4068 | + for ($i = 1; $i <= $limit; $i++) { |
|
4069 | + $index = $processed + $i; |
|
4070 | + $gd_post = array(); |
|
4071 | 4071 | |
4072 | - if (isset($file[$index])) { |
|
4073 | - $processed_actual++; |
|
4074 | - $row = $file[$index]; |
|
4075 | - $row = array_map( 'trim', $row ); |
|
4076 | - //$row = array_map( 'utf8_encode', $row ); |
|
4077 | - $row = array_map( 'addslashes_gpc', $row ); |
|
4072 | + if (isset($file[$index])) { |
|
4073 | + $processed_actual++; |
|
4074 | + $row = $file[$index]; |
|
4075 | + $row = array_map( 'trim', $row ); |
|
4076 | + //$row = array_map( 'utf8_encode', $row ); |
|
4077 | + $row = array_map( 'addslashes_gpc', $row ); |
|
4078 | 4078 | |
4079 | - $post_id = ''; |
|
4080 | - $post_title = ''; |
|
4081 | - $post_date = ''; |
|
4082 | - $post_author = ''; |
|
4083 | - $post_content = ''; |
|
4084 | - $post_category_arr = array(); |
|
4085 | - $default_category = ''; |
|
4086 | - $post_tags = array(); |
|
4087 | - $post_type = ''; |
|
4088 | - $post_status = ''; |
|
4089 | - $is_featured = 0; |
|
4090 | - $geodir_video = ''; |
|
4091 | - $post_address = ''; |
|
4092 | - $post_city = ''; |
|
4093 | - $post_region = ''; |
|
4094 | - $post_country = ''; |
|
4095 | - $post_zip = ''; |
|
4096 | - $post_latitude = ''; |
|
4097 | - $post_longitude = ''; |
|
4098 | - $post_neighbourhood = ''; |
|
4099 | - $neighbourhood_latitude = ''; |
|
4100 | - $neighbourhood_longitude = ''; |
|
4101 | - $geodir_timing = ''; |
|
4102 | - $geodir_contact = ''; |
|
4103 | - $geodir_email = ''; |
|
4104 | - $geodir_website = ''; |
|
4105 | - $geodir_twitter = ''; |
|
4106 | - $geodir_facebook = ''; |
|
4107 | - $geodir_twitter = ''; |
|
4108 | - $geodir_link_business = null; |
|
4109 | - $post_images = array(); |
|
4079 | + $post_id = ''; |
|
4080 | + $post_title = ''; |
|
4081 | + $post_date = ''; |
|
4082 | + $post_author = ''; |
|
4083 | + $post_content = ''; |
|
4084 | + $post_category_arr = array(); |
|
4085 | + $default_category = ''; |
|
4086 | + $post_tags = array(); |
|
4087 | + $post_type = ''; |
|
4088 | + $post_status = ''; |
|
4089 | + $is_featured = 0; |
|
4090 | + $geodir_video = ''; |
|
4091 | + $post_address = ''; |
|
4092 | + $post_city = ''; |
|
4093 | + $post_region = ''; |
|
4094 | + $post_country = ''; |
|
4095 | + $post_zip = ''; |
|
4096 | + $post_latitude = ''; |
|
4097 | + $post_longitude = ''; |
|
4098 | + $post_neighbourhood = ''; |
|
4099 | + $neighbourhood_latitude = ''; |
|
4100 | + $neighbourhood_longitude = ''; |
|
4101 | + $geodir_timing = ''; |
|
4102 | + $geodir_contact = ''; |
|
4103 | + $geodir_email = ''; |
|
4104 | + $geodir_website = ''; |
|
4105 | + $geodir_twitter = ''; |
|
4106 | + $geodir_facebook = ''; |
|
4107 | + $geodir_twitter = ''; |
|
4108 | + $geodir_link_business = null; |
|
4109 | + $post_images = array(); |
|
4110 | 4110 | |
4111 | - $expire_date = 'Never'; |
|
4111 | + $expire_date = 'Never'; |
|
4112 | 4112 | |
4113 | - $language = ''; |
|
4114 | - $original_post_id = ''; |
|
4113 | + $language = ''; |
|
4114 | + $original_post_id = ''; |
|
4115 | 4115 | |
4116 | - $c = 0; |
|
4117 | - foreach ($columns as $column ) { |
|
4118 | - $gd_post[$column] = $row[$c]; |
|
4116 | + $c = 0; |
|
4117 | + foreach ($columns as $column ) { |
|
4118 | + $gd_post[$column] = $row[$c]; |
|
4119 | 4119 | |
4120 | - if ( $column == 'post_id' ) { |
|
4121 | - $post_id = $row[$c]; |
|
4122 | - } else if ( $column == 'post_title' ) { |
|
4123 | - $post_title = sanitize_text_field($row[$c]); |
|
4124 | - } else if ( $column == 'post_author' ) { |
|
4125 | - $post_author = $row[$c]; |
|
4126 | - } else if ( $column == 'post_date' ) { |
|
4127 | - $post_date = $row[$c]; |
|
4128 | - } else if ( $column == 'post_content' ) { |
|
4129 | - $post_content = $row[$c]; |
|
4130 | - } else if ( $column == 'post_category' && $row[$c] != '' ) { |
|
4131 | - $post_category_arr = explode( ',', $row[$c] ); |
|
4132 | - } else if ( $column == 'default_category' ) { |
|
4133 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
4134 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) { |
|
4135 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
4136 | - } else if ( $column == 'post_type' ) { |
|
4137 | - $post_type = $row[$c]; |
|
4138 | - } else if ( $column == 'post_status' ) { |
|
4139 | - $post_status = sanitize_key( $row[$c] ); |
|
4140 | - } else if ( $column == 'is_featured' ) { |
|
4141 | - $is_featured = (int)$row[$c]; |
|
4142 | - } else if ( $column == 'geodir_video' ) { |
|
4143 | - $geodir_video = $row[$c]; |
|
4144 | - } else if ( $column == 'post_address' ) { |
|
4145 | - $post_address = sanitize_text_field($row[$c]); |
|
4146 | - } else if ( $column == 'post_city' ) { |
|
4147 | - $post_city = sanitize_text_field($row[$c]); |
|
4148 | - } else if ( $column == 'post_region' ) { |
|
4149 | - $post_region = sanitize_text_field($row[$c]); |
|
4150 | - } else if ( $column == 'post_country' ) { |
|
4151 | - $post_country = sanitize_text_field($row[$c]); |
|
4152 | - } else if ( $column == 'post_zip' ) { |
|
4153 | - $post_zip = sanitize_text_field($row[$c]); |
|
4154 | - } else if ( $column == 'post_latitude' ) { |
|
4155 | - $post_latitude = sanitize_text_field($row[$c]); |
|
4156 | - } else if ( $column == 'post_longitude' ) { |
|
4157 | - $post_longitude = sanitize_text_field($row[$c]); |
|
4158 | - } else if ( $column == 'post_neighbourhood' ) { |
|
4159 | - $post_neighbourhood = sanitize_text_field($row[$c]); |
|
4160 | - unset($gd_post[$column]); |
|
4161 | - } else if ( $column == 'neighbourhood_latitude' ) { |
|
4162 | - $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
4163 | - } else if ( $column == 'neighbourhood_longitude' ) { |
|
4164 | - $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
4165 | - } else if ( $column == 'geodir_timing' ) { |
|
4166 | - $geodir_timing = sanitize_text_field($row[$c]); |
|
4167 | - } else if ( $column == 'geodir_contact' ) { |
|
4168 | - $geodir_contact = sanitize_text_field($row[$c]); |
|
4169 | - } else if ( $column == 'geodir_email' ) { |
|
4170 | - $geodir_email = sanitize_email($row[$c]); |
|
4171 | - } else if ( $column == 'geodir_website' ) { |
|
4172 | - $geodir_website = sanitize_text_field($row[$c]); |
|
4173 | - } else if ( $column == 'geodir_twitter' ) { |
|
4174 | - $geodir_twitter = sanitize_text_field($row[$c]); |
|
4175 | - } else if ( $column == 'geodir_facebook' ) { |
|
4176 | - $geodir_facebook = sanitize_text_field($row[$c]); |
|
4177 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) { |
|
4178 | - $post_images[] = $row[$c]; |
|
4179 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) { |
|
4180 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
4181 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) { |
|
4182 | - $row[$c] = str_replace('/', '-', $row[$c]); |
|
4183 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
4184 | - } else if ( strpos( $column, 'linked_' ) === 0 ) { |
|
4185 | - $geodir_link_business = (int)$row[$c]; |
|
4186 | - } |
|
4187 | - // WPML |
|
4188 | - if ($is_wpml) { |
|
4189 | - if ($column == 'language') { |
|
4190 | - $language = geodir_strtolower(trim($row[$c])); |
|
4191 | - } else if ($column == 'original_post_id') { |
|
4192 | - $original_post_id = (int)$row[$c]; |
|
4193 | - } |
|
4194 | - } |
|
4195 | - // WPML |
|
4196 | - $c++; |
|
4197 | - } |
|
4198 | - // listing claimed or not |
|
4199 | - if ($is_claim_active && isset($gd_post['claimed'])) { |
|
4200 | - $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
4201 | - } |
|
4120 | + if ( $column == 'post_id' ) { |
|
4121 | + $post_id = $row[$c]; |
|
4122 | + } else if ( $column == 'post_title' ) { |
|
4123 | + $post_title = sanitize_text_field($row[$c]); |
|
4124 | + } else if ( $column == 'post_author' ) { |
|
4125 | + $post_author = $row[$c]; |
|
4126 | + } else if ( $column == 'post_date' ) { |
|
4127 | + $post_date = $row[$c]; |
|
4128 | + } else if ( $column == 'post_content' ) { |
|
4129 | + $post_content = $row[$c]; |
|
4130 | + } else if ( $column == 'post_category' && $row[$c] != '' ) { |
|
4131 | + $post_category_arr = explode( ',', $row[$c] ); |
|
4132 | + } else if ( $column == 'default_category' ) { |
|
4133 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
4134 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) { |
|
4135 | + $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
4136 | + } else if ( $column == 'post_type' ) { |
|
4137 | + $post_type = $row[$c]; |
|
4138 | + } else if ( $column == 'post_status' ) { |
|
4139 | + $post_status = sanitize_key( $row[$c] ); |
|
4140 | + } else if ( $column == 'is_featured' ) { |
|
4141 | + $is_featured = (int)$row[$c]; |
|
4142 | + } else if ( $column == 'geodir_video' ) { |
|
4143 | + $geodir_video = $row[$c]; |
|
4144 | + } else if ( $column == 'post_address' ) { |
|
4145 | + $post_address = sanitize_text_field($row[$c]); |
|
4146 | + } else if ( $column == 'post_city' ) { |
|
4147 | + $post_city = sanitize_text_field($row[$c]); |
|
4148 | + } else if ( $column == 'post_region' ) { |
|
4149 | + $post_region = sanitize_text_field($row[$c]); |
|
4150 | + } else if ( $column == 'post_country' ) { |
|
4151 | + $post_country = sanitize_text_field($row[$c]); |
|
4152 | + } else if ( $column == 'post_zip' ) { |
|
4153 | + $post_zip = sanitize_text_field($row[$c]); |
|
4154 | + } else if ( $column == 'post_latitude' ) { |
|
4155 | + $post_latitude = sanitize_text_field($row[$c]); |
|
4156 | + } else if ( $column == 'post_longitude' ) { |
|
4157 | + $post_longitude = sanitize_text_field($row[$c]); |
|
4158 | + } else if ( $column == 'post_neighbourhood' ) { |
|
4159 | + $post_neighbourhood = sanitize_text_field($row[$c]); |
|
4160 | + unset($gd_post[$column]); |
|
4161 | + } else if ( $column == 'neighbourhood_latitude' ) { |
|
4162 | + $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
4163 | + } else if ( $column == 'neighbourhood_longitude' ) { |
|
4164 | + $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
4165 | + } else if ( $column == 'geodir_timing' ) { |
|
4166 | + $geodir_timing = sanitize_text_field($row[$c]); |
|
4167 | + } else if ( $column == 'geodir_contact' ) { |
|
4168 | + $geodir_contact = sanitize_text_field($row[$c]); |
|
4169 | + } else if ( $column == 'geodir_email' ) { |
|
4170 | + $geodir_email = sanitize_email($row[$c]); |
|
4171 | + } else if ( $column == 'geodir_website' ) { |
|
4172 | + $geodir_website = sanitize_text_field($row[$c]); |
|
4173 | + } else if ( $column == 'geodir_twitter' ) { |
|
4174 | + $geodir_twitter = sanitize_text_field($row[$c]); |
|
4175 | + } else if ( $column == 'geodir_facebook' ) { |
|
4176 | + $geodir_facebook = sanitize_text_field($row[$c]); |
|
4177 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) { |
|
4178 | + $post_images[] = $row[$c]; |
|
4179 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) { |
|
4180 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
4181 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) { |
|
4182 | + $row[$c] = str_replace('/', '-', $row[$c]); |
|
4183 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
4184 | + } else if ( strpos( $column, 'linked_' ) === 0 ) { |
|
4185 | + $geodir_link_business = (int)$row[$c]; |
|
4186 | + } |
|
4187 | + // WPML |
|
4188 | + if ($is_wpml) { |
|
4189 | + if ($column == 'language') { |
|
4190 | + $language = geodir_strtolower(trim($row[$c])); |
|
4191 | + } else if ($column == 'original_post_id') { |
|
4192 | + $original_post_id = (int)$row[$c]; |
|
4193 | + } |
|
4194 | + } |
|
4195 | + // WPML |
|
4196 | + $c++; |
|
4197 | + } |
|
4198 | + // listing claimed or not |
|
4199 | + if ($is_claim_active && isset($gd_post['claimed'])) { |
|
4200 | + $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
4201 | + } |
|
4202 | 4202 | |
4203 | - // WPML |
|
4204 | - if ($is_wpml && $language != '') { |
|
4205 | - $sitepress->switch_lang($language, true); |
|
4206 | - } |
|
4207 | - // WPML |
|
4203 | + // WPML |
|
4204 | + if ($is_wpml && $language != '') { |
|
4205 | + $sitepress->switch_lang($language, true); |
|
4206 | + } |
|
4207 | + // WPML |
|
4208 | 4208 | |
4209 | - $gd_post['IMAGE'] = $post_images; |
|
4209 | + $gd_post['IMAGE'] = $post_images; |
|
4210 | 4210 | |
4211 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
4212 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
4211 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
4212 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
4213 | 4213 | |
4214 | - $valid = true; |
|
4214 | + $valid = true; |
|
4215 | 4215 | |
4216 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) { |
|
4217 | - $invalid++; |
|
4218 | - $valid = false; |
|
4219 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
4220 | - } |
|
4221 | - $xtimings['###3'] = microtime(true)-$xstart; |
|
4222 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
4223 | - if ( $location_allowed ) { |
|
4224 | - $location_result = geodir_get_default_location(); |
|
4225 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) { |
|
4226 | - $invalid_addr++; |
|
4227 | - $valid = false; |
|
4228 | - 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' ) ); |
|
4229 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) { |
|
4230 | - 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 ) ) ) { |
|
4231 | - $invalid_addr++; |
|
4232 | - $valid = false; |
|
4233 | - 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' ) ); |
|
4234 | - } else { |
|
4235 | - if (!$location_manager) { |
|
4236 | - $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. |
|
4237 | - } |
|
4238 | - } |
|
4239 | - } |
|
4240 | - } |
|
4241 | - $xtimings['###4'] = microtime(true)-$xstart; |
|
4242 | - if ( !$valid ) { |
|
4243 | - continue; |
|
4244 | - } |
|
4216 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) { |
|
4217 | + $invalid++; |
|
4218 | + $valid = false; |
|
4219 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
4220 | + } |
|
4221 | + $xtimings['###3'] = microtime(true)-$xstart; |
|
4222 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
4223 | + if ( $location_allowed ) { |
|
4224 | + $location_result = geodir_get_default_location(); |
|
4225 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) { |
|
4226 | + $invalid_addr++; |
|
4227 | + $valid = false; |
|
4228 | + 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' ) ); |
|
4229 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) { |
|
4230 | + 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 ) ) ) { |
|
4231 | + $invalid_addr++; |
|
4232 | + $valid = false; |
|
4233 | + 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' ) ); |
|
4234 | + } else { |
|
4235 | + if (!$location_manager) { |
|
4236 | + $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. |
|
4237 | + } |
|
4238 | + } |
|
4239 | + } |
|
4240 | + } |
|
4241 | + $xtimings['###4'] = microtime(true)-$xstart; |
|
4242 | + if ( !$valid ) { |
|
4243 | + continue; |
|
4244 | + } |
|
4245 | 4245 | |
4246 | - $cat_taxonomy = $post_type . 'category'; |
|
4247 | - $tags_taxonomy = $post_type . '_tags'; |
|
4246 | + $cat_taxonomy = $post_type . 'category'; |
|
4247 | + $tags_taxonomy = $post_type . '_tags'; |
|
4248 | 4248 | |
4249 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) { |
|
4250 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
4251 | - } |
|
4249 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) { |
|
4250 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
4251 | + } |
|
4252 | 4252 | |
4253 | - $post_category = array(); |
|
4254 | - $default_category_id = NULL; |
|
4255 | - if ( !empty( $post_category_arr ) ) { |
|
4256 | - foreach ( $post_category_arr as $value ) { |
|
4257 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
4253 | + $post_category = array(); |
|
4254 | + $default_category_id = NULL; |
|
4255 | + if ( !empty( $post_category_arr ) ) { |
|
4256 | + foreach ( $post_category_arr as $value ) { |
|
4257 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
4258 | 4258 | |
4259 | - if ( $category_name != '' ) { |
|
4260 | - $term_category = array(); |
|
4259 | + if ( $category_name != '' ) { |
|
4260 | + $term_category = array(); |
|
4261 | 4261 | |
4262 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) { |
|
4263 | - $term_category = $term; |
|
4264 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) { |
|
4265 | - $term_category = $term; |
|
4266 | - } else { |
|
4267 | - $term_data = array(); |
|
4268 | - $term_data['name'] = $category_name; |
|
4269 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
4262 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) { |
|
4263 | + $term_category = $term; |
|
4264 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) { |
|
4265 | + $term_category = $term; |
|
4266 | + } else { |
|
4267 | + $term_data = array(); |
|
4268 | + $term_data['name'] = $category_name; |
|
4269 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
4270 | 4270 | |
4271 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
4272 | - if ( $term_id ) { |
|
4273 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
4274 | - } |
|
4275 | - } |
|
4271 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
4272 | + if ( $term_id ) { |
|
4273 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
4274 | + } |
|
4275 | + } |
|
4276 | 4276 | |
4277 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) { |
|
4278 | - $post_category[] = intval($term_category->term_id); |
|
4277 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) { |
|
4278 | + $post_category[] = intval($term_category->term_id); |
|
4279 | 4279 | |
4280 | - if ($category_name == $default_category) { |
|
4281 | - $default_category_id = intval($term_category->term_id); |
|
4282 | - } |
|
4283 | - } |
|
4284 | - } |
|
4285 | - } |
|
4286 | - } |
|
4287 | - $xtimings['###5'] = microtime(true)-$xstart; |
|
4288 | - $save_post = array(); |
|
4289 | - $save_post['post_title'] = $post_title; |
|
4290 | - if (!empty($post_date)) { |
|
4291 | - $post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format. |
|
4280 | + if ($category_name == $default_category) { |
|
4281 | + $default_category_id = intval($term_category->term_id); |
|
4282 | + } |
|
4283 | + } |
|
4284 | + } |
|
4285 | + } |
|
4286 | + } |
|
4287 | + $xtimings['###5'] = microtime(true)-$xstart; |
|
4288 | + $save_post = array(); |
|
4289 | + $save_post['post_title'] = $post_title; |
|
4290 | + if (!empty($post_date)) { |
|
4291 | + $post_date = geodir_date( $post_date, 'Y-m-d H:i:s' ); // convert to mysql date format. |
|
4292 | 4292 | |
4293 | - $save_post['post_date'] = $post_date; |
|
4294 | - $save_post['post_date_gmt'] = get_gmt_from_date( $post_date ); |
|
4295 | - } |
|
4296 | - $save_post['post_content'] = $post_content; |
|
4297 | - $save_post['post_type'] = $post_type; |
|
4298 | - $save_post['post_author'] = $post_author; |
|
4299 | - $save_post['post_status'] = $post_status; |
|
4300 | - $save_post['post_category'] = $post_category; |
|
4301 | - $save_post['post_tags'] = $post_tags; |
|
4302 | - |
|
4303 | - $saved_post_id = NULL; |
|
4304 | - if ( $import_choice == 'update' ) { |
|
4305 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
4293 | + $save_post['post_date'] = $post_date; |
|
4294 | + $save_post['post_date_gmt'] = get_gmt_from_date( $post_date ); |
|
4295 | + } |
|
4296 | + $save_post['post_content'] = $post_content; |
|
4297 | + $save_post['post_type'] = $post_type; |
|
4298 | + $save_post['post_author'] = $post_author; |
|
4299 | + $save_post['post_status'] = $post_status; |
|
4300 | + $save_post['post_category'] = $post_category; |
|
4301 | + $save_post['post_tags'] = $post_tags; |
|
4302 | + |
|
4303 | + $saved_post_id = NULL; |
|
4304 | + if ( $import_choice == 'update' ) { |
|
4305 | + $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
4306 | 4306 | |
4307 | - if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4308 | - $save_post['ID'] = $post_id; |
|
4307 | + if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4308 | + $save_post['ID'] = $post_id; |
|
4309 | 4309 | |
4310 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) { |
|
4311 | - if ( is_wp_error( $saved_post_id ) ) { |
|
4312 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4313 | - $saved_post_id = 0; |
|
4314 | - } else { |
|
4315 | - $saved_post_id = $post_id; |
|
4316 | - $updated++; |
|
4317 | - } |
|
4318 | - } |
|
4319 | - } else { |
|
4320 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4321 | - if ( is_wp_error( $saved_post_id ) ) { |
|
4322 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4323 | - $saved_post_id = 0; |
|
4324 | - } else { |
|
4325 | - $created++; |
|
4326 | - } |
|
4327 | - } |
|
4328 | - } |
|
4310 | + if ( $saved_post_id = wp_update_post( $save_post, true ) ) { |
|
4311 | + if ( is_wp_error( $saved_post_id ) ) { |
|
4312 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4313 | + $saved_post_id = 0; |
|
4314 | + } else { |
|
4315 | + $saved_post_id = $post_id; |
|
4316 | + $updated++; |
|
4317 | + } |
|
4318 | + } |
|
4319 | + } else { |
|
4320 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4321 | + if ( is_wp_error( $saved_post_id ) ) { |
|
4322 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4323 | + $saved_post_id = 0; |
|
4324 | + } else { |
|
4325 | + $created++; |
|
4326 | + } |
|
4327 | + } |
|
4328 | + } |
|
4329 | 4329 | |
4330 | - if ( !$saved_post_id > 0 ) { |
|
4331 | - $invalid++; |
|
4332 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
4333 | - } |
|
4334 | - } else if ( $import_choice == 'skip' ) { |
|
4335 | - if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4336 | - $skipped++; |
|
4337 | - } else { |
|
4338 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4339 | - if ( is_wp_error( $saved_post_id ) ) { |
|
4340 | - $invalid++; |
|
4330 | + if ( !$saved_post_id > 0 ) { |
|
4331 | + $invalid++; |
|
4332 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
4333 | + } |
|
4334 | + } else if ( $import_choice == 'skip' ) { |
|
4335 | + if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4336 | + $skipped++; |
|
4337 | + } else { |
|
4338 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4339 | + if ( is_wp_error( $saved_post_id ) ) { |
|
4340 | + $invalid++; |
|
4341 | 4341 | |
4342 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
4343 | - $saved_post_id = 0; |
|
4344 | - } else { |
|
4345 | - $created++; |
|
4346 | - } |
|
4347 | - } else { |
|
4348 | - $invalid++; |
|
4342 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
4343 | + $saved_post_id = 0; |
|
4344 | + } else { |
|
4345 | + $created++; |
|
4346 | + } |
|
4347 | + } else { |
|
4348 | + $invalid++; |
|
4349 | 4349 | |
4350 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4351 | - } |
|
4352 | - } |
|
4353 | - } else { |
|
4354 | - $invalid++; |
|
4350 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4351 | + } |
|
4352 | + } |
|
4353 | + } else { |
|
4354 | + $invalid++; |
|
4355 | 4355 | |
4356 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4357 | - } |
|
4358 | - $xtimings['###6'] = microtime(true)-$xstart; |
|
4359 | - if ( (int)$saved_post_id > 0 ) { |
|
4360 | - // WPML |
|
4361 | - if ($is_wpml && geodir_wpml_is_post_type_translated($post_type) && $original_post_id > 0 && $language != '') { |
|
4362 | - $wpml_post_type = 'post_' . $post_type; |
|
4363 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
4364 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
4365 | - |
|
4366 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
4356 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4357 | + } |
|
4358 | + $xtimings['###6'] = microtime(true)-$xstart; |
|
4359 | + if ( (int)$saved_post_id > 0 ) { |
|
4360 | + // WPML |
|
4361 | + if ($is_wpml && geodir_wpml_is_post_type_translated($post_type) && $original_post_id > 0 && $language != '') { |
|
4362 | + $wpml_post_type = 'post_' . $post_type; |
|
4363 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
4364 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
4365 | + |
|
4366 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
4367 | 4367 | |
4368 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
4369 | - } |
|
4370 | - // WPML |
|
4371 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
4368 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
4369 | + } |
|
4370 | + // WPML |
|
4371 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
4372 | 4372 | |
4373 | - $gd_post['post_id'] = $saved_post_id; |
|
4374 | - $gd_post['ID'] = $saved_post_id; |
|
4375 | - $gd_post['post_tags'] = $post_tags; |
|
4376 | - $gd_post['post_title'] = $post_title; |
|
4377 | - $gd_post['post_status'] = $post_status; |
|
4378 | - $gd_post['submit_time'] = time(); |
|
4379 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
4373 | + $gd_post['post_id'] = $saved_post_id; |
|
4374 | + $gd_post['ID'] = $saved_post_id; |
|
4375 | + $gd_post['post_tags'] = $post_tags; |
|
4376 | + $gd_post['post_title'] = $post_title; |
|
4377 | + $gd_post['post_status'] = $post_status; |
|
4378 | + $gd_post['submit_time'] = time(); |
|
4379 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
4380 | 4380 | |
4381 | - // post location |
|
4382 | - $post_location_id = 0; |
|
4383 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) { |
|
4384 | - $gd_post['post_neighbourhood'] = ''; |
|
4381 | + // post location |
|
4382 | + $post_location_id = 0; |
|
4383 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) { |
|
4384 | + $gd_post['post_neighbourhood'] = ''; |
|
4385 | 4385 | |
4386 | - $post_location_info = array( |
|
4387 | - 'city' => $post_city, |
|
4388 | - 'region' => $post_region, |
|
4389 | - 'country' => $post_country, |
|
4390 | - 'geo_lat' => $post_latitude, |
|
4391 | - 'geo_lng' => $post_longitude |
|
4392 | - ); |
|
4393 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) { |
|
4394 | - $post_location_id = $location_id; |
|
4395 | - } |
|
4386 | + $post_location_info = array( |
|
4387 | + 'city' => $post_city, |
|
4388 | + 'region' => $post_region, |
|
4389 | + 'country' => $post_country, |
|
4390 | + 'geo_lat' => $post_latitude, |
|
4391 | + 'geo_lng' => $post_longitude |
|
4392 | + ); |
|
4393 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) { |
|
4394 | + $post_location_id = $location_id; |
|
4395 | + } |
|
4396 | 4396 | |
4397 | - if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) { |
|
4398 | - $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
4397 | + if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) { |
|
4398 | + $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
4399 | 4399 | |
4400 | - $hood_data = array(); |
|
4401 | - $hood_data['hood_location_id'] = $post_location_id; |
|
4402 | - $hood_data['hood_name'] = $post_neighbourhood; |
|
4400 | + $hood_data = array(); |
|
4401 | + $hood_data['hood_location_id'] = $post_location_id; |
|
4402 | + $hood_data['hood_name'] = $post_neighbourhood; |
|
4403 | 4403 | |
4404 | - if (!empty($neighbourhood_info)) { |
|
4405 | - $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
4406 | - $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
4404 | + if (!empty($neighbourhood_info)) { |
|
4405 | + $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
4406 | + $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
4407 | 4407 | |
4408 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4409 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4410 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4411 | - } |
|
4412 | - } |
|
4408 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4409 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4410 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4411 | + } |
|
4412 | + } |
|
4413 | 4413 | |
4414 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4415 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4416 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4417 | - } |
|
4414 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4415 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4416 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4417 | + } |
|
4418 | 4418 | |
4419 | - $hood_data['hood_latitude'] = $post_latitude; |
|
4420 | - $hood_data['hood_longitude'] = $post_longitude; |
|
4421 | - |
|
4422 | - $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
4423 | - if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) { |
|
4424 | - $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
4425 | - } |
|
4426 | - } |
|
4427 | - } |
|
4428 | - $gd_post['post_location_id'] = $post_location_id; |
|
4419 | + $hood_data['hood_latitude'] = $post_latitude; |
|
4420 | + $hood_data['hood_longitude'] = $post_longitude; |
|
4421 | + |
|
4422 | + $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
4423 | + if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) { |
|
4424 | + $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
4425 | + } |
|
4426 | + } |
|
4427 | + } |
|
4428 | + $gd_post['post_location_id'] = $post_location_id; |
|
4429 | 4429 | |
4430 | - if ($geodir_link_business !== null) { |
|
4431 | - $gd_post['geodir_link_business'] = $geodir_link_business > 0 ? $geodir_link_business : ''; |
|
4432 | - } |
|
4430 | + if ($geodir_link_business !== null) { |
|
4431 | + $gd_post['geodir_link_business'] = $geodir_link_business > 0 ? $geodir_link_business : ''; |
|
4432 | + } |
|
4433 | 4433 | |
4434 | - // post package info |
|
4435 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
4436 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) { |
|
4437 | - $package_id = $gd_post_info->package_id; |
|
4438 | - } |
|
4434 | + // post package info |
|
4435 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
4436 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) { |
|
4437 | + $package_id = $gd_post_info->package_id; |
|
4438 | + } |
|
4439 | 4439 | |
4440 | - $package_info = array(); |
|
4441 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) { |
|
4442 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
4440 | + $package_info = array(); |
|
4441 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) { |
|
4442 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
4443 | 4443 | |
4444 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) { |
|
4445 | - $package_info = array(); |
|
4446 | - } |
|
4447 | - } |
|
4444 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) { |
|
4445 | + $package_info = array(); |
|
4446 | + } |
|
4447 | + } |
|
4448 | 4448 | |
4449 | - if (empty($package_info)) { |
|
4450 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
4451 | - } |
|
4449 | + if (empty($package_info)) { |
|
4450 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
4451 | + } |
|
4452 | 4452 | |
4453 | - if (!empty($package_info)) { |
|
4454 | - $package_id = $package_info['pid']; |
|
4453 | + if (!empty($package_info)) { |
|
4454 | + $package_id = $package_info['pid']; |
|
4455 | 4455 | |
4456 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) { |
|
4457 | - $gd_post['expire_date'] = $expire_date; |
|
4458 | - } else { |
|
4459 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) { |
|
4460 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
4461 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
4462 | - } else { |
|
4463 | - $gd_post['expire_date'] = 'Never'; |
|
4464 | - } |
|
4465 | - } |
|
4456 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) { |
|
4457 | + $gd_post['expire_date'] = $expire_date; |
|
4458 | + } else { |
|
4459 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) { |
|
4460 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
4461 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
4462 | + } else { |
|
4463 | + $gd_post['expire_date'] = 'Never'; |
|
4464 | + } |
|
4465 | + } |
|
4466 | 4466 | |
4467 | - $gd_post['package_id'] = $package_id; |
|
4468 | - } |
|
4467 | + $gd_post['package_id'] = $package_id; |
|
4468 | + } |
|
4469 | 4469 | |
4470 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
4470 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
4471 | 4471 | |
4472 | - if ($post_type == 'gd_event') { |
|
4473 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
4474 | - } |
|
4472 | + if ($post_type == 'gd_event') { |
|
4473 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
4474 | + } |
|
4475 | 4475 | |
4476 | - if (isset($gd_post['post_id'])) { |
|
4477 | - unset($gd_post['post_id']); |
|
4478 | - } |
|
4476 | + if (isset($gd_post['post_id'])) { |
|
4477 | + unset($gd_post['post_id']); |
|
4478 | + } |
|
4479 | 4479 | |
4480 | - // Export franchise fields |
|
4481 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
4482 | - if ($is_franchise_active) { |
|
4483 | - if ( isset( $gd_post['gd_is_franchise'] ) && empty( $gd_post['franchise'] ) ) { |
|
4484 | - if ( absint( $gd_post['gd_is_franchise'] ) != 0 ) { |
|
4485 | - $gd_franchise_lock = array(); |
|
4480 | + // Export franchise fields |
|
4481 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
4482 | + if ($is_franchise_active) { |
|
4483 | + if ( isset( $gd_post['gd_is_franchise'] ) && empty( $gd_post['franchise'] ) ) { |
|
4484 | + if ( absint( $gd_post['gd_is_franchise'] ) != 0 ) { |
|
4485 | + $gd_franchise_lock = array(); |
|
4486 | 4486 | |
4487 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) { |
|
4488 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] ); |
|
4489 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
4490 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
4491 | - } |
|
4487 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) { |
|
4488 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] ); |
|
4489 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
4490 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
4491 | + } |
|
4492 | 4492 | |
4493 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
4494 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
4495 | - } else { |
|
4496 | - if ( function_exists( 'geodir_franchise_remove_franchise' ) ) { |
|
4497 | - geodir_franchise_remove_franchise( $saved_post_id ); |
|
4498 | - } |
|
4499 | - } |
|
4500 | - } else { |
|
4501 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) { |
|
4502 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
4503 | - } |
|
4504 | - } |
|
4505 | - } |
|
4493 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
4494 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
4495 | + } else { |
|
4496 | + if ( function_exists( 'geodir_franchise_remove_franchise' ) ) { |
|
4497 | + geodir_franchise_remove_franchise( $saved_post_id ); |
|
4498 | + } |
|
4499 | + } |
|
4500 | + } else { |
|
4501 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) { |
|
4502 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
4503 | + } |
|
4504 | + } |
|
4505 | + } |
|
4506 | 4506 | |
4507 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) { |
|
4508 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
4509 | - if ($default_category_id) { |
|
4510 | - $save_post['post_default_category'] = $default_category_id; |
|
4511 | - $gd_post['default_category'] = $default_category_id; |
|
4512 | - } |
|
4513 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
4514 | - } |
|
4515 | - $xtimings['###7'] = microtime(true)-$xstart; |
|
4516 | - // Save post info |
|
4517 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
4518 | - $xtimings['###8'] = microtime(true)-$xstart; |
|
4519 | - // post taxonomies |
|
4520 | - if ( !empty( $save_post['post_category'] ) ) { |
|
4521 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
4507 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) { |
|
4508 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
4509 | + if ($default_category_id) { |
|
4510 | + $save_post['post_default_category'] = $default_category_id; |
|
4511 | + $gd_post['default_category'] = $default_category_id; |
|
4512 | + } |
|
4513 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
4514 | + } |
|
4515 | + $xtimings['###7'] = microtime(true)-$xstart; |
|
4516 | + // Save post info |
|
4517 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
4518 | + $xtimings['###8'] = microtime(true)-$xstart; |
|
4519 | + // post taxonomies |
|
4520 | + if ( !empty( $save_post['post_category'] ) ) { |
|
4521 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
4522 | 4522 | |
4523 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
4524 | - if ($default_category_id) { |
|
4525 | - $post_default_category = $default_category_id; |
|
4526 | - } |
|
4527 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
4528 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category']; |
|
4529 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : ''; |
|
4523 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
4524 | + if ($default_category_id) { |
|
4525 | + $post_default_category = $default_category_id; |
|
4526 | + } |
|
4527 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
4528 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category']; |
|
4529 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : ''; |
|
4530 | 4530 | |
4531 | - if ($post_category_str != '' && $post_default_category) { |
|
4532 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
4533 | - } |
|
4531 | + if ($post_category_str != '' && $post_default_category) { |
|
4532 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
4533 | + } |
|
4534 | 4534 | |
4535 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
4535 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
4536 | 4536 | |
4537 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
4538 | - } |
|
4539 | - $xtimings['###8.1'] = microtime(true)-$xstart; |
|
4540 | - if ( !empty( $save_post['post_tags'] ) ) { |
|
4541 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
4542 | - } |
|
4543 | - $xtimings['###9'] = microtime(true)-$xstart; |
|
4544 | - // Post images |
|
4545 | - if ( !empty( $post_images ) ) { |
|
4546 | - $post_images = array_unique($post_images); |
|
4537 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
4538 | + } |
|
4539 | + $xtimings['###8.1'] = microtime(true)-$xstart; |
|
4540 | + if ( !empty( $save_post['post_tags'] ) ) { |
|
4541 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
4542 | + } |
|
4543 | + $xtimings['###9'] = microtime(true)-$xstart; |
|
4544 | + // Post images |
|
4545 | + if ( !empty( $post_images ) ) { |
|
4546 | + $post_images = array_unique($post_images); |
|
4547 | 4547 | |
4548 | - $old_post_images_arr = array(); |
|
4549 | - $saved_post_images_arr = array(); |
|
4548 | + $old_post_images_arr = array(); |
|
4549 | + $saved_post_images_arr = array(); |
|
4550 | 4550 | |
4551 | - $order = 1; |
|
4551 | + $order = 1; |
|
4552 | 4552 | |
4553 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
4554 | - $xtimings['###9.1'] = microtime(true)-$xstart; |
|
4555 | - if (!empty($old_post_images)) { |
|
4556 | - foreach( $old_post_images as $old_post_image ) { |
|
4557 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') { |
|
4558 | - $old_post_images_arr[] = $old_post_image->file; |
|
4559 | - } |
|
4560 | - } |
|
4561 | - } |
|
4553 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
4554 | + $xtimings['###9.1'] = microtime(true)-$xstart; |
|
4555 | + if (!empty($old_post_images)) { |
|
4556 | + foreach( $old_post_images as $old_post_image ) { |
|
4557 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') { |
|
4558 | + $old_post_images_arr[] = $old_post_image->file; |
|
4559 | + } |
|
4560 | + } |
|
4561 | + } |
|
4562 | 4562 | |
4563 | - foreach ( $post_images as $post_image ) { |
|
4564 | - $image_name = basename( $post_image ); |
|
4565 | - $saved_post_images_arr[] = $image_name; |
|
4563 | + foreach ( $post_images as $post_image ) { |
|
4564 | + $image_name = basename( $post_image ); |
|
4565 | + $saved_post_images_arr[] = $image_name; |
|
4566 | 4566 | |
4567 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) { |
|
4568 | - continue; // Skip if image already exists. |
|
4569 | - } |
|
4567 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) { |
|
4568 | + continue; // Skip if image already exists. |
|
4569 | + } |
|
4570 | 4570 | |
4571 | - $image_name_parts = explode( '.', $image_name ); |
|
4572 | - array_pop( $image_name_parts ); |
|
4573 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
4574 | - $xtimings['###9.2'] = microtime(true)-$xstart; |
|
4575 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
4576 | - $xtimings['###9.3'] = microtime(true)-$xstart; |
|
4577 | - if ( !empty( $arr_file_type ) ) { |
|
4578 | - $uploaded_file_type = $arr_file_type['type']; |
|
4571 | + $image_name_parts = explode( '.', $image_name ); |
|
4572 | + array_pop( $image_name_parts ); |
|
4573 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
4574 | + $xtimings['###9.2'] = microtime(true)-$xstart; |
|
4575 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
4576 | + $xtimings['###9.3'] = microtime(true)-$xstart; |
|
4577 | + if ( !empty( $arr_file_type ) ) { |
|
4578 | + $uploaded_file_type = $arr_file_type['type']; |
|
4579 | 4579 | |
4580 | - $attachment = array(); |
|
4581 | - $attachment['post_id'] = $saved_post_id; |
|
4582 | - $attachment['title'] = $proper_image_name; |
|
4583 | - $attachment['content'] = ''; |
|
4584 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
4585 | - $attachment['mime_type'] = $uploaded_file_type; |
|
4586 | - $attachment['menu_order'] = $order; |
|
4587 | - $attachment['is_featured'] = 0; |
|
4588 | - |
|
4589 | - $attachment_set = ''; |
|
4590 | - foreach ( $attachment as $key => $val ) { |
|
4591 | - if ( $val != '' ) { |
|
4592 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
4593 | - } |
|
4594 | - } |
|
4595 | - $attachment_set = trim( $attachment_set, ", " ); |
|
4580 | + $attachment = array(); |
|
4581 | + $attachment['post_id'] = $saved_post_id; |
|
4582 | + $attachment['title'] = $proper_image_name; |
|
4583 | + $attachment['content'] = ''; |
|
4584 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
4585 | + $attachment['mime_type'] = $uploaded_file_type; |
|
4586 | + $attachment['menu_order'] = $order; |
|
4587 | + $attachment['is_featured'] = 0; |
|
4588 | + |
|
4589 | + $attachment_set = ''; |
|
4590 | + foreach ( $attachment as $key => $val ) { |
|
4591 | + if ( $val != '' ) { |
|
4592 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
4593 | + } |
|
4594 | + } |
|
4595 | + $attachment_set = trim( $attachment_set, ", " ); |
|
4596 | 4596 | |
4597 | - // Add new attachment |
|
4598 | - $xtimings['###9.4'] = microtime(true)-$xstart; |
|
4599 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
4600 | - $xtimings['###9.5'] = microtime(true)-$xstart; |
|
4601 | - $order++; |
|
4602 | - } |
|
4603 | - } |
|
4604 | - |
|
4605 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : ''; |
|
4606 | - // Remove previous attachment |
|
4607 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
4608 | - $xtimings['###9.6'] = microtime(true)-$xstart; |
|
4609 | - if ( !empty( $saved_post_images_arr ) ) { |
|
4610 | - geodir_set_wp_featured_image($saved_post_id); |
|
4611 | - $xtimings['###9.7'] = microtime(true)-$xstart; |
|
4612 | - /* |
|
4597 | + // Add new attachment |
|
4598 | + $xtimings['###9.4'] = microtime(true)-$xstart; |
|
4599 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
4600 | + $xtimings['###9.5'] = microtime(true)-$xstart; |
|
4601 | + $order++; |
|
4602 | + } |
|
4603 | + } |
|
4604 | + |
|
4605 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : ''; |
|
4606 | + // Remove previous attachment |
|
4607 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
4608 | + $xtimings['###9.6'] = microtime(true)-$xstart; |
|
4609 | + if ( !empty( $saved_post_images_arr ) ) { |
|
4610 | + geodir_set_wp_featured_image($saved_post_id); |
|
4611 | + $xtimings['###9.7'] = microtime(true)-$xstart; |
|
4612 | + /* |
|
4613 | 4613 | $menu_order = 1; |
4614 | 4614 | |
4615 | 4615 | foreach ( $saved_post_images_arr as $img_name ) { |
@@ -4622,288 +4622,288 @@ discard block |
||
4622 | 4622 | } |
4623 | 4623 | $menu_order++; |
4624 | 4624 | }*/ |
4625 | - } |
|
4625 | + } |
|
4626 | 4626 | |
4627 | - if ( $order > 1 ) { |
|
4628 | - $images++; |
|
4629 | - } |
|
4630 | - } |
|
4631 | - $xtimings['###10'] = microtime(true)-$xstart; |
|
4632 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
4633 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
4634 | - $xtimings['###11'] = microtime(true)-$xstart; |
|
4635 | - if (isset($is_featured)) { |
|
4636 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
4637 | - } |
|
4638 | - if (isset($gd_post['alive_days'])) { |
|
4639 | - geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
4640 | - } |
|
4641 | - if (isset($gd_post['expire_date'])) { |
|
4642 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
4643 | - } |
|
4644 | - $xtimings['###12'] = microtime(true)-$xstart; |
|
4645 | - } |
|
4627 | + if ( $order > 1 ) { |
|
4628 | + $images++; |
|
4629 | + } |
|
4630 | + } |
|
4631 | + $xtimings['###10'] = microtime(true)-$xstart; |
|
4632 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
4633 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
4634 | + $xtimings['###11'] = microtime(true)-$xstart; |
|
4635 | + if (isset($is_featured)) { |
|
4636 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
4637 | + } |
|
4638 | + if (isset($gd_post['alive_days'])) { |
|
4639 | + geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
4640 | + } |
|
4641 | + if (isset($gd_post['expire_date'])) { |
|
4642 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
4643 | + } |
|
4644 | + $xtimings['###12'] = microtime(true)-$xstart; |
|
4645 | + } |
|
4646 | 4646 | |
4647 | - // WPML |
|
4648 | - if ($is_wpml && $language != '') { |
|
4649 | - $sitepress->switch_lang($active_lang, true); |
|
4650 | - } |
|
4651 | - // WPML |
|
4652 | - } |
|
4653 | - } |
|
4654 | - } |
|
4647 | + // WPML |
|
4648 | + if ($is_wpml && $language != '') { |
|
4649 | + $sitepress->switch_lang($active_lang, true); |
|
4650 | + } |
|
4651 | + // WPML |
|
4652 | + } |
|
4653 | + } |
|
4654 | + } |
|
4655 | 4655 | |
4656 | - //undo some stuff to make the import quicker |
|
4657 | - wp_defer_term_counting( false ); |
|
4658 | - wp_defer_comment_counting( false ); |
|
4659 | - $wpdb->query( 'COMMIT;' ); |
|
4660 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
4661 | - $xtimings['###13'] = microtime(true)-$xstart; |
|
4662 | - $json = array(); |
|
4663 | - $json['processed'] = $processed_actual; |
|
4664 | - $json['created'] = $created; |
|
4665 | - $json['updated'] = $updated; |
|
4666 | - $json['skipped'] = $skipped; |
|
4667 | - $json['invalid'] = $invalid; |
|
4668 | - $json['invalid_addr'] = $invalid_addr; |
|
4669 | - $json['images'] = $images; |
|
4670 | - $json['timing'] = microtime(true)-$xstart; |
|
4671 | - $json['timings'] = $xtimings; |
|
4656 | + //undo some stuff to make the import quicker |
|
4657 | + wp_defer_term_counting( false ); |
|
4658 | + wp_defer_comment_counting( false ); |
|
4659 | + $wpdb->query( 'COMMIT;' ); |
|
4660 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
4661 | + $xtimings['###13'] = microtime(true)-$xstart; |
|
4662 | + $json = array(); |
|
4663 | + $json['processed'] = $processed_actual; |
|
4664 | + $json['created'] = $created; |
|
4665 | + $json['updated'] = $updated; |
|
4666 | + $json['skipped'] = $skipped; |
|
4667 | + $json['invalid'] = $invalid; |
|
4668 | + $json['invalid_addr'] = $invalid_addr; |
|
4669 | + $json['images'] = $images; |
|
4670 | + $json['timing'] = microtime(true)-$xstart; |
|
4671 | + $json['timings'] = $xtimings; |
|
4672 | 4672 | |
4673 | 4673 | |
4674 | - wp_send_json( $json ); |
|
4675 | - exit; |
|
4676 | - } else if ( $task == 'import_loc' ) { |
|
4677 | - global $gd_post_types; |
|
4678 | - $gd_post_types = $post_types; |
|
4674 | + wp_send_json( $json ); |
|
4675 | + exit; |
|
4676 | + } else if ( $task == 'import_loc' ) { |
|
4677 | + global $gd_post_types; |
|
4678 | + $gd_post_types = $post_types; |
|
4679 | 4679 | |
4680 | - if (!empty($file)) { |
|
4681 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
4680 | + if (!empty($file)) { |
|
4681 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
4682 | 4682 | |
4683 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4684 | - $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory'); |
|
4685 | - wp_send_json( $json ); |
|
4686 | - } |
|
4683 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4684 | + $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory'); |
|
4685 | + wp_send_json( $json ); |
|
4686 | + } |
|
4687 | 4687 | |
4688 | - $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory'); |
|
4689 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
4690 | - for ($i = 1; $i <= $limit; $i++) { |
|
4691 | - $index = $processed + $i; |
|
4688 | + $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory'); |
|
4689 | + $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
4690 | + for ($i = 1; $i <= $limit; $i++) { |
|
4691 | + $index = $processed + $i; |
|
4692 | 4692 | |
4693 | - if (isset($file[$index])) { |
|
4694 | - $row = $file[$index]; |
|
4695 | - $row = array_map( 'trim', $row ); |
|
4696 | - $data = array(); |
|
4693 | + if (isset($file[$index])) { |
|
4694 | + $row = $file[$index]; |
|
4695 | + $row = array_map( 'trim', $row ); |
|
4696 | + $data = array(); |
|
4697 | 4697 | |
4698 | - foreach ($columns as $c => $column ) { |
|
4699 | - 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'))) { |
|
4700 | - $data[$column] = $row[$c]; |
|
4701 | - } |
|
4702 | - } |
|
4698 | + foreach ($columns as $c => $column ) { |
|
4699 | + 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'))) { |
|
4700 | + $data[$column] = $row[$c]; |
|
4701 | + } |
|
4702 | + } |
|
4703 | 4703 | |
4704 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) { |
|
4705 | - $invalid++; |
|
4706 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4707 | - continue; |
|
4708 | - } |
|
4704 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) { |
|
4705 | + $invalid++; |
|
4706 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4707 | + continue; |
|
4708 | + } |
|
4709 | 4709 | |
4710 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
4710 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
4711 | 4711 | |
4712 | - if ( $import_choice == 'update' ) { |
|
4713 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4714 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4715 | - $updated++; |
|
4716 | - } else { |
|
4717 | - $invalid++; |
|
4718 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4719 | - } |
|
4720 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4721 | - $data['location_id'] = (int)$location->location_id; |
|
4712 | + if ( $import_choice == 'update' ) { |
|
4713 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4714 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4715 | + $updated++; |
|
4716 | + } else { |
|
4717 | + $invalid++; |
|
4718 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4719 | + } |
|
4720 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4721 | + $data['location_id'] = (int)$location->location_id; |
|
4722 | 4722 | |
4723 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) { |
|
4724 | - $data['location_id'] = (int)$location->location_id; |
|
4725 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) { |
|
4726 | - $data['location_id'] = (int)$location->location_id; |
|
4727 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) { |
|
4728 | - $data['location_id'] = (int)$location->location_id; |
|
4729 | - } |
|
4723 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) { |
|
4724 | + $data['location_id'] = (int)$location->location_id; |
|
4725 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) { |
|
4726 | + $data['location_id'] = (int)$location->location_id; |
|
4727 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) { |
|
4728 | + $data['location_id'] = (int)$location->location_id; |
|
4729 | + } |
|
4730 | 4730 | |
4731 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4732 | - $updated++; |
|
4733 | - } else { |
|
4734 | - $invalid++; |
|
4735 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4736 | - } |
|
4737 | - } else { |
|
4738 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4739 | - $created++; |
|
4740 | - } else { |
|
4741 | - $invalid++; |
|
4742 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4743 | - } |
|
4744 | - } |
|
4745 | - } elseif ( $import_choice == 'skip' ) { |
|
4746 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4747 | - $skipped++; |
|
4748 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4749 | - $skipped++; |
|
4750 | - } else { |
|
4751 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4752 | - $created++; |
|
4753 | - } else { |
|
4754 | - $invalid++; |
|
4755 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4756 | - } |
|
4757 | - } |
|
4758 | - } else { |
|
4759 | - $invalid++; |
|
4760 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4761 | - } |
|
4762 | - } |
|
4763 | - } |
|
4764 | - } |
|
4731 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4732 | + $updated++; |
|
4733 | + } else { |
|
4734 | + $invalid++; |
|
4735 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4736 | + } |
|
4737 | + } else { |
|
4738 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4739 | + $created++; |
|
4740 | + } else { |
|
4741 | + $invalid++; |
|
4742 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4743 | + } |
|
4744 | + } |
|
4745 | + } elseif ( $import_choice == 'skip' ) { |
|
4746 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4747 | + $skipped++; |
|
4748 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4749 | + $skipped++; |
|
4750 | + } else { |
|
4751 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4752 | + $created++; |
|
4753 | + } else { |
|
4754 | + $invalid++; |
|
4755 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4756 | + } |
|
4757 | + } |
|
4758 | + } else { |
|
4759 | + $invalid++; |
|
4760 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4761 | + } |
|
4762 | + } |
|
4763 | + } |
|
4764 | + } |
|
4765 | 4765 | |
4766 | - $json = array(); |
|
4767 | - $json['processed'] = $limit; |
|
4768 | - $json['created'] = $created; |
|
4769 | - $json['updated'] = $updated; |
|
4770 | - $json['skipped'] = $skipped; |
|
4771 | - $json['invalid'] = $invalid; |
|
4772 | - $json['images'] = $images; |
|
4766 | + $json = array(); |
|
4767 | + $json['processed'] = $limit; |
|
4768 | + $json['created'] = $created; |
|
4769 | + $json['updated'] = $updated; |
|
4770 | + $json['skipped'] = $skipped; |
|
4771 | + $json['invalid'] = $invalid; |
|
4772 | + $json['images'] = $images; |
|
4773 | 4773 | |
4774 | - wp_send_json( $json ); |
|
4775 | - } else if ( $task == 'import_hood' ) { |
|
4776 | - if (!empty($file)) { |
|
4777 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
4774 | + wp_send_json( $json ); |
|
4775 | + } else if ( $task == 'import_hood' ) { |
|
4776 | + if (!empty($file)) { |
|
4777 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
4778 | 4778 | |
4779 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4780 | - $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory'); |
|
4781 | - wp_send_json( $json ); |
|
4782 | - } |
|
4779 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4780 | + $json['error'] = __('The file you are uploading is not valid. There are problems with the file columns.', 'geodirectory'); |
|
4781 | + wp_send_json( $json ); |
|
4782 | + } |
|
4783 | 4783 | |
4784 | - $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory'); |
|
4785 | - $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' ); |
|
4786 | - for ($i = 1; $i <= $limit; $i++) { |
|
4787 | - $index = $processed + $i; |
|
4784 | + $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory'); |
|
4785 | + $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' ); |
|
4786 | + for ($i = 1; $i <= $limit; $i++) { |
|
4787 | + $index = $processed + $i; |
|
4788 | 4788 | |
4789 | - if (isset($file[$index])) { |
|
4790 | - $row = $file[$index]; |
|
4791 | - $row = array_map( 'trim', $row ); |
|
4792 | - $data = array(); |
|
4789 | + if (isset($file[$index])) { |
|
4790 | + $row = $file[$index]; |
|
4791 | + $row = array_map( 'trim', $row ); |
|
4792 | + $data = array(); |
|
4793 | 4793 | |
4794 | - foreach ($columns as $c => $column) { |
|
4795 | - if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) { |
|
4796 | - $data[$column] = sanitize_text_field($row[$c]); |
|
4797 | - } |
|
4798 | - } |
|
4794 | + foreach ($columns as $c => $column) { |
|
4795 | + if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) { |
|
4796 | + $data[$column] = sanitize_text_field($row[$c]); |
|
4797 | + } |
|
4798 | + } |
|
4799 | 4799 | |
4800 | - if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) { |
|
4801 | - $invalid++; |
|
4802 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4803 | - continue; |
|
4804 | - } |
|
4800 | + if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) { |
|
4801 | + $invalid++; |
|
4802 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4803 | + continue; |
|
4804 | + } |
|
4805 | 4805 | |
4806 | - $location_info = array(); |
|
4807 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) { |
|
4808 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']); |
|
4809 | - } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) { |
|
4810 | - $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region'])); |
|
4811 | - } |
|
4806 | + $location_info = array(); |
|
4807 | + if (!empty($data['location_id']) && (int)$data['location_id'] > 0) { |
|
4808 | + $location_info = geodir_get_location_by_id('', (int)$data['location_id']); |
|
4809 | + } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) { |
|
4810 | + $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region'])); |
|
4811 | + } |
|
4812 | 4812 | |
4813 | - if (empty($location_info)) { |
|
4814 | - $invalid++; |
|
4815 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4816 | - continue; |
|
4817 | - } |
|
4813 | + if (empty($location_info)) { |
|
4814 | + $invalid++; |
|
4815 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4816 | + continue; |
|
4817 | + } |
|
4818 | 4818 | |
4819 | - $location_id = $location_info->location_id; |
|
4819 | + $location_id = $location_info->location_id; |
|
4820 | 4820 | |
4821 | - $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
4821 | + $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
4822 | 4822 | |
4823 | - $hood_data = array(); |
|
4824 | - $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
4825 | - $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
4826 | - $hood_data['hood_latitude'] = $data['latitude']; |
|
4827 | - $hood_data['hood_longitude'] = $data['longitude']; |
|
4828 | - $hood_data['hood_location_id'] = $location_id; |
|
4823 | + $hood_data = array(); |
|
4824 | + $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
4825 | + $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
4826 | + $hood_data['hood_latitude'] = $data['latitude']; |
|
4827 | + $hood_data['hood_longitude'] = $data['longitude']; |
|
4828 | + $hood_data['hood_location_id'] = $location_id; |
|
4829 | 4829 | |
4830 | - if ( $import_choice == 'update' ) { |
|
4831 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4832 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
4830 | + if ( $import_choice == 'update' ) { |
|
4831 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4832 | + $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
4833 | 4833 | |
4834 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4835 | - $updated++; |
|
4836 | - } else { |
|
4837 | - $invalid++; |
|
4838 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4839 | - } |
|
4840 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4841 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
4834 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4835 | + $updated++; |
|
4836 | + } else { |
|
4837 | + $invalid++; |
|
4838 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4839 | + } |
|
4840 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4841 | + $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
4842 | 4842 | |
4843 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4844 | - $updated++; |
|
4845 | - } else { |
|
4846 | - $invalid++; |
|
4847 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4848 | - } |
|
4849 | - } else { |
|
4850 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4851 | - $created++; |
|
4852 | - } else { |
|
4853 | - $invalid++; |
|
4854 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4855 | - } |
|
4856 | - } |
|
4857 | - } elseif ( $import_choice == 'skip' ) { |
|
4858 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4859 | - $skipped++; |
|
4860 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4861 | - $skipped++; |
|
4862 | - } else { |
|
4843 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4844 | + $updated++; |
|
4845 | + } else { |
|
4846 | + $invalid++; |
|
4847 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4848 | + } |
|
4849 | + } else { |
|
4850 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4851 | + $created++; |
|
4852 | + } else { |
|
4853 | + $invalid++; |
|
4854 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4855 | + } |
|
4856 | + } |
|
4857 | + } elseif ( $import_choice == 'skip' ) { |
|
4858 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4859 | + $skipped++; |
|
4860 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4861 | + $skipped++; |
|
4862 | + } else { |
|
4863 | 4863 | |
4864 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4865 | - $created++; |
|
4866 | - } else { |
|
4867 | - $invalid++; |
|
4868 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4869 | - } |
|
4870 | - } |
|
4871 | - } else { |
|
4872 | - $invalid++; |
|
4873 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4874 | - } |
|
4875 | - } |
|
4876 | - } |
|
4877 | - } |
|
4864 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4865 | + $created++; |
|
4866 | + } else { |
|
4867 | + $invalid++; |
|
4868 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4869 | + } |
|
4870 | + } |
|
4871 | + } else { |
|
4872 | + $invalid++; |
|
4873 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4874 | + } |
|
4875 | + } |
|
4876 | + } |
|
4877 | + } |
|
4878 | 4878 | |
4879 | - $json = array(); |
|
4880 | - $json['processed'] = $limit; |
|
4881 | - $json['created'] = $created; |
|
4882 | - $json['updated'] = $updated; |
|
4883 | - $json['skipped'] = $skipped; |
|
4884 | - $json['invalid'] = $invalid; |
|
4885 | - $json['images'] = $images; |
|
4879 | + $json = array(); |
|
4880 | + $json['processed'] = $limit; |
|
4881 | + $json['created'] = $created; |
|
4882 | + $json['updated'] = $updated; |
|
4883 | + $json['skipped'] = $skipped; |
|
4884 | + $json['invalid'] = $invalid; |
|
4885 | + $json['images'] = $images; |
|
4886 | 4886 | |
4887 | - wp_send_json( $json ); |
|
4888 | - } |
|
4889 | - } |
|
4890 | - break; |
|
4891 | - case 'import_finish':{ |
|
4892 | - /** |
|
4893 | - * Run an action when an import finishes. |
|
4894 | - * |
|
4895 | - * This action can be used to fire functions after an import ends. |
|
4896 | - * |
|
4897 | - * @since 1.5.3 |
|
4898 | - * @package GeoDirectory |
|
4899 | - */ |
|
4900 | - do_action('geodir_import_finished'); |
|
4901 | - } |
|
4902 | - break; |
|
4887 | + wp_send_json( $json ); |
|
4888 | + } |
|
4889 | + } |
|
4890 | + break; |
|
4891 | + case 'import_finish':{ |
|
4892 | + /** |
|
4893 | + * Run an action when an import finishes. |
|
4894 | + * |
|
4895 | + * This action can be used to fire functions after an import ends. |
|
4896 | + * |
|
4897 | + * @since 1.5.3 |
|
4898 | + * @package GeoDirectory |
|
4899 | + */ |
|
4900 | + do_action('geodir_import_finished'); |
|
4901 | + } |
|
4902 | + break; |
|
4903 | 4903 | |
4904 | - } |
|
4905 | - echo '0'; |
|
4906 | - gd_die(); |
|
4904 | + } |
|
4905 | + echo '0'; |
|
4906 | + gd_die(); |
|
4907 | 4907 | } |
4908 | 4908 | |
4909 | 4909 | /** |
@@ -4947,12 +4947,12 @@ discard block |
||
4947 | 4947 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
4948 | 4948 | } |
4949 | 4949 | |
4950 | - if( !empty( $term ) ) { |
|
4950 | + if( !empty( $term ) ) { |
|
4951 | 4951 | $result = wp_insert_term( $term, $taxonomy, $args ); |
4952 | - if( !is_wp_error( $result ) ) { |
|
4953 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4954 | - } |
|
4955 | - } |
|
4952 | + if( !is_wp_error( $result ) ) { |
|
4953 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4954 | + } |
|
4955 | + } |
|
4956 | 4956 | |
4957 | 4957 | return false; |
4958 | 4958 | } |
@@ -4998,16 +4998,16 @@ discard block |
||
4998 | 4998 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
4999 | 4999 | |
5000 | 5000 | if( !is_wp_error( $result ) ) { |
5001 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
5002 | - } |
|
5001 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
5002 | + } |
|
5003 | 5003 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
5004 | 5004 | $term_data['term_id'] = $term_info['term_id']; |
5005 | 5005 | |
5006 | 5006 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
5007 | 5007 | |
5008 | 5008 | if( !is_wp_error( $result ) ) { |
5009 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
5010 | - } |
|
5009 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
5010 | + } |
|
5011 | 5011 | } else { |
5012 | 5012 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
5013 | 5013 | } |
@@ -5029,47 +5029,47 @@ discard block |
||
5029 | 5029 | * @return int Posts count. |
5030 | 5030 | */ |
5031 | 5031 | function geodir_get_posts_count( $post_type ) { |
5032 | - global $wpdb, $plugin_prefix; |
|
5032 | + global $wpdb, $plugin_prefix; |
|
5033 | 5033 | |
5034 | - if ( !post_type_exists( $post_type ) ) { |
|
5035 | - return 0; |
|
5036 | - } |
|
5034 | + if ( !post_type_exists( $post_type ) ) { |
|
5035 | + return 0; |
|
5036 | + } |
|
5037 | 5037 | |
5038 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
5038 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
5039 | 5039 | |
5040 | - // Skip listing with statuses trash, auto-draft etc... |
|
5041 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5042 | - $where_statuses = ''; |
|
5043 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5044 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5045 | - } |
|
5040 | + // Skip listing with statuses trash, auto-draft etc... |
|
5041 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5042 | + $where_statuses = ''; |
|
5043 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5044 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5045 | + } |
|
5046 | 5046 | |
5047 | - /** |
|
5048 | - * Filter the SQL where clause part to filter posts count in import/export. |
|
5049 | - * |
|
5050 | - * @since 1.6.4 |
|
5051 | - * @package GeoDirectory |
|
5052 | - * |
|
5053 | - * @param string $where SQL where clause part. |
|
5054 | - */ |
|
5055 | - $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
5056 | - |
|
5057 | - $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 ); |
|
5058 | - |
|
5059 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
5047 | + /** |
|
5048 | + * Filter the SQL where clause part to filter posts count in import/export. |
|
5049 | + * |
|
5050 | + * @since 1.6.4 |
|
5051 | + * @package GeoDirectory |
|
5052 | + * |
|
5053 | + * @param string $where SQL where clause part. |
|
5054 | + */ |
|
5055 | + $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
5056 | + |
|
5057 | + $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 ); |
|
5058 | + |
|
5059 | + $posts_count = (int)$wpdb->get_var( $query ); |
|
5060 | 5060 | |
5061 | - /** |
|
5062 | - * Modify returned post counts for the current post type. |
|
5063 | - * |
|
5064 | - * @since 1.4.6 |
|
5065 | - * @package GeoDirectory |
|
5066 | - * |
|
5067 | - * @param int $posts_count Post counts. |
|
5068 | - * @param string $post_type Post type. |
|
5069 | - */ |
|
5070 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
5071 | - |
|
5072 | - return $posts_count; |
|
5061 | + /** |
|
5062 | + * Modify returned post counts for the current post type. |
|
5063 | + * |
|
5064 | + * @since 1.4.6 |
|
5065 | + * @package GeoDirectory |
|
5066 | + * |
|
5067 | + * @param int $posts_count Post counts. |
|
5068 | + * @param string $post_type Post type. |
|
5069 | + */ |
|
5070 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
5071 | + |
|
5072 | + return $posts_count; |
|
5073 | 5073 | } |
5074 | 5074 | |
5075 | 5075 | /** |
@@ -5137,7 +5137,7 @@ discard block |
||
5137 | 5137 | } |
5138 | 5138 | $csv_row[] = 'post_status'; |
5139 | 5139 | $csv_row[] = 'is_featured'; |
5140 | - // Export claim listing field |
|
5140 | + // Export claim listing field |
|
5141 | 5141 | if ($is_claim_active) { |
5142 | 5142 | $csv_row[] = 'claimed'; |
5143 | 5143 | } |
@@ -5146,7 +5146,7 @@ discard block |
||
5146 | 5146 | $csv_row[] = 'alive_days'; |
5147 | 5147 | $csv_row[] = 'expire_date'; |
5148 | 5148 | } |
5149 | - $csv_row[] = 'post_date'; |
|
5149 | + $csv_row[] = 'post_date'; |
|
5150 | 5150 | $csv_row[] = 'post_address'; |
5151 | 5151 | $csv_row[] = 'post_city'; |
5152 | 5152 | $csv_row[] = 'post_region'; |
@@ -5154,11 +5154,11 @@ discard block |
||
5154 | 5154 | $csv_row[] = 'post_zip'; |
5155 | 5155 | $csv_row[] = 'post_latitude'; |
5156 | 5156 | $csv_row[] = 'post_longitude'; |
5157 | - if ($neighbourhood_active) { |
|
5158 | - $csv_row[] = 'post_neighbourhood'; |
|
5159 | - $csv_row[] = 'neighbourhood_latitude'; |
|
5160 | - $csv_row[] = 'neighbourhood_longitude'; |
|
5161 | - } |
|
5157 | + if ($neighbourhood_active) { |
|
5158 | + $csv_row[] = 'post_neighbourhood'; |
|
5159 | + $csv_row[] = 'neighbourhood_latitude'; |
|
5160 | + $csv_row[] = 'neighbourhood_longitude'; |
|
5161 | + } |
|
5162 | 5162 | $csv_row[] = 'geodir_timing'; |
5163 | 5163 | $csv_row[] = 'geodir_contact'; |
5164 | 5164 | $csv_row[] = 'geodir_email'; |
@@ -5193,21 +5193,21 @@ discard block |
||
5193 | 5193 | $csv_row[] = 'franchise'; |
5194 | 5194 | } |
5195 | 5195 | |
5196 | - /** |
|
5197 | - * Filter columns field names of gd export listings csv. |
|
5198 | - * |
|
5199 | - * @since 1.6.5 |
|
5200 | - * @package GeoDirectory |
|
5201 | - * |
|
5202 | - * @param array $csv_row Column names being exported in csv. |
|
5203 | - * @param string $post_type The post type. |
|
5204 | - */ |
|
5205 | - $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type); |
|
5196 | + /** |
|
5197 | + * Filter columns field names of gd export listings csv. |
|
5198 | + * |
|
5199 | + * @since 1.6.5 |
|
5200 | + * @package GeoDirectory |
|
5201 | + * |
|
5202 | + * @param array $csv_row Column names being exported in csv. |
|
5203 | + * @param string $post_type The post type. |
|
5204 | + */ |
|
5205 | + $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type); |
|
5206 | 5206 | |
5207 | 5207 | $csv_rows[] = $csv_row; |
5208 | 5208 | |
5209 | 5209 | $images_count = 5; |
5210 | - $xx=0; |
|
5210 | + $xx=0; |
|
5211 | 5211 | foreach ( $posts as $post ) {$xx++; |
5212 | 5212 | $post_id = $post['ID']; |
5213 | 5213 | |
@@ -5338,15 +5338,15 @@ discard block |
||
5338 | 5338 | } |
5339 | 5339 | $csv_row[] = $post_info['post_status']; // post_status |
5340 | 5340 | $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
5341 | - if ($is_claim_active) { |
|
5342 | - $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
5343 | - } |
|
5341 | + if ($is_claim_active) { |
|
5342 | + $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
5343 | + } |
|
5344 | 5344 | if ($is_payment_plugin) { |
5345 | 5345 | $csv_row[] = (int)$post_info['package_id']; // package_id |
5346 | 5346 | $csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days |
5347 | 5347 | $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 |
5348 | 5348 | } |
5349 | - $csv_row[] = $post_info['post_date']; // post_date |
|
5349 | + $csv_row[] = $post_info['post_date']; // post_date |
|
5350 | 5350 | $csv_row[] = stripslashes($post_info['post_address']); // post_address |
5351 | 5351 | $csv_row[] = stripslashes($post_info['post_city']); // post_city |
5352 | 5352 | $csv_row[] = stripslashes($post_info['post_region']); // post_region |
@@ -5354,21 +5354,21 @@ discard block |
||
5354 | 5354 | $csv_row[] = stripslashes($post_info['post_zip']); // post_zip |
5355 | 5355 | $csv_row[] = $post_info['post_latitude']; // post_latitude |
5356 | 5356 | $csv_row[] = $post_info['post_longitude']; // post_longitude |
5357 | - if ($neighbourhood_active) { |
|
5358 | - $post_neighbourhood = ''; |
|
5359 | - $neighbourhood_latitude = ''; |
|
5360 | - $neighbourhood_longitude = ''; |
|
5361 | - if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) { |
|
5362 | - if (!empty($hood_info)) { |
|
5363 | - $post_neighbourhood = $hood_info->hood_name; |
|
5364 | - $neighbourhood_latitude = $hood_info->hood_latitude; |
|
5365 | - $neighbourhood_longitude = $hood_info->hood_longitude; |
|
5366 | - } |
|
5367 | - } |
|
5368 | - $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
5369 | - $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
5370 | - $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
5371 | - } |
|
5357 | + if ($neighbourhood_active) { |
|
5358 | + $post_neighbourhood = ''; |
|
5359 | + $neighbourhood_latitude = ''; |
|
5360 | + $neighbourhood_longitude = ''; |
|
5361 | + if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) { |
|
5362 | + if (!empty($hood_info)) { |
|
5363 | + $post_neighbourhood = $hood_info->hood_name; |
|
5364 | + $neighbourhood_latitude = $hood_info->hood_latitude; |
|
5365 | + $neighbourhood_longitude = $hood_info->hood_longitude; |
|
5366 | + } |
|
5367 | + } |
|
5368 | + $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
5369 | + $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
5370 | + $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
5371 | + } |
|
5372 | 5372 | $csv_row[] = stripslashes($post_info['geodir_timing']); // geodir_timing |
5373 | 5373 | $csv_row[] = stripslashes($post_info['geodir_contact']); // geodir_contact |
5374 | 5374 | $csv_row[] = stripslashes($post_info['geodir_email']); // geodir_email |
@@ -5411,16 +5411,16 @@ discard block |
||
5411 | 5411 | $csv_row[] = (int)$franchise; // franchise id |
5412 | 5412 | } |
5413 | 5413 | |
5414 | - /** |
|
5415 | - * Filter columns values of gd export listings csv file |
|
5416 | - * |
|
5417 | - * @since 1.6.5 |
|
5418 | - * @package GeoDirectory |
|
5419 | - * |
|
5420 | - * @param array $csv_row Field values being exported in csv. |
|
5421 | - * @param array $post_info The post info. |
|
5422 | - */ |
|
5423 | - $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info); |
|
5414 | + /** |
|
5415 | + * Filter columns values of gd export listings csv file |
|
5416 | + * |
|
5417 | + * @since 1.6.5 |
|
5418 | + * @package GeoDirectory |
|
5419 | + * |
|
5420 | + * @param array $csv_row Field values being exported in csv. |
|
5421 | + * @param array $post_info The post info. |
|
5422 | + */ |
|
5423 | + $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info); |
|
5424 | 5424 | |
5425 | 5425 | for ( $c = 0; $c < $images_count; $c++ ) { |
5426 | 5426 | $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
@@ -5453,64 +5453,64 @@ discard block |
||
5453 | 5453 | * @return array Array of posts data. |
5454 | 5454 | */ |
5455 | 5455 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) { |
5456 | - global $wpdb, $plugin_prefix; |
|
5456 | + global $wpdb, $plugin_prefix; |
|
5457 | 5457 | |
5458 | - if ( ! post_type_exists( $post_type ) ) |
|
5459 | - return new stdClass; |
|
5458 | + if ( ! post_type_exists( $post_type ) ) |
|
5459 | + return new stdClass; |
|
5460 | 5460 | |
5461 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
5461 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
5462 | 5462 | |
5463 | - $limit = ''; |
|
5464 | - if ( $per_page > 0 && $page_no > 0 ) { |
|
5465 | - $offset = ( $page_no - 1 ) * $per_page; |
|
5463 | + $limit = ''; |
|
5464 | + if ( $per_page > 0 && $page_no > 0 ) { |
|
5465 | + $offset = ( $page_no - 1 ) * $per_page; |
|
5466 | 5466 | |
5467 | - if ( $offset > 0 ) { |
|
5468 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
5469 | - } else { |
|
5470 | - $limit = " LIMIT " . $per_page; |
|
5471 | - } |
|
5472 | - } |
|
5467 | + if ( $offset > 0 ) { |
|
5468 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
5469 | + } else { |
|
5470 | + $limit = " LIMIT " . $per_page; |
|
5471 | + } |
|
5472 | + } |
|
5473 | 5473 | |
5474 | - // Skip listing with statuses trash, auto-draft etc... |
|
5475 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5476 | - $where_statuses = ''; |
|
5477 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5478 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5479 | - } |
|
5474 | + // Skip listing with statuses trash, auto-draft etc... |
|
5475 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5476 | + $where_statuses = ''; |
|
5477 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5478 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5479 | + } |
|
5480 | 5480 | |
5481 | - /** |
|
5482 | - * Filter the SQL where clause part to filter posts in import/export. |
|
5483 | - * |
|
5484 | - * @since 1.6.4 |
|
5485 | - * @package GeoDirectory |
|
5486 | - * |
|
5487 | - * @param string $where SQL where clause part. |
|
5488 | - */ |
|
5489 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5490 | - |
|
5491 | - $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 ); |
|
5492 | - /** |
|
5493 | - * Modify returned posts SQL query for the current post type. |
|
5494 | - * |
|
5495 | - * @since 1.4.6 |
|
5496 | - * @package GeoDirectory |
|
5497 | - * |
|
5498 | - * @param int $query The SQL query. |
|
5499 | - * @param string $post_type Post type. |
|
5500 | - */ |
|
5501 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
5502 | - $results = (array)$wpdb->get_results( $query, ARRAY_A ); |
|
5503 | - |
|
5504 | - /** |
|
5505 | - * Modify returned post results for the current post type. |
|
5506 | - * |
|
5507 | - * @since 1.4.6 |
|
5508 | - * @package GeoDirectory |
|
5509 | - * |
|
5510 | - * @param object $results An object containing all post ids. |
|
5511 | - * @param string $post_type Post type. |
|
5512 | - */ |
|
5513 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
5481 | + /** |
|
5482 | + * Filter the SQL where clause part to filter posts in import/export. |
|
5483 | + * |
|
5484 | + * @since 1.6.4 |
|
5485 | + * @package GeoDirectory |
|
5486 | + * |
|
5487 | + * @param string $where SQL where clause part. |
|
5488 | + */ |
|
5489 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5490 | + |
|
5491 | + $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 ); |
|
5492 | + /** |
|
5493 | + * Modify returned posts SQL query for the current post type. |
|
5494 | + * |
|
5495 | + * @since 1.4.6 |
|
5496 | + * @package GeoDirectory |
|
5497 | + * |
|
5498 | + * @param int $query The SQL query. |
|
5499 | + * @param string $post_type Post type. |
|
5500 | + */ |
|
5501 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
5502 | + $results = (array)$wpdb->get_results( $query, ARRAY_A ); |
|
5503 | + |
|
5504 | + /** |
|
5505 | + * Modify returned post results for the current post type. |
|
5506 | + * |
|
5507 | + * @since 1.4.6 |
|
5508 | + * @package GeoDirectory |
|
5509 | + * |
|
5510 | + * @param object $results An object containing all post ids. |
|
5511 | + * @param string $post_type Post type. |
|
5512 | + */ |
|
5513 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
5514 | 5514 | } |
5515 | 5515 | |
5516 | 5516 | /** |
@@ -5529,26 +5529,26 @@ discard block |
||
5529 | 5529 | * @return string The SQL query. |
5530 | 5530 | */ |
5531 | 5531 | function geodir_imex_get_events_query( $query, $post_type ) { |
5532 | - if ( $post_type == 'gd_event' ) { |
|
5533 | - global $wpdb, $plugin_prefix; |
|
5532 | + if ( $post_type == 'gd_event' ) { |
|
5533 | + global $wpdb, $plugin_prefix; |
|
5534 | 5534 | |
5535 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
5536 | - $schedule_table = EVENT_SCHEDULE; |
|
5535 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
5536 | + $schedule_table = EVENT_SCHEDULE; |
|
5537 | 5537 | |
5538 | - // Skip listing with statuses trash, auto-draft etc... |
|
5539 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5540 | - $where_statuses = ''; |
|
5541 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5542 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5543 | - } |
|
5538 | + // Skip listing with statuses trash, auto-draft etc... |
|
5539 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5540 | + $where_statuses = ''; |
|
5541 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5542 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5543 | + } |
|
5544 | 5544 | |
5545 | - /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
5546 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5545 | + /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
5546 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5547 | 5547 | |
5548 | - $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 ); |
|
5549 | - } |
|
5548 | + $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 ); |
|
5549 | + } |
|
5550 | 5550 | |
5551 | - return $query; |
|
5551 | + return $query; |
|
5552 | 5552 | } |
5553 | 5553 | |
5554 | 5554 | /** |
@@ -5570,36 +5570,36 @@ discard block |
||
5570 | 5570 | * @return int Total terms count. |
5571 | 5571 | */ |
5572 | 5572 | function geodir_get_terms_count( $post_type ) { |
5573 | - $args = array( 'hide_empty' => 0 ); |
|
5573 | + $args = array( 'hide_empty' => 0 ); |
|
5574 | 5574 | |
5575 | - remove_all_filters( 'get_terms' ); |
|
5575 | + remove_all_filters( 'get_terms' ); |
|
5576 | 5576 | |
5577 | - $taxonomy = $post_type . 'category'; |
|
5577 | + $taxonomy = $post_type . 'category'; |
|
5578 | 5578 | |
5579 | - // WPML |
|
5580 | - $is_wpml = geodir_is_wpml(); |
|
5581 | - $active_lang = 'all'; |
|
5582 | - if ( $is_wpml ) { |
|
5583 | - global $sitepress; |
|
5584 | - $active_lang = $sitepress->get_current_language(); |
|
5579 | + // WPML |
|
5580 | + $is_wpml = geodir_is_wpml(); |
|
5581 | + $active_lang = 'all'; |
|
5582 | + if ( $is_wpml ) { |
|
5583 | + global $sitepress; |
|
5584 | + $active_lang = $sitepress->get_current_language(); |
|
5585 | 5585 | |
5586 | - if ( $active_lang != 'all' ) { |
|
5587 | - $sitepress->switch_lang( 'all', true ); |
|
5588 | - } |
|
5589 | - } |
|
5590 | - // WPML |
|
5586 | + if ( $active_lang != 'all' ) { |
|
5587 | + $sitepress->switch_lang( 'all', true ); |
|
5588 | + } |
|
5589 | + } |
|
5590 | + // WPML |
|
5591 | 5591 | |
5592 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
5592 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
5593 | 5593 | |
5594 | - // WPML |
|
5595 | - if ( $is_wpml && $active_lang !== 'all' ) { |
|
5596 | - global $sitepress; |
|
5597 | - $sitepress->switch_lang( $active_lang, true ); |
|
5598 | - } |
|
5599 | - // WPML |
|
5600 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
5594 | + // WPML |
|
5595 | + if ( $is_wpml && $active_lang !== 'all' ) { |
|
5596 | + global $sitepress; |
|
5597 | + $sitepress->switch_lang( $active_lang, true ); |
|
5598 | + } |
|
5599 | + // WPML |
|
5600 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
5601 | 5601 | |
5602 | - return $count_terms; |
|
5602 | + return $count_terms; |
|
5603 | 5603 | } |
5604 | 5604 | |
5605 | 5605 | /** |
@@ -5638,11 +5638,11 @@ discard block |
||
5638 | 5638 | $csv_row[] = 'cat_posttype'; |
5639 | 5639 | $csv_row[] = 'cat_parent'; |
5640 | 5640 | $csv_row[] = 'cat_schema'; |
5641 | - // WPML |
|
5641 | + // WPML |
|
5642 | 5642 | $is_wpml = geodir_wpml_is_taxonomy_translated( $taxonomy ); |
5643 | 5643 | if ($is_wpml) { |
5644 | 5644 | $csv_row[] = 'cat_language'; |
5645 | - $csv_row[] = 'cat_id_original'; |
|
5645 | + $csv_row[] = 'cat_id_original'; |
|
5646 | 5646 | } |
5647 | 5647 | // WPML |
5648 | 5648 | $csv_row[] = 'cat_description'; |
@@ -5672,10 +5672,10 @@ discard block |
||
5672 | 5672 | $csv_row[] = $post_type; |
5673 | 5673 | $csv_row[] = $cat_parent; |
5674 | 5674 | $csv_row[] = geodir_get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
5675 | - // WPML |
|
5675 | + // WPML |
|
5676 | 5676 | if ($is_wpml) { |
5677 | 5677 | $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
5678 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
5678 | + $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
5679 | 5679 | } |
5680 | 5680 | // WPML |
5681 | 5681 | $csv_row[] = $term->description; |
@@ -6093,43 +6093,43 @@ discard block |
||
6093 | 6093 | * @param string $status Post status. |
6094 | 6094 | */ |
6095 | 6095 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') { |
6096 | - global $wpdb, $current_user; |
|
6097 | - |
|
6098 | - $option_value = get_option($option); |
|
6099 | - |
|
6100 | - if ($option_value > 0) : |
|
6101 | - if (get_post($option_value)) : |
|
6102 | - // Page exists |
|
6103 | - return; |
|
6104 | - endif; |
|
6105 | - endif; |
|
6106 | - |
|
6107 | - $page_found = $wpdb->get_var( |
|
6108 | - $wpdb->prepare( |
|
6109 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
6110 | - array($slug) |
|
6111 | - ) |
|
6112 | - ); |
|
6113 | - |
|
6114 | - if ($page_found) : |
|
6115 | - // Page exists |
|
6116 | - if (!$option_value) update_option($option, $page_found); |
|
6117 | - return; |
|
6118 | - endif; |
|
6119 | - |
|
6120 | - $page_data = array( |
|
6121 | - 'post_status' => $status, |
|
6122 | - 'post_type' => 'page', |
|
6123 | - 'post_author' => $current_user->ID, |
|
6124 | - 'post_name' => $slug, |
|
6125 | - 'post_title' => $page_title, |
|
6126 | - 'post_content' => $page_content, |
|
6127 | - 'post_parent' => $post_parent, |
|
6128 | - 'comment_status' => 'closed' |
|
6129 | - ); |
|
6130 | - $page_id = wp_insert_post($page_data); |
|
6131 | - |
|
6132 | - add_option($option, $page_id); |
|
6096 | + global $wpdb, $current_user; |
|
6097 | + |
|
6098 | + $option_value = get_option($option); |
|
6099 | + |
|
6100 | + if ($option_value > 0) : |
|
6101 | + if (get_post($option_value)) : |
|
6102 | + // Page exists |
|
6103 | + return; |
|
6104 | + endif; |
|
6105 | + endif; |
|
6106 | + |
|
6107 | + $page_found = $wpdb->get_var( |
|
6108 | + $wpdb->prepare( |
|
6109 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
6110 | + array($slug) |
|
6111 | + ) |
|
6112 | + ); |
|
6113 | + |
|
6114 | + if ($page_found) : |
|
6115 | + // Page exists |
|
6116 | + if (!$option_value) update_option($option, $page_found); |
|
6117 | + return; |
|
6118 | + endif; |
|
6119 | + |
|
6120 | + $page_data = array( |
|
6121 | + 'post_status' => $status, |
|
6122 | + 'post_type' => 'page', |
|
6123 | + 'post_author' => $current_user->ID, |
|
6124 | + 'post_name' => $slug, |
|
6125 | + 'post_title' => $page_title, |
|
6126 | + 'post_content' => $page_content, |
|
6127 | + 'post_parent' => $post_parent, |
|
6128 | + 'comment_status' => 'closed' |
|
6129 | + ); |
|
6130 | + $page_id = wp_insert_post($page_data); |
|
6131 | + |
|
6132 | + add_option($option, $page_id); |
|
6133 | 6133 | |
6134 | 6134 | } |
6135 | 6135 | |
@@ -6160,9 +6160,9 @@ discard block |
||
6160 | 6160 | * @package GeoDirectory |
6161 | 6161 | */ |
6162 | 6162 | function geodir_admin_upgrade_notice() { |
6163 | - $class = "error"; |
|
6164 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory"); |
|
6165 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
6163 | + $class = "error"; |
|
6164 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory"); |
|
6165 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
6166 | 6166 | } |
6167 | 6167 | |
6168 | 6168 | /** |
@@ -6175,18 +6175,18 @@ discard block |
||
6175 | 6175 | */ |
6176 | 6176 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
6177 | 6177 | { |
6178 | - // readme contents |
|
6179 | - $args = array( |
|
6180 | - 'timeout' => 15, |
|
6181 | - 'redirection' => 5 |
|
6182 | - ); |
|
6183 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
6184 | - $data = wp_remote_get( $url, $args ); |
|
6178 | + // readme contents |
|
6179 | + $args = array( |
|
6180 | + 'timeout' => 15, |
|
6181 | + 'redirection' => 5 |
|
6182 | + ); |
|
6183 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
6184 | + $data = wp_remote_get( $url, $args ); |
|
6185 | 6185 | |
6186 | - if (!is_wp_error($data) && $data['response']['code'] == 200) { |
|
6186 | + if (!is_wp_error($data) && $data['response']['code'] == 200) { |
|
6187 | 6187 | |
6188 | - geodir_in_plugin_update_message($data['body']); |
|
6189 | - } |
|
6188 | + geodir_in_plugin_update_message($data['body']); |
|
6189 | + } |
|
6190 | 6190 | } |
6191 | 6191 | |
6192 | 6192 | |
@@ -6194,28 +6194,28 @@ discard block |
||
6194 | 6194 | * @param string $content http response body |
6195 | 6195 | */ |
6196 | 6196 | function geodir_in_plugin_update_message($content) { |
6197 | - // Output Upgrade Notice |
|
6198 | - $matches = null; |
|
6199 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
6200 | - $upgrade_notice = ''; |
|
6201 | - if ( preg_match( $regexp, $content, $matches ) ) { |
|
6202 | - if(empty($matches)){return;} |
|
6203 | - |
|
6204 | - $version = trim( $matches[1] ); |
|
6205 | - if($version && $version>GEODIRECTORY_VERSION){ |
|
6206 | - |
|
6207 | - |
|
6208 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) ); |
|
6209 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) { |
|
6210 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
6211 | - foreach ( $notices as $index => $line ) { |
|
6212 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) ); |
|
6213 | - } |
|
6214 | - $upgrade_notice .= '</div> '; |
|
6215 | - } |
|
6216 | - } |
|
6217 | - } |
|
6218 | - echo $upgrade_notice; |
|
6197 | + // Output Upgrade Notice |
|
6198 | + $matches = null; |
|
6199 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
6200 | + $upgrade_notice = ''; |
|
6201 | + if ( preg_match( $regexp, $content, $matches ) ) { |
|
6202 | + if(empty($matches)){return;} |
|
6203 | + |
|
6204 | + $version = trim( $matches[1] ); |
|
6205 | + if($version && $version>GEODIRECTORY_VERSION){ |
|
6206 | + |
|
6207 | + |
|
6208 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) ); |
|
6209 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) { |
|
6210 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
6211 | + foreach ( $notices as $index => $line ) { |
|
6212 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) ); |
|
6213 | + } |
|
6214 | + $upgrade_notice .= '</div> '; |
|
6215 | + } |
|
6216 | + } |
|
6217 | + } |
|
6218 | + echo $upgrade_notice; |
|
6219 | 6219 | } |
6220 | 6220 | |
6221 | 6221 | /** |
@@ -6248,19 +6248,19 @@ discard block |
||
6248 | 6248 | * @param array Listing statuses to be skipped. |
6249 | 6249 | */ |
6250 | 6250 | function geodir_imex_export_skip_statuses() { |
6251 | - $statuses = array( 'trash', 'auto-draft' ); |
|
6251 | + $statuses = array( 'trash', 'auto-draft' ); |
|
6252 | 6252 | |
6253 | - /** |
|
6254 | - * Filter the statuses to skip during GD export listings. |
|
6255 | - * |
|
6256 | - * @since 1.6.0 |
|
6257 | - * @package GeoDirectory |
|
6258 | - * |
|
6259 | - * @param array $statuses Listing statuses to be skipped. |
|
6260 | - */ |
|
6261 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
6253 | + /** |
|
6254 | + * Filter the statuses to skip during GD export listings. |
|
6255 | + * |
|
6256 | + * @since 1.6.0 |
|
6257 | + * @package GeoDirectory |
|
6258 | + * |
|
6259 | + * @param array $statuses Listing statuses to be skipped. |
|
6260 | + */ |
|
6261 | + $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
6262 | 6262 | |
6263 | - return $statuses; |
|
6263 | + return $statuses; |
|
6264 | 6264 | } |
6265 | 6265 | |
6266 | 6266 | /** |
@@ -6276,42 +6276,42 @@ discard block |
||
6276 | 6276 | * @global string $typenow Current post type. |
6277 | 6277 | */ |
6278 | 6278 | function geodir_admin_dequeue_scripts() { |
6279 | - global $typenow; |
|
6279 | + global $typenow; |
|
6280 | 6280 | |
6281 | - // EDD |
|
6282 | - if (wp_script_is('jquery-chosen', 'enqueued')) { |
|
6283 | - wp_dequeue_script('jquery-chosen'); |
|
6284 | - } |
|
6281 | + // EDD |
|
6282 | + if (wp_script_is('jquery-chosen', 'enqueued')) { |
|
6283 | + wp_dequeue_script('jquery-chosen'); |
|
6284 | + } |
|
6285 | 6285 | |
6286 | - // Ultimate Addons for Visual Composer |
|
6287 | - if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) { |
|
6288 | - wp_dequeue_script('ultimate-vc-backend-script'); |
|
6289 | - } |
|
6286 | + // Ultimate Addons for Visual Composer |
|
6287 | + if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) { |
|
6288 | + wp_dequeue_script('ultimate-vc-backend-script'); |
|
6289 | + } |
|
6290 | 6290 | |
6291 | - // VC editor conflicts |
|
6292 | - if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) { |
|
6293 | - wp_dequeue_script('dfd_vc_damin_scripts'); |
|
6294 | - } |
|
6291 | + // VC editor conflicts |
|
6292 | + if (class_exists('Vc_Role_Access_Controller') && wp_script_is('dfd_vc_damin_scripts', 'enqueued')) { |
|
6293 | + wp_dequeue_script('dfd_vc_damin_scripts'); |
|
6294 | + } |
|
6295 | 6295 | |
6296 | - // Ultimate chosen |
|
6297 | - if (wp_script_is('ultimate-chosen-script', 'enqueued')) { |
|
6298 | - wp_dequeue_script('ultimate-chosen-script'); |
|
6299 | - } |
|
6296 | + // Ultimate chosen |
|
6297 | + if (wp_script_is('ultimate-chosen-script', 'enqueued')) { |
|
6298 | + wp_dequeue_script('ultimate-chosen-script'); |
|
6299 | + } |
|
6300 | 6300 | |
6301 | - // Crum composer choosen |
|
6302 | - if (wp_script_is('crum-composer-choosen', 'enqueued')) { |
|
6303 | - wp_dequeue_script('crum-composer-choosen'); |
|
6304 | - } |
|
6301 | + // Crum composer choosen |
|
6302 | + if (wp_script_is('crum-composer-choosen', 'enqueued')) { |
|
6303 | + wp_dequeue_script('crum-composer-choosen'); |
|
6304 | + } |
|
6305 | 6305 | |
6306 | - // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
6307 | - if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) { |
|
6308 | - wp_dequeue_script('fusion_builder_chosen_js'); |
|
6309 | - } |
|
6306 | + // Fix conflict Fusion Builder jquery chosen with GD jquery chosen. |
|
6307 | + if (class_exists('FusionBuilder') && wp_script_is('fusion_builder_chosen_js', 'enqueued')) { |
|
6308 | + wp_dequeue_script('fusion_builder_chosen_js'); |
|
6309 | + } |
|
6310 | 6310 | |
6311 | - // Fix conflicts timepicker & setting date value. |
|
6312 | - if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) { |
|
6313 | - wp_dequeue_script('acf-timepicker'); |
|
6314 | - } |
|
6311 | + // Fix conflicts timepicker & setting date value. |
|
6312 | + if (class_exists('acf') && wp_script_is('acf-timepicker', 'enqueued')) { |
|
6313 | + wp_dequeue_script('acf-timepicker'); |
|
6314 | + } |
|
6315 | 6315 | } |
6316 | 6316 | |
6317 | 6317 | /** |
@@ -6327,48 +6327,48 @@ discard block |
||
6327 | 6327 | * @return string SQL where clause part. |
6328 | 6328 | */ |
6329 | 6329 | function geodir_imex_get_filter_where($where = '', $post_type = '') { |
6330 | - global $wpdb; |
|
6330 | + global $wpdb; |
|
6331 | 6331 | |
6332 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
6332 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
6333 | 6333 | |
6334 | - if ( !empty( $filters ) ) { |
|
6335 | - foreach ( $filters as $field => $value ) { |
|
6336 | - switch ($field) { |
|
6337 | - case 'start_date': |
|
6338 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
6339 | - break; |
|
6340 | - case 'end_date': |
|
6341 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
6342 | - break; |
|
6343 | - } |
|
6344 | - } |
|
6345 | - } |
|
6334 | + if ( !empty( $filters ) ) { |
|
6335 | + foreach ( $filters as $field => $value ) { |
|
6336 | + switch ($field) { |
|
6337 | + case 'start_date': |
|
6338 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
6339 | + break; |
|
6340 | + case 'end_date': |
|
6341 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
6342 | + break; |
|
6343 | + } |
|
6344 | + } |
|
6345 | + } |
|
6346 | 6346 | |
6347 | - return $where; |
|
6347 | + return $where; |
|
6348 | 6348 | } |
6349 | 6349 | add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2); |
6350 | 6350 | add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2); |
6351 | 6351 | |
6352 | 6352 | |
6353 | 6353 | function geodir_fix_for_primer_theme(){ |
6354 | - if(!defined( 'PRIMER_VERSION' )){return;} |
|
6355 | - global $pagenow; |
|
6354 | + if(!defined( 'PRIMER_VERSION' )){return;} |
|
6355 | + global $pagenow; |
|
6356 | 6356 | |
6357 | - if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){ |
|
6357 | + if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){ |
|
6358 | 6358 | |
6359 | - $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
6359 | + $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
6360 | 6360 | |
6361 | - $post_types = geodir_get_posttypes(); |
|
6362 | - if ($post_type && in_array($post_type, $post_types) ) { |
|
6363 | - global $primer_customizer_layouts; |
|
6364 | - remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
6365 | - } |
|
6366 | - } |
|
6361 | + $post_types = geodir_get_posttypes(); |
|
6362 | + if ($post_type && in_array($post_type, $post_types) ) { |
|
6363 | + global $primer_customizer_layouts; |
|
6364 | + remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
6365 | + } |
|
6366 | + } |
|
6367 | 6367 | |
6368 | 6368 | } |
6369 | 6369 | |
6370 | 6370 | if(is_admin()){ |
6371 | - add_action('add_meta_boxes','geodir_fix_for_primer_theme',0); |
|
6371 | + add_action('add_meta_boxes','geodir_fix_for_primer_theme',0); |
|
6372 | 6372 | } |
6373 | 6373 | |
6374 | 6374 | |
@@ -6501,96 +6501,96 @@ discard block |
||
6501 | 6501 | |
6502 | 6502 | function geodir_ga_activation_url() { |
6503 | 6503 | |
6504 | - return add_query_arg( array( |
|
6505 | - 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"), |
|
6506 | - 'scope' => GEODIR_GA_SCOPE, |
|
6507 | - 'response_type' => 'code', |
|
6508 | - 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
6509 | - 'client_id' => GEODIR_GA_CLIENTID, |
|
6510 | - ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
6504 | + return add_query_arg( array( |
|
6505 | + 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"), |
|
6506 | + 'scope' => GEODIR_GA_SCOPE, |
|
6507 | + 'response_type' => 'code', |
|
6508 | + 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
6509 | + 'client_id' => GEODIR_GA_CLIENTID, |
|
6510 | + ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
6511 | 6511 | |
6512 | - return $url; |
|
6512 | + return $url; |
|
6513 | 6513 | } |
6514 | 6514 | |
6515 | 6515 | function geodir_gd_accounts(){ |
6516 | - $accounts = array(); |
|
6517 | - $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
6518 | - if($useAuth){ |
|
6519 | - try { |
|
6520 | - $accounts = geodir_ga_get_analytics_accounts(); |
|
6521 | - } catch (Exception $e) { |
|
6522 | - geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
6523 | - } |
|
6516 | + $accounts = array(); |
|
6517 | + $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
6518 | + if($useAuth){ |
|
6519 | + try { |
|
6520 | + $accounts = geodir_ga_get_analytics_accounts(); |
|
6521 | + } catch (Exception $e) { |
|
6522 | + geodir_error_log( wp_sprintf( __( 'GD Google Analytics API Error(%s) : %s', 'geodirectory' ), $e->getCode(), $e->getMessage() ) ); |
|
6523 | + } |
|
6524 | 6524 | |
6525 | - if(is_array($accounts)){ |
|
6526 | - $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts); |
|
6527 | - }elseif(get_option('geodir_ga_account_id')){ |
|
6528 | - $accounts = array(); |
|
6529 | - $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')'; |
|
6530 | - } |
|
6531 | - } |
|
6532 | - return $accounts; |
|
6525 | + if(is_array($accounts)){ |
|
6526 | + $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts); |
|
6527 | + }elseif(get_option('geodir_ga_account_id')){ |
|
6528 | + $accounts = array(); |
|
6529 | + $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')'; |
|
6530 | + } |
|
6531 | + } |
|
6532 | + return $accounts; |
|
6533 | 6533 | } |
6534 | 6534 | |
6535 | 6535 | function geodir_ga_get_analytics_accounts() |
6536 | 6536 | { |
6537 | - global $gd_ga_errors; |
|
6538 | - $accounts = array(); |
|
6537 | + global $gd_ga_errors; |
|
6538 | + $accounts = array(); |
|
6539 | 6539 | |
6540 | - if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');} |
|
6540 | + if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');} |
|
6541 | 6541 | |
6542 | 6542 | |
6543 | - if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){ |
|
6544 | - return get_option('geodir_gd_uids'); |
|
6545 | - } |
|
6543 | + if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){ |
|
6544 | + return get_option('geodir_gd_uids'); |
|
6545 | + } |
|
6546 | 6546 | |
6547 | - # Create a new Gdata call |
|
6548 | - if ( trim(get_option('geodir_ga_auth_code')) != '' ) |
|
6549 | - $stats = new GDGoogleAnalyticsStats(); |
|
6550 | - else |
|
6551 | - return false; |
|
6547 | + # Create a new Gdata call |
|
6548 | + if ( trim(get_option('geodir_ga_auth_code')) != '' ) |
|
6549 | + $stats = new GDGoogleAnalyticsStats(); |
|
6550 | + else |
|
6551 | + return false; |
|
6552 | 6552 | |
6553 | - # Check if Google sucessfully logged in |
|
6554 | - if ( ! $stats->checkLogin() ) |
|
6555 | - return false; |
|
6553 | + # Check if Google sucessfully logged in |
|
6554 | + if ( ! $stats->checkLogin() ) |
|
6555 | + return false; |
|
6556 | 6556 | |
6557 | - # Get a list of accounts |
|
6558 | - try { |
|
6559 | - $accounts = $stats->getAllProfiles(); |
|
6560 | - } catch (Exception $e) { |
|
6561 | - $gd_ga_errors[] = $e->getMessage(); |
|
6562 | - return false; |
|
6563 | - } |
|
6557 | + # Get a list of accounts |
|
6558 | + try { |
|
6559 | + $accounts = $stats->getAllProfiles(); |
|
6560 | + } catch (Exception $e) { |
|
6561 | + $gd_ga_errors[] = $e->getMessage(); |
|
6562 | + return false; |
|
6563 | + } |
|
6564 | 6564 | |
6565 | 6565 | |
6566 | - natcasesort ($accounts); |
|
6566 | + natcasesort ($accounts); |
|
6567 | 6567 | |
6568 | - # Return the account array if there are accounts |
|
6569 | - if ( count($accounts) > 0 ){ |
|
6570 | - update_option('geodir_gd_uids',$accounts); |
|
6571 | - return $accounts; |
|
6572 | - } |
|
6573 | - else |
|
6574 | - return false; |
|
6568 | + # Return the account array if there are accounts |
|
6569 | + if ( count($accounts) > 0 ){ |
|
6570 | + update_option('geodir_gd_uids',$accounts); |
|
6571 | + return $accounts; |
|
6572 | + } |
|
6573 | + else |
|
6574 | + return false; |
|
6575 | 6575 | } |
6576 | 6576 | |
6577 | 6577 | add_action( 'wp_ajax_geodir_ga_deauthorize', 'geodir_ga_deauthorize' ); |
6578 | 6578 | function geodir_ga_deauthorize(){ |
6579 | 6579 | |
6580 | - if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) { |
|
6580 | + if ( ! wp_verify_nonce( $_REQUEST['_wpnonce'], 'gd_ga_deauthorize' ) ) { |
|
6581 | 6581 | |
6582 | - die( 'Security check' ); |
|
6582 | + die( 'Security check' ); |
|
6583 | 6583 | |
6584 | - } else { |
|
6585 | - update_option('geodir_ga_auth_token',''); |
|
6586 | - update_option('geodir_ga_auth_code',''); |
|
6587 | - update_option('geodir_gd_uids',''); |
|
6584 | + } else { |
|
6585 | + update_option('geodir_ga_auth_token',''); |
|
6586 | + update_option('geodir_ga_auth_code',''); |
|
6587 | + update_option('geodir_gd_uids',''); |
|
6588 | 6588 | |
6589 | 6589 | |
6590 | - echo admin_url('?page=geodirectory&active_tab=google_analytic_settings'); |
|
6591 | - } |
|
6590 | + echo admin_url('?page=geodirectory&active_tab=google_analytic_settings'); |
|
6591 | + } |
|
6592 | 6592 | |
6593 | - die(); |
|
6593 | + die(); |
|
6594 | 6594 | } |
6595 | 6595 | |
6596 | 6596 | |
@@ -6601,14 +6601,14 @@ discard block |
||
6601 | 6601 | * @package GeoDirectory |
6602 | 6602 | */ |
6603 | 6603 | function geodir_post_type_setting_fun() { |
6604 | - $post_type_arr = array(); |
|
6604 | + $post_type_arr = array(); |
|
6605 | 6605 | |
6606 | - $post_types = geodir_get_posttypes('object'); |
|
6606 | + $post_types = geodir_get_posttypes('object'); |
|
6607 | 6607 | |
6608 | - foreach ($post_types as $key => $post_types_obj) { |
|
6609 | - $post_type_arr[$key] = $post_types_obj->labels->singular_name; |
|
6610 | - } |
|
6611 | - return $post_type_arr; |
|
6608 | + foreach ($post_types as $key => $post_types_obj) { |
|
6609 | + $post_type_arr[$key] = $post_types_obj->labels->singular_name; |
|
6610 | + } |
|
6611 | + return $post_type_arr; |
|
6612 | 6612 | } |
6613 | 6613 | |
6614 | 6614 | /** |
@@ -6619,35 +6619,35 @@ discard block |
||
6619 | 6619 | */ |
6620 | 6620 | function geodir_listing_image_size_arr(){ |
6621 | 6621 | |
6622 | - global $_wp_additional_image_sizes; |
|
6623 | - |
|
6624 | - $sizes = array(); |
|
6625 | - |
|
6626 | - foreach ( get_intermediate_image_sizes() as $_size ) { |
|
6627 | - if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) { |
|
6628 | - $sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" ); |
|
6629 | - $sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" ); |
|
6630 | - $sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" ); |
|
6631 | - } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { |
|
6632 | - $sizes[ $_size ] = array( |
|
6633 | - 'width' => $_wp_additional_image_sizes[ $_size ]['width'], |
|
6634 | - 'height' => $_wp_additional_image_sizes[ $_size ]['height'], |
|
6635 | - 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], |
|
6636 | - ); |
|
6637 | - } |
|
6638 | - } |
|
6622 | + global $_wp_additional_image_sizes; |
|
6623 | + |
|
6624 | + $sizes = array(); |
|
6625 | + |
|
6626 | + foreach ( get_intermediate_image_sizes() as $_size ) { |
|
6627 | + if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) { |
|
6628 | + $sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" ); |
|
6629 | + $sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" ); |
|
6630 | + $sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" ); |
|
6631 | + } elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) { |
|
6632 | + $sizes[ $_size ] = array( |
|
6633 | + 'width' => $_wp_additional_image_sizes[ $_size ]['width'], |
|
6634 | + 'height' => $_wp_additional_image_sizes[ $_size ]['height'], |
|
6635 | + 'crop' => $_wp_additional_image_sizes[ $_size ]['crop'], |
|
6636 | + ); |
|
6637 | + } |
|
6638 | + } |
|
6639 | 6639 | |
6640 | 6640 | |
6641 | 6641 | |
6642 | - $options = array(); |
|
6642 | + $options = array(); |
|
6643 | 6643 | |
6644 | - $options['default'] = __('GD Default', 'geodirectory'); |
|
6644 | + $options['default'] = __('GD Default', 'geodirectory'); |
|
6645 | 6645 | |
6646 | - if(!empty($sizes)){ |
|
6647 | - foreach($sizes as $key=>$val){ |
|
6648 | - $options[$key] = $key. ' ( '.$val['width'].' x '.$val['height']. ' )'; |
|
6649 | - } |
|
6650 | - } |
|
6646 | + if(!empty($sizes)){ |
|
6647 | + foreach($sizes as $key=>$val){ |
|
6648 | + $options[$key] = $key. ' ( '.$val['width'].' x '.$val['height']. ' )'; |
|
6649 | + } |
|
6650 | + } |
|
6651 | 6651 | |
6652 | - return $options; |
|
6652 | + return $options; |
|
6653 | 6653 | } |
6654 | 6654 | \ No newline at end of file |
@@ -36,177 +36,177 @@ discard block |
||
36 | 36 | */ |
37 | 37 | function geodir_templates_scripts() |
38 | 38 | { |
39 | - $is_detail_page = false; |
|
40 | - $geodir_map_name = geodir_map_name(); |
|
39 | + $is_detail_page = false; |
|
40 | + $geodir_map_name = geodir_map_name(); |
|
41 | 41 | |
42 | - if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) { |
|
43 | - $is_detail_page = true; |
|
44 | - } |
|
42 | + if((is_single() && geodir_is_geodir_page()) || (is_page() && geodir_is_page('preview') )) { |
|
43 | + $is_detail_page = true; |
|
44 | + } |
|
45 | 45 | |
46 | - wp_enqueue_script('jquery'); |
|
46 | + wp_enqueue_script('jquery'); |
|
47 | 47 | |
48 | - wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION); |
|
49 | - wp_enqueue_script('geodirectory-script'); |
|
48 | + wp_register_script('geodirectory-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory.min.js', array(), GEODIRECTORY_VERSION); |
|
49 | + wp_enqueue_script('geodirectory-script'); |
|
50 | 50 | |
51 | - $geodir_vars_data = array( |
|
52 | - 'siteurl' => get_option('siteurl'), |
|
53 | - 'geodir_plugin_url' => geodir_plugin_url(), |
|
54 | - 'geodir_lazy_load' => get_option('geodir_lazy_load',1), |
|
55 | - 'geodir_ajax_url' => geodir_get_ajax_url(), |
|
56 | - 'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'), |
|
57 | - 'is_rtl' => is_rtl() ? 1 : 0, // fix rtl issue |
|
51 | + $geodir_vars_data = array( |
|
52 | + 'siteurl' => get_option('siteurl'), |
|
53 | + 'geodir_plugin_url' => geodir_plugin_url(), |
|
54 | + 'geodir_lazy_load' => get_option('geodir_lazy_load',1), |
|
55 | + 'geodir_ajax_url' => geodir_get_ajax_url(), |
|
56 | + 'geodir_gd_modal' => (int)get_option('geodir_disable_gb_modal'), |
|
57 | + 'is_rtl' => is_rtl() ? 1 : 0, // fix rtl issue |
|
58 | 58 | 'lightBox_txtImage' => addslashes(__('Image', 'geodirectory')), |
59 | 59 | 'lightBox_txtOf' => addslashes(__('of', 'geodirectory')), |
60 | - ); |
|
61 | - |
|
62 | - /** |
|
63 | - * Filter the `geodir_var` data array that outputs the wp_localize_script() translations and variables. |
|
64 | - * |
|
65 | - * This is used by addons to add JS translatable variables. |
|
66 | - * |
|
67 | - * @since 1.4.4 |
|
68 | - * @param array $geodir_vars_data { |
|
69 | - * geodir var data used by addons to add JS translatable variables. |
|
70 | - * |
|
71 | - * @type string $siteurl Site url. |
|
72 | - * @type string $geodir_plugin_url Geodirectory core plugin url. |
|
73 | - * @type string $geodir_ajax_url Geodirectory plugin ajax url. |
|
74 | - * @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?. |
|
75 | - * @type int $is_rtl Checks if current locale is RTL. |
|
76 | - * |
|
77 | - * } |
|
78 | - */ |
|
79 | - $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data); |
|
80 | - |
|
81 | - wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data); |
|
82 | - |
|
83 | - wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true); |
|
84 | - if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');} |
|
85 | - |
|
86 | - wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true); |
|
87 | - wp_enqueue_script('geodirectory-lightbox-jquery'); |
|
88 | - |
|
89 | - wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true); |
|
90 | - if ($is_detail_page) { |
|
91 | - wp_enqueue_script('geodirectory-jquery-simplemodal'); |
|
92 | - } |
|
60 | + ); |
|
61 | + |
|
62 | + /** |
|
63 | + * Filter the `geodir_var` data array that outputs the wp_localize_script() translations and variables. |
|
64 | + * |
|
65 | + * This is used by addons to add JS translatable variables. |
|
66 | + * |
|
67 | + * @since 1.4.4 |
|
68 | + * @param array $geodir_vars_data { |
|
69 | + * geodir var data used by addons to add JS translatable variables. |
|
70 | + * |
|
71 | + * @type string $siteurl Site url. |
|
72 | + * @type string $geodir_plugin_url Geodirectory core plugin url. |
|
73 | + * @type string $geodir_ajax_url Geodirectory plugin ajax url. |
|
74 | + * @type int $geodir_gd_modal Disable GD modal that displays slideshow images in popup?. |
|
75 | + * @type int $is_rtl Checks if current locale is RTL. |
|
76 | + * |
|
77 | + * } |
|
78 | + */ |
|
79 | + $geodir_vars_data = apply_filters('geodir_vars_data',$geodir_vars_data); |
|
80 | + |
|
81 | + wp_localize_script('geodirectory-script', 'geodir_var', $geodir_vars_data); |
|
82 | + |
|
83 | + wp_register_script('geodirectory-jquery-flexslider-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.flexslider.min.js', array(), GEODIRECTORY_VERSION,true); |
|
84 | + if($is_detail_page){wp_enqueue_script('geodirectory-jquery-flexslider-js');} |
|
85 | + |
|
86 | + wp_register_script('geodirectory-lightbox-jquery', geodir_plugin_url() . '/geodirectory-assets/js/jquery.lightbox-0.5.min.js', array(), GEODIRECTORY_VERSION,true); |
|
87 | + wp_enqueue_script('geodirectory-lightbox-jquery'); |
|
88 | + |
|
89 | + wp_register_script('geodirectory-jquery-simplemodal', geodir_plugin_url() . '/geodirectory-assets/js/jquery.simplemodal.min.js', array(), GEODIRECTORY_VERSION,true); |
|
90 | + if ($is_detail_page) { |
|
91 | + wp_enqueue_script('geodirectory-jquery-simplemodal'); |
|
92 | + } |
|
93 | 93 | |
94 | - if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
95 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
96 | - $map_key = "&key=" . geodir_get_map_api_key(); |
|
97 | - /** |
|
98 | - * Filter the variables that are added to the end of the google maps script call. |
|
99 | - * |
|
100 | - * This i used to change things like google maps language etc. |
|
101 | - * |
|
102 | - * @since 1.0.0 |
|
103 | - * @param string $var The string to filter, default is empty string. |
|
104 | - */ |
|
105 | - $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
106 | - wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL); |
|
94 | + if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
95 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
96 | + $map_key = "&key=" . geodir_get_map_api_key(); |
|
97 | + /** |
|
98 | + * Filter the variables that are added to the end of the google maps script call. |
|
99 | + * |
|
100 | + * This i used to change things like google maps language etc. |
|
101 | + * |
|
102 | + * @since 1.0.0 |
|
103 | + * @param string $var The string to filter, default is empty string. |
|
104 | + */ |
|
105 | + $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
106 | + wp_enqueue_script('google-maps-api', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra , '', NULL); |
|
107 | 107 | |
108 | - // Overlapping Marker Spiderfier |
|
109 | - wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION); |
|
110 | - wp_enqueue_script('geodirectory-g-overlappingmarker-script'); |
|
111 | - } |
|
108 | + // Overlapping Marker Spiderfier |
|
109 | + wp_register_script('geodirectory-g-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms.min.js', array(), GEODIRECTORY_VERSION); |
|
110 | + wp_enqueue_script('geodirectory-g-overlappingmarker-script'); |
|
111 | + } |
|
112 | 112 | |
113 | - if ($geodir_map_name == 'osm') { |
|
114 | - // Leaflet OpenStreetMap |
|
115 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
116 | - wp_enqueue_style('geodirectory-leaflet-style'); |
|
113 | + if ($geodir_map_name == 'osm') { |
|
114 | + // Leaflet OpenStreetMap |
|
115 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
116 | + wp_enqueue_style('geodirectory-leaflet-style'); |
|
117 | 117 | |
118 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
119 | - wp_enqueue_script('geodirectory-leaflet-script'); |
|
118 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
119 | + wp_enqueue_script('geodirectory-leaflet-script'); |
|
120 | 120 | |
121 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION); |
|
122 | - wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
121 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.min.js', array(), GEODIRECTORY_VERSION); |
|
122 | + wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
123 | 123 | |
124 | - if ($is_detail_page) { |
|
125 | - wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION); |
|
126 | - wp_enqueue_style('geodirectory-leaflet-routing-style'); |
|
124 | + if ($is_detail_page) { |
|
125 | + wp_register_style('geodirectory-leaflet-routing-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.css', array(), GEODIRECTORY_VERSION); |
|
126 | + wp_enqueue_style('geodirectory-leaflet-routing-style'); |
|
127 | 127 | |
128 | - wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION); |
|
129 | - wp_enqueue_script('geodirectory-leaflet-routing-script'); |
|
130 | - } |
|
128 | + wp_register_script('geodirectory-leaflet-routing-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/routing/leaflet-routing-machine.min.js', array(), GEODIRECTORY_VERSION); |
|
129 | + wp_enqueue_script('geodirectory-leaflet-routing-script'); |
|
130 | + } |
|
131 | 131 | |
132 | - // Overlapping Marker Spiderfier Leaflet |
|
133 | - wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
134 | - wp_enqueue_script('geodirectory-o-overlappingmarker-script'); |
|
135 | - } |
|
136 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
132 | + // Overlapping Marker Spiderfier Leaflet |
|
133 | + wp_register_script('geodirectory-o-overlappingmarker-script', geodir_plugin_url() . '/geodirectory-assets/jawj/oms-leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
134 | + wp_enqueue_script('geodirectory-o-overlappingmarker-script'); |
|
135 | + } |
|
136 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
137 | 137 | |
138 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true); |
|
139 | - wp_enqueue_script('geodirectory-goMap-script'); |
|
140 | - |
|
141 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION); |
|
142 | - wp_enqueue_script('chosen'); |
|
143 | - |
|
144 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION); |
|
145 | - wp_enqueue_script('geodirectory-choose-ajax'); |
|
146 | - |
|
147 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true); |
|
148 | - |
|
149 | - if (is_page() && geodir_is_page('add-listing')) { |
|
150 | - // SCRIPT FOR UPLOAD |
|
151 | - wp_enqueue_script('plupload-all'); |
|
152 | - wp_enqueue_script('jquery-ui-sortable'); |
|
153 | - |
|
154 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true); |
|
155 | - wp_enqueue_script('geodirectory-plupload-script'); |
|
156 | - // SCRIPT FOR UPLOAD END |
|
157 | - |
|
158 | - // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls |
|
159 | - if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
160 | - $ajax_url = admin_url('admin-ajax.php'); |
|
161 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
162 | - $ajax_url = admin_url('admin-ajax.php'); |
|
163 | - } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
164 | - $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
165 | - } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
166 | - $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
167 | - } else { |
|
168 | - $ajax_url = admin_url('admin-ajax.php'); |
|
169 | - } |
|
138 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION, true); |
|
139 | + wp_enqueue_script('geodirectory-goMap-script'); |
|
140 | + |
|
141 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.min.js', array(), GEODIRECTORY_VERSION); |
|
142 | + wp_enqueue_script('chosen'); |
|
143 | + |
|
144 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.min.js', array(), GEODIRECTORY_VERSION); |
|
145 | + wp_enqueue_script('geodirectory-choose-ajax'); |
|
146 | + |
|
147 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.min.js', array('jquery-ui-datepicker', 'jquery-ui-slider', 'jquery-effects-core', 'jquery-effects-slide'), '', true); |
|
148 | + |
|
149 | + if (is_page() && geodir_is_page('add-listing')) { |
|
150 | + // SCRIPT FOR UPLOAD |
|
151 | + wp_enqueue_script('plupload-all'); |
|
152 | + wp_enqueue_script('jquery-ui-sortable'); |
|
153 | + |
|
154 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.min.js#asyncload', array(), GEODIRECTORY_VERSION,true); |
|
155 | + wp_enqueue_script('geodirectory-plupload-script'); |
|
156 | + // SCRIPT FOR UPLOAD END |
|
157 | + |
|
158 | + // check_ajax_referer function is used to make sure no files are uplaoded remotly but it will fail if used between https and non https so we do the check below of the urls |
|
159 | + if (str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
160 | + $ajax_url = admin_url('admin-ajax.php'); |
|
161 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
162 | + $ajax_url = admin_url('admin-ajax.php'); |
|
163 | + } elseif (str_replace("https", "http", admin_url('admin-ajax.php')) && empty($_SERVER['HTTPS'])) { |
|
164 | + $ajax_url = str_replace("https", "http", admin_url('admin-ajax.php')); |
|
165 | + } elseif (!str_replace("https", "http", admin_url('admin-ajax.php')) && !empty($_SERVER['HTTPS'])) { |
|
166 | + $ajax_url = str_replace("http", "https", admin_url('admin-ajax.php')); |
|
167 | + } else { |
|
168 | + $ajax_url = admin_url('admin-ajax.php'); |
|
169 | + } |
|
170 | 170 | |
171 | - // place js config array for plupload |
|
172 | - $plupload_init = array( |
|
173 | - 'runtimes' => 'html5,silverlight,browserplus,gears,html4', |
|
174 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
175 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
176 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
177 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
178 | - 'multiple_queues' => true, |
|
179 | - 'max_file_size' => geodir_max_upload_size(), |
|
180 | - 'url' => $ajax_url, |
|
181 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
182 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
183 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
184 | - 'multipart' => true, |
|
185 | - 'urlstream_upload' => true, |
|
186 | - 'multi_selection' => false, // will be added per uploader |
|
187 | - // additional post data to send to our ajax hook |
|
188 | - 'multipart_params' => array( |
|
189 | - '_ajax_nonce' => "", // will be added per uploader |
|
190 | - 'action' => 'plupload_action', // the ajax action name |
|
191 | - 'imgid' => 0 // will be added per uploader |
|
192 | - ) |
|
193 | - ); |
|
194 | - $base_plupload_config = json_encode($plupload_init); |
|
195 | - |
|
196 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
197 | - 'upload_img_size' => geodir_max_upload_size()); |
|
198 | - |
|
199 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
200 | - |
|
201 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload'); |
|
202 | - } // End if for add place page |
|
203 | - |
|
204 | - wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
205 | - if ($is_detail_page) { |
|
171 | + // place js config array for plupload |
|
172 | + $plupload_init = array( |
|
173 | + 'runtimes' => 'html5,silverlight,browserplus,gears,html4', |
|
174 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
175 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
176 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
177 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
178 | + 'multiple_queues' => true, |
|
179 | + 'max_file_size' => geodir_max_upload_size(), |
|
180 | + 'url' => $ajax_url, |
|
181 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
182 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
183 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
184 | + 'multipart' => true, |
|
185 | + 'urlstream_upload' => true, |
|
186 | + 'multi_selection' => false, // will be added per uploader |
|
187 | + // additional post data to send to our ajax hook |
|
188 | + 'multipart_params' => array( |
|
189 | + '_ajax_nonce' => "", // will be added per uploader |
|
190 | + 'action' => 'plupload_action', // the ajax action name |
|
191 | + 'imgid' => 0 // will be added per uploader |
|
192 | + ) |
|
193 | + ); |
|
194 | + $base_plupload_config = json_encode($plupload_init); |
|
195 | + |
|
196 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
197 | + 'upload_img_size' => geodir_max_upload_size()); |
|
198 | + |
|
199 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
200 | + |
|
201 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation.min.js#asyncload'); |
|
202 | + } // End if for add place page |
|
203 | + |
|
204 | + wp_register_script('geodirectory-post-custom-js', geodir_plugin_url() . '/geodirectory-assets/js/post.custom.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
205 | + if ($is_detail_page) { |
|
206 | 206 | wp_enqueue_script('geodirectory-post-custom-js'); |
207 | 207 | } |
208 | 208 | |
209 | - // font awesome rating script |
|
209 | + // font awesome rating script |
|
210 | 210 | if (get_option('geodir_reviewrating_enable_font_awesome')) { |
211 | 211 | wp_register_script('geodir-barrating-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.barrating.min.js', array(), GEODIRECTORY_VERSION, true); |
212 | 212 | wp_enqueue_script('geodir-barrating-js'); |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | wp_enqueue_script('geodir-jRating-js'); |
216 | 216 | } |
217 | 217 | |
218 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
219 | - wp_enqueue_script('geodir-on-document-load'); |
|
218 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
219 | + wp_enqueue_script('geodir-on-document-load'); |
|
220 | 220 | |
221 | - wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
222 | - wp_enqueue_script('google-geometa'); |
|
221 | + wp_register_script('google-geometa', geodir_plugin_url() . '/geodirectory-assets/js/geometa.min.js#asyncload', array(), GEODIRECTORY_VERSION, true); |
|
222 | + wp_enqueue_script('google-geometa'); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | */ |
234 | 234 | function geodir_header_scripts() |
235 | 235 | { |
236 | - echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>'; |
|
237 | - echo stripslashes(get_option('geodir_header_scripts')); |
|
236 | + echo '<style>' . stripslashes(get_option('geodir_coustem_css')) . '</style>'; |
|
237 | + echo stripslashes(get_option('geodir_header_scripts')); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | function geodir_google_analytics_tracking_code() |
249 | 249 | { |
250 | - if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?> |
|
250 | + if(get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_account_id')){?> |
|
251 | 251 | |
252 | 252 | <script> |
253 | 253 | (function(i,s,o,g,r,a,m){ i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ |
@@ -262,9 +262,9 @@ discard block |
||
262 | 262 | </script> |
263 | 263 | |
264 | 264 | <?php |
265 | - }elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){ |
|
266 | - echo stripslashes(get_option('geodir_ga_tracking_code')); |
|
267 | - } |
|
265 | + }elseif( get_option('geodir_ga_add_tracking_code') && get_option('geodir_ga_tracking_code') && !get_option('geodir_ga_account_id')){ |
|
266 | + echo stripslashes(get_option('geodir_ga_tracking_code')); |
|
267 | + } |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -278,16 +278,16 @@ discard block |
||
278 | 278 | function geodir_footer_scripts() |
279 | 279 | { |
280 | 280 | |
281 | - echo stripslashes(get_option('geodir_footer_scripts')); |
|
281 | + echo stripslashes(get_option('geodir_footer_scripts')); |
|
282 | 282 | |
283 | - /* |
|
283 | + /* |
|
284 | 284 | * Apple suck and can't/won't fix bugs: https://bugs.webkit.org/show_bug.cgi?id=136041 |
285 | 285 | * |
286 | 286 | * Flexbox wont wrap on ios for search form items |
287 | 287 | */ |
288 | - if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
289 | - echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>"; |
|
290 | - } |
|
288 | + if ( !empty( $_SERVER['HTTP_USER_AGENT'] ) && preg_match( '/iPad|iPod|iPhone|Safari/', $_SERVER['HTTP_USER_AGENT'] ) ) { |
|
289 | + echo "<style>body .geodir-listing-search.gd-search-bar-style .geodir-loc-bar .clearfix.geodir-loc-bar-in .geodir-search .gd-search-input-wrapper{flex:50 1 auto !important;min-width: initial !important;width:auto !important;}.geodir-filter-container .geodir-filter-cat{width:auto !important;}</style>"; |
|
290 | + } |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | |
@@ -301,12 +301,12 @@ discard block |
||
301 | 301 | */ |
302 | 302 | function geodir_add_async_forscript($url) |
303 | 303 | { |
304 | - if (strpos($url, '#asyncload')===false) |
|
305 | - return $url; |
|
306 | - else if (is_admin()) |
|
307 | - return str_replace('#asyncload', '', $url); |
|
308 | - else |
|
309 | - return str_replace('#asyncload', '', $url)."' async='async"; |
|
304 | + if (strpos($url, '#asyncload')===false) |
|
305 | + return $url; |
|
306 | + else if (is_admin()) |
|
307 | + return str_replace('#asyncload', '', $url); |
|
308 | + else |
|
309 | + return str_replace('#asyncload', '', $url)."' async='async"; |
|
310 | 310 | } |
311 | 311 | add_filter('clean_url', 'geodir_add_async_forscript', 11, 1); |
312 | 312 | |
@@ -319,18 +319,18 @@ discard block |
||
319 | 319 | function geodir_templates_styles() |
320 | 320 | { |
321 | 321 | |
322 | - wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION); |
|
323 | - wp_enqueue_style('geodir-core-scss'); |
|
324 | - wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION); |
|
322 | + wp_register_style('geodir-core-scss', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend.css', array(), GEODIRECTORY_VERSION); |
|
323 | + wp_enqueue_style('geodir-core-scss'); |
|
324 | + wp_register_style('geodir-core-scss-footer', geodir_plugin_url() . '/geodirectory-assets/css/gd_core_frontend_footer.css', array(), GEODIRECTORY_VERSION); |
|
325 | 325 | |
326 | - if(is_rtl()){ |
|
327 | - wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION); |
|
328 | - wp_enqueue_style('geodirectory-frontend-rtl-style'); |
|
329 | - } |
|
326 | + if(is_rtl()){ |
|
327 | + wp_register_style('geodirectory-frontend-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl-frontend.css', array(), GEODIRECTORY_VERSION); |
|
328 | + wp_enqueue_style('geodirectory-frontend-rtl-style'); |
|
329 | + } |
|
330 | 330 | |
331 | - wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.5.0/js/all.js#faload', array('font-awesome-shim'), GEODIRECTORY_VERSION); |
|
332 | - wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.5.0/js/v4-shims.js', array(), GEODIRECTORY_VERSION); |
|
333 | - wp_enqueue_script( 'font-awesome' ); |
|
331 | + wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.5.0/js/all.js#faload', array('font-awesome-shim'), GEODIRECTORY_VERSION); |
|
332 | + wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.5.0/js/v4-shims.js', array(), GEODIRECTORY_VERSION); |
|
333 | + wp_enqueue_script( 'font-awesome' ); |
|
334 | 334 | |
335 | 335 | |
336 | 336 | } |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | */ |
345 | 345 | function geodir_get_sidebar() |
346 | 346 | { |
347 | - get_sidebar('geodirectory'); |
|
347 | + get_sidebar('geodirectory'); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -363,122 +363,122 @@ discard block |
||
363 | 363 | * @param bool $always_show Do you want to show the pagination always? Default: false. |
364 | 364 | */ |
365 | 365 | function geodir_pagination($before = '', $after = '', $prelabel = '', $nxtlabel = '', $pages_to_show = 5, $always_show = false) { |
366 | - global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id; |
|
366 | + global $wp_query, $posts_per_page, $wpdb, $paged, $blog_id; |
|
367 | 367 | |
368 | - if (empty($prelabel)) { |
|
369 | - $prelabel = '<strong><</strong>'; |
|
370 | - } |
|
368 | + if (empty($prelabel)) { |
|
369 | + $prelabel = '<strong><</strong>'; |
|
370 | + } |
|
371 | 371 | |
372 | - if (empty($nxtlabel)) { |
|
373 | - $nxtlabel = '<strong>></strong>'; |
|
374 | - } |
|
372 | + if (empty($nxtlabel)) { |
|
373 | + $nxtlabel = '<strong>></strong>'; |
|
374 | + } |
|
375 | 375 | |
376 | - $half_pages_to_show = round($pages_to_show / 2); |
|
376 | + $half_pages_to_show = round($pages_to_show / 2); |
|
377 | 377 | |
378 | - if (geodir_is_page('home')) // dont apply default pagination for geodirectory home page. |
|
379 | - return; |
|
378 | + if (geodir_is_page('home')) // dont apply default pagination for geodirectory home page. |
|
379 | + return; |
|
380 | 380 | |
381 | - if (!is_single()) { |
|
382 | - if (function_exists('geodir_location_geo_home_link')) { |
|
383 | - remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
384 | - } |
|
385 | - $numposts = $wp_query->found_posts; |
|
381 | + if (!is_single()) { |
|
382 | + if (function_exists('geodir_location_geo_home_link')) { |
|
383 | + remove_filter('home_url', 'geodir_location_geo_home_link', 100000); |
|
384 | + } |
|
385 | + $numposts = $wp_query->found_posts; |
|
386 | 386 | |
387 | - $max_page = ceil($numposts / $posts_per_page); |
|
387 | + $max_page = ceil($numposts / $posts_per_page); |
|
388 | 388 | |
389 | - if (empty($paged)) { |
|
390 | - $paged = 1; |
|
391 | - } |
|
389 | + if (empty($paged)) { |
|
390 | + $paged = 1; |
|
391 | + } |
|
392 | 392 | |
393 | - $post_type = geodir_get_current_posttype(); |
|
394 | - $listing_type_name = get_post_type_plural_label($post_type); |
|
395 | - if (geodir_is_page('listing') || geodir_is_page('search')) { |
|
396 | - $term = array(); |
|
393 | + $post_type = geodir_get_current_posttype(); |
|
394 | + $listing_type_name = get_post_type_plural_label($post_type); |
|
395 | + if (geodir_is_page('listing') || geodir_is_page('search')) { |
|
396 | + $term = array(); |
|
397 | 397 | |
398 | - if (is_tax()) { |
|
399 | - $term_id = get_queried_object_id(); |
|
400 | - $taxonomy = get_query_var('taxonomy'); |
|
398 | + if (is_tax()) { |
|
399 | + $term_id = get_queried_object_id(); |
|
400 | + $taxonomy = get_query_var('taxonomy'); |
|
401 | 401 | |
402 | - if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) { |
|
403 | - $term = get_term($term_id, $post_type . 'category'); |
|
404 | - } |
|
405 | - } |
|
402 | + if ($term_id && $post_type && get_query_var('taxonomy') == $post_type . 'category' ) { |
|
403 | + $term = get_term($term_id, $post_type . 'category'); |
|
404 | + } |
|
405 | + } |
|
406 | 406 | |
407 | - if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) { |
|
408 | - $taxonomy_search = $_REQUEST['s' . $post_type . 'category']; |
|
407 | + if (geodir_is_page('search') && !empty($_REQUEST['s' . $post_type . 'category'])) { |
|
408 | + $taxonomy_search = $_REQUEST['s' . $post_type . 'category']; |
|
409 | 409 | |
410 | - if (!is_array($taxonomy_search)) { |
|
411 | - $term = get_term((int)$taxonomy_search, $post_type . 'category'); |
|
412 | - } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search |
|
413 | - $term = get_term((int)$taxonomy_search[0], $post_type . 'category'); |
|
414 | - } |
|
415 | - } |
|
410 | + if (!is_array($taxonomy_search)) { |
|
411 | + $term = get_term((int)$taxonomy_search, $post_type . 'category'); |
|
412 | + } else if(is_array($taxonomy_search) && count($taxonomy_search) == 1) { // single category search |
|
413 | + $term = get_term((int)$taxonomy_search[0], $post_type . 'category'); |
|
414 | + } |
|
415 | + } |
|
416 | 416 | |
417 | - if (!empty($term) && !is_wp_error($term)) { |
|
418 | - $listing_type_name = $term->name; |
|
419 | - } |
|
420 | - } |
|
417 | + if (!empty($term) && !is_wp_error($term)) { |
|
418 | + $listing_type_name = $term->name; |
|
419 | + } |
|
420 | + } |
|
421 | 421 | |
422 | - if ($max_page > 1 || $always_show) { |
|
423 | - // Extra pagination info |
|
424 | - $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); |
|
425 | - $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
426 | - $end_no = min($paged * $posts_per_page, $numposts); |
|
422 | + if ($max_page > 1 || $always_show) { |
|
423 | + // Extra pagination info |
|
424 | + $geodir_pagination_more_info = get_option('geodir_pagination_advance_info'); |
|
425 | + $start_no = ( $paged - 1 ) * $posts_per_page + 1; |
|
426 | + $end_no = min($paged * $posts_per_page, $numposts); |
|
427 | 427 | |
428 | - if ($geodir_pagination_more_info != '') { |
|
429 | - if ($listing_type_name) { |
|
430 | - $listing_type_name = __($listing_type_name, 'geodirectory'); |
|
431 | - $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts); |
|
432 | - } else { |
|
433 | - $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts); |
|
434 | - } |
|
435 | - $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>'; |
|
436 | - /** |
|
437 | - * Adds an extra pagination info above/under pagination. |
|
438 | - * |
|
439 | - * @since 1.5.9 |
|
440 | - * |
|
441 | - * @param string $pagination_info Extra pagination info content. |
|
442 | - * @param string $listing_type_name Listing results type. |
|
443 | - * @param string $start_no First result number. |
|
444 | - * @param string $end_no Last result number. |
|
445 | - * @param string $numposts Total number of listings. |
|
446 | - * @param string $post_type The post type. |
|
447 | - */ |
|
448 | - $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type); |
|
428 | + if ($geodir_pagination_more_info != '') { |
|
429 | + if ($listing_type_name) { |
|
430 | + $listing_type_name = __($listing_type_name, 'geodirectory'); |
|
431 | + $pegination_desc = wp_sprintf(__('Showing %s %d-%d of %d', 'geodirectory'), $listing_type_name, $start_no, $end_no, $numposts); |
|
432 | + } else { |
|
433 | + $pegination_desc = wp_sprintf(__('Showing listings %d-%d of %d', 'geodirectory'), $start_no, $end_no, $numposts); |
|
434 | + } |
|
435 | + $pagination_info = '<div class="gd-pagination-details">' . $pegination_desc . '</div>'; |
|
436 | + /** |
|
437 | + * Adds an extra pagination info above/under pagination. |
|
438 | + * |
|
439 | + * @since 1.5.9 |
|
440 | + * |
|
441 | + * @param string $pagination_info Extra pagination info content. |
|
442 | + * @param string $listing_type_name Listing results type. |
|
443 | + * @param string $start_no First result number. |
|
444 | + * @param string $end_no Last result number. |
|
445 | + * @param string $numposts Total number of listings. |
|
446 | + * @param string $post_type The post type. |
|
447 | + */ |
|
448 | + $pagination_info = apply_filters('geodir_pagination_advance_info', $pagination_info, $listing_type_name, $start_no, $end_no, $numposts, $post_type); |
|
449 | 449 | |
450 | - if ($geodir_pagination_more_info == 'before') { |
|
451 | - $before = $before . $pagination_info; |
|
452 | - } else if ($geodir_pagination_more_info == 'after') { |
|
453 | - $after = $pagination_info . $after; |
|
454 | - } |
|
455 | - } |
|
450 | + if ($geodir_pagination_more_info == 'before') { |
|
451 | + $before = $before . $pagination_info; |
|
452 | + } else if ($geodir_pagination_more_info == 'after') { |
|
453 | + $after = $pagination_info . $after; |
|
454 | + } |
|
455 | + } |
|
456 | 456 | |
457 | - echo "$before <div class='Navi gd-navi'>"; |
|
458 | - if ($paged >= ($pages_to_show - 1)) { |
|
459 | - echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>'; |
|
460 | - } |
|
461 | - previous_posts_link($prelabel); |
|
462 | - for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { |
|
463 | - if ($i >= 1 && $i <= $max_page) { |
|
464 | - if ($i == $paged) { |
|
465 | - echo "<strong class='on'>$i</strong>"; |
|
466 | - } else { |
|
467 | - echo ' <a href="' . str_replace('&paged', '&paged', get_pagenum_link($i)) . '">' . $i . '</a> '; |
|
468 | - } |
|
469 | - } |
|
470 | - } |
|
471 | - next_posts_link($nxtlabel, $max_page); |
|
472 | - if (($paged + $half_pages_to_show) < ($max_page)) { |
|
473 | - echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link($max_page)) . '">»</a>'; |
|
474 | - } |
|
475 | - echo "</div> $after"; |
|
476 | - } |
|
457 | + echo "$before <div class='Navi gd-navi'>"; |
|
458 | + if ($paged >= ($pages_to_show - 1)) { |
|
459 | + echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link()) . '">«</a>'; |
|
460 | + } |
|
461 | + previous_posts_link($prelabel); |
|
462 | + for ($i = $paged - $half_pages_to_show; $i <= $paged + $half_pages_to_show; $i++) { |
|
463 | + if ($i >= 1 && $i <= $max_page) { |
|
464 | + if ($i == $paged) { |
|
465 | + echo "<strong class='on'>$i</strong>"; |
|
466 | + } else { |
|
467 | + echo ' <a href="' . str_replace('&paged', '&paged', get_pagenum_link($i)) . '">' . $i . '</a> '; |
|
468 | + } |
|
469 | + } |
|
470 | + } |
|
471 | + next_posts_link($nxtlabel, $max_page); |
|
472 | + if (($paged + $half_pages_to_show) < ($max_page)) { |
|
473 | + echo '<a href="' . str_replace('&paged', '&paged', get_pagenum_link($max_page)) . '">»</a>'; |
|
474 | + } |
|
475 | + echo "</div> $after"; |
|
476 | + } |
|
477 | 477 | |
478 | - if (function_exists('geodir_location_geo_home_link')) { |
|
479 | - add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
480 | - } |
|
481 | - } |
|
478 | + if (function_exists('geodir_location_geo_home_link')) { |
|
479 | + add_filter('home_url', 'geodir_location_geo_home_link', 100000, 2); |
|
480 | + } |
|
481 | + } |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | /** |
@@ -489,20 +489,20 @@ discard block |
||
489 | 489 | */ |
490 | 490 | function geodir_listingsearch_scripts() |
491 | 491 | { |
492 | - if (get_option('gd_search_dist') != '') { |
|
493 | - $dist = get_option('gd_search_dist'); |
|
494 | - } else { |
|
495 | - $dist = 500; |
|
496 | - } |
|
497 | - $dist_dif = 1000; |
|
498 | - |
|
499 | - if ($dist <= 5000) $dist_dif = 500; |
|
500 | - if ($dist <= 1000) $dist_dif = 100; |
|
501 | - if ($dist <= 500) $dist_dif = 50; |
|
502 | - if ($dist <= 100) $dist_dif = 10; |
|
503 | - if ($dist <= 50) $dist_dif = 5; |
|
504 | - |
|
505 | - ?> |
|
492 | + if (get_option('gd_search_dist') != '') { |
|
493 | + $dist = get_option('gd_search_dist'); |
|
494 | + } else { |
|
495 | + $dist = 500; |
|
496 | + } |
|
497 | + $dist_dif = 1000; |
|
498 | + |
|
499 | + if ($dist <= 5000) $dist_dif = 500; |
|
500 | + if ($dist <= 1000) $dist_dif = 100; |
|
501 | + if ($dist <= 500) $dist_dif = 50; |
|
502 | + if ($dist <= 100) $dist_dif = 10; |
|
503 | + if ($dist <= 50) $dist_dif = 5; |
|
504 | + |
|
505 | + ?> |
|
506 | 506 | <script type="text/javascript"> |
507 | 507 | |
508 | 508 | jQuery(function ($) { |
@@ -560,20 +560,20 @@ discard block |
||
560 | 560 | * @package GeoDirectory |
561 | 561 | */ |
562 | 562 | function geodir_add_sharelocation_scripts() { |
563 | - $default_search_for_text = SEARCH_FOR_TEXT; |
|
564 | - if (get_option('geodir_search_field_default_text')) |
|
565 | - $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory'); |
|
563 | + $default_search_for_text = SEARCH_FOR_TEXT; |
|
564 | + if (get_option('geodir_search_field_default_text')) |
|
565 | + $default_search_for_text = __(get_option('geodir_search_field_default_text'), 'geodirectory'); |
|
566 | 566 | |
567 | - $default_near_text = NEAR_TEXT; |
|
568 | - if (get_option('geodir_near_field_default_text')) |
|
569 | - $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory'); |
|
567 | + $default_near_text = NEAR_TEXT; |
|
568 | + if (get_option('geodir_near_field_default_text')) |
|
569 | + $default_near_text = __(get_option('geodir_near_field_default_text'), 'geodirectory'); |
|
570 | 570 | |
571 | - $search_location = geodir_get_default_location(); |
|
571 | + $search_location = geodir_get_default_location(); |
|
572 | 572 | |
573 | - $default_search_for_text = addslashes(stripslashes($default_search_for_text)); |
|
574 | - $default_near_text = addslashes(stripslashes($default_near_text)); |
|
575 | - $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : ''; |
|
576 | - ?> |
|
573 | + $default_search_for_text = addslashes(stripslashes($default_search_for_text)); |
|
574 | + $default_near_text = addslashes(stripslashes($default_near_text)); |
|
575 | + $city = !empty($search_location) ? addslashes(stripslashes($search_location->city)) : ''; |
|
576 | + ?> |
|
577 | 577 | <script type="text/javascript"> |
578 | 578 | var default_location = '<?php echo $city ;?>'; |
579 | 579 | var latlng; |
@@ -665,14 +665,14 @@ discard block |
||
665 | 665 | initialise2(); |
666 | 666 | } else { |
667 | 667 | <?php |
668 | - $near_add = get_option('geodir_search_near_addition'); |
|
669 | - /** |
|
670 | - * Adds any extra info to the near search box query when trying to geolocate it via google api. |
|
671 | - * |
|
672 | - * @since 1.0.0 |
|
673 | - */ |
|
674 | - $near_add2 = apply_filters('geodir_search_near_addition', ''); |
|
675 | - ?> |
|
668 | + $near_add = get_option('geodir_search_near_addition'); |
|
669 | + /** |
|
670 | + * Adds any extra info to the near search box query when trying to geolocate it via google api. |
|
671 | + * |
|
672 | + * @since 1.0.0 |
|
673 | + */ |
|
674 | + $near_add2 = apply_filters('geodir_search_near_addition', ''); |
|
675 | + ?> |
|
676 | 676 | if (window.gdMaps === 'google') { |
677 | 677 | Sgeocoder.geocode({'address': address<?php echo ($near_add ? '+", ' . $near_add . '"' : '') . $near_add2;?>}, |
678 | 678 | function (results, status) { |
@@ -786,32 +786,32 @@ discard block |
||
786 | 786 | */ |
787 | 787 | function geodir_show_badges_on_image($which, $post, $link) |
788 | 788 | { |
789 | - $return = ''; |
|
790 | - switch ($which) { |
|
791 | - case 'featured': |
|
792 | - /** |
|
793 | - * Filter the featured image badge html that appears in the listings pages over the thumbnail. |
|
794 | - * |
|
795 | - * @since 1.0.0 |
|
796 | - * @param object $post The post object. |
|
797 | - * @param string $link The link to the post. |
|
798 | - */ |
|
799 | - $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>',$post,$link); |
|
800 | - break; |
|
801 | - case 'new' : |
|
802 | - /** |
|
803 | - * Filter the new image badge html that appears in the listings pages over the thumbnail. |
|
804 | - * |
|
805 | - * @since 1.0.0 |
|
806 | - * @param object $post The post object. |
|
807 | - * @param string $link The link to the post. |
|
808 | - */ |
|
809 | - $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>',$post,$link); |
|
810 | - break; |
|
811 | - |
|
812 | - } |
|
789 | + $return = ''; |
|
790 | + switch ($which) { |
|
791 | + case 'featured': |
|
792 | + /** |
|
793 | + * Filter the featured image badge html that appears in the listings pages over the thumbnail. |
|
794 | + * |
|
795 | + * @since 1.0.0 |
|
796 | + * @param object $post The post object. |
|
797 | + * @param string $link The link to the post. |
|
798 | + */ |
|
799 | + $return = apply_filters('geodir_featured_badge_on_image', '<a href="' . $link . '"><span class="geodir_featured_img"> </span></a>',$post,$link); |
|
800 | + break; |
|
801 | + case 'new' : |
|
802 | + /** |
|
803 | + * Filter the new image badge html that appears in the listings pages over the thumbnail. |
|
804 | + * |
|
805 | + * @since 1.0.0 |
|
806 | + * @param object $post The post object. |
|
807 | + * @param string $link The link to the post. |
|
808 | + */ |
|
809 | + $return = apply_filters('geodir_new_badge_on_image', '<a href="' . $link . '"><span class="geodir_new_listing"> </span></a>',$post,$link); |
|
810 | + break; |
|
811 | + |
|
812 | + } |
|
813 | 813 | |
814 | - return $return; |
|
814 | + return $return; |
|
815 | 815 | } |
816 | 816 | |
817 | 817 | /** |
@@ -820,9 +820,9 @@ discard block |
||
820 | 820 | * @since 1.6.22 |
821 | 821 | */ |
822 | 822 | function geodir_fix_script_conflict() { |
823 | - if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) { |
|
824 | - wp_dequeue_script( 'flexslider' ); |
|
825 | - } |
|
823 | + if ( wp_script_is( 'flexslider', 'enqueued' ) && wp_script_is( 'geodirectory-jquery-flexslider-js', 'enqueued' ) ) { |
|
824 | + wp_dequeue_script( 'flexslider' ); |
|
825 | + } |
|
826 | 826 | } |
827 | 827 | add_action( 'wp_enqueue_scripts', 'geodir_fix_script_conflict', 100 ); |
828 | 828 | |
@@ -835,12 +835,12 @@ discard block |
||
835 | 835 | */ |
836 | 836 | function geodir_fontawesome_defer($url) |
837 | 837 | { |
838 | - if (strpos($url, '#faload')===false) |
|
839 | - return $url; |
|
840 | - else if (is_admin()) |
|
841 | - return str_replace('#faload', '', $url); |
|
842 | - else |
|
843 | - return str_replace('#faload', '', $url)."' data-search-pseudo-elements defer='defer"; |
|
838 | + if (strpos($url, '#faload')===false) |
|
839 | + return $url; |
|
840 | + else if (is_admin()) |
|
841 | + return str_replace('#faload', '', $url); |
|
842 | + else |
|
843 | + return str_replace('#faload', '', $url)."' data-search-pseudo-elements defer='defer"; |
|
844 | 844 | |
845 | 845 | |
846 | 846 | } |
@@ -850,8 +850,8 @@ discard block |
||
850 | 850 | * Dequeue our fontawesome if using BB page. |
851 | 851 | */ |
852 | 852 | function geodir_fix_beaver_builder(){ |
853 | - if(isset($_REQUEST['fl_builder'])){ |
|
854 | - wp_dequeue_script( 'font-awesome' ); |
|
855 | - } |
|
853 | + if(isset($_REQUEST['fl_builder'])){ |
|
854 | + wp_dequeue_script( 'font-awesome' ); |
|
855 | + } |
|
856 | 856 | } |
857 | 857 | add_filter('wp_print_scripts','geodir_fix_beaver_builder',100); |