@@ -13,125 +13,125 @@ discard block |
||
13 | 13 | * @package GeoDirectory |
14 | 14 | */ |
15 | 15 | function geodir_deactivation() { |
16 | - // Update installed variable |
|
17 | - update_option("geodir_installed", 0); |
|
16 | + // Update installed variable |
|
17 | + update_option("geodir_installed", 0); |
|
18 | 18 | |
19 | - // Remove rewrite rules and then recreate rewrite rules. |
|
20 | - flush_rewrite_rules(); |
|
19 | + // Remove rewrite rules and then recreate rewrite rules. |
|
20 | + flush_rewrite_rules(); |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | if (!function_exists('geodir_admin_styles')) { |
24 | - /** |
|
25 | - * Enqueue Admin Styles. |
|
26 | - * |
|
27 | - * @since 1.0.0 |
|
28 | - * @package GeoDirectory |
|
29 | - */ |
|
30 | - function geodir_admin_styles() { |
|
31 | - wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION); |
|
32 | - wp_enqueue_style('geodirectory-admin-css'); |
|
24 | + /** |
|
25 | + * Enqueue Admin Styles. |
|
26 | + * |
|
27 | + * @since 1.0.0 |
|
28 | + * @package GeoDirectory |
|
29 | + */ |
|
30 | + function geodir_admin_styles() { |
|
31 | + wp_register_style('geodirectory-admin-css', geodir_plugin_url() . '/geodirectory-assets/css/admin.css', array(), GEODIRECTORY_VERSION); |
|
32 | + wp_enqueue_style('geodirectory-admin-css'); |
|
33 | 33 | |
34 | - wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION); |
|
35 | - wp_enqueue_style('geodirectory-frontend-style'); |
|
34 | + wp_register_style('geodirectory-frontend-style', geodir_plugin_url() . '/geodirectory-assets/css/style.css', array(), GEODIRECTORY_VERSION); |
|
35 | + wp_enqueue_style('geodirectory-frontend-style'); |
|
36 | 36 | |
37 | - wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION); |
|
38 | - wp_enqueue_style('geodir-chosen-style'); |
|
37 | + wp_register_style('geodir-chosen-style', geodir_plugin_url() . '/geodirectory-assets/css/chosen.css', array(), GEODIRECTORY_VERSION); |
|
38 | + wp_enqueue_style('geodir-chosen-style'); |
|
39 | 39 | |
40 | - wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION); |
|
41 | - wp_enqueue_style('geodirectory-jquery-ui-timepicker-css'); |
|
40 | + wp_register_style('geodirectory-jquery-ui-timepicker-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery.ui.timepicker.css', array(), GEODIRECTORY_VERSION); |
|
41 | + wp_enqueue_style('geodirectory-jquery-ui-timepicker-css'); |
|
42 | 42 | |
43 | - wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION); |
|
44 | - wp_enqueue_style('geodirectory-jquery-ui-css'); |
|
43 | + wp_register_style('geodirectory-jquery-ui-css', geodir_plugin_url() . '/geodirectory-assets/css/jquery-ui.css', array(), GEODIRECTORY_VERSION); |
|
44 | + wp_enqueue_style('geodirectory-jquery-ui-css'); |
|
45 | 45 | |
46 | - wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION); |
|
47 | - wp_enqueue_style('geodirectory-custom-fields-css'); |
|
46 | + wp_register_style('geodirectory-custom-fields-css', geodir_plugin_url() . '/geodirectory-assets/css/custom_field.css', array(), GEODIRECTORY_VERSION); |
|
47 | + wp_enqueue_style('geodirectory-custom-fields-css'); |
|
48 | 48 | |
49 | - wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION); |
|
50 | - wp_enqueue_style('geodirectory-pluplodar-css'); |
|
49 | + wp_register_style('geodirectory-pluplodar-css', geodir_plugin_url() . '/geodirectory-assets/css/pluploader.css', array(), GEODIRECTORY_VERSION); |
|
50 | + wp_enqueue_style('geodirectory-pluplodar-css'); |
|
51 | 51 | |
52 | - wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION); |
|
53 | - wp_enqueue_style('geodir-rating-style'); |
|
52 | + wp_register_style('geodir-rating-style', geodir_plugin_url() . '/geodirectory-assets/css/jRating.jquery.css', array(), GEODIRECTORY_VERSION); |
|
53 | + wp_enqueue_style('geodir-rating-style'); |
|
54 | 54 | |
55 | - wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION); |
|
56 | - wp_enqueue_style('geodir-rtl-style'); |
|
57 | - } |
|
55 | + wp_register_style('geodir-rtl-style', geodir_plugin_url() . '/geodirectory-assets/css/rtl.css', array(), GEODIRECTORY_VERSION); |
|
56 | + wp_enqueue_style('geodir-rtl-style'); |
|
57 | + } |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | if (!function_exists('geodir_admin_styles_req')) { |
61 | - /** |
|
62 | - * Loads stylesheets from CDN. |
|
63 | - * |
|
64 | - * @since 1.0.0 |
|
65 | - * @package GeoDirectory |
|
66 | - */ |
|
67 | - function geodir_admin_styles_req() |
|
68 | - { |
|
61 | + /** |
|
62 | + * Loads stylesheets from CDN. |
|
63 | + * |
|
64 | + * @since 1.0.0 |
|
65 | + * @package GeoDirectory |
|
66 | + */ |
|
67 | + function geodir_admin_styles_req() |
|
68 | + { |
|
69 | 69 | |
70 | - wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION); |
|
71 | - wp_enqueue_style('font-awesome'); |
|
70 | + wp_register_style('font-awesome', '//netdna.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css', array(), GEODIRECTORY_VERSION); |
|
71 | + wp_enqueue_style('font-awesome'); |
|
72 | 72 | |
73 | - wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION); |
|
74 | - wp_enqueue_script('geodirectory-admin'); |
|
73 | + wp_register_script('geodirectory-admin', geodir_plugin_url() . '/geodirectory-assets/js/admin-req.min.js', array('jquery'), GEODIRECTORY_VERSION); |
|
74 | + wp_enqueue_script('geodirectory-admin'); |
|
75 | 75 | |
76 | - } |
|
76 | + } |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | if (!function_exists('geodir_admin_scripts')) { |
80 | - /** |
|
81 | - * Enqueue Admin Scripts. |
|
82 | - * |
|
83 | - * @since 1.0.0 |
|
84 | - * @package GeoDirectory |
|
85 | - */ |
|
86 | - function geodir_admin_scripts() |
|
87 | - { |
|
88 | - $geodir_map_name = geodir_map_name(); |
|
80 | + /** |
|
81 | + * Enqueue Admin Scripts. |
|
82 | + * |
|
83 | + * @since 1.0.0 |
|
84 | + * @package GeoDirectory |
|
85 | + */ |
|
86 | + function geodir_admin_scripts() |
|
87 | + { |
|
88 | + $geodir_map_name = geodir_map_name(); |
|
89 | 89 | |
90 | - wp_enqueue_script('jquery'); |
|
90 | + wp_enqueue_script('jquery'); |
|
91 | 91 | |
92 | - wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true); |
|
92 | + wp_enqueue_script('geodirectory-jquery-ui-timepicker-js', geodir_plugin_url() . '/geodirectory-assets/js/jquery.ui.timepicker.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), '', true); |
|
93 | 93 | |
94 | - wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION); |
|
95 | - wp_enqueue_script('chosen'); |
|
94 | + wp_register_script('chosen', geodir_plugin_url() . '/geodirectory-assets/js/chosen.jquery.js', array('jquery'), GEODIRECTORY_VERSION); |
|
95 | + wp_enqueue_script('chosen'); |
|
96 | 96 | |
97 | - wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION); |
|
98 | - wp_enqueue_script('geodirectory-choose-ajax'); |
|
97 | + wp_register_script('geodirectory-choose-ajax', geodir_plugin_url() . '/geodirectory-assets/js/ajax-chosen.js', array(), GEODIRECTORY_VERSION); |
|
98 | + wp_enqueue_script('geodirectory-choose-ajax'); |
|
99 | 99 | |
100 | - if (isset($_REQUEST['listing_type'])) { |
|
101 | - wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION); |
|
102 | - } |
|
100 | + if (isset($_REQUEST['listing_type'])) { |
|
101 | + wp_register_script('geodirectory-custom-fields-script', geodir_plugin_url() . '/geodirectory-assets/js/custom_fields.js', array(), GEODIRECTORY_VERSION); |
|
102 | + } |
|
103 | 103 | |
104 | - wp_enqueue_script('geodirectory-custom-fields-script'); |
|
105 | - $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
104 | + wp_enqueue_script('geodirectory-custom-fields-script'); |
|
105 | + $plugin_path = geodir_plugin_url() . '/geodirectory-functions/cat-meta-functions'; |
|
106 | 106 | |
107 | - wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true); |
|
107 | + wp_enqueue_script('tax-meta-clss', $plugin_path . '/js/tax-meta-clss.js', array('jquery'), null, true); |
|
108 | 108 | |
109 | - if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
110 | - $map_lang = "&language=" . geodir_get_map_default_language(); |
|
111 | - $map_key = "&key=" . geodir_get_map_api_key(); |
|
112 | - /** This filter is documented in geodirectory_template_tags.php */ |
|
113 | - $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
114 | - wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL); |
|
115 | - } |
|
109 | + if (in_array($geodir_map_name, array('auto', 'google'))) { |
|
110 | + $map_lang = "&language=" . geodir_get_map_default_language(); |
|
111 | + $map_key = "&key=" . geodir_get_map_api_key(); |
|
112 | + /** This filter is documented in geodirectory_template_tags.php */ |
|
113 | + $map_extra = apply_filters('geodir_googlemap_script_extra', ''); |
|
114 | + wp_enqueue_script('geodirectory-googlemap-script', 'https://maps.google.com/maps/api/js?' . $map_lang . $map_key . $map_extra, '', NULL); |
|
115 | + } |
|
116 | 116 | |
117 | - if ($geodir_map_name == 'osm') { |
|
118 | - // Leaflet OpenStreetMap |
|
119 | - wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
120 | - wp_enqueue_style('geodirectory-leaflet-style'); |
|
117 | + if ($geodir_map_name == 'osm') { |
|
118 | + // Leaflet OpenStreetMap |
|
119 | + wp_register_style('geodirectory-leaflet-style', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.css', array(), GEODIRECTORY_VERSION); |
|
120 | + wp_enqueue_style('geodirectory-leaflet-style'); |
|
121 | 121 | |
122 | - wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
123 | - wp_enqueue_script('geodirectory-leaflet-script'); |
|
122 | + wp_register_script('geodirectory-leaflet-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/leaflet.min.js', array(), GEODIRECTORY_VERSION); |
|
123 | + wp_enqueue_script('geodirectory-leaflet-script'); |
|
124 | 124 | |
125 | - wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION); |
|
126 | - wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
127 | - } |
|
128 | - wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
125 | + wp_register_script('geodirectory-leaflet-geo-script', geodir_plugin_url() . '/geodirectory-assets/leaflet/osm.geocode.js', array('geodirectory-leaflet-script'), GEODIRECTORY_VERSION); |
|
126 | + wp_enqueue_script('geodirectory-leaflet-geo-script'); |
|
127 | + } |
|
128 | + wp_enqueue_script( 'jquery-ui-autocomplete' ); |
|
129 | 129 | |
130 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true); |
|
131 | - wp_enqueue_script('geodirectory-goMap-script'); |
|
130 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.min.js', array(), GEODIRECTORY_VERSION,true); |
|
131 | + wp_enqueue_script('geodirectory-goMap-script'); |
|
132 | 132 | |
133 | - wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION); |
|
134 | - wp_enqueue_script('geodirectory-goMap-script'); |
|
133 | + wp_register_script('geodirectory-goMap-script', geodir_plugin_url() . '/geodirectory-assets/js/goMap.js', array(), GEODIRECTORY_VERSION); |
|
134 | + wp_enqueue_script('geodirectory-goMap-script'); |
|
135 | 135 | |
136 | 136 | // font awesome rating script |
137 | 137 | if (get_option('geodir_reviewrating_enable_font_awesome')) { |
@@ -142,167 +142,167 @@ discard block |
||
142 | 142 | wp_enqueue_script('geodir-jRating-js'); |
143 | 143 | } |
144 | 144 | |
145 | - wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION); |
|
146 | - wp_enqueue_script('geodir-on-document-load'); |
|
147 | - |
|
148 | - |
|
149 | - // SCRIPT FOR UPLOAD |
|
150 | - wp_enqueue_script('plupload-all'); |
|
151 | - wp_enqueue_script('jquery-ui-sortable'); |
|
152 | - |
|
153 | - wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION); |
|
154 | - wp_enqueue_script('geodirectory-plupload-script'); |
|
155 | - |
|
156 | - // SCRIPT FOR UPLOAD END |
|
157 | - |
|
158 | - |
|
159 | - // place js config array for plupload |
|
160 | - $plupload_init = array( |
|
161 | - 'runtimes' => 'html5,silverlight,flash,html4', |
|
162 | - 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
163 | - 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
164 | - 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
165 | - 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
166 | - 'multiple_queues' => true, |
|
167 | - 'max_file_size' => geodir_max_upload_size(), |
|
168 | - 'url' => admin_url('admin-ajax.php'), |
|
169 | - 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
170 | - 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
171 | - 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
172 | - 'multipart' => true, |
|
173 | - 'urlstream_upload' => true, |
|
174 | - 'multi_selection' => false, // will be added per uploader |
|
175 | - // additional post data to send to our ajax hook |
|
176 | - 'multipart_params' => array( |
|
177 | - '_ajax_nonce' => "", // will be added per uploader |
|
178 | - 'action' => 'plupload_action', // the ajax action name |
|
179 | - 'imgid' => 0 // will be added per uploader |
|
180 | - ) |
|
181 | - ); |
|
182 | - $base_plupload_config = json_encode($plupload_init); |
|
183 | - |
|
184 | - |
|
185 | - $thumb_img_arr = array(); |
|
186 | - |
|
187 | - if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
188 | - $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
189 | - |
|
190 | - $totImg = ''; |
|
191 | - $image_limit = ''; |
|
192 | - if (!empty($thumb_img_arr)) { |
|
193 | - $totImg = count($thumb_img_arr); |
|
194 | - } |
|
145 | + wp_register_script('geodir-on-document-load', geodir_plugin_url() . '/geodirectory-assets/js/on_document_load.min.js', array(), GEODIRECTORY_VERSION); |
|
146 | + wp_enqueue_script('geodir-on-document-load'); |
|
147 | + |
|
148 | + |
|
149 | + // SCRIPT FOR UPLOAD |
|
150 | + wp_enqueue_script('plupload-all'); |
|
151 | + wp_enqueue_script('jquery-ui-sortable'); |
|
152 | + |
|
153 | + wp_register_script('geodirectory-plupload-script', geodir_plugin_url() . '/geodirectory-assets/js/geodirectory-plupload.js', array(), GEODIRECTORY_VERSION); |
|
154 | + wp_enqueue_script('geodirectory-plupload-script'); |
|
155 | + |
|
156 | + // SCRIPT FOR UPLOAD END |
|
157 | + |
|
158 | + |
|
159 | + // place js config array for plupload |
|
160 | + $plupload_init = array( |
|
161 | + 'runtimes' => 'html5,silverlight,flash,html4', |
|
162 | + 'browse_button' => 'plupload-browse-button', // will be adjusted per uploader |
|
163 | + 'container' => 'plupload-upload-ui', // will be adjusted per uploader |
|
164 | + 'drop_element' => 'dropbox', // will be adjusted per uploader |
|
165 | + 'file_data_name' => 'async-upload', // will be adjusted per uploader |
|
166 | + 'multiple_queues' => true, |
|
167 | + 'max_file_size' => geodir_max_upload_size(), |
|
168 | + 'url' => admin_url('admin-ajax.php'), |
|
169 | + 'flash_swf_url' => includes_url('js/plupload/plupload.flash.swf'), |
|
170 | + 'silverlight_xap_url' => includes_url('js/plupload/plupload.silverlight.xap'), |
|
171 | + 'filters' => array(array('title' => __('Allowed Files', 'geodirectory'), 'extensions' => '*')), |
|
172 | + 'multipart' => true, |
|
173 | + 'urlstream_upload' => true, |
|
174 | + 'multi_selection' => false, // will be added per uploader |
|
175 | + // additional post data to send to our ajax hook |
|
176 | + 'multipart_params' => array( |
|
177 | + '_ajax_nonce' => "", // will be added per uploader |
|
178 | + 'action' => 'plupload_action', // the ajax action name |
|
179 | + 'imgid' => 0 // will be added per uploader |
|
180 | + ) |
|
181 | + ); |
|
182 | + $base_plupload_config = json_encode($plupload_init); |
|
183 | + |
|
184 | + |
|
185 | + $thumb_img_arr = array(); |
|
186 | + |
|
187 | + if (isset($_REQUEST['pid']) && $_REQUEST['pid'] != '') |
|
188 | + $thumb_img_arr = geodir_get_images($_REQUEST['pid']); |
|
189 | + |
|
190 | + $totImg = ''; |
|
191 | + $image_limit = ''; |
|
192 | + if (!empty($thumb_img_arr)) { |
|
193 | + $totImg = count($thumb_img_arr); |
|
194 | + } |
|
195 | 195 | |
196 | - $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
197 | - 'totalImg' => $totImg, |
|
198 | - 'image_limit' => $image_limit, |
|
199 | - 'upload_img_size' => geodir_max_upload_size()); |
|
196 | + $gd_plupload_init = array('base_plupload_config' => $base_plupload_config, |
|
197 | + 'totalImg' => $totImg, |
|
198 | + 'image_limit' => $image_limit, |
|
199 | + 'upload_img_size' => geodir_max_upload_size()); |
|
200 | 200 | |
201 | - wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
201 | + wp_localize_script('geodirectory-plupload-script', 'gd_plupload', $gd_plupload_init); |
|
202 | 202 | |
203 | - $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php'))); |
|
204 | - wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data); |
|
203 | + $ajax_cons_data = array('url' => __(admin_url('admin-ajax.php'))); |
|
204 | + wp_localize_script('geodirectory-custom-fields-script', 'geodir_admin_ajax', $ajax_cons_data); |
|
205 | 205 | |
206 | 206 | |
207 | - wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION); |
|
208 | - wp_enqueue_script('geodirectory-admin-script'); |
|
207 | + wp_register_script('geodirectory-admin-script', geodir_plugin_url() . '/geodirectory-assets/js/admin.js', array(), GEODIRECTORY_VERSION); |
|
208 | + wp_enqueue_script('geodirectory-admin-script'); |
|
209 | 209 | |
210 | - wp_enqueue_style('farbtastic'); |
|
211 | - wp_enqueue_script('farbtastic'); |
|
210 | + wp_enqueue_style('farbtastic'); |
|
211 | + wp_enqueue_script('farbtastic'); |
|
212 | 212 | |
213 | - $screen = get_current_screen(); |
|
214 | - if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) { |
|
215 | - wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js'); |
|
216 | - } |
|
213 | + $screen = get_current_screen(); |
|
214 | + if ($screen->base == 'post' && in_array($screen->post_type, geodir_get_posttypes())) { |
|
215 | + wp_enqueue_script('geodirectory-listing-validation-script', geodir_plugin_url() . '/geodirectory-assets/js/listing_validation_admin.js'); |
|
216 | + } |
|
217 | 217 | |
218 | - $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true'))); |
|
219 | - wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data); |
|
218 | + $ajax_cons_data = array('url' => esc_url(__(get_option('siteurl') . '?geodir_ajax=true'))); |
|
219 | + wp_localize_script('geodirectory-admin-script', 'geodir_ajax', $ajax_cons_data); |
|
220 | 220 | |
221 | - } |
|
221 | + } |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | if (!function_exists('geodir_admin_menu')) { |
225 | - /** |
|
226 | - * Admin Menus |
|
227 | - * |
|
228 | - * Sets up the admin menus in wordpress. |
|
229 | - * |
|
230 | - * @since 1.0.0 |
|
231 | - * @package GeoDirectory |
|
232 | - * @global array $menu Menu array. |
|
233 | - * @global object $geodirectory GeoDirectory plugin object. |
|
234 | - */ |
|
235 | - function geodir_admin_menu() |
|
236 | - { |
|
237 | - global $menu, $geodirectory; |
|
225 | + /** |
|
226 | + * Admin Menus |
|
227 | + * |
|
228 | + * Sets up the admin menus in wordpress. |
|
229 | + * |
|
230 | + * @since 1.0.0 |
|
231 | + * @package GeoDirectory |
|
232 | + * @global array $menu Menu array. |
|
233 | + * @global object $geodirectory GeoDirectory plugin object. |
|
234 | + */ |
|
235 | + function geodir_admin_menu() |
|
236 | + { |
|
237 | + global $menu, $geodirectory; |
|
238 | 238 | |
239 | - if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory'); |
|
239 | + if (current_user_can('manage_options')) $menu[] = array('', 'read', 'separator-geodirectory', '', 'wp-menu-separator geodirectory'); |
|
240 | 240 | |
241 | - add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984'); |
|
241 | + add_menu_page(__('Geodirectory', 'geodirectory'), __('Geodirectory', 'geodirectory'), 'manage_options', 'geodirectory', 'geodir_admin_panel', geodir_plugin_url() . '/geodirectory-assets/images/favicon.ico', '55.1984'); |
|
242 | 242 | |
243 | 243 | |
244 | - } |
|
244 | + } |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | if (!function_exists('geodir_admin_menu_order')) { |
248 | - /** |
|
249 | - * Order admin menus. |
|
250 | - * |
|
251 | - * @since 1.0.0 |
|
252 | - * @package GeoDirectory |
|
253 | - * @param array $menu_order Menu order array. |
|
254 | - * @return array Modified menu order array. |
|
255 | - */ |
|
256 | - function geodir_admin_menu_order($menu_order) |
|
257 | - { |
|
258 | - |
|
259 | - // Initialize our custom order array |
|
260 | - $geodir_menu_order = array(); |
|
261 | - |
|
262 | - // Get the index of our custom separator |
|
263 | - $geodir_separator = array_search('separator-geodirectory', $menu_order); |
|
264 | - |
|
265 | - // Get index of posttype menu |
|
266 | - $post_types = geodir_get_posttypes(); |
|
267 | - |
|
268 | - // Loop through menu order and do some rearranging |
|
269 | - foreach ($menu_order as $index => $item) : |
|
270 | - |
|
271 | - if ((('geodirectory') == $item)) : |
|
272 | - $geodir_menu_order[] = 'separator-geodirectory'; |
|
273 | - if (!empty($post_types)) { |
|
274 | - foreach ($post_types as $post_type) { |
|
275 | - $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
276 | - } |
|
277 | - } |
|
278 | - $geodir_menu_order[] = $item; |
|
248 | + /** |
|
249 | + * Order admin menus. |
|
250 | + * |
|
251 | + * @since 1.0.0 |
|
252 | + * @package GeoDirectory |
|
253 | + * @param array $menu_order Menu order array. |
|
254 | + * @return array Modified menu order array. |
|
255 | + */ |
|
256 | + function geodir_admin_menu_order($menu_order) |
|
257 | + { |
|
279 | 258 | |
280 | - unset($menu_order[$geodir_separator]); |
|
281 | - //unset( $menu_order[$geodir_places] ); |
|
282 | - elseif (!in_array($item, array('separator-geodirectory'))) : |
|
283 | - $geodir_menu_order[] = $item; |
|
284 | - endif; |
|
259 | + // Initialize our custom order array |
|
260 | + $geodir_menu_order = array(); |
|
285 | 261 | |
286 | - endforeach; |
|
262 | + // Get the index of our custom separator |
|
263 | + $geodir_separator = array_search('separator-geodirectory', $menu_order); |
|
287 | 264 | |
288 | - // Return order |
|
289 | - return $geodir_menu_order; |
|
290 | - } |
|
265 | + // Get index of posttype menu |
|
266 | + $post_types = geodir_get_posttypes(); |
|
267 | + |
|
268 | + // Loop through menu order and do some rearranging |
|
269 | + foreach ($menu_order as $index => $item) : |
|
270 | + |
|
271 | + if ((('geodirectory') == $item)) : |
|
272 | + $geodir_menu_order[] = 'separator-geodirectory'; |
|
273 | + if (!empty($post_types)) { |
|
274 | + foreach ($post_types as $post_type) { |
|
275 | + $geodir_menu_order[] = 'edit.php?post_type=' . $post_type; |
|
276 | + } |
|
277 | + } |
|
278 | + $geodir_menu_order[] = $item; |
|
279 | + |
|
280 | + unset($menu_order[$geodir_separator]); |
|
281 | + //unset( $menu_order[$geodir_places] ); |
|
282 | + elseif (!in_array($item, array('separator-geodirectory'))) : |
|
283 | + $geodir_menu_order[] = $item; |
|
284 | + endif; |
|
285 | + |
|
286 | + endforeach; |
|
287 | + |
|
288 | + // Return order |
|
289 | + return $geodir_menu_order; |
|
290 | + } |
|
291 | 291 | } |
292 | 292 | |
293 | 293 | if (!function_exists('geodir_admin_custom_menu_order')) { |
294 | - /** |
|
295 | - * Enables custom menu order. |
|
296 | - * |
|
297 | - * @since 1.0.0 |
|
298 | - * @package GeoDirectory |
|
299 | - * @return bool |
|
300 | - */ |
|
301 | - function geodir_admin_custom_menu_order() |
|
302 | - { |
|
303 | - if (!current_user_can('manage_options')) return false; |
|
304 | - return true; |
|
305 | - } |
|
294 | + /** |
|
295 | + * Enables custom menu order. |
|
296 | + * |
|
297 | + * @since 1.0.0 |
|
298 | + * @package GeoDirectory |
|
299 | + * @return bool |
|
300 | + */ |
|
301 | + function geodir_admin_custom_menu_order() |
|
302 | + { |
|
303 | + if (!current_user_can('manage_options')) return false; |
|
304 | + return true; |
|
305 | + } |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -313,51 +313,51 @@ discard block |
||
313 | 313 | */ |
314 | 314 | function geodir_before_admin_panel() |
315 | 315 | { |
316 | - if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') { |
|
317 | - echo '<div id="message" class="updated fade"> |
|
316 | + if (isset($_REQUEST['installed']) && $_REQUEST['installed'] != '') { |
|
317 | + echo '<div id="message" class="updated fade"> |
|
318 | 318 | <p style="float:right;">' . __('Like Geodirectory?', 'geodirectory') . ' <a href="http://wordpress.org/extend/plugins/Geodirectory/" target="_blank">' . __('Support us by leaving a rating!', 'geodirectory') . '</a></p> |
319 | 319 | <p><strong>' . __('Geodirectory has been installed and setup. Enjoy :)', 'geodirectory') . '</strong></p> |
320 | 320 | </div>'; |
321 | 321 | |
322 | - } |
|
322 | + } |
|
323 | 323 | |
324 | - if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') { |
|
325 | - switch ($_REQUEST['msg']) { |
|
326 | - case 'success': |
|
327 | - echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>'; |
|
328 | - flush_rewrite_rules(false); |
|
324 | + if (isset($_REQUEST['msg']) && $_REQUEST['msg'] != '') { |
|
325 | + switch ($_REQUEST['msg']) { |
|
326 | + case 'success': |
|
327 | + echo '<div id="message" class="updated fade"><p><strong>' . __('Your settings have been saved.', 'geodirectory') . '</strong></p></div>'; |
|
328 | + flush_rewrite_rules(false); |
|
329 | 329 | |
330 | - break; |
|
330 | + break; |
|
331 | 331 | case 'fail': |
332 | 332 | $gderr = isset($_REQUEST['gderr']) ? $_REQUEST['gderr'] : ''; |
333 | 333 | |
334 | 334 | if ($gderr == 21) |
335 | - echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>'; |
|
335 | + echo '<div id="message" class="error fade"><p><strong>' . __('Error: You can not add same permalinks for both Listing and Location, please try again.', 'geodirectory') . '</strong></p></div>'; |
|
336 | 336 | else |
337 | 337 | echo '<div id="message" class="error fade"><p><strong>' . __('Error: Your settings have not been saved, please try again.', 'geodirectory') . '</strong></p></div>'; |
338 | - break; |
|
339 | - } |
|
340 | - } |
|
338 | + break; |
|
339 | + } |
|
340 | + } |
|
341 | 341 | |
342 | - $geodir_load_map = get_option('geodir_load_map'); |
|
343 | - $need_map_key = false; |
|
344 | - if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){ |
|
345 | - $need_map_key = true; |
|
346 | - } |
|
342 | + $geodir_load_map = get_option('geodir_load_map'); |
|
343 | + $need_map_key = false; |
|
344 | + if($geodir_load_map=='' || $geodir_load_map=='google' || $geodir_load_map=='auto' ){ |
|
345 | + $need_map_key = true; |
|
346 | + } |
|
347 | 347 | |
348 | - if (!geodir_get_map_api_key() && $need_map_key) { |
|
349 | - echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
350 | - } |
|
348 | + if (!geodir_get_map_api_key() && $need_map_key) { |
|
349 | + echo '<div class="error"><p><strong>' . sprintf(__('Google Maps API KEY not set, %sclick here%s to set one OR use Open Street Maps instead.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=design_settings&active_tab=geodir_map_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
350 | + } |
|
351 | 351 | |
352 | - if (!geodir_is_default_location_set()) { |
|
353 | - echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
352 | + if (!geodir_is_default_location_set()) { |
|
353 | + echo '<div class="updated fade"><p><strong>' . sprintf(__('Please %sclick here%s to set a default location, this will make the plugin work properly.', 'geodirectory'), '<a href=\'' . admin_url('admin.php?page=geodirectory&tab=default_location_settings') . '\'>', '</a>') . '</strong></p></div>'; |
|
354 | 354 | |
355 | - } |
|
355 | + } |
|
356 | 356 | |
357 | - if (!function_exists('curl_init')) { |
|
358 | - echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>'; |
|
357 | + if (!function_exists('curl_init')) { |
|
358 | + echo '<div class="error"><p><strong>' . __('CURL is not installed on this server, this can cause problems, please ask your server admin to install it.', 'geodirectory') . '</strong></p></div>'; |
|
359 | 359 | |
360 | - } |
|
360 | + } |
|
361 | 361 | |
362 | 362 | |
363 | 363 | |
@@ -374,19 +374,19 @@ discard block |
||
374 | 374 | */ |
375 | 375 | function geodir_handle_option_form_submit($current_tab) |
376 | 376 | { |
377 | - global $geodir_settings; |
|
378 | - if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) { |
|
379 | - /** |
|
380 | - * Contains settings array for current tab. |
|
381 | - * |
|
382 | - * @since 1.0.0 |
|
383 | - * @package GeoDirectory |
|
384 | - */ |
|
385 | - include_once('option-pages/' . $current_tab . '_array.php'); |
|
386 | - } |
|
387 | - if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
388 | - if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
389 | - if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
377 | + global $geodir_settings; |
|
378 | + if (file_exists(dirname(__FILE__) . '/option-pages/' . $current_tab . '_array.php')) { |
|
379 | + /** |
|
380 | + * Contains settings array for current tab. |
|
381 | + * |
|
382 | + * @since 1.0.0 |
|
383 | + * @package GeoDirectory |
|
384 | + */ |
|
385 | + include_once('option-pages/' . $current_tab . '_array.php'); |
|
386 | + } |
|
387 | + if (isset($_POST) && $_POST && isset($_REQUEST['page']) && $_REQUEST['page'] == 'geodirectory') : |
|
388 | + if (!wp_verify_nonce($_REQUEST['_wpnonce'], 'geodir-settings')) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
389 | + if (!wp_verify_nonce($_REQUEST['_wpnonce-' . $current_tab], 'geodir-settings-' . $current_tab)) die(__('Action failed. Please refresh the page and retry.', 'geodirectory')); |
|
390 | 390 | |
391 | 391 | /** |
392 | 392 | * Fires before updating geodirectory admin settings. |
@@ -398,38 +398,38 @@ discard block |
||
398 | 398 | */ |
399 | 399 | do_action('geodir_before_update_options', $current_tab, $geodir_settings); |
400 | 400 | |
401 | - if (!empty($geodir_settings[$current_tab])) |
|
402 | - geodir_update_options($geodir_settings[$current_tab]); |
|
401 | + if (!empty($geodir_settings[$current_tab])) |
|
402 | + geodir_update_options($geodir_settings[$current_tab]); |
|
403 | 403 | |
404 | - /** |
|
405 | - * Called after GeoDirectory options settings are updated. |
|
406 | - * |
|
407 | - * @since 1.0.0 |
|
408 | - * @param array $geodir_settings The array of GeoDirectory settings. |
|
409 | - * @see 'geodir_before_update_options' |
|
410 | - */ |
|
411 | - do_action('geodir_update_options', $geodir_settings); |
|
404 | + /** |
|
405 | + * Called after GeoDirectory options settings are updated. |
|
406 | + * |
|
407 | + * @since 1.0.0 |
|
408 | + * @param array $geodir_settings The array of GeoDirectory settings. |
|
409 | + * @see 'geodir_before_update_options' |
|
410 | + */ |
|
411 | + do_action('geodir_update_options', $geodir_settings); |
|
412 | 412 | |
413 | - /** |
|
414 | - * Called after GeoDirectory options settings are updated. |
|
415 | - * |
|
416 | - * Provides tab specific settings. |
|
417 | - * |
|
418 | - * @since 1.0.0 |
|
419 | - * @param string $current_tab The current settings tab name. |
|
420 | - * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
421 | - */ |
|
422 | - do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]); |
|
413 | + /** |
|
414 | + * Called after GeoDirectory options settings are updated. |
|
415 | + * |
|
416 | + * Provides tab specific settings. |
|
417 | + * |
|
418 | + * @since 1.0.0 |
|
419 | + * @param string $current_tab The current settings tab name. |
|
420 | + * @param array $geodir_settings[$current_tab] The array of settings for the current settings tab. |
|
421 | + */ |
|
422 | + do_action('geodir_update_options_' . $current_tab, $geodir_settings[$current_tab]); |
|
423 | 423 | |
424 | - flush_rewrite_rules(false); |
|
424 | + flush_rewrite_rules(false); |
|
425 | 425 | |
426 | - $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
426 | + $current_tab = isset($_REQUEST['tab']) ? $_REQUEST['tab'] : ''; |
|
427 | 427 | |
428 | - $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success'); |
|
428 | + $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $_REQUEST['active_tab'] . '&msg=success'); |
|
429 | 429 | |
430 | - wp_redirect($redirect_url); |
|
431 | - exit(); |
|
432 | - endif; |
|
430 | + wp_redirect($redirect_url); |
|
431 | + exit(); |
|
432 | + endif; |
|
433 | 433 | |
434 | 434 | |
435 | 435 | } |
@@ -447,144 +447,144 @@ discard block |
||
447 | 447 | * @return bool Returns true if saved. |
448 | 448 | */ |
449 | 449 | function geodir_update_options($options, $dummy = false) { |
450 | - if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
450 | + if ((!isset($_POST) || !$_POST) && !$dummy) return false; |
|
451 | 451 | |
452 | - foreach ($options as $value) { |
|
453 | - if ($dummy && isset($value['std'])) |
|
454 | - $_POST[$value['id']] = $value['std']; |
|
452 | + foreach ($options as $value) { |
|
453 | + if ($dummy && isset($value['std'])) |
|
454 | + $_POST[$value['id']] = $value['std']; |
|
455 | 455 | |
456 | 456 | |
457 | - if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
457 | + if (isset($value['type']) && $value['type'] == 'checkbox') : |
|
458 | 458 | |
459 | - if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
460 | - update_option($value['id'], $_POST[$value['id']]); |
|
461 | - } else { |
|
462 | - update_option($value['id'], 0); |
|
463 | - } |
|
459 | + if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
460 | + update_option($value['id'], $_POST[$value['id']]); |
|
461 | + } else { |
|
462 | + update_option($value['id'], 0); |
|
463 | + } |
|
464 | 464 | |
465 | - elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
465 | + elseif (isset($value['type']) && $value['type'] == 'image_width') : |
|
466 | 466 | |
467 | - if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) { |
|
468 | - update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
469 | - update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
470 | - if (isset($_POST[$value['id'] . '_crop'])) : |
|
471 | - update_option($value['id'] . '_crop', 1); |
|
472 | - else : |
|
473 | - update_option($value['id'] . '_crop', 0); |
|
474 | - endif; |
|
475 | - } else { |
|
476 | - update_option($value['id'] . '_width', $value['std']); |
|
477 | - update_option($value['id'] . '_height', $value['std']); |
|
478 | - update_option($value['id'] . '_crop', 1); |
|
479 | - } |
|
467 | + if (isset($value['id']) && isset($_POST[$value['id'] . '_width'])) { |
|
468 | + update_option($value['id'] . '_width', $_POST[$value['id'] . '_width']); |
|
469 | + update_option($value['id'] . '_height', $_POST[$value['id'] . '_height']); |
|
470 | + if (isset($_POST[$value['id'] . '_crop'])) : |
|
471 | + update_option($value['id'] . '_crop', 1); |
|
472 | + else : |
|
473 | + update_option($value['id'] . '_crop', 0); |
|
474 | + endif; |
|
475 | + } else { |
|
476 | + update_option($value['id'] . '_width', $value['std']); |
|
477 | + update_option($value['id'] . '_height', $value['std']); |
|
478 | + update_option($value['id'] . '_crop', 1); |
|
479 | + } |
|
480 | 480 | |
481 | - elseif (isset($value['type']) && $value['type'] == 'map') : |
|
482 | - $post_types = array(); |
|
483 | - $categories = array(); |
|
481 | + elseif (isset($value['type']) && $value['type'] == 'map') : |
|
482 | + $post_types = array(); |
|
483 | + $categories = array(); |
|
484 | 484 | |
485 | - if (!empty($_POST['home_map_post_types'])) : |
|
486 | - foreach ($_POST['home_map_post_types'] as $post_type) : |
|
487 | - $post_types[] = $post_type; |
|
488 | - endforeach; |
|
489 | - endif; |
|
485 | + if (!empty($_POST['home_map_post_types'])) : |
|
486 | + foreach ($_POST['home_map_post_types'] as $post_type) : |
|
487 | + $post_types[] = $post_type; |
|
488 | + endforeach; |
|
489 | + endif; |
|
490 | 490 | |
491 | - update_option('geodir_exclude_post_type_on_map', $post_types); |
|
491 | + update_option('geodir_exclude_post_type_on_map', $post_types); |
|
492 | 492 | |
493 | - if (!empty($_POST['post_category'])) : |
|
494 | - foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
495 | - $categories[$texonomy] = array(); |
|
496 | - foreach ($cat_arr as $category) : |
|
497 | - $categories[$texonomy][] = $category; |
|
498 | - endforeach; |
|
499 | - $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
500 | - endforeach; |
|
501 | - endif; |
|
502 | - update_option('geodir_exclude_cat_on_map', $categories); |
|
503 | - update_option('geodir_exclude_cat_on_map_upgrade', 1); |
|
504 | - elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
493 | + if (!empty($_POST['post_category'])) : |
|
494 | + foreach ($_POST['post_category'] as $texonomy => $cat_arr) : |
|
495 | + $categories[$texonomy] = array(); |
|
496 | + foreach ($cat_arr as $category) : |
|
497 | + $categories[$texonomy][] = $category; |
|
498 | + endforeach; |
|
499 | + $categories[$texonomy] = !empty($categories[$texonomy]) ? array_unique($categories[$texonomy]) : array(); |
|
500 | + endforeach; |
|
501 | + endif; |
|
502 | + update_option('geodir_exclude_cat_on_map', $categories); |
|
503 | + update_option('geodir_exclude_cat_on_map_upgrade', 1); |
|
504 | + elseif (isset($value['type']) && $value['type'] == 'map_default_settings') : |
|
505 | 505 | |
506 | 506 | |
507 | - if (!empty($_POST['geodir_default_map_language'])): |
|
508 | - update_option('geodir_default_map_language', $_POST['geodir_default_map_language']); |
|
509 | - endif; |
|
507 | + if (!empty($_POST['geodir_default_map_language'])): |
|
508 | + update_option('geodir_default_map_language', $_POST['geodir_default_map_language']); |
|
509 | + endif; |
|
510 | 510 | |
511 | 511 | |
512 | - if (!empty($_POST['geodir_default_map_search_pt'])): |
|
513 | - update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']); |
|
514 | - endif; |
|
512 | + if (!empty($_POST['geodir_default_map_search_pt'])): |
|
513 | + update_option('geodir_default_map_search_pt', $_POST['geodir_default_map_search_pt']); |
|
514 | + endif; |
|
515 | 515 | |
516 | 516 | |
517 | - elseif (isset($value['type']) && $value['type'] == 'file') : |
|
517 | + elseif (isset($value['type']) && $value['type'] == 'file') : |
|
518 | 518 | |
519 | 519 | |
520 | - if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file |
|
520 | + if (isset($_POST[$value['id'] . '_remove']) && $_POST[$value['id'] . '_remove']) {// if remove is set then remove the file |
|
521 | 521 | |
522 | - if (get_option($value['id'])) { |
|
523 | - $image_name_arr = explode('/', get_option($value['id'])); |
|
524 | - $noimg_name = end($image_name_arr); |
|
525 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
526 | - if (file_exists($img_path)) |
|
527 | - unlink($img_path); |
|
528 | - } |
|
522 | + if (get_option($value['id'])) { |
|
523 | + $image_name_arr = explode('/', get_option($value['id'])); |
|
524 | + $noimg_name = end($image_name_arr); |
|
525 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
526 | + if (file_exists($img_path)) |
|
527 | + unlink($img_path); |
|
528 | + } |
|
529 | 529 | |
530 | - update_option($value['id'], ''); |
|
531 | - } |
|
530 | + update_option($value['id'], ''); |
|
531 | + } |
|
532 | 532 | |
533 | - $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
534 | - $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
535 | - |
|
536 | - if (!empty($filename)): |
|
537 | - $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
538 | - $uplaods = array(); |
|
539 | - |
|
540 | - foreach ($uploadedfile as $key => $uplaod): |
|
541 | - if ($key == 'name'): |
|
542 | - $uplaods[$key] = $filename; |
|
543 | - else : |
|
544 | - $uplaods[$key] = $uplaod; |
|
545 | - endif; |
|
546 | - endforeach; |
|
547 | - |
|
548 | - $uploads = wp_upload_dir(); |
|
549 | - |
|
550 | - if (get_option($value['id'])) { |
|
551 | - $image_name_arr = explode('/', get_option($value['id'])); |
|
552 | - $noimg_name = end($image_name_arr); |
|
553 | - $img_path = $uploads['path'] . '/' . $noimg_name; |
|
554 | - if (file_exists($img_path)) |
|
555 | - unlink($img_path); |
|
556 | - } |
|
533 | + $uploadedfile = isset($_FILES[$value['id']]) ? $_FILES[$value['id']] : ''; |
|
534 | + $filename = isset($_FILES[$value['id']]['name']) ? $_FILES[$value['id']]['name'] : ''; |
|
535 | + |
|
536 | + if (!empty($filename)): |
|
537 | + $ext = pathinfo($filename, PATHINFO_EXTENSION); |
|
538 | + $uplaods = array(); |
|
539 | + |
|
540 | + foreach ($uploadedfile as $key => $uplaod): |
|
541 | + if ($key == 'name'): |
|
542 | + $uplaods[$key] = $filename; |
|
543 | + else : |
|
544 | + $uplaods[$key] = $uplaod; |
|
545 | + endif; |
|
546 | + endforeach; |
|
547 | + |
|
548 | + $uploads = wp_upload_dir(); |
|
549 | + |
|
550 | + if (get_option($value['id'])) { |
|
551 | + $image_name_arr = explode('/', get_option($value['id'])); |
|
552 | + $noimg_name = end($image_name_arr); |
|
553 | + $img_path = $uploads['path'] . '/' . $noimg_name; |
|
554 | + if (file_exists($img_path)) |
|
555 | + unlink($img_path); |
|
556 | + } |
|
557 | 557 | |
558 | - $upload_overrides = array('test_form' => false); |
|
559 | - $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
558 | + $upload_overrides = array('test_form' => false); |
|
559 | + $movefile = wp_handle_upload($uplaods, $upload_overrides); |
|
560 | 560 | |
561 | - update_option($value['id'], $movefile['url']); |
|
561 | + update_option($value['id'], $movefile['url']); |
|
562 | 562 | |
563 | - endif; |
|
563 | + endif; |
|
564 | 564 | |
565 | - if (!get_option($value['id']) && isset($value['value'])): |
|
566 | - update_option($value['id'], $value['value']); |
|
567 | - endif; |
|
565 | + if (!get_option($value['id']) && isset($value['value'])): |
|
566 | + update_option($value['id'], $value['value']); |
|
567 | + endif; |
|
568 | 568 | |
569 | 569 | |
570 | - else : |
|
571 | - // same menu setting per theme. |
|
572 | - if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) { |
|
573 | - $theme = wp_get_theme(); |
|
574 | - update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]); |
|
575 | - } |
|
570 | + else : |
|
571 | + // same menu setting per theme. |
|
572 | + if (isset($value['id']) && $value['id'] == 'geodir_theme_location_nav' && isset($_POST[$value['id']])) { |
|
573 | + $theme = wp_get_theme(); |
|
574 | + update_option('geodir_theme_location_nav_' . $theme->name, $_POST[$value['id']]); |
|
575 | + } |
|
576 | 576 | |
577 | - if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
578 | - update_option($value['id'], $_POST[$value['id']]); |
|
579 | - } else { |
|
580 | - delete_option($value['id']); |
|
581 | - } |
|
577 | + if (isset($value['id']) && isset($_POST[$value['id']])) { |
|
578 | + update_option($value['id'], $_POST[$value['id']]); |
|
579 | + } else { |
|
580 | + delete_option($value['id']); |
|
581 | + } |
|
582 | 582 | |
583 | - endif; |
|
584 | - } |
|
585 | - if ($dummy) |
|
586 | - $_POST = array(); |
|
587 | - return true; |
|
583 | + endif; |
|
584 | + } |
|
585 | + if ($dummy) |
|
586 | + $_POST = array(); |
|
587 | + return true; |
|
588 | 588 | |
589 | 589 | } |
590 | 590 | |
@@ -633,33 +633,33 @@ discard block |
||
633 | 633 | function places_custom_fields_tab($tabs) |
634 | 634 | { |
635 | 635 | |
636 | - $geodir_post_types = get_option('geodir_post_types'); |
|
636 | + $geodir_post_types = get_option('geodir_post_types'); |
|
637 | 637 | |
638 | - if (!empty($geodir_post_types)) { |
|
638 | + if (!empty($geodir_post_types)) { |
|
639 | 639 | |
640 | - foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
640 | + foreach ($geodir_post_types as $geodir_post_type => $geodir_posttype_info): |
|
641 | 641 | |
642 | - $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
642 | + $listing_slug = $geodir_posttype_info['labels']['singular_name']; |
|
643 | 643 | |
644 | - $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
645 | - 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
646 | - 'subtabs' => array( |
|
647 | - array('subtab' => 'custom_fields', |
|
648 | - 'label' => __('Custom Fields', 'geodirectory'), |
|
649 | - 'request' => array('listing_type' => $geodir_post_type)), |
|
650 | - array('subtab' => 'sorting_options', |
|
651 | - 'label' => __('Sorting Options', 'geodirectory'), |
|
652 | - 'request' => array('listing_type' => $geodir_post_type)), |
|
653 | - ), |
|
654 | - 'tab_index' => 9, |
|
655 | - 'request' => array('listing_type' => $geodir_post_type) |
|
656 | - ); |
|
644 | + $tabs[$geodir_post_type . '_fields_settings'] = array( |
|
645 | + 'label' => __(ucfirst($listing_slug) . ' Settings', 'geodirectory'), |
|
646 | + 'subtabs' => array( |
|
647 | + array('subtab' => 'custom_fields', |
|
648 | + 'label' => __('Custom Fields', 'geodirectory'), |
|
649 | + 'request' => array('listing_type' => $geodir_post_type)), |
|
650 | + array('subtab' => 'sorting_options', |
|
651 | + 'label' => __('Sorting Options', 'geodirectory'), |
|
652 | + 'request' => array('listing_type' => $geodir_post_type)), |
|
653 | + ), |
|
654 | + 'tab_index' => 9, |
|
655 | + 'request' => array('listing_type' => $geodir_post_type) |
|
656 | + ); |
|
657 | 657 | |
658 | - endforeach; |
|
658 | + endforeach; |
|
659 | 659 | |
660 | - } |
|
660 | + } |
|
661 | 661 | |
662 | - return $tabs; |
|
662 | + return $tabs; |
|
663 | 663 | } |
664 | 664 | |
665 | 665 | |
@@ -675,9 +675,9 @@ discard block |
||
675 | 675 | */ |
676 | 676 | function geodir_tools_setting_tab($tabs) |
677 | 677 | { |
678 | - wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
679 | - $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory')); |
|
680 | - return $tabs; |
|
678 | + wp_enqueue_script( 'jquery-ui-progressbar' ); |
|
679 | + $tabs['tools_settings'] = array('label' => __('GD Tools', 'geodirectory')); |
|
680 | + return $tabs; |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -692,8 +692,8 @@ discard block |
||
692 | 692 | */ |
693 | 693 | function geodir_compatibility_setting_tab($tabs) |
694 | 694 | { |
695 | - $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory')); |
|
696 | - return $tabs; |
|
695 | + $tabs['compatibility_settings'] = array('label' => __('Theme Compatibility', 'geodirectory')); |
|
696 | + return $tabs; |
|
697 | 697 | } |
698 | 698 | |
699 | 699 | |
@@ -709,144 +709,144 @@ discard block |
||
709 | 709 | */ |
710 | 710 | function geodir_extend_geodirectory_setting_tab($tabs) |
711 | 711 | { |
712 | - $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank'); |
|
713 | - return $tabs; |
|
712 | + $tabs['extend_geodirectory_settings'] = array('label' => __('Extend Geodirectory', 'geodirectory'). ' <i class="fa fa-plug"></i>', 'url' => 'https://wpgeodirectory.com', 'target' => '_blank'); |
|
713 | + return $tabs; |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | |
717 | 717 | if (!function_exists('geodir_edit_post_columns')) { |
718 | - /** |
|
719 | - * Modify admin post listing page columns. |
|
720 | - * |
|
721 | - * @since 1.0.0 |
|
722 | - * @package GeoDirectory |
|
723 | - * @param array $columns The column array. |
|
724 | - * @return array Altered column array. |
|
725 | - */ |
|
726 | - function geodir_edit_post_columns($columns) |
|
727 | - { |
|
728 | - |
|
729 | - $new_columns = array('location' => __('Location (ID)', 'geodirectory'), |
|
730 | - 'categorys' => __('Categories', 'geodirectory')); |
|
731 | - |
|
732 | - if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist |
|
733 | - { |
|
734 | - $offset = 0; // should we prepend $array with $data? |
|
735 | - $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
736 | - } |
|
718 | + /** |
|
719 | + * Modify admin post listing page columns. |
|
720 | + * |
|
721 | + * @since 1.0.0 |
|
722 | + * @package GeoDirectory |
|
723 | + * @param array $columns The column array. |
|
724 | + * @return array Altered column array. |
|
725 | + */ |
|
726 | + function geodir_edit_post_columns($columns) |
|
727 | + { |
|
728 | + |
|
729 | + $new_columns = array('location' => __('Location (ID)', 'geodirectory'), |
|
730 | + 'categorys' => __('Categories', 'geodirectory')); |
|
737 | 731 | |
738 | - $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
732 | + if (($offset = array_search('author', array_keys($columns))) === false) // if the key doesn't exist |
|
733 | + { |
|
734 | + $offset = 0; // should we prepend $array with $data? |
|
735 | + $offset = count($columns); // or should we append $array with $data? lets pick this one... |
|
736 | + } |
|
739 | 737 | |
740 | - $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory'))); |
|
738 | + $columns = array_merge(array_slice($columns, 0, $offset), $new_columns, array_slice($columns, $offset)); |
|
741 | 739 | |
742 | - return $columns; |
|
743 | - } |
|
740 | + $columns = array_merge($columns, array('expire' => __('Expires', 'geodirectory'))); |
|
741 | + |
|
742 | + return $columns; |
|
743 | + } |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | |
747 | 747 | if (!function_exists('geodir_manage_post_columns')) { |
748 | - /** |
|
749 | - * Adds content to our custom post listing page columns. |
|
750 | - * |
|
751 | - * @since 1.0.0 |
|
752 | - * @package GeoDirectory |
|
753 | - * @global object $wpdb WordPress Database object. |
|
754 | - * @global object $post WordPress Post object. |
|
755 | - * @param string $column The column name. |
|
756 | - * @param int $post_id The post ID. |
|
757 | - */ |
|
758 | - function geodir_manage_post_columns($column, $post_id) |
|
759 | - { |
|
760 | - global $post, $wpdb; |
|
761 | - |
|
762 | - switch ($column): |
|
763 | - /* If displaying the 'city' column. */ |
|
764 | - case 'location' : |
|
765 | - $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
766 | - $location = geodir_get_location($location_id); |
|
767 | - /* If no city is found, output a default message. */ |
|
768 | - if (empty($location)) { |
|
769 | - _e('Unknown', 'geodirectory'); |
|
770 | - } else { |
|
771 | - /* If there is a city id, append 'city name' to the text string. */ |
|
772 | - $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : ''; |
|
773 | - echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
774 | - } |
|
775 | - break; |
|
776 | - |
|
777 | - /* If displaying the 'expire' column. */ |
|
778 | - case 'expire' : |
|
779 | - $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
780 | - $d1 = $expire_date; // get expire_date |
|
781 | - $d2 = date('Y-m-d'); // get current date |
|
782 | - $state = __('days left', 'geodirectory'); |
|
783 | - $date_diff_text = ''; |
|
784 | - $expire_class = 'expire_left'; |
|
785 | - if ($expire_date != 'Never') { |
|
786 | - if (strtotime($d1) < strtotime($d2)) { |
|
787 | - $state = __('days overdue', 'geodirectory'); |
|
788 | - $expire_class = 'expire_over'; |
|
789 | - } |
|
790 | - $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
791 | - $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>'; |
|
792 | - } |
|
793 | - /* If no expire_date is found, output a default message. */ |
|
794 | - if (empty($expire_date)) |
|
795 | - echo __('Unknown', 'geodirectory'); |
|
796 | - /* If there is a expire_date, append 'days left' to the text string. */ |
|
797 | - else |
|
798 | - echo $expire_date . $date_diff_text; |
|
799 | - break; |
|
800 | - |
|
801 | - /* If displaying the 'categorys' column. */ |
|
802 | - case 'categorys' : |
|
803 | - |
|
804 | - /* Get the categorys for the post. */ |
|
805 | - |
|
806 | - |
|
807 | - $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
808 | - |
|
809 | - /* If terms were found. */ |
|
810 | - if (!empty($terms)) { |
|
811 | - $out = array(); |
|
812 | - /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
813 | - foreach ($terms as $term) { |
|
814 | - if (!strstr($term->taxonomy, 'tag')) { |
|
815 | - $out[] = sprintf('<a href="%s">%s</a>', |
|
816 | - esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')), |
|
817 | - esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display')) |
|
818 | - ); |
|
819 | - } |
|
820 | - } |
|
821 | - /* Join the terms, separating them with a comma. */ |
|
822 | - echo(join(', ', $out)); |
|
823 | - } /* If no terms were found, output a default message. */ |
|
824 | - else { |
|
825 | - _e('No Categories', 'geodirectory'); |
|
826 | - } |
|
827 | - break; |
|
748 | + /** |
|
749 | + * Adds content to our custom post listing page columns. |
|
750 | + * |
|
751 | + * @since 1.0.0 |
|
752 | + * @package GeoDirectory |
|
753 | + * @global object $wpdb WordPress Database object. |
|
754 | + * @global object $post WordPress Post object. |
|
755 | + * @param string $column The column name. |
|
756 | + * @param int $post_id The post ID. |
|
757 | + */ |
|
758 | + function geodir_manage_post_columns($column, $post_id) |
|
759 | + { |
|
760 | + global $post, $wpdb; |
|
761 | + |
|
762 | + switch ($column): |
|
763 | + /* If displaying the 'city' column. */ |
|
764 | + case 'location' : |
|
765 | + $location_id = geodir_get_post_meta($post->ID, 'post_location_id', true); |
|
766 | + $location = geodir_get_location($location_id); |
|
767 | + /* If no city is found, output a default message. */ |
|
768 | + if (empty($location)) { |
|
769 | + _e('Unknown', 'geodirectory'); |
|
770 | + } else { |
|
771 | + /* If there is a city id, append 'city name' to the text string. */ |
|
772 | + $add_location_id = $location_id > 0 ? ' (' . $location_id . ')' : ''; |
|
773 | + echo(__($location->country, 'geodirectory') . '-' . $location->region . '-' . $location->city . $add_location_id); |
|
774 | + } |
|
775 | + break; |
|
776 | + |
|
777 | + /* If displaying the 'expire' column. */ |
|
778 | + case 'expire' : |
|
779 | + $expire_date = geodir_get_post_meta($post->ID, 'expire_date', true); |
|
780 | + $d1 = $expire_date; // get expire_date |
|
781 | + $d2 = date('Y-m-d'); // get current date |
|
782 | + $state = __('days left', 'geodirectory'); |
|
783 | + $date_diff_text = ''; |
|
784 | + $expire_class = 'expire_left'; |
|
785 | + if ($expire_date != 'Never') { |
|
786 | + if (strtotime($d1) < strtotime($d2)) { |
|
787 | + $state = __('days overdue', 'geodirectory'); |
|
788 | + $expire_class = 'expire_over'; |
|
789 | + } |
|
790 | + $date_diff = round(abs(strtotime($d1) - strtotime($d2)) / 86400); // get the difference in days |
|
791 | + $date_diff_text = '<br /><span class="' . $expire_class . '">(' . $date_diff . ' ' . $state . ')</span>'; |
|
792 | + } |
|
793 | + /* If no expire_date is found, output a default message. */ |
|
794 | + if (empty($expire_date)) |
|
795 | + echo __('Unknown', 'geodirectory'); |
|
796 | + /* If there is a expire_date, append 'days left' to the text string. */ |
|
797 | + else |
|
798 | + echo $expire_date . $date_diff_text; |
|
799 | + break; |
|
828 | 800 | |
829 | - endswitch; |
|
830 | - } |
|
801 | + /* If displaying the 'categorys' column. */ |
|
802 | + case 'categorys' : |
|
803 | + |
|
804 | + /* Get the categorys for the post. */ |
|
805 | + |
|
806 | + |
|
807 | + $terms = wp_get_object_terms($post_id, get_object_taxonomies($post)); |
|
808 | + |
|
809 | + /* If terms were found. */ |
|
810 | + if (!empty($terms)) { |
|
811 | + $out = array(); |
|
812 | + /* Loop through each term, linking to the 'edit posts' page for the specific term. */ |
|
813 | + foreach ($terms as $term) { |
|
814 | + if (!strstr($term->taxonomy, 'tag')) { |
|
815 | + $out[] = sprintf('<a href="%s">%s</a>', |
|
816 | + esc_url(add_query_arg(array('post_type' => $post->post_type, $term->taxonomy => $term->slug), 'edit.php')), |
|
817 | + esc_html(sanitize_term_field('name', $term->name, $term->term_id, $term->taxonomy, 'display')) |
|
818 | + ); |
|
819 | + } |
|
820 | + } |
|
821 | + /* Join the terms, separating them with a comma. */ |
|
822 | + echo(join(', ', $out)); |
|
823 | + } /* If no terms were found, output a default message. */ |
|
824 | + else { |
|
825 | + _e('No Categories', 'geodirectory'); |
|
826 | + } |
|
827 | + break; |
|
828 | + |
|
829 | + endswitch; |
|
830 | + } |
|
831 | 831 | } |
832 | 832 | |
833 | 833 | |
834 | 834 | if (!function_exists('geodir_post_sortable_columns')) { |
835 | - /** |
|
836 | - * Makes admin post listing page columns sortable. |
|
837 | - * |
|
838 | - * @since 1.0.0 |
|
839 | - * @package GeoDirectory |
|
840 | - * @param array $columns The column array. |
|
841 | - * @return array Altered column array. |
|
842 | - */ |
|
843 | - function geodir_post_sortable_columns($columns) |
|
844 | - { |
|
845 | - |
|
846 | - $columns['expire'] = 'expire'; |
|
847 | - |
|
848 | - return $columns; |
|
849 | - } |
|
835 | + /** |
|
836 | + * Makes admin post listing page columns sortable. |
|
837 | + * |
|
838 | + * @since 1.0.0 |
|
839 | + * @package GeoDirectory |
|
840 | + * @param array $columns The column array. |
|
841 | + * @return array Altered column array. |
|
842 | + */ |
|
843 | + function geodir_post_sortable_columns($columns) |
|
844 | + { |
|
845 | + |
|
846 | + $columns['expire'] = 'expire'; |
|
847 | + |
|
848 | + return $columns; |
|
849 | + } |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | /** |
@@ -860,32 +860,32 @@ discard block |
||
860 | 860 | * @param int $post_id The post ID. |
861 | 861 | */ |
862 | 862 | function geodir_post_information_save($post_id, $post) { |
863 | - global $wpdb, $current_user; |
|
863 | + global $wpdb, $current_user; |
|
864 | 864 | |
865 | - if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) { |
|
866 | - return; |
|
867 | - } |
|
865 | + if (isset($post->post_type) && ($post->post_type=='nav_menu_item' || $post->post_type=='page' || $post->post_type=='post')) { |
|
866 | + return; |
|
867 | + } |
|
868 | 868 | |
869 | - $geodir_posttypes = geodir_get_posttypes(); |
|
869 | + $geodir_posttypes = geodir_get_posttypes(); |
|
870 | 870 | |
871 | - if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
872 | - return; |
|
871 | + if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) |
|
872 | + return; |
|
873 | 873 | |
874 | - if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) { |
|
875 | - if (isset($_REQUEST['_status'])) |
|
876 | - geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
874 | + if (!wp_is_post_revision($post_id) && isset($post->post_type) && in_array($post->post_type, $geodir_posttypes)) { |
|
875 | + if (isset($_REQUEST['_status'])) |
|
876 | + geodir_change_post_status($post_id, $_REQUEST['_status']); |
|
877 | 877 | |
878 | - if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
879 | - return; |
|
878 | + if (isset($_REQUEST['action']) && ($_REQUEST['action'] == 'trash' || $_REQUEST['action'] == 'untrash')) |
|
879 | + return; |
|
880 | 880 | |
881 | - if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
882 | - return; |
|
881 | + if (!isset($_POST['geodir_post_info_noncename']) || !wp_verify_nonce($_POST['geodir_post_info_noncename'], plugin_basename(__FILE__))) |
|
882 | + return; |
|
883 | 883 | |
884 | - if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
885 | - return; |
|
884 | + if (!isset($_POST['geodir_post_attachments_noncename']) || !wp_verify_nonce($_POST['geodir_post_attachments_noncename'], plugin_basename(__FILE__))) |
|
885 | + return; |
|
886 | 886 | |
887 | - geodir_save_listing($_REQUEST); |
|
888 | - } |
|
887 | + geodir_save_listing($_REQUEST); |
|
888 | + } |
|
889 | 889 | } |
890 | 890 | |
891 | 891 | /** |
@@ -901,102 +901,102 @@ discard block |
||
901 | 901 | */ |
902 | 902 | function geodir_admin_fields($options) |
903 | 903 | { |
904 | - global $geodirectory; |
|
905 | - |
|
906 | - $first_title = true; |
|
907 | - $tab_id = ''; |
|
908 | - $i = 0; |
|
909 | - foreach ($options as $value) : |
|
910 | - if (!isset($value['name'])) $value['name'] = ''; |
|
911 | - if (!isset($value['class'])) $value['class'] = ''; |
|
912 | - if (!isset($value['css'])) $value['css'] = ''; |
|
913 | - if (!isset($value['std'])) $value['std'] = ''; |
|
914 | - $desc = ''; |
|
915 | - switch ($value['type']) : |
|
916 | - case 'dummy_installer': |
|
917 | - $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
918 | - geodir_autoinstall_admin_header($post_type); |
|
919 | - break; |
|
920 | - case 'title': |
|
921 | - |
|
922 | - if ($i == 0) { |
|
923 | - echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
924 | - echo '<div class="inner_content_tab_main">'; |
|
925 | - } |
|
904 | + global $geodirectory; |
|
905 | + |
|
906 | + $first_title = true; |
|
907 | + $tab_id = ''; |
|
908 | + $i = 0; |
|
909 | + foreach ($options as $value) : |
|
910 | + if (!isset($value['name'])) $value['name'] = ''; |
|
911 | + if (!isset($value['class'])) $value['class'] = ''; |
|
912 | + if (!isset($value['css'])) $value['css'] = ''; |
|
913 | + if (!isset($value['std'])) $value['std'] = ''; |
|
914 | + $desc = ''; |
|
915 | + switch ($value['type']) : |
|
916 | + case 'dummy_installer': |
|
917 | + $post_type = isset($value['post_type']) ? $value['post_type'] : 'gd_place'; |
|
918 | + geodir_autoinstall_admin_header($post_type); |
|
919 | + break; |
|
920 | + case 'title': |
|
921 | + |
|
922 | + if ($i == 0) { |
|
923 | + echo '<dl id="geodir_oiption_tabs" class="gd-tab-head"></dl>'; |
|
924 | + echo '<div class="inner_content_tab_main">'; |
|
925 | + } |
|
926 | 926 | |
927 | - $i++; |
|
927 | + $i++; |
|
928 | 928 | |
929 | - if (isset($value['id']) && $value['id']) |
|
930 | - $tab_id = $value['id']; |
|
929 | + if (isset($value['id']) && $value['id']) |
|
930 | + $tab_id = $value['id']; |
|
931 | 931 | |
932 | - if (isset($value['desc']) && $value['desc']) |
|
933 | - $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
932 | + if (isset($value['desc']) && $value['desc']) |
|
933 | + $desc = '<span style=" text-transform:none;">:- ' . $value['desc'] . '</span>'; |
|
934 | 934 | |
935 | - if (isset($value['name']) && $value['name']) { |
|
936 | - if ($first_title === true) { |
|
937 | - $first_title = false; |
|
938 | - } else { |
|
939 | - echo '</div>'; |
|
940 | - } |
|
941 | - echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
935 | + if (isset($value['name']) && $value['name']) { |
|
936 | + if ($first_title === true) { |
|
937 | + $first_title = false; |
|
938 | + } else { |
|
939 | + echo '</div>'; |
|
940 | + } |
|
941 | + echo '<dd id="' . trim($tab_id) . '" class="geodir_option_tabs" ><a href="javascript:void(0);">' . $value['name'] . '</a></dd>'; |
|
942 | 942 | |
943 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
944 | - } |
|
943 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
944 | + } |
|
945 | 945 | |
946 | - /** |
|
947 | - * Called after a GeoDirectory settings title is output in the GD settings page. |
|
948 | - * |
|
949 | - * The action is called dynamically geodir_settings_$value['id']. |
|
950 | - * |
|
951 | - * @since 1.0.0 |
|
952 | - */ |
|
953 | - do_action('geodir_settings_' . sanitize_title($value['id'])); |
|
954 | - break; |
|
955 | - |
|
956 | - case 'no_tabs': |
|
957 | - |
|
958 | - echo '<div class="inner_content_tab_main">'; |
|
959 | - echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
960 | - |
|
961 | - break; |
|
962 | - |
|
963 | - case 'sectionstart': |
|
964 | - if (isset($value['desc']) && $value['desc']) |
|
965 | - $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
966 | - if (isset($value['name']) && $value['name']) |
|
967 | - echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
968 | - /** |
|
969 | - * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
970 | - * |
|
971 | - * The action is called dynamically geodir_settings_$value['id']_start. |
|
972 | - * |
|
973 | - * @since 1.0.0 |
|
974 | - */ |
|
975 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start'); |
|
976 | - echo '<table class="form-table">' . "\n\n"; |
|
977 | - |
|
978 | - break; |
|
979 | - case 'sectionend': |
|
980 | - /** |
|
981 | - * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
982 | - * |
|
983 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
984 | - * |
|
985 | - * @since 1.0.0 |
|
986 | - */ |
|
987 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end'); |
|
988 | - echo '</table>'; |
|
989 | - /** |
|
990 | - * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
991 | - * |
|
992 | - * The action is called dynamically geodir_settings_$value['id']_end. |
|
993 | - * |
|
994 | - * @since 1.0.0 |
|
995 | - */ |
|
996 | - if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after'); |
|
997 | - break; |
|
998 | - case 'text': |
|
999 | - ?> |
|
946 | + /** |
|
947 | + * Called after a GeoDirectory settings title is output in the GD settings page. |
|
948 | + * |
|
949 | + * The action is called dynamically geodir_settings_$value['id']. |
|
950 | + * |
|
951 | + * @since 1.0.0 |
|
952 | + */ |
|
953 | + do_action('geodir_settings_' . sanitize_title($value['id'])); |
|
954 | + break; |
|
955 | + |
|
956 | + case 'no_tabs': |
|
957 | + |
|
958 | + echo '<div class="inner_content_tab_main">'; |
|
959 | + echo '<div id="sub_' . trim($tab_id) . '" class="gd-content-heading" style=" margin-bottom:10px;" >'; |
|
960 | + |
|
961 | + break; |
|
962 | + |
|
963 | + case 'sectionstart': |
|
964 | + if (isset($value['desc']) && $value['desc']) |
|
965 | + $desc = '<span style=" text-transform:none;"> - ' . $value['desc'] . '</span>'; |
|
966 | + if (isset($value['name']) && $value['name']) |
|
967 | + echo '<h3>' . $value['name'] . $desc . '</h3>'; |
|
968 | + /** |
|
969 | + * Called after a GeoDirectory settings sectionstart is output in the GD settings page. |
|
970 | + * |
|
971 | + * The action is called dynamically geodir_settings_$value['id']_start. |
|
972 | + * |
|
973 | + * @since 1.0.0 |
|
974 | + */ |
|
975 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_start'); |
|
976 | + echo '<table class="form-table">' . "\n\n"; |
|
977 | + |
|
978 | + break; |
|
979 | + case 'sectionend': |
|
980 | + /** |
|
981 | + * Called before a GeoDirectory settings sectionend is output in the GD settings page. |
|
982 | + * |
|
983 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
984 | + * |
|
985 | + * @since 1.0.0 |
|
986 | + */ |
|
987 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_end'); |
|
988 | + echo '</table>'; |
|
989 | + /** |
|
990 | + * Called after a GeoDirectory settings sectionend is output in the GD settings page. |
|
991 | + * |
|
992 | + * The action is called dynamically geodir_settings_$value['id']_end. |
|
993 | + * |
|
994 | + * @since 1.0.0 |
|
995 | + */ |
|
996 | + if (isset($value['id']) && $value['id']) do_action('geodir_settings_' . sanitize_title($value['id']) . '_after'); |
|
997 | + break; |
|
998 | + case 'text': |
|
999 | + ?> |
|
1000 | 1000 | <tr valign="top"> |
1001 | 1001 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1002 | 1002 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1005,15 +1005,15 @@ discard block |
||
1005 | 1005 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?> |
1006 | 1006 | style=" <?php echo esc_attr($value['css']); ?>" |
1007 | 1007 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { |
1008 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
1009 | - } else { |
|
1010 | - echo esc_attr($value['std']); |
|
1011 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1008 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
1009 | + } else { |
|
1010 | + echo esc_attr($value['std']); |
|
1011 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1012 | 1012 | </tr><?php |
1013 | - break; |
|
1013 | + break; |
|
1014 | 1014 | |
1015 | - case 'password': |
|
1016 | - ?> |
|
1015 | + case 'password': |
|
1016 | + ?> |
|
1017 | 1017 | <tr valign="top"> |
1018 | 1018 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1019 | 1019 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
@@ -1022,42 +1022,42 @@ discard block |
||
1022 | 1022 | <?php if(isset($value['placeholder'])){?>placeholder="<?php echo esc_attr($value['placeholder']); ?>"<?php }?> |
1023 | 1023 | style="<?php echo esc_attr($value['css']); ?>" |
1024 | 1024 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { |
1025 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
1026 | - } else { |
|
1027 | - echo esc_attr($value['std']); |
|
1028 | - } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1025 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
1026 | + } else { |
|
1027 | + echo esc_attr($value['std']); |
|
1028 | + } ?>"/> <span class="description"><?php echo $value['desc']; ?></span></td> |
|
1029 | 1029 | </tr><?php |
1030 | - break; |
|
1030 | + break; |
|
1031 | 1031 | |
1032 | - case 'html_content': |
|
1033 | - ?> |
|
1032 | + case 'html_content': |
|
1033 | + ?> |
|
1034 | 1034 | <tr valign="top"> |
1035 | 1035 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1036 | 1036 | <td class="forminp"><span class="description"><?php echo $value['desc']; ?></span></td> |
1037 | 1037 | </tr><?php |
1038 | - break; |
|
1038 | + break; |
|
1039 | 1039 | |
1040 | - case 'color' : |
|
1041 | - ?> |
|
1040 | + case 'color' : |
|
1041 | + ?> |
|
1042 | 1042 | <tr valign="top"> |
1043 | 1043 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1044 | 1044 | <td class="forminp"><input name="<?php echo esc_attr($value['id']); ?>" |
1045 | 1045 | id="<?php echo esc_attr($value['id']); ?>" type="text" |
1046 | 1046 | style="<?php echo esc_attr($value['css']); ?>" |
1047 | 1047 | value="<?php if (get_option($value['id']) !== false && get_option($value['id']) !== null) { |
1048 | - echo esc_attr(stripslashes(get_option($value['id']))); |
|
1049 | - } else { |
|
1050 | - echo esc_attr($value['std']); |
|
1051 | - } ?>" class="colorpick"/> <span |
|
1048 | + echo esc_attr(stripslashes(get_option($value['id']))); |
|
1049 | + } else { |
|
1050 | + echo esc_attr($value['std']); |
|
1051 | + } ?>" class="colorpick"/> <span |
|
1052 | 1052 | class="description"><?php echo $value['desc']; ?></span> |
1053 | 1053 | |
1054 | 1054 | <div id="colorPickerDiv_<?php echo esc_attr($value['id']); ?>" class="colorpickdiv" |
1055 | 1055 | style="z-index: 100;background:#eee;border:1px solid #ccc;position:absolute;display:none;"></div> |
1056 | 1056 | </td> |
1057 | 1057 | </tr><?php |
1058 | - break; |
|
1059 | - case 'image_width' : |
|
1060 | - ?> |
|
1058 | + break; |
|
1059 | + case 'image_width' : |
|
1060 | + ?> |
|
1061 | 1061 | <tr valign="top"> |
1062 | 1062 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1063 | 1063 | <td class="forminp"> |
@@ -1079,11 +1079,11 @@ discard block |
||
1079 | 1079 | |
1080 | 1080 | <span class="description"><?php echo $value['desc'] ?></span></td> |
1081 | 1081 | </tr><?php |
1082 | - break; |
|
1083 | - case 'select': |
|
1084 | - $option_value = get_option($value['id']); |
|
1085 | - $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
1086 | - ?> |
|
1082 | + break; |
|
1083 | + case 'select': |
|
1084 | + $option_value = get_option($value['id']); |
|
1085 | + $option_value = !empty($option_value) ? stripslashes_deep($option_value) : $option_value; |
|
1086 | + ?> |
|
1087 | 1087 | <tr valign="top"> |
1088 | 1088 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1089 | 1089 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1092,33 +1092,33 @@ discard block |
||
1092 | 1092 | class="<?php if (isset($value['class'])) echo $value['class']; ?>" |
1093 | 1093 | option-ajaxchosen="false"> |
1094 | 1094 | <?php |
1095 | - foreach ($value['options'] as $key => $val) { |
|
1096 | - $geodir_select_value = ''; |
|
1097 | - if ($option_value != '') { |
|
1098 | - if ($option_value != '' && $option_value == $key) |
|
1099 | - $geodir_select_value = ' selected="selected" '; |
|
1100 | - } else { |
|
1101 | - if ($value['std'] == $key) |
|
1102 | - $geodir_select_value = ' selected="selected" '; |
|
1103 | - } |
|
1104 | - ?> |
|
1095 | + foreach ($value['options'] as $key => $val) { |
|
1096 | + $geodir_select_value = ''; |
|
1097 | + if ($option_value != '') { |
|
1098 | + if ($option_value != '' && $option_value == $key) |
|
1099 | + $geodir_select_value = ' selected="selected" '; |
|
1100 | + } else { |
|
1101 | + if ($value['std'] == $key) |
|
1102 | + $geodir_select_value = ' selected="selected" '; |
|
1103 | + } |
|
1104 | + ?> |
|
1105 | 1105 | <option |
1106 | 1106 | value="<?php echo esc_attr($key); ?>" <?php echo $geodir_select_value; ?> ><?php echo ucfirst($val) ?></option> |
1107 | 1107 | <?php |
1108 | - } |
|
1109 | - ?> |
|
1108 | + } |
|
1109 | + ?> |
|
1110 | 1110 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
1111 | 1111 | </td> |
1112 | 1112 | </tr><?php |
1113 | - break; |
|
1113 | + break; |
|
1114 | 1114 | |
1115 | - case 'multiselect': |
|
1116 | - $option_values = get_option($value['id']); |
|
1117 | - if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) { |
|
1118 | - $option_values = $value['std']; |
|
1119 | - } |
|
1120 | - $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
1121 | - ?> |
|
1115 | + case 'multiselect': |
|
1116 | + $option_values = get_option($value['id']); |
|
1117 | + if ($option_values === '' && !empty($value['std']) && is_array($value['std'])) { |
|
1118 | + $option_values = $value['std']; |
|
1119 | + } |
|
1120 | + $option_values = !empty($option_values) ? stripslashes_deep($option_values) : $option_values; |
|
1121 | + ?> |
|
1122 | 1122 | <tr valign="top"> |
1123 | 1123 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1124 | 1124 | <td class="forminp"><select multiple="multiple" name="<?php echo esc_attr($value['id']); ?>[]" |
@@ -1128,25 +1128,25 @@ discard block |
||
1128 | 1128 | data-placeholder="<?php if (isset($value['placeholder_text'])) echo $value['placeholder_text'];?>" |
1129 | 1129 | option-ajaxchosen="false"> |
1130 | 1130 | <?php |
1131 | - foreach ($value['options'] as $key => $val) { |
|
1132 | - if (strpos($key, 'optgroup_start-') === 0) { |
|
1133 | - ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
1134 | - } else if (strpos($key, 'optgroup_end-') === 0) { |
|
1135 | - ?></optgroup><?php |
|
1136 | - } else { |
|
1137 | - ?> |
|
1131 | + foreach ($value['options'] as $key => $val) { |
|
1132 | + if (strpos($key, 'optgroup_start-') === 0) { |
|
1133 | + ?><optgroup label="<?php echo ucfirst($val); ?>"><?php |
|
1134 | + } else if (strpos($key, 'optgroup_end-') === 0) { |
|
1135 | + ?></optgroup><?php |
|
1136 | + } else { |
|
1137 | + ?> |
|
1138 | 1138 | <option |
1139 | 1139 | value="<?php echo esc_attr($key); ?>" <?php selected(true, (is_array($option_values) && in_array($key, $option_values)));?>><?php echo ucfirst($val) ?></option> |
1140 | 1140 | <?php |
1141 | - } |
|
1142 | - } |
|
1143 | - ?> |
|
1141 | + } |
|
1142 | + } |
|
1143 | + ?> |
|
1144 | 1144 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
1145 | 1145 | </td> |
1146 | 1146 | </tr><?php |
1147 | - break; |
|
1148 | - case 'file': |
|
1149 | - ?> |
|
1147 | + break; |
|
1148 | + case 'file': |
|
1149 | + ?> |
|
1150 | 1150 | <tr valign="top"> |
1151 | 1151 | <th scope="row" class="titledesc"><?php echo $value['name']; ?></th> |
1152 | 1152 | <td class="forminp"> |
@@ -1166,87 +1166,87 @@ discard block |
||
1166 | 1166 | <?php } ?> |
1167 | 1167 | </td> |
1168 | 1168 | </tr><?php |
1169 | - break; |
|
1170 | - case 'map_default_settings' : |
|
1171 | - ?> |
|
1169 | + break; |
|
1170 | + case 'map_default_settings' : |
|
1171 | + ?> |
|
1172 | 1172 | |
1173 | 1173 | <tr valign="top"> |
1174 | 1174 | <th class="titledesc" width="40%"><?php _e('Default map language', 'geodirectory');?></th> |
1175 | 1175 | <td width="60%"> |
1176 | 1176 | <select name="geodir_default_map_language" style="width:60%"> |
1177 | 1177 | <?php |
1178 | - $arr_map_langages = array( |
|
1179 | - 'ar' => __('ARABIC', 'geodirectory'), |
|
1180 | - 'eu' => __('BASQUE', 'geodirectory'), |
|
1181 | - 'bg' => __('BULGARIAN', 'geodirectory'), |
|
1182 | - 'bn' => __('BENGALI', 'geodirectory'), |
|
1183 | - 'ca' => __('CATALAN', 'geodirectory'), |
|
1184 | - 'cs' => __('CZECH', 'geodirectory'), |
|
1185 | - 'da' => __('DANISH', 'geodirectory'), |
|
1186 | - 'de' => __('GERMAN', 'geodirectory'), |
|
1187 | - 'el' => __('GREEK', 'geodirectory'), |
|
1188 | - 'en' => __('ENGLISH', 'geodirectory'), |
|
1189 | - 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'), |
|
1190 | - 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'), |
|
1191 | - 'es' => __('SPANISH', 'geodirectory'), |
|
1192 | - 'eu' => __('BASQUE', 'geodirectory'), |
|
1193 | - 'fa' => __('FARSI', 'geodirectory'), |
|
1194 | - 'fi' => __('FINNISH', 'geodirectory'), |
|
1195 | - 'fil' => __('FILIPINO', 'geodirectory'), |
|
1196 | - 'fr' => __('FRENCH', 'geodirectory'), |
|
1197 | - 'gl' => __('GALICIAN', 'geodirectory'), |
|
1198 | - 'gu' => __('GUJARATI', 'geodirectory'), |
|
1199 | - 'hi' => __('HINDI', 'geodirectory'), |
|
1200 | - 'hr' => __('CROATIAN', 'geodirectory'), |
|
1201 | - 'hu' => __('HUNGARIAN', 'geodirectory'), |
|
1202 | - 'id' => __('INDONESIAN', 'geodirectory'), |
|
1203 | - 'it' => __('ITALIAN', 'geodirectory'), |
|
1204 | - 'iw' => __('HEBREW', 'geodirectory'), |
|
1205 | - 'ja' => __('JAPANESE', 'geodirectory'), |
|
1206 | - 'kn' => __('KANNADA', 'geodirectory'), |
|
1207 | - 'ko' => __('KOREAN', 'geodirectory'), |
|
1208 | - 'lt' => __('LITHUANIAN', 'geodirectory'), |
|
1209 | - 'lv' => __('LATVIAN', 'geodirectory'), |
|
1210 | - 'ml' => __('MALAYALAM', 'geodirectory'), |
|
1211 | - 'mr' => __('MARATHI', 'geodirectory'), |
|
1212 | - 'nl' => __('DUTCH', 'geodirectory'), |
|
1213 | - 'no' => __('NORWEGIAN', 'geodirectory'), |
|
1214 | - 'pl' => __('POLISH', 'geodirectory'), |
|
1215 | - 'pt' => __('PORTUGUESE', 'geodirectory'), |
|
1216 | - 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'), |
|
1217 | - 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'), |
|
1218 | - 'ro' => __('ROMANIAN', 'geodirectory'), |
|
1219 | - 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1220 | - 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1221 | - 'sk' => __('SLOVAK', 'geodirectory'), |
|
1222 | - 'sl' => __('SLOVENIAN', 'geodirectory'), |
|
1223 | - 'sr' => __('SERBIAN', 'geodirectory'), |
|
1224 | - 'sv' => __(' SWEDISH', 'geodirectory'), |
|
1225 | - 'tl' => __('TAGALOG', 'geodirectory'), |
|
1226 | - 'ta' => __('TAMIL', 'geodirectory'), |
|
1227 | - 'te' => __('TELUGU', 'geodirectory'), |
|
1228 | - 'th' => __('THAI', 'geodirectory'), |
|
1229 | - 'tr' => __('TURKISH', 'geodirectory'), |
|
1230 | - 'uk' => __('UKRAINIAN', 'geodirectory'), |
|
1231 | - 'vi' => __('VIETNAMESE', 'geodirectory'), |
|
1232 | - 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'), |
|
1233 | - 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'), |
|
1234 | - ); |
|
1235 | - $geodir_default_map_language = get_option('geodir_default_map_language'); |
|
1236 | - if (empty($geodir_default_map_language)) |
|
1237 | - $geodir_default_map_language = 'en'; |
|
1238 | - foreach ($arr_map_langages as $language_key => $language_txt) { |
|
1239 | - if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
1240 | - $geodir_default_language_selected = "selected='selected'"; |
|
1241 | - else |
|
1242 | - $geodir_default_language_selected = ''; |
|
1243 | - |
|
1244 | - ?> |
|
1178 | + $arr_map_langages = array( |
|
1179 | + 'ar' => __('ARABIC', 'geodirectory'), |
|
1180 | + 'eu' => __('BASQUE', 'geodirectory'), |
|
1181 | + 'bg' => __('BULGARIAN', 'geodirectory'), |
|
1182 | + 'bn' => __('BENGALI', 'geodirectory'), |
|
1183 | + 'ca' => __('CATALAN', 'geodirectory'), |
|
1184 | + 'cs' => __('CZECH', 'geodirectory'), |
|
1185 | + 'da' => __('DANISH', 'geodirectory'), |
|
1186 | + 'de' => __('GERMAN', 'geodirectory'), |
|
1187 | + 'el' => __('GREEK', 'geodirectory'), |
|
1188 | + 'en' => __('ENGLISH', 'geodirectory'), |
|
1189 | + 'en-AU' => __('ENGLISH (AUSTRALIAN)', 'geodirectory'), |
|
1190 | + 'en-GB' => __('ENGLISH (GREAT BRITAIN)', 'geodirectory'), |
|
1191 | + 'es' => __('SPANISH', 'geodirectory'), |
|
1192 | + 'eu' => __('BASQUE', 'geodirectory'), |
|
1193 | + 'fa' => __('FARSI', 'geodirectory'), |
|
1194 | + 'fi' => __('FINNISH', 'geodirectory'), |
|
1195 | + 'fil' => __('FILIPINO', 'geodirectory'), |
|
1196 | + 'fr' => __('FRENCH', 'geodirectory'), |
|
1197 | + 'gl' => __('GALICIAN', 'geodirectory'), |
|
1198 | + 'gu' => __('GUJARATI', 'geodirectory'), |
|
1199 | + 'hi' => __('HINDI', 'geodirectory'), |
|
1200 | + 'hr' => __('CROATIAN', 'geodirectory'), |
|
1201 | + 'hu' => __('HUNGARIAN', 'geodirectory'), |
|
1202 | + 'id' => __('INDONESIAN', 'geodirectory'), |
|
1203 | + 'it' => __('ITALIAN', 'geodirectory'), |
|
1204 | + 'iw' => __('HEBREW', 'geodirectory'), |
|
1205 | + 'ja' => __('JAPANESE', 'geodirectory'), |
|
1206 | + 'kn' => __('KANNADA', 'geodirectory'), |
|
1207 | + 'ko' => __('KOREAN', 'geodirectory'), |
|
1208 | + 'lt' => __('LITHUANIAN', 'geodirectory'), |
|
1209 | + 'lv' => __('LATVIAN', 'geodirectory'), |
|
1210 | + 'ml' => __('MALAYALAM', 'geodirectory'), |
|
1211 | + 'mr' => __('MARATHI', 'geodirectory'), |
|
1212 | + 'nl' => __('DUTCH', 'geodirectory'), |
|
1213 | + 'no' => __('NORWEGIAN', 'geodirectory'), |
|
1214 | + 'pl' => __('POLISH', 'geodirectory'), |
|
1215 | + 'pt' => __('PORTUGUESE', 'geodirectory'), |
|
1216 | + 'pt-BR' => __('PORTUGUESE (BRAZIL)', 'geodirectory'), |
|
1217 | + 'pt-PT' => __('PORTUGUESE (PORTUGAL)', 'geodirectory'), |
|
1218 | + 'ro' => __('ROMANIAN', 'geodirectory'), |
|
1219 | + 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1220 | + 'ru' => __('RUSSIAN', 'geodirectory'), |
|
1221 | + 'sk' => __('SLOVAK', 'geodirectory'), |
|
1222 | + 'sl' => __('SLOVENIAN', 'geodirectory'), |
|
1223 | + 'sr' => __('SERBIAN', 'geodirectory'), |
|
1224 | + 'sv' => __(' SWEDISH', 'geodirectory'), |
|
1225 | + 'tl' => __('TAGALOG', 'geodirectory'), |
|
1226 | + 'ta' => __('TAMIL', 'geodirectory'), |
|
1227 | + 'te' => __('TELUGU', 'geodirectory'), |
|
1228 | + 'th' => __('THAI', 'geodirectory'), |
|
1229 | + 'tr' => __('TURKISH', 'geodirectory'), |
|
1230 | + 'uk' => __('UKRAINIAN', 'geodirectory'), |
|
1231 | + 'vi' => __('VIETNAMESE', 'geodirectory'), |
|
1232 | + 'zh-CN' => __('CHINESE (SIMPLIFIED)', 'geodirectory'), |
|
1233 | + 'zh-TW' => __('CHINESE (TRADITIONAL)', 'geodirectory'), |
|
1234 | + ); |
|
1235 | + $geodir_default_map_language = get_option('geodir_default_map_language'); |
|
1236 | + if (empty($geodir_default_map_language)) |
|
1237 | + $geodir_default_map_language = 'en'; |
|
1238 | + foreach ($arr_map_langages as $language_key => $language_txt) { |
|
1239 | + if (!empty($geodir_default_map_language) && $language_key == $geodir_default_map_language) |
|
1240 | + $geodir_default_language_selected = "selected='selected'"; |
|
1241 | + else |
|
1242 | + $geodir_default_language_selected = ''; |
|
1243 | + |
|
1244 | + ?> |
|
1245 | 1245 | <option |
1246 | 1246 | value="<?php echo $language_key?>" <?php echo $geodir_default_language_selected; ?>><?php echo $language_txt; ?></option> |
1247 | 1247 | |
1248 | 1248 | <?php } |
1249 | - ?> |
|
1249 | + ?> |
|
1250 | 1250 | </select> |
1251 | 1251 | </td> |
1252 | 1252 | </tr> |
@@ -1257,46 +1257,46 @@ discard block |
||
1257 | 1257 | <td width="60%"> |
1258 | 1258 | <select name="geodir_default_map_search_pt" style="width:60%"> |
1259 | 1259 | <?php |
1260 | - $post_types = geodir_get_posttypes('array'); |
|
1261 | - $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt'); |
|
1262 | - if (empty($geodir_default_map_search_pt)) |
|
1263 | - $geodir_default_map_search_pt = 'gd_place'; |
|
1264 | - if (is_array($post_types)) { |
|
1265 | - foreach ($post_types as $key => $post_types_obj) { |
|
1266 | - if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
1267 | - $geodir_search_pt_selected = "selected='selected'"; |
|
1268 | - else |
|
1269 | - $geodir_search_pt_selected = ''; |
|
1270 | - |
|
1271 | - ?> |
|
1260 | + $post_types = geodir_get_posttypes('array'); |
|
1261 | + $geodir_default_map_search_pt = get_option('geodir_default_map_search_pt'); |
|
1262 | + if (empty($geodir_default_map_search_pt)) |
|
1263 | + $geodir_default_map_search_pt = 'gd_place'; |
|
1264 | + if (is_array($post_types)) { |
|
1265 | + foreach ($post_types as $key => $post_types_obj) { |
|
1266 | + if (!empty($geodir_default_map_search_pt) && $key == $geodir_default_map_search_pt) |
|
1267 | + $geodir_search_pt_selected = "selected='selected'"; |
|
1268 | + else |
|
1269 | + $geodir_search_pt_selected = ''; |
|
1270 | + |
|
1271 | + ?> |
|
1272 | 1272 | <option |
1273 | 1273 | value="<?php echo $key?>" <?php echo $geodir_search_pt_selected; ?>><?php echo $post_types_obj['labels']['singular_name']; ?></option> |
1274 | 1274 | |
1275 | 1275 | <?php } |
1276 | 1276 | |
1277 | - } |
|
1277 | + } |
|
1278 | 1278 | |
1279 | - ?> |
|
1279 | + ?> |
|
1280 | 1280 | </select> |
1281 | 1281 | </td> |
1282 | 1282 | </tr> |
1283 | 1283 | |
1284 | 1284 | <?php |
1285 | - break; |
|
1285 | + break; |
|
1286 | 1286 | |
1287 | - case 'map': |
|
1288 | - ?> |
|
1287 | + case 'map': |
|
1288 | + ?> |
|
1289 | 1289 | <tr valign="top"> |
1290 | 1290 | <td class="forminp"> |
1291 | 1291 | <?php |
1292 | - global $post_cat, $cat_display; |
|
1293 | - $post_types = geodir_get_posttypes('object'); |
|
1294 | - $cat_display = 'checkbox'; |
|
1295 | - $gd_post_types = get_option('geodir_exclude_post_type_on_map'); |
|
1296 | - $gd_cats = get_option('geodir_exclude_cat_on_map'); |
|
1297 | - $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade'); |
|
1298 | - $count = 1; |
|
1299 | - ?> |
|
1292 | + global $post_cat, $cat_display; |
|
1293 | + $post_types = geodir_get_posttypes('object'); |
|
1294 | + $cat_display = 'checkbox'; |
|
1295 | + $gd_post_types = get_option('geodir_exclude_post_type_on_map'); |
|
1296 | + $gd_cats = get_option('geodir_exclude_cat_on_map'); |
|
1297 | + $gd_cats_upgrade = (int)get_option('geodir_exclude_cat_on_map_upgrade'); |
|
1298 | + $count = 1; |
|
1299 | + ?> |
|
1300 | 1300 | <table width="70%" class="widefat"> |
1301 | 1301 | <thead> |
1302 | 1302 | <tr> |
@@ -1305,18 +1305,18 @@ discard block |
||
1305 | 1305 | <th><b><?php echo DESIGN_POST_TYPE_CAT; ?></b></th> |
1306 | 1306 | </tr> |
1307 | 1307 | <?php |
1308 | - $gd_categs = $gd_cats; |
|
1309 | - foreach ($post_types as $key => $post_types_obj) : |
|
1310 | - $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
1311 | - $gd_taxonomy = geodir_get_taxonomies($key); |
|
1312 | - if ($gd_cats_upgrade) { |
|
1313 | - $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
1314 | - $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
1315 | - $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
1316 | - } |
|
1317 | - $post_cat = implode(',', $gd_cats); |
|
1318 | - $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
1319 | - ?> |
|
1308 | + $gd_categs = $gd_cats; |
|
1309 | + foreach ($post_types as $key => $post_types_obj) : |
|
1310 | + $checked = is_array($gd_post_types) && in_array($key, $gd_post_types) ? 'checked="checked"' : ''; |
|
1311 | + $gd_taxonomy = geodir_get_taxonomies($key); |
|
1312 | + if ($gd_cats_upgrade) { |
|
1313 | + $gd_cat_taxonomy = isset($gd_taxonomy[0]) ? $gd_taxonomy[0] : ''; |
|
1314 | + $gd_cats = isset($gd_categs[$gd_cat_taxonomy]) ? $gd_categs[$gd_cat_taxonomy] : array(); |
|
1315 | + $gd_cats = !empty($gd_cats) && is_array($gd_cats) ? array_unique($gd_cats) : array(); |
|
1316 | + } |
|
1317 | + $post_cat = implode(',', $gd_cats); |
|
1318 | + $gd_taxonomy_list = geodir_custom_taxonomy_walker($gd_taxonomy); |
|
1319 | + ?> |
|
1320 | 1320 | <tr> |
1321 | 1321 | <td valign="top" width="5%"><?php echo $count; ?></td> |
1322 | 1322 | <td valign="top" width="25%" id="td_post_types"><input type="checkbox" |
@@ -1337,19 +1337,19 @@ discard block |
||
1337 | 1337 | </td> |
1338 | 1338 | </tr> |
1339 | 1339 | <?php |
1340 | - break; |
|
1340 | + break; |
|
1341 | 1341 | |
1342 | - case 'checkbox' : |
|
1342 | + case 'checkbox' : |
|
1343 | 1343 | |
1344 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
1345 | - ?> |
|
1344 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'start')) : |
|
1345 | + ?> |
|
1346 | 1346 | <tr valign="top"> |
1347 | 1347 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1348 | 1348 | <td class="forminp"> |
1349 | 1349 | <?php |
1350 | - endif; |
|
1350 | + endif; |
|
1351 | 1351 | |
1352 | - ?> |
|
1352 | + ?> |
|
1353 | 1353 | <fieldset> |
1354 | 1354 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
1355 | 1355 | <label for="<?php echo $value['id'] ?>"> |
@@ -1359,49 +1359,49 @@ discard block |
||
1359 | 1359 | </fieldset> |
1360 | 1360 | <?php |
1361 | 1361 | |
1362 | - if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
1363 | - ?> |
|
1362 | + if (!isset($value['checkboxgroup']) || (isset($value['checkboxgroup']) && $value['checkboxgroup'] == 'end')) : |
|
1363 | + ?> |
|
1364 | 1364 | </td> |
1365 | 1365 | </tr> |
1366 | 1366 | <?php |
1367 | - endif; |
|
1367 | + endif; |
|
1368 | 1368 | |
1369 | - break; |
|
1369 | + break; |
|
1370 | 1370 | |
1371 | - case 'radio' : |
|
1371 | + case 'radio' : |
|
1372 | 1372 | |
1373 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
1374 | - ?> |
|
1373 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'start')) : |
|
1374 | + ?> |
|
1375 | 1375 | <tr valign="top"> |
1376 | 1376 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1377 | 1377 | <td class="forminp"> |
1378 | 1378 | <?php |
1379 | - endif; |
|
1379 | + endif; |
|
1380 | 1380 | |
1381 | - ?> |
|
1381 | + ?> |
|
1382 | 1382 | <fieldset> |
1383 | 1383 | <legend class="screen-reader-text"><span><?php echo $value['name'] ?></span></legend> |
1384 | 1384 | <label for="<?php echo $value['id'];?>"> |
1385 | 1385 | <input name="<?php echo esc_attr($value['id']); ?>" |
1386 | 1386 | id="<?php echo esc_attr($value['id'] . $value['value']); ?>" type="radio" |
1387 | 1387 | value="<?php echo $value['value'] ?>" <?php if (get_option($value['id']) == $value['value']) { |
1388 | - echo 'checked="checked"'; |
|
1389 | - }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> /> |
|
1388 | + echo 'checked="checked"'; |
|
1389 | + }elseif(get_option($value['id'])=='' && $value['std']==$value['value']){echo 'checked="checked"';} ?> /> |
|
1390 | 1390 | <?php echo $value['desc']; ?></label><br> |
1391 | 1391 | </fieldset> |
1392 | 1392 | <?php |
1393 | 1393 | |
1394 | - if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
1395 | - ?> |
|
1394 | + if (!isset($value['radiogroup']) || (isset($value['radiogroup']) && $value['radiogroup'] == 'end')) : |
|
1395 | + ?> |
|
1396 | 1396 | </td> |
1397 | 1397 | </tr> |
1398 | 1398 | <?php |
1399 | - endif; |
|
1399 | + endif; |
|
1400 | 1400 | |
1401 | - break; |
|
1401 | + break; |
|
1402 | 1402 | |
1403 | - case 'textarea': |
|
1404 | - ?> |
|
1403 | + case 'textarea': |
|
1404 | + ?> |
|
1405 | 1405 | <tr valign="top"> |
1406 | 1406 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1407 | 1407 | <td class="forminp"> |
@@ -1414,30 +1414,30 @@ discard block |
||
1414 | 1414 | |
1415 | 1415 | </td> |
1416 | 1416 | </tr><?php |
1417 | - break; |
|
1417 | + break; |
|
1418 | 1418 | |
1419 | - case 'editor': |
|
1420 | - ?> |
|
1419 | + case 'editor': |
|
1420 | + ?> |
|
1421 | 1421 | <tr valign="top"> |
1422 | 1422 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1423 | 1423 | <td class="forminp"><?php |
1424 | - if (get_option($value['id'])) |
|
1425 | - $content = stripslashes(get_option($value['id'])); |
|
1426 | - else |
|
1427 | - $content = $value['std']; |
|
1424 | + if (get_option($value['id'])) |
|
1425 | + $content = stripslashes(get_option($value['id'])); |
|
1426 | + else |
|
1427 | + $content = $value['std']; |
|
1428 | 1428 | |
1429 | - $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); |
|
1429 | + $editor_settings = array('media_buttons' => false, 'textarea_rows' => 10); |
|
1430 | 1430 | |
1431 | - wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
1431 | + wp_editor($content, esc_attr($value['id']), $editor_settings); |
|
1432 | 1432 | |
1433 | - ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
1433 | + ?> <span class="description"><?php echo $value['desc'] ?></span> |
|
1434 | 1434 | |
1435 | 1435 | </td> |
1436 | 1436 | </tr><?php |
1437 | - break; |
|
1437 | + break; |
|
1438 | 1438 | |
1439 | - case 'single_select_page' : |
|
1440 | - // WPML |
|
1439 | + case 'single_select_page' : |
|
1440 | + // WPML |
|
1441 | 1441 | $switch_lang = false; |
1442 | 1442 | $disabled = ''; |
1443 | 1443 | if (geodir_is_wpml() && isset($_REQUEST['tab']) && $_REQUEST['tab'] == 'permalink_settings') { |
@@ -1455,18 +1455,18 @@ discard block |
||
1455 | 1455 | // |
1456 | 1456 | $page_setting = (int)get_option($value['id']); |
1457 | 1457 | |
1458 | - $args = array('name' => $value['id'], |
|
1459 | - 'id' => $value['id'], |
|
1460 | - 'sort_column' => 'menu_order', |
|
1461 | - 'sort_order' => 'ASC', |
|
1462 | - 'show_option_none' => ' ', |
|
1463 | - 'class' => $value['class'], |
|
1464 | - 'echo' => false, |
|
1465 | - 'selected' => $page_setting); |
|
1458 | + $args = array('name' => $value['id'], |
|
1459 | + 'id' => $value['id'], |
|
1460 | + 'sort_column' => 'menu_order', |
|
1461 | + 'sort_order' => 'ASC', |
|
1462 | + 'show_option_none' => ' ', |
|
1463 | + 'class' => $value['class'], |
|
1464 | + 'echo' => false, |
|
1465 | + 'selected' => $page_setting); |
|
1466 | 1466 | |
1467 | - if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
1467 | + if (isset($value['args'])) $args = wp_parse_args($value['args'], $args); |
|
1468 | 1468 | |
1469 | - ?> |
|
1469 | + ?> |
|
1470 | 1470 | <tr valign="top" class="single_select_page"> |
1471 | 1471 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1472 | 1472 | <td class="forminp"> |
@@ -1477,17 +1477,17 @@ discard block |
||
1477 | 1477 | if ($switch_lang) { |
1478 | 1478 | $sitepress->switch_lang($switch_lang, true); |
1479 | 1479 | } |
1480 | - break; |
|
1481 | - case 'single_select_country' : |
|
1482 | - $country_setting = (string)get_option($value['id']); |
|
1483 | - if (strstr($country_setting, ':')) : |
|
1484 | - $country = current(explode(':', $country_setting)); |
|
1485 | - $state = end(explode(':', $country_setting)); |
|
1486 | - else : |
|
1487 | - $country = $country_setting; |
|
1488 | - $state = '*'; |
|
1489 | - endif; |
|
1490 | - ?> |
|
1480 | + break; |
|
1481 | + case 'single_select_country' : |
|
1482 | + $country_setting = (string)get_option($value['id']); |
|
1483 | + if (strstr($country_setting, ':')) : |
|
1484 | + $country = current(explode(':', $country_setting)); |
|
1485 | + $state = end(explode(':', $country_setting)); |
|
1486 | + else : |
|
1487 | + $country = $country_setting; |
|
1488 | + $state = '*'; |
|
1489 | + endif; |
|
1490 | + ?> |
|
1491 | 1491 | <tr valign="top"> |
1492 | 1492 | <th scope="rpw" class="titledesc"><?php echo $value['name'] ?></th> |
1493 | 1493 | <td class="forminp"><select name="<?php echo esc_attr($value['id']); ?>" |
@@ -1498,12 +1498,12 @@ discard block |
||
1498 | 1498 | </select> <span class="description"><?php echo $value['desc'] ?></span> |
1499 | 1499 | </td> |
1500 | 1500 | </tr><?php |
1501 | - break; |
|
1502 | - case 'multi_select_countries' : |
|
1503 | - $countries = $geodirectory->countries->countries; |
|
1504 | - asort($countries); |
|
1505 | - $selections = (array)get_option($value['id']); |
|
1506 | - ?> |
|
1501 | + break; |
|
1502 | + case 'multi_select_countries' : |
|
1503 | + $countries = $geodirectory->countries->countries; |
|
1504 | + asort($countries); |
|
1505 | + $selections = (array)get_option($value['id']); |
|
1506 | + ?> |
|
1507 | 1507 | <tr valign="top"> |
1508 | 1508 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1509 | 1509 | <td class="forminp"> |
@@ -1511,21 +1511,21 @@ discard block |
||
1511 | 1511 | data-placeholder="<?php _e('Choose countries…', 'geodirectory'); ?>" |
1512 | 1512 | title="Country" class="chosen_select"> |
1513 | 1513 | <?php |
1514 | - if ($countries) foreach ($countries as $key => $val) : |
|
1515 | - echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
1516 | - endforeach; |
|
1517 | - ?> |
|
1514 | + if ($countries) foreach ($countries as $key => $val) : |
|
1515 | + echo '<option value="' . $key . '" ' . selected(in_array($key, $selections), true, false) . '>' . $val . '</option>'; |
|
1516 | + endforeach; |
|
1517 | + ?> |
|
1518 | 1518 | </select> |
1519 | 1519 | </td> |
1520 | 1520 | </tr> |
1521 | 1521 | |
1522 | 1522 | <?php |
1523 | 1523 | |
1524 | - break; |
|
1524 | + break; |
|
1525 | 1525 | |
1526 | - case 'google_analytics' : |
|
1527 | - $selections = (array)get_option($value['id']); |
|
1528 | - ?> |
|
1526 | + case 'google_analytics' : |
|
1527 | + $selections = (array)get_option($value['id']); |
|
1528 | + ?> |
|
1529 | 1529 | <tr valign="top"> |
1530 | 1530 | <th scope="row" class="titledesc"><?php echo $value['name'] ?></th> |
1531 | 1531 | <td class="forminp"> |
@@ -1533,59 +1533,59 @@ discard block |
||
1533 | 1533 | |
1534 | 1534 | <?php |
1535 | 1535 | |
1536 | - $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
1537 | - $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
1538 | - $state = "&state=123";//any string |
|
1539 | - $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
1540 | - $response_type = "&response_type=code"; |
|
1541 | - $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
1542 | - $access_type = "&access_type=offline"; |
|
1543 | - $approval_prompt = "&approval_prompt=force"; |
|
1536 | + $oAuthURL = "https://accounts.google.com/o/oauth2/auth?"; |
|
1537 | + $scope = "scope=https://www.googleapis.com/auth/analytics.readonly"; |
|
1538 | + $state = "&state=123";//any string |
|
1539 | + $redirect_uri = "&redirect_uri=" . admin_url('admin-ajax.php') . "?action=geodir_ga_callback"; |
|
1540 | + $response_type = "&response_type=code"; |
|
1541 | + $client_id = "&client_id=".get_option('geodir_ga_client_id'); |
|
1542 | + $access_type = "&access_type=offline"; |
|
1543 | + $approval_prompt = "&approval_prompt=force"; |
|
1544 | 1544 | |
1545 | - $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
1545 | + $auth_url = $oAuthURL . $scope . $state . $redirect_uri . $response_type . $client_id . $access_type . $approval_prompt; |
|
1546 | 1546 | |
1547 | 1547 | |
1548 | - if (get_option('geodir_ga_auth_token')) { |
|
1549 | - ?> |
|
1548 | + if (get_option('geodir_ga_auth_token')) { |
|
1549 | + ?> |
|
1550 | 1550 | <span class="button-primary" |
1551 | 1551 | onclick="window.open('<?php echo geodir_ga_activation_url();?>', 'activate','width=700, height=600, menubar=0, status=0, location=0, toolbar=0')"><?php _e('Re-authorize', 'geodirectory'); ?></span> |
1552 | 1552 | <span |
1553 | 1553 | style="color: green; font-weight: bold;"><?php _e('Authorized', 'geodirectory'); ?></span> |
1554 | 1554 | <?php |
1555 | - } else { |
|
1556 | - ?> |
|
1555 | + } else { |
|
1556 | + ?> |
|
1557 | 1557 | <span class="button-primary" |
1558 | 1558 | 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> |
1559 | 1559 | <?php |
1560 | - } |
|
1561 | - ?> |
|
1560 | + } |
|
1561 | + ?> |
|
1562 | 1562 | </td> |
1563 | 1563 | </tr> |
1564 | 1564 | |
1565 | 1565 | <?php |
1566 | 1566 | |
1567 | 1567 | |
1568 | - break; |
|
1568 | + break; |
|
1569 | 1569 | |
1570 | - case 'field_seperator' : |
|
1570 | + case 'field_seperator' : |
|
1571 | 1571 | |
1572 | - ?> |
|
1572 | + ?> |
|
1573 | 1573 | <tr valign="top"> |
1574 | 1574 | <td colspan="2" class="forminp geodir_line_seperator"></td> |
1575 | 1575 | </tr> |
1576 | 1576 | <?php |
1577 | 1577 | |
1578 | - break; |
|
1578 | + break; |
|
1579 | 1579 | |
1580 | - endswitch; |
|
1580 | + endswitch; |
|
1581 | 1581 | |
1582 | - endforeach; |
|
1582 | + endforeach; |
|
1583 | 1583 | |
1584 | - if ($first_title === false) { |
|
1585 | - echo "</div>"; |
|
1586 | - } |
|
1584 | + if ($first_title === false) { |
|
1585 | + echo "</div>"; |
|
1586 | + } |
|
1587 | 1587 | |
1588 | - ?> |
|
1588 | + ?> |
|
1589 | 1589 | |
1590 | 1590 | <script type="text/javascript"> |
1591 | 1591 | |
@@ -1645,33 +1645,33 @@ discard block |
||
1645 | 1645 | */ |
1646 | 1646 | function geodir_post_info_setting() |
1647 | 1647 | { |
1648 | - global $post, $post_id; |
|
1649 | - |
|
1650 | - $post_type = get_post_type(); |
|
1651 | - |
|
1652 | - $package_info = array(); |
|
1653 | - |
|
1654 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1655 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
1656 | - echo '<div id="geodir_wrapper">'; |
|
1657 | - /** |
|
1658 | - * Called before the GD custom fields are output in the wp-admin area. |
|
1659 | - * |
|
1660 | - * @since 1.0.0 |
|
1661 | - * @see 'geodir_after_default_field_in_meta_box' |
|
1662 | - */ |
|
1663 | - do_action('geodir_before_default_field_in_meta_box'); |
|
1664 | - //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
1665 | - // to display all fields in one information box |
|
1666 | - geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
1667 | - /** |
|
1668 | - * Called after the GD custom fields are output in the wp-admin area. |
|
1669 | - * |
|
1670 | - * @since 1.0.0 |
|
1671 | - * @see 'geodir_before_default_field_in_meta_box' |
|
1672 | - */ |
|
1673 | - do_action('geodir_after_default_field_in_meta_box'); |
|
1674 | - echo '</div>'; |
|
1648 | + global $post, $post_id; |
|
1649 | + |
|
1650 | + $post_type = get_post_type(); |
|
1651 | + |
|
1652 | + $package_info = array(); |
|
1653 | + |
|
1654 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1655 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_info_noncename'); |
|
1656 | + echo '<div id="geodir_wrapper">'; |
|
1657 | + /** |
|
1658 | + * Called before the GD custom fields are output in the wp-admin area. |
|
1659 | + * |
|
1660 | + * @since 1.0.0 |
|
1661 | + * @see 'geodir_after_default_field_in_meta_box' |
|
1662 | + */ |
|
1663 | + do_action('geodir_before_default_field_in_meta_box'); |
|
1664 | + //geodir_get_custom_fields_html($package_info->pid,'default',$post_type); |
|
1665 | + // to display all fields in one information box |
|
1666 | + geodir_get_custom_fields_html($package_info->pid, 'all', $post_type); |
|
1667 | + /** |
|
1668 | + * Called after the GD custom fields are output in the wp-admin area. |
|
1669 | + * |
|
1670 | + * @since 1.0.0 |
|
1671 | + * @see 'geodir_before_default_field_in_meta_box' |
|
1672 | + */ |
|
1673 | + do_action('geodir_after_default_field_in_meta_box'); |
|
1674 | + echo '</div>'; |
|
1675 | 1675 | } |
1676 | 1676 | |
1677 | 1677 | /** |
@@ -1684,18 +1684,18 @@ discard block |
||
1684 | 1684 | */ |
1685 | 1685 | function geodir_post_addinfo_setting() |
1686 | 1686 | { |
1687 | - global $post, $post_id; |
|
1687 | + global $post, $post_id; |
|
1688 | 1688 | |
1689 | - $post_type = get_post_type(); |
|
1689 | + $post_type = get_post_type(); |
|
1690 | 1690 | |
1691 | - $package_info = array(); |
|
1691 | + $package_info = array(); |
|
1692 | 1692 | |
1693 | - $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1693 | + $package_info = geodir_post_package_info($package_info, $post, $post_type); |
|
1694 | 1694 | |
1695 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
1696 | - echo '<div id="geodir_wrapper">'; |
|
1697 | - geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
1698 | - echo '</div>'; |
|
1695 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_addinfo_noncename'); |
|
1696 | + echo '<div id="geodir_wrapper">'; |
|
1697 | + geodir_get_custom_fields_html($package_info->pid, 'custom', $post_type); |
|
1698 | + echo '</div>'; |
|
1699 | 1699 | |
1700 | 1700 | } |
1701 | 1701 | |
@@ -1709,60 +1709,60 @@ discard block |
||
1709 | 1709 | */ |
1710 | 1710 | function geodir_post_attachments() |
1711 | 1711 | { |
1712 | - global $post, $post_id; |
|
1712 | + global $post, $post_id; |
|
1713 | 1713 | |
1714 | - wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
1714 | + wp_nonce_field(plugin_basename(__FILE__), 'geodir_post_attachments_noncename'); |
|
1715 | 1715 | |
1716 | - if (geodir_get_featured_image($post_id, 'thumbnail')) { |
|
1717 | - echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>'; |
|
1718 | - geodir_show_featured_image($post_id, 'thumbnail'); |
|
1719 | - } |
|
1716 | + if (geodir_get_featured_image($post_id, 'thumbnail')) { |
|
1717 | + echo '<h4>' . __('Featured Image', 'geodirectory') . '</h4>'; |
|
1718 | + geodir_show_featured_image($post_id, 'thumbnail'); |
|
1719 | + } |
|
1720 | 1720 | |
1721 | - $image_limit = 0; |
|
1721 | + $image_limit = 0; |
|
1722 | 1722 | |
1723 | - ?> |
|
1723 | + ?> |
|
1724 | 1724 | |
1725 | 1725 | |
1726 | 1726 | <h5 class="form_title"> |
1727 | 1727 | <?php if ($image_limit != 0 && $image_limit == 1) { |
1728 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>'; |
|
1729 | - } ?> |
|
1728 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('image with this package', 'geodirectory') . ')</small>'; |
|
1729 | + } ?> |
|
1730 | 1730 | <?php if ($image_limit != 0 && $image_limit > 1) { |
1731 | - echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>'; |
|
1732 | - } ?> |
|
1731 | + echo '<br /><small>(' . __('You can upload', 'geodirectory') . ' ' . $image_limit . ' ' . __('images with this package', 'geodirectory') . ')</small>'; |
|
1732 | + } ?> |
|
1733 | 1733 | <?php if ($image_limit == 0) { |
1734 | - echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>'; |
|
1735 | - } ?> |
|
1734 | + echo '<br /><small>(' . __('You can upload unlimited images with this package', 'geodirectory') . ')</small>'; |
|
1735 | + } ?> |
|
1736 | 1736 | </h5> |
1737 | 1737 | |
1738 | 1738 | |
1739 | 1739 | <?php |
1740 | 1740 | |
1741 | - $curImages = geodir_get_images($post_id); |
|
1742 | - $place_img_array = array(); |
|
1741 | + $curImages = geodir_get_images($post_id); |
|
1742 | + $place_img_array = array(); |
|
1743 | 1743 | |
1744 | - if (!empty($curImages)): |
|
1745 | - foreach ($curImages as $p_img): |
|
1746 | - $place_img_array[] = $p_img->src; |
|
1747 | - endforeach; |
|
1748 | - endif; |
|
1744 | + if (!empty($curImages)): |
|
1745 | + foreach ($curImages as $p_img): |
|
1746 | + $place_img_array[] = $p_img->src; |
|
1747 | + endforeach; |
|
1748 | + endif; |
|
1749 | 1749 | |
1750 | - if (!empty($place_img_array)) |
|
1751 | - $curImages = implode(',', $place_img_array); |
|
1750 | + if (!empty($place_img_array)) |
|
1751 | + $curImages = implode(',', $place_img_array); |
|
1752 | 1752 | |
1753 | 1753 | |
1754 | - // adjust values here |
|
1755 | - $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 |
|
1754 | + // adjust values here |
|
1755 | + $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 |
|
1756 | 1756 | |
1757 | - $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
1757 | + $svalue = $curImages; // this will be initial value of the above form field. Image urls. |
|
1758 | 1758 | |
1759 | - $multiple = true; // allow multiple files upload |
|
1759 | + $multiple = true; // allow multiple files upload |
|
1760 | 1760 | |
1761 | - $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
1761 | + $width = geodir_media_image_large_width(); // If you want to automatically resize all uploaded images then provide width here (in pixels) |
|
1762 | 1762 | |
1763 | - $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
1763 | + $height = geodir_media_image_large_height(); // If you want to automatically resize all uploaded images then provide height here (in pixels) |
|
1764 | 1764 | |
1765 | - ?> |
|
1765 | + ?> |
|
1766 | 1766 | |
1767 | 1767 | <div class="gtd-form_row clearfix" id="<?php echo $id; ?>dropbox" style="border:1px solid #999999;padding:5px;text-align:center;"> |
1768 | 1768 | <input type="hidden" name="<?php echo $id; ?>" id="<?php echo $id; ?>" value="<?php echo $svalue; ?>"/> |
@@ -1804,13 +1804,13 @@ discard block |
||
1804 | 1804 | */ |
1805 | 1805 | function geodir_action_post_updated($post_ID, $post_after, $post_before) |
1806 | 1806 | { |
1807 | - $post_type = get_post_type($post_ID); |
|
1807 | + $post_type = get_post_type($post_ID); |
|
1808 | 1808 | |
1809 | - if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { |
|
1810 | - 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) { |
|
1811 | - geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
1812 | - } |
|
1813 | - } |
|
1809 | + if (isset($_POST['action']) && $_POST['action'] == 'inline-save') { |
|
1810 | + 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) { |
|
1811 | + geodir_save_post_meta($post_ID, 'post_title', $post_after->post_title); |
|
1812 | + } |
|
1813 | + } |
|
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | /** |
@@ -1825,39 +1825,39 @@ discard block |
||
1825 | 1825 | */ |
1826 | 1826 | function geodir_notification_add_bcc_option($settings) |
1827 | 1827 | { |
1828 | - if (!empty($settings)) { |
|
1829 | - $new_settings = array(); |
|
1830 | - foreach ($settings as $setting) { |
|
1831 | - if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') { |
|
1832 | - $geodir_bcc_listing_published_yes = array( |
|
1833 | - 'name' => __('Listing published', 'geodirectory'), |
|
1834 | - 'desc' => __('Yes', 'geodirectory'), |
|
1835 | - 'id' => 'geodir_bcc_listing_published', |
|
1836 | - 'std' => 'yes', |
|
1837 | - 'type' => 'radio', |
|
1838 | - 'value' => '1', |
|
1839 | - 'radiogroup' => 'start' |
|
1840 | - ); |
|
1841 | - |
|
1842 | - $geodir_bcc_listing_published_no = array( |
|
1843 | - 'name' => __('Listing published', 'geodirectory'), |
|
1844 | - 'desc' => __('No', 'geodirectory'), |
|
1845 | - 'id' => 'geodir_bcc_listing_published', |
|
1846 | - 'std' => 'yes', |
|
1847 | - 'type' => 'radio', |
|
1848 | - 'value' => '0', |
|
1849 | - 'radiogroup' => 'end' |
|
1850 | - ); |
|
1851 | - |
|
1852 | - $new_settings[] = $geodir_bcc_listing_published_yes; |
|
1853 | - $new_settings[] = $geodir_bcc_listing_published_no; |
|
1854 | - } |
|
1855 | - $new_settings[] = $setting; |
|
1856 | - } |
|
1857 | - $settings = $new_settings; |
|
1858 | - } |
|
1828 | + if (!empty($settings)) { |
|
1829 | + $new_settings = array(); |
|
1830 | + foreach ($settings as $setting) { |
|
1831 | + if (isset($setting['id']) && $setting['id'] == 'site_bcc_options' && isset($setting['type']) && $setting['type'] == 'sectionend') { |
|
1832 | + $geodir_bcc_listing_published_yes = array( |
|
1833 | + 'name' => __('Listing published', 'geodirectory'), |
|
1834 | + 'desc' => __('Yes', 'geodirectory'), |
|
1835 | + 'id' => 'geodir_bcc_listing_published', |
|
1836 | + 'std' => 'yes', |
|
1837 | + 'type' => 'radio', |
|
1838 | + 'value' => '1', |
|
1839 | + 'radiogroup' => 'start' |
|
1840 | + ); |
|
1841 | + |
|
1842 | + $geodir_bcc_listing_published_no = array( |
|
1843 | + 'name' => __('Listing published', 'geodirectory'), |
|
1844 | + 'desc' => __('No', 'geodirectory'), |
|
1845 | + 'id' => 'geodir_bcc_listing_published', |
|
1846 | + 'std' => 'yes', |
|
1847 | + 'type' => 'radio', |
|
1848 | + 'value' => '0', |
|
1849 | + 'radiogroup' => 'end' |
|
1850 | + ); |
|
1851 | + |
|
1852 | + $new_settings[] = $geodir_bcc_listing_published_yes; |
|
1853 | + $new_settings[] = $geodir_bcc_listing_published_no; |
|
1854 | + } |
|
1855 | + $new_settings[] = $setting; |
|
1856 | + } |
|
1857 | + $settings = $new_settings; |
|
1858 | + } |
|
1859 | 1859 | |
1860 | - return $settings; |
|
1860 | + return $settings; |
|
1861 | 1861 | } |
1862 | 1862 | |
1863 | 1863 | |
@@ -1872,19 +1872,19 @@ discard block |
||
1872 | 1872 | */ |
1873 | 1873 | function get_gd_theme_compat_callback() |
1874 | 1874 | { |
1875 | - global $wpdb; |
|
1876 | - $themes = get_option('gd_theme_compats'); |
|
1877 | - |
|
1878 | - if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) { |
|
1879 | - if (isset($_POST['export'])) { |
|
1880 | - echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
1881 | - } else { |
|
1882 | - echo json_encode($themes[$_POST['theme']]); |
|
1883 | - } |
|
1875 | + global $wpdb; |
|
1876 | + $themes = get_option('gd_theme_compats'); |
|
1884 | 1877 | |
1885 | - } |
|
1878 | + if (isset($_POST['theme']) && isset($themes[$_POST['theme']]) && !empty($themes[$_POST['theme']])) { |
|
1879 | + if (isset($_POST['export'])) { |
|
1880 | + echo json_encode(array($_POST['theme'] => $themes[$_POST['theme']])); |
|
1881 | + } else { |
|
1882 | + echo json_encode($themes[$_POST['theme']]); |
|
1883 | + } |
|
1884 | + |
|
1885 | + } |
|
1886 | 1886 | |
1887 | - die(); |
|
1887 | + die(); |
|
1888 | 1888 | } |
1889 | 1889 | |
1890 | 1890 | add_action('wp_ajax_get_gd_theme_compat_import_callback', 'get_gd_theme_compat_import_callback'); |
@@ -1898,20 +1898,20 @@ discard block |
||
1898 | 1898 | */ |
1899 | 1899 | function get_gd_theme_compat_import_callback() |
1900 | 1900 | { |
1901 | - global $wpdb; |
|
1902 | - $themes = get_option('gd_theme_compats'); |
|
1903 | - if (isset($_POST['theme']) && !empty($_POST['theme'])) { |
|
1904 | - $json = json_decode(stripslashes($_POST['theme']), true); |
|
1905 | - if (!empty($json) && is_array($json)) { |
|
1906 | - $key = sanitize_text_field(key($json)); |
|
1907 | - $themes[$key] = $json[$key]; |
|
1908 | - update_option('gd_theme_compats', $themes); |
|
1909 | - echo $key; |
|
1910 | - die(); |
|
1911 | - } |
|
1912 | - } |
|
1913 | - echo '0'; |
|
1914 | - die(); |
|
1901 | + global $wpdb; |
|
1902 | + $themes = get_option('gd_theme_compats'); |
|
1903 | + if (isset($_POST['theme']) && !empty($_POST['theme'])) { |
|
1904 | + $json = json_decode(stripslashes($_POST['theme']), true); |
|
1905 | + if (!empty($json) && is_array($json)) { |
|
1906 | + $key = sanitize_text_field(key($json)); |
|
1907 | + $themes[$key] = $json[$key]; |
|
1908 | + update_option('gd_theme_compats', $themes); |
|
1909 | + echo $key; |
|
1910 | + die(); |
|
1911 | + } |
|
1912 | + } |
|
1913 | + echo '0'; |
|
1914 | + die(); |
|
1915 | 1915 | } |
1916 | 1916 | |
1917 | 1917 | |
@@ -1924,39 +1924,39 @@ discard block |
||
1924 | 1924 | */ |
1925 | 1925 | function gd_set_theme_compat() |
1926 | 1926 | { |
1927 | - global $wpdb; |
|
1928 | - $theme = wp_get_theme(); |
|
1927 | + global $wpdb; |
|
1928 | + $theme = wp_get_theme(); |
|
1929 | 1929 | |
1930 | - if ($theme->parent()) { |
|
1931 | - $theme_name = str_replace(" ", "_", $theme->parent()->get('Name')); |
|
1932 | - } else { |
|
1933 | - $theme_name = str_replace(" ", "_", $theme->get('Name')); |
|
1934 | - } |
|
1930 | + if ($theme->parent()) { |
|
1931 | + $theme_name = str_replace(" ", "_", $theme->parent()->get('Name')); |
|
1932 | + } else { |
|
1933 | + $theme_name = str_replace(" ", "_", $theme->get('Name')); |
|
1934 | + } |
|
1935 | 1935 | |
1936 | - $theme_compats = get_option('gd_theme_compats'); |
|
1937 | - $current_compat = get_option('gd_theme_compat'); |
|
1938 | - $current_compat = str_replace("_custom", "", $current_compat); |
|
1936 | + $theme_compats = get_option('gd_theme_compats'); |
|
1937 | + $current_compat = get_option('gd_theme_compat'); |
|
1938 | + $current_compat = str_replace("_custom", "", $current_compat); |
|
1939 | 1939 | |
1940 | - if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) { |
|
1941 | - return; |
|
1942 | - }// if already running correct compat then bail |
|
1940 | + if ($current_compat == $theme_name && strpos("_custom", get_option('gd_theme_compat')) !== false) { |
|
1941 | + return; |
|
1942 | + }// if already running correct compat then bail |
|
1943 | 1943 | |
1944 | - if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it |
|
1945 | - update_option('gd_theme_compat', $theme_name); |
|
1946 | - update_option('theme_compatibility_setting', $theme_compats[$theme_name]); |
|
1944 | + if (isset($theme_compats[$theme_name])) {// if there is a compat avail then set it |
|
1945 | + update_option('gd_theme_compat', $theme_name); |
|
1946 | + update_option('theme_compatibility_setting', $theme_compats[$theme_name]); |
|
1947 | 1947 | |
1948 | - // if there are default options to set then set them |
|
1949 | - if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) { |
|
1948 | + // if there are default options to set then set them |
|
1949 | + if (isset($theme_compats[$theme_name]['geodir_theme_compat_default_options']) && !empty($theme_compats[$theme_name]['geodir_theme_compat_default_options'])) { |
|
1950 | 1950 | |
1951 | - foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) { |
|
1952 | - update_option($key, $val); |
|
1953 | - } |
|
1954 | - } |
|
1951 | + foreach ($theme_compats[$theme_name]['geodir_theme_compat_default_options'] as $key => $val) { |
|
1952 | + update_option($key, $val); |
|
1953 | + } |
|
1954 | + } |
|
1955 | 1955 | |
1956 | - } else { |
|
1957 | - update_option('gd_theme_compat', ''); |
|
1958 | - update_option('theme_compatibility_setting', ''); |
|
1959 | - } |
|
1956 | + } else { |
|
1957 | + update_option('gd_theme_compat', ''); |
|
1958 | + update_option('theme_compatibility_setting', ''); |
|
1959 | + } |
|
1960 | 1960 | |
1961 | 1961 | |
1962 | 1962 | } |
@@ -1971,9 +1971,9 @@ discard block |
||
1971 | 1971 | */ |
1972 | 1972 | function gd_check_avada_compat() |
1973 | 1973 | { |
1974 | - if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) { |
|
1975 | - add_action('admin_notices', 'gd_avada_compat_warning'); |
|
1976 | - } |
|
1974 | + if (function_exists('avada_load_textdomain') && !get_option('avada_nag')) { |
|
1975 | + add_action('admin_notices', 'gd_avada_compat_warning'); |
|
1976 | + } |
|
1977 | 1977 | } |
1978 | 1978 | |
1979 | 1979 | |
@@ -1986,22 +1986,22 @@ discard block |
||
1986 | 1986 | function gd_avada_compat_warning() |
1987 | 1987 | { |
1988 | 1988 | |
1989 | - /* |
|
1989 | + /* |
|
1990 | 1990 | $msg_type = error |
1991 | 1991 | $msg_type = updated fade |
1992 | 1992 | $msg_type = update-nag |
1993 | 1993 | */ |
1994 | 1994 | |
1995 | - $plugin = 'avada-nag'; |
|
1996 | - $timestamp = 'avada-nag1234'; |
|
1997 | - $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'); |
|
1998 | - echo '<div id="' . $timestamp . '" class="error">'; |
|
1999 | - echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
2000 | - echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > "; |
|
2001 | - echo "<p>$message</p>"; |
|
2002 | - echo "</div>"; |
|
1995 | + $plugin = 'avada-nag'; |
|
1996 | + $timestamp = 'avada-nag1234'; |
|
1997 | + $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'); |
|
1998 | + echo '<div id="' . $timestamp . '" class="error">'; |
|
1999 | + echo '<span class="gd-remove-noti" onclick="gdRemoveANotification(\'' . $plugin . '\',\'' . $timestamp . '\');" ><i class="fa fa-times"></i></span>'; |
|
2000 | + echo "<img class='gd-icon-noti' src='" . plugin_dir_url('') . "geodirectory/geodirectory-assets/images/favicon.ico' > "; |
|
2001 | + echo "<p>$message</p>"; |
|
2002 | + echo "</div>"; |
|
2003 | 2003 | |
2004 | - ?> |
|
2004 | + ?> |
|
2005 | 2005 | <script> |
2006 | 2006 | function gdRemoveANotification($plugin, $timestamp) { |
2007 | 2007 | |
@@ -2069,10 +2069,10 @@ discard block |
||
2069 | 2069 | */ |
2070 | 2070 | function geodir_avada_remove_notification() |
2071 | 2071 | { |
2072 | - update_option('avada_nag', TRUE); |
|
2072 | + update_option('avada_nag', TRUE); |
|
2073 | 2073 | |
2074 | - // Always die in functions echoing ajax content |
|
2075 | - die(); |
|
2074 | + // Always die in functions echoing ajax content |
|
2075 | + die(); |
|
2076 | 2076 | } |
2077 | 2077 | |
2078 | 2078 | |
@@ -2094,9 +2094,9 @@ discard block |
||
2094 | 2094 | global $post, $typenow, $current_screen; |
2095 | 2095 | |
2096 | 2096 | $post_type = NULL; |
2097 | - if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
2097 | + if (isset($_REQUEST['post']) && get_post_type($_REQUEST['post'])) |
|
2098 | 2098 | $post_type = get_post_type($_REQUEST['post']); |
2099 | - elseif ($post && isset($post->post_type)) |
|
2099 | + elseif ($post && isset($post->post_type)) |
|
2100 | 2100 | $post_type = $post->post_type; |
2101 | 2101 | elseif ($typenow) |
2102 | 2102 | $post_type = $typenow; |
@@ -2131,7 +2131,7 @@ discard block |
||
2131 | 2131 | // Don't allow same slug url for listing and location |
2132 | 2132 | if (geodir_strtolower($listing_prefix) == geodir_strtolower($location_prefix)) { |
2133 | 2133 | $redirect_url = admin_url('admin.php?page=geodirectory&tab=' . $current_tab . '&active_tab=' . $active_tab . '&msg=fail&gderr=21'); |
2134 | - wp_redirect($redirect_url); |
|
2134 | + wp_redirect($redirect_url); |
|
2135 | 2135 | exit; |
2136 | 2136 | } |
2137 | 2137 | |
@@ -2161,10 +2161,10 @@ discard block |
||
2161 | 2161 | * @package GeoDirectory |
2162 | 2162 | */ |
2163 | 2163 | function geodir_hide_admin_preview_button() { |
2164 | - global $post_type; |
|
2165 | - $post_types = geodir_get_posttypes(); |
|
2166 | - if(in_array($post_type, $post_types)) |
|
2167 | - echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>'; |
|
2164 | + global $post_type; |
|
2165 | + $post_types = geodir_get_posttypes(); |
|
2166 | + if(in_array($post_type, $post_types)) |
|
2167 | + echo '<style type="text/css">#post-preview, #view-post-btn{display: none;}</style>'; |
|
2168 | 2168 | } |
2169 | 2169 | add_action( 'admin_head-post-new.php', 'geodir_hide_admin_preview_button' ); |
2170 | 2170 | add_action( 'admin_head-post.php', 'geodir_hide_admin_preview_button' ); |
@@ -2179,7 +2179,7 @@ discard block |
||
2179 | 2179 | */ |
2180 | 2180 | function geodir_import_export_tab( $tabs ) { |
2181 | 2181 | $tabs['import_export'] = array( 'label' => __( 'Import & Export', 'geodirectory' ) ); |
2182 | - return $tabs; |
|
2182 | + return $tabs; |
|
2183 | 2183 | } |
2184 | 2184 | |
2185 | 2185 | /** |
@@ -2194,26 +2194,26 @@ discard block |
||
2194 | 2194 | function geodir_import_export_page() { |
2195 | 2195 | $nonce = wp_create_nonce( 'geodir_import_export_nonce' ); |
2196 | 2196 | $gd_cats_sample_csv = geodir_plugin_url() . '/geodirectory-assets/gd_sample_categories.csv'; |
2197 | - /** |
|
2198 | - * Filter sample category data csv file url. |
|
2199 | - * |
|
2200 | - * @since 1.0.0 |
|
2201 | - * @package GeoDirectory |
|
2202 | - * |
|
2203 | - * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
2204 | - */ |
|
2197 | + /** |
|
2198 | + * Filter sample category data csv file url. |
|
2199 | + * |
|
2200 | + * @since 1.0.0 |
|
2201 | + * @package GeoDirectory |
|
2202 | + * |
|
2203 | + * @param string $gd_cats_sample_csv Sample category data csv file url. |
|
2204 | + */ |
|
2205 | 2205 | $gd_cats_sample_csv = apply_filters( 'geodir_export_cats_sample_csv', $gd_cats_sample_csv ); |
2206 | 2206 | |
2207 | 2207 | $gd_posts_sample_csv = geodir_plugin_url() . '/geodirectory-assets/place_listing.csv'; |
2208 | - /** |
|
2209 | - * Filter sample post data csv file url. |
|
2210 | - * |
|
2211 | - * @since 1.0.0 |
|
2212 | - * @package GeoDirectory |
|
2213 | - * |
|
2214 | - * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
2215 | - */ |
|
2216 | - $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
2208 | + /** |
|
2209 | + * Filter sample post data csv file url. |
|
2210 | + * |
|
2211 | + * @since 1.0.0 |
|
2212 | + * @package GeoDirectory |
|
2213 | + * |
|
2214 | + * @param string $gd_posts_sample_csv Sample post data csv file url. |
|
2215 | + */ |
|
2216 | + $gd_posts_sample_csv = apply_filters( 'geodir_export_posts_sample_csv', $gd_posts_sample_csv ); |
|
2217 | 2217 | |
2218 | 2218 | $gd_posttypes = geodir_get_posttypes( 'array' ); |
2219 | 2219 | |
@@ -2236,14 +2236,14 @@ discard block |
||
2236 | 2236 | $gd_chunksize_options[100000] = 100000; |
2237 | 2237 | |
2238 | 2238 | /** |
2239 | - * Filter max entries per export csv file. |
|
2240 | - * |
|
2241 | - * @since 1.5.6 |
|
2242 | - * @package GeoDirectory |
|
2243 | - * |
|
2244 | - * @param string $gd_chunksize_options Entries options. |
|
2245 | - */ |
|
2246 | - $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
2239 | + * Filter max entries per export csv file. |
|
2240 | + * |
|
2241 | + * @since 1.5.6 |
|
2242 | + * @package GeoDirectory |
|
2243 | + * |
|
2244 | + * @param string $gd_chunksize_options Entries options. |
|
2245 | + */ |
|
2246 | + $gd_chunksize_options = apply_filters( 'geodir_export_csv_chunksize_options', $gd_chunksize_options ); |
|
2247 | 2247 | |
2248 | 2248 | $gd_chunksize_option = ''; |
2249 | 2249 | foreach ($gd_chunksize_options as $value => $title) { |
@@ -2260,12 +2260,12 @@ discard block |
||
2260 | 2260 | <div class="gd-content-heading"> |
2261 | 2261 | |
2262 | 2262 | <?php |
2263 | - ini_set('max_execution_time', 999999); |
|
2264 | - $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
2265 | - ini_restore('max_execution_time'); |
|
2263 | + ini_set('max_execution_time', 999999); |
|
2264 | + $ini_max_execution_time_check = @ini_get( 'max_execution_time' ); |
|
2265 | + ini_restore('max_execution_time'); |
|
2266 | 2266 | |
2267 | - if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting |
|
2268 | - ?> |
|
2267 | + if($ini_max_execution_time_check != 999999){ // only show these setting to the user if we can't change the ini setting |
|
2268 | + ?> |
|
2269 | 2269 | <div id="gd_ie_reqs" class="metabox-holder"> |
2270 | 2270 | <div class="meta-box-sortables ui-sortable"> |
2271 | 2271 | <div class="postbox"> |
@@ -2438,7 +2438,7 @@ discard block |
||
2438 | 2438 | * Called just after the sample CSV download link. |
2439 | 2439 | * |
2440 | 2440 | * @since 1.0.0 |
2441 | - * @package GeoDirectory |
|
2441 | + * @package GeoDirectory |
|
2442 | 2442 | */ |
2443 | 2443 | do_action('geodir_sample_cats_csv_download_link'); |
2444 | 2444 | ?> |
@@ -2523,11 +2523,11 @@ discard block |
||
2523 | 2523 | * |
2524 | 2524 | * Called after the last setting on the GD > Import & Export page. |
2525 | 2525 | * @since 1.4.6 |
2526 | - * @package GeoDirectory |
|
2526 | + * @package GeoDirectory |
|
2527 | 2527 | * |
2528 | 2528 | * @param array $gd_posttypes GD post types. |
2529 | - * @param array $gd_chunksize_options File chunk size options. |
|
2530 | - * @param string $nonce Wordpress security token for GD import & export. |
|
2529 | + * @param array $gd_chunksize_options File chunk size options. |
|
2530 | + * @param string $nonce Wordpress security token for GD import & export. |
|
2531 | 2531 | */ |
2532 | 2532 | do_action( 'geodir_import_export', $gd_posttypes, $gd_chunksize_options, $nonce ); |
2533 | 2533 | ?> |
@@ -3214,44 +3214,44 @@ discard block |
||
3214 | 3214 | function geodir_init_filesystem() |
3215 | 3215 | { |
3216 | 3216 | |
3217 | - if(!function_exists('get_filesystem_method')){ |
|
3218 | - require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
3219 | - } |
|
3220 | - $access_type = get_filesystem_method(); |
|
3221 | - if ($access_type === 'direct') { |
|
3222 | - /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
3223 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3224 | - |
|
3225 | - /* initialize the API */ |
|
3226 | - if (!WP_Filesystem($creds)) { |
|
3227 | - /* any problems and we exit */ |
|
3228 | - //return '@@@3'; |
|
3229 | - return false; |
|
3230 | - } |
|
3217 | + if(!function_exists('get_filesystem_method')){ |
|
3218 | + require_once(ABSPATH."/wp-admin/includes/file.php"); |
|
3219 | + } |
|
3220 | + $access_type = get_filesystem_method(); |
|
3221 | + if ($access_type === 'direct') { |
|
3222 | + /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */ |
|
3223 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3224 | + |
|
3225 | + /* initialize the API */ |
|
3226 | + if (!WP_Filesystem($creds)) { |
|
3227 | + /* any problems and we exit */ |
|
3228 | + //return '@@@3'; |
|
3229 | + return false; |
|
3230 | + } |
|
3231 | 3231 | |
3232 | - global $wp_filesystem; |
|
3233 | - return $wp_filesystem; |
|
3234 | - /* do our file manipulations below */ |
|
3235 | - } elseif (defined('FTP_USER')) { |
|
3236 | - $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3232 | + global $wp_filesystem; |
|
3233 | + return $wp_filesystem; |
|
3234 | + /* do our file manipulations below */ |
|
3235 | + } elseif (defined('FTP_USER')) { |
|
3236 | + $creds = request_filesystem_credentials(trailingslashit(site_url()) . 'wp-admin/', '', false, false, array()); |
|
3237 | + |
|
3238 | + /* initialize the API */ |
|
3239 | + if (!WP_Filesystem($creds)) { |
|
3240 | + /* any problems and we exit */ |
|
3241 | + //return '@@@33'; |
|
3242 | + return false; |
|
3243 | + } |
|
3237 | 3244 | |
3238 | - /* initialize the API */ |
|
3239 | - if (!WP_Filesystem($creds)) { |
|
3240 | - /* any problems and we exit */ |
|
3241 | - //return '@@@33'; |
|
3242 | - return false; |
|
3243 | - } |
|
3245 | + global $wp_filesystem; |
|
3246 | + //return '@@@1'; |
|
3247 | + return $wp_filesystem; |
|
3244 | 3248 | |
3245 | - global $wp_filesystem; |
|
3246 | - //return '@@@1'; |
|
3247 | - return $wp_filesystem; |
|
3248 | - |
|
3249 | - } else { |
|
3250 | - //return '@@@2'; |
|
3251 | - /* don't have direct write access. Prompt user with our notice */ |
|
3252 | - add_action('admin_notice', 'geodir_filesystem_notice'); |
|
3253 | - return false; |
|
3254 | - } |
|
3249 | + } else { |
|
3250 | + //return '@@@2'; |
|
3251 | + /* don't have direct write access. Prompt user with our notice */ |
|
3252 | + add_action('admin_notice', 'geodir_filesystem_notice'); |
|
3253 | + return false; |
|
3254 | + } |
|
3255 | 3255 | |
3256 | 3256 | } |
3257 | 3257 | |
@@ -3269,10 +3269,10 @@ discard block |
||
3269 | 3269 | */ |
3270 | 3270 | function geodir_filesystem_notice() |
3271 | 3271 | { if ( defined( 'DOING_AJAX' ) ){return;} |
3272 | - $access_type = get_filesystem_method(); |
|
3273 | - if ($access_type === 'direct') { |
|
3274 | - } elseif (!defined('FTP_USER')) { |
|
3275 | - ?> |
|
3272 | + $access_type = get_filesystem_method(); |
|
3273 | + if ($access_type === 'direct') { |
|
3274 | + } elseif (!defined('FTP_USER')) { |
|
3275 | + ?> |
|
3276 | 3276 | <div class="error"> |
3277 | 3277 | <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'); ?> |
3278 | 3278 | <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> |
@@ -3299,1251 +3299,1251 @@ discard block |
||
3299 | 3299 | * @return string Json data. |
3300 | 3300 | */ |
3301 | 3301 | function geodir_ajax_import_export() { |
3302 | - global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
3302 | + global $wpdb, $plugin_prefix, $current_user, $wp_filesystem; |
|
3303 | 3303 | |
3304 | - error_reporting(0); |
|
3304 | + error_reporting(0); |
|
3305 | 3305 | |
3306 | - // try to set higher limits for import |
|
3307 | - $max_input_time = ini_get('max_input_time'); |
|
3308 | - $max_execution_time = ini_get('max_execution_time'); |
|
3309 | - $memory_limit= ini_get('memory_limit'); |
|
3306 | + // try to set higher limits for import |
|
3307 | + $max_input_time = ini_get('max_input_time'); |
|
3308 | + $max_execution_time = ini_get('max_execution_time'); |
|
3309 | + $memory_limit= ini_get('memory_limit'); |
|
3310 | 3310 | |
3311 | - if(!$max_input_time || $max_input_time<3000){ |
|
3312 | - ini_set('max_input_time', 3000); |
|
3313 | - } |
|
3311 | + if(!$max_input_time || $max_input_time<3000){ |
|
3312 | + ini_set('max_input_time', 3000); |
|
3313 | + } |
|
3314 | 3314 | |
3315 | - if(!$max_execution_time || $max_execution_time<3000){ |
|
3316 | - ini_set('max_execution_time', 3000); |
|
3317 | - } |
|
3315 | + if(!$max_execution_time || $max_execution_time<3000){ |
|
3316 | + ini_set('max_execution_time', 3000); |
|
3317 | + } |
|
3318 | 3318 | |
3319 | - if($memory_limit && str_replace('M','',$memory_limit)){ |
|
3320 | - if(str_replace('M','',$memory_limit)<256){ |
|
3321 | - ini_set('memory_limit', '256M'); |
|
3322 | - } |
|
3323 | - } |
|
3319 | + if($memory_limit && str_replace('M','',$memory_limit)){ |
|
3320 | + if(str_replace('M','',$memory_limit)<256){ |
|
3321 | + ini_set('memory_limit', '256M'); |
|
3322 | + } |
|
3323 | + } |
|
3324 | 3324 | |
3325 | - $json = array(); |
|
3325 | + $json = array(); |
|
3326 | 3326 | |
3327 | - if ( !current_user_can( 'manage_options' ) ) { |
|
3328 | - wp_send_json( $json ); |
|
3329 | - } |
|
3327 | + if ( !current_user_can( 'manage_options' ) ) { |
|
3328 | + wp_send_json( $json ); |
|
3329 | + } |
|
3330 | 3330 | |
3331 | - $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
3332 | - $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
3333 | - $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
3331 | + $task = isset( $_REQUEST['task'] ) ? $_REQUEST['task'] : NULL; |
|
3332 | + $nonce = isset( $_REQUEST['_nonce'] ) ? $_REQUEST['_nonce'] : NULL; |
|
3333 | + $stat = isset( $_REQUEST['_st'] ) ? $_REQUEST['_st'] : false; |
|
3334 | 3334 | |
3335 | - if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) { |
|
3336 | - wp_send_json( $json ); |
|
3337 | - } |
|
3335 | + if ( !wp_verify_nonce( $nonce, 'geodir_import_export_nonce' ) ) { |
|
3336 | + wp_send_json( $json ); |
|
3337 | + } |
|
3338 | 3338 | |
3339 | - $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
3340 | - $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
3341 | - $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
3342 | - $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
3339 | + $post_type = isset( $_REQUEST['_pt'] ) ? $_REQUEST['_pt'] : NULL; |
|
3340 | + $chunk_per_page = isset( $_REQUEST['_n'] ) ? absint($_REQUEST['_n']) : NULL; |
|
3341 | + $chunk_per_page = $chunk_per_page < 50 || $chunk_per_page > 100000 ? 5000 : $chunk_per_page; |
|
3342 | + $chunk_page_no = isset( $_REQUEST['_p'] ) ? absint($_REQUEST['_p']) : 1; |
|
3343 | 3343 | |
3344 | - $wp_filesystem = geodir_init_filesystem(); |
|
3345 | - if (!$wp_filesystem) { |
|
3346 | - $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
3347 | - wp_send_json( $json ); |
|
3348 | - } |
|
3344 | + $wp_filesystem = geodir_init_filesystem(); |
|
3345 | + if (!$wp_filesystem) { |
|
3346 | + $json['error'] = __( 'Filesystem ERROR: Could not access filesystem.', 'geodirectory' ); |
|
3347 | + wp_send_json( $json ); |
|
3348 | + } |
|
3349 | 3349 | |
3350 | - if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
3351 | - $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
3352 | - wp_send_json( $json ); |
|
3353 | - } |
|
3350 | + if (!empty($wp_filesystem) && isset($wp_filesystem->errors) && is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) { |
|
3351 | + $json['error'] = __( 'Filesystem ERROR: ' . $wp_filesystem->errors->get_error_message(), 'geodirectory' ); |
|
3352 | + wp_send_json( $json ); |
|
3353 | + } |
|
3354 | 3354 | |
3355 | - $csv_file_dir = geodir_path_import_export( false ); |
|
3356 | - if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) { |
|
3357 | - if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) { |
|
3358 | - $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3359 | - wp_send_json( $json ); |
|
3360 | - } |
|
3361 | - } |
|
3355 | + $csv_file_dir = geodir_path_import_export( false ); |
|
3356 | + if ( !$wp_filesystem->is_dir( $csv_file_dir ) ) { |
|
3357 | + if ( !$wp_filesystem->mkdir( $csv_file_dir, FS_CHMOD_DIR ) ) { |
|
3358 | + $json['error'] = __( 'ERROR: Could not create cache directory. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3359 | + wp_send_json( $json ); |
|
3360 | + } |
|
3361 | + } |
|
3362 | 3362 | |
3363 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active. |
|
3364 | - $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
3365 | - |
|
3366 | - switch ( $task ) { |
|
3367 | - case 'export_posts': { |
|
3368 | - // WPML |
|
3369 | - $is_wpml = geodir_is_wpml(); |
|
3370 | - if ($is_wpml) { |
|
3371 | - global $sitepress; |
|
3372 | - $active_lang = ICL_LANGUAGE_CODE; |
|
3363 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active. |
|
3364 | + $neighbourhood_active = $location_manager && get_option('location_neighbourhoods') ? true : false; |
|
3365 | + |
|
3366 | + switch ( $task ) { |
|
3367 | + case 'export_posts': { |
|
3368 | + // WPML |
|
3369 | + $is_wpml = geodir_is_wpml(); |
|
3370 | + if ($is_wpml) { |
|
3371 | + global $sitepress; |
|
3372 | + $active_lang = ICL_LANGUAGE_CODE; |
|
3373 | 3373 | |
3374 | - $sitepress->switch_lang('all', true); |
|
3375 | - } |
|
3376 | - // WPML |
|
3377 | - if ( $post_type == 'gd_event' ) { |
|
3378 | - add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
3379 | - } |
|
3380 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
3374 | + $sitepress->switch_lang('all', true); |
|
3375 | + } |
|
3376 | + // WPML |
|
3377 | + if ( $post_type == 'gd_event' ) { |
|
3378 | + add_filter( 'geodir_imex_export_posts_query', 'geodir_imex_get_events_query', 10, 2 ); |
|
3379 | + } |
|
3380 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
3381 | 3381 | |
3382 | - $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
3383 | - if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) { |
|
3384 | - $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
3385 | - } |
|
3386 | - $posts_count = geodir_get_posts_count( $post_type ); |
|
3387 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3388 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3389 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3390 | - $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
3382 | + $file_name = $post_type . '_' . date( 'dmyHi' ); |
|
3383 | + if ( $filters && isset( $filters['start_date'] ) && isset( $filters['end_date'] ) ) { |
|
3384 | + $file_name = $post_type . '_' . date_i18n( 'dmy', strtotime( $filters['start_date'] ) ) . '_' . date_i18n( 'dmy', strtotime( $filters['end_date'] ) ); |
|
3385 | + } |
|
3386 | + $posts_count = geodir_get_posts_count( $post_type ); |
|
3387 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3388 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3389 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3390 | + $file_path_temp = $csv_file_dir . '/' . $post_type . '_' . $nonce . '.csv'; |
|
3391 | 3391 | |
3392 | - $chunk_file_paths = array(); |
|
3392 | + $chunk_file_paths = array(); |
|
3393 | 3393 | |
3394 | - if ( isset( $_REQUEST['_c'] ) ) { |
|
3395 | - $json['total'] = $posts_count; |
|
3396 | - // WPML |
|
3397 | - if ($is_wpml) { |
|
3398 | - $sitepress->switch_lang($active_lang, true); |
|
3399 | - } |
|
3400 | - // WPML |
|
3401 | - wp_send_json( $json ); |
|
3402 | - gd_die(); |
|
3403 | - } else if ( isset( $_REQUEST['_st'] ) ) { |
|
3404 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3405 | - $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
3406 | - $percentage = min( $percentage, 100 ); |
|
3394 | + if ( isset( $_REQUEST['_c'] ) ) { |
|
3395 | + $json['total'] = $posts_count; |
|
3396 | + // WPML |
|
3397 | + if ($is_wpml) { |
|
3398 | + $sitepress->switch_lang($active_lang, true); |
|
3399 | + } |
|
3400 | + // WPML |
|
3401 | + wp_send_json( $json ); |
|
3402 | + gd_die(); |
|
3403 | + } else if ( isset( $_REQUEST['_st'] ) ) { |
|
3404 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3405 | + $percentage = count( $posts_count ) > 0 && $line_count > 0 ? ceil( $line_count / $posts_count ) * 100 : 0; |
|
3406 | + $percentage = min( $percentage, 100 ); |
|
3407 | 3407 | |
3408 | - $json['percentage'] = $percentage; |
|
3409 | - // WPML |
|
3410 | - if ($is_wpml) { |
|
3411 | - $sitepress->switch_lang($active_lang, true); |
|
3412 | - } |
|
3413 | - // WPML |
|
3414 | - wp_send_json( $json ); |
|
3415 | - gd_die(); |
|
3416 | - } else { |
|
3417 | - if ( !$posts_count > 0 ) { |
|
3418 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3419 | - } else { |
|
3420 | - $total_posts = $posts_count; |
|
3421 | - if ($chunk_per_page > $total_posts) { |
|
3422 | - $chunk_per_page = $total_posts; |
|
3423 | - } |
|
3424 | - $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
3408 | + $json['percentage'] = $percentage; |
|
3409 | + // WPML |
|
3410 | + if ($is_wpml) { |
|
3411 | + $sitepress->switch_lang($active_lang, true); |
|
3412 | + } |
|
3413 | + // WPML |
|
3414 | + wp_send_json( $json ); |
|
3415 | + gd_die(); |
|
3416 | + } else { |
|
3417 | + if ( !$posts_count > 0 ) { |
|
3418 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3419 | + } else { |
|
3420 | + $total_posts = $posts_count; |
|
3421 | + if ($chunk_per_page > $total_posts) { |
|
3422 | + $chunk_per_page = $total_posts; |
|
3423 | + } |
|
3424 | + $chunk_total_pages = ceil( $total_posts / $chunk_per_page ); |
|
3425 | 3425 | |
3426 | - $j = $chunk_page_no; |
|
3427 | - $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
3426 | + $j = $chunk_page_no; |
|
3427 | + $chunk_save_posts = geodir_imex_get_posts( $post_type, $chunk_per_page, $j ); |
|
3428 | 3428 | |
3429 | - $per_page = 500; |
|
3430 | - if ($per_page > $chunk_per_page) { |
|
3431 | - $per_page = $chunk_per_page; |
|
3432 | - } |
|
3433 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3429 | + $per_page = 500; |
|
3430 | + if ($per_page > $chunk_per_page) { |
|
3431 | + $per_page = $chunk_per_page; |
|
3432 | + } |
|
3433 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3434 | 3434 | |
3435 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3436 | - $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
3435 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3436 | + $save_posts = array_slice( $chunk_save_posts , ( $i * $per_page ), $per_page ); |
|
3437 | 3437 | |
3438 | - $clear = $i == 0 ? true : false; |
|
3439 | - geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
3440 | - } |
|
3438 | + $clear = $i == 0 ? true : false; |
|
3439 | + geodir_save_csv_data( $file_path_temp, $save_posts, $clear ); |
|
3440 | + } |
|
3441 | 3441 | |
3442 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3443 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3444 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3445 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3446 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3442 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3443 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3444 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3445 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3446 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3447 | 3447 | |
3448 | - $file_url = $file_url_base . $chunk_file_name; |
|
3449 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3450 | - } |
|
3448 | + $file_url = $file_url_base . $chunk_file_name; |
|
3449 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3450 | + } |
|
3451 | 3451 | |
3452 | - if ( !empty($chunk_file_paths) ) { |
|
3453 | - $json['total'] = $posts_count; |
|
3454 | - $json['files'] = $chunk_file_paths; |
|
3455 | - } else { |
|
3456 | - if ($j > 1) { |
|
3457 | - $json['total'] = $posts_count; |
|
3458 | - $json['files'] = array(); |
|
3459 | - } else { |
|
3460 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3461 | - } |
|
3462 | - } |
|
3463 | - } |
|
3464 | - // WPML |
|
3465 | - if ($is_wpml) { |
|
3466 | - $sitepress->switch_lang($active_lang, true); |
|
3467 | - } |
|
3468 | - // WPML |
|
3469 | - wp_send_json( $json ); |
|
3470 | - } |
|
3471 | - } |
|
3472 | - break; |
|
3473 | - case 'export_cats': { |
|
3474 | - // WPML |
|
3475 | - $is_wpml = geodir_is_wpml(); |
|
3476 | - if ($is_wpml) { |
|
3477 | - global $sitepress; |
|
3478 | - $active_lang = ICL_LANGUAGE_CODE; |
|
3452 | + if ( !empty($chunk_file_paths) ) { |
|
3453 | + $json['total'] = $posts_count; |
|
3454 | + $json['files'] = $chunk_file_paths; |
|
3455 | + } else { |
|
3456 | + if ($j > 1) { |
|
3457 | + $json['total'] = $posts_count; |
|
3458 | + $json['files'] = array(); |
|
3459 | + } else { |
|
3460 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3461 | + } |
|
3462 | + } |
|
3463 | + } |
|
3464 | + // WPML |
|
3465 | + if ($is_wpml) { |
|
3466 | + $sitepress->switch_lang($active_lang, true); |
|
3467 | + } |
|
3468 | + // WPML |
|
3469 | + wp_send_json( $json ); |
|
3470 | + } |
|
3471 | + } |
|
3472 | + break; |
|
3473 | + case 'export_cats': { |
|
3474 | + // WPML |
|
3475 | + $is_wpml = geodir_is_wpml(); |
|
3476 | + if ($is_wpml) { |
|
3477 | + global $sitepress; |
|
3478 | + $active_lang = ICL_LANGUAGE_CODE; |
|
3479 | 3479 | |
3480 | - $sitepress->switch_lang('all', true); |
|
3481 | - } |
|
3482 | - // WPML |
|
3483 | - $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
3480 | + $sitepress->switch_lang('all', true); |
|
3481 | + } |
|
3482 | + // WPML |
|
3483 | + $file_name = $post_type . 'category_' . date( 'dmyHi' ); |
|
3484 | 3484 | |
3485 | - $terms_count = geodir_get_terms_count( $post_type ); |
|
3486 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3487 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3488 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3489 | - $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
3485 | + $terms_count = geodir_get_terms_count( $post_type ); |
|
3486 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3487 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3488 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3489 | + $file_path_temp = $csv_file_dir . '/' . $post_type . 'category_' . $nonce . '.csv'; |
|
3490 | 3490 | |
3491 | - $chunk_file_paths = array(); |
|
3491 | + $chunk_file_paths = array(); |
|
3492 | 3492 | |
3493 | - if ( isset( $_REQUEST['_st'] ) ) { |
|
3494 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3495 | - $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
3496 | - $percentage = min( $percentage, 100 ); |
|
3493 | + if ( isset( $_REQUEST['_st'] ) ) { |
|
3494 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3495 | + $percentage = count( $terms_count ) > 0 && $line_count > 0 ? ceil( $line_count / $terms_count ) * 100 : 0; |
|
3496 | + $percentage = min( $percentage, 100 ); |
|
3497 | 3497 | |
3498 | - $json['percentage'] = $percentage; |
|
3499 | - // WPML |
|
3500 | - if ($is_wpml) { |
|
3501 | - $sitepress->switch_lang($active_lang, true); |
|
3502 | - } |
|
3503 | - // WPML |
|
3504 | - wp_send_json( $json ); |
|
3505 | - } else { |
|
3506 | - if ( !$terms_count > 0 ) { |
|
3507 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3508 | - } else { |
|
3509 | - $total_terms = $terms_count; |
|
3510 | - if ($chunk_per_page > $terms_count) { |
|
3511 | - $chunk_per_page = $terms_count; |
|
3512 | - } |
|
3513 | - $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
3498 | + $json['percentage'] = $percentage; |
|
3499 | + // WPML |
|
3500 | + if ($is_wpml) { |
|
3501 | + $sitepress->switch_lang($active_lang, true); |
|
3502 | + } |
|
3503 | + // WPML |
|
3504 | + wp_send_json( $json ); |
|
3505 | + } else { |
|
3506 | + if ( !$terms_count > 0 ) { |
|
3507 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3508 | + } else { |
|
3509 | + $total_terms = $terms_count; |
|
3510 | + if ($chunk_per_page > $terms_count) { |
|
3511 | + $chunk_per_page = $terms_count; |
|
3512 | + } |
|
3513 | + $chunk_total_pages = ceil( $total_terms / $chunk_per_page ); |
|
3514 | 3514 | |
3515 | - $j = $chunk_page_no; |
|
3516 | - $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
3515 | + $j = $chunk_page_no; |
|
3516 | + $chunk_save_terms = geodir_imex_get_terms( $post_type, $chunk_per_page, $j ); |
|
3517 | 3517 | |
3518 | - $per_page = 500; |
|
3519 | - if ($per_page > $chunk_per_page) { |
|
3520 | - $per_page = $chunk_per_page; |
|
3521 | - } |
|
3522 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3518 | + $per_page = 500; |
|
3519 | + if ($per_page > $chunk_per_page) { |
|
3520 | + $per_page = $chunk_per_page; |
|
3521 | + } |
|
3522 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3523 | 3523 | |
3524 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3525 | - $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
3524 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3525 | + $save_terms = array_slice( $chunk_save_terms , ( $i * $per_page ), $per_page ); |
|
3526 | 3526 | |
3527 | - $clear = $i == 0 ? true : false; |
|
3528 | - geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
3529 | - } |
|
3527 | + $clear = $i == 0 ? true : false; |
|
3528 | + geodir_save_csv_data( $file_path_temp, $save_terms, $clear ); |
|
3529 | + } |
|
3530 | 3530 | |
3531 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3532 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3533 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3534 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3535 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3531 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3532 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3533 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3534 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3535 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3536 | 3536 | |
3537 | - $file_url = $file_url_base . $chunk_file_name; |
|
3538 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3539 | - } |
|
3537 | + $file_url = $file_url_base . $chunk_file_name; |
|
3538 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3539 | + } |
|
3540 | 3540 | |
3541 | - if ( !empty($chunk_file_paths) ) { |
|
3542 | - $json['total'] = $terms_count; |
|
3543 | - $json['files'] = $chunk_file_paths; |
|
3544 | - } else { |
|
3545 | - $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3546 | - } |
|
3547 | - } |
|
3548 | - // WPML |
|
3549 | - if ($is_wpml) { |
|
3550 | - $sitepress->switch_lang($active_lang, true); |
|
3551 | - } |
|
3552 | - // WPML |
|
3553 | - wp_send_json( $json ); |
|
3554 | - } |
|
3555 | - } |
|
3556 | - break; |
|
3557 | - case 'export_locations': { |
|
3558 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3559 | - $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
3560 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3561 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3562 | - $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
3541 | + if ( !empty($chunk_file_paths) ) { |
|
3542 | + $json['total'] = $terms_count; |
|
3543 | + $json['files'] = $chunk_file_paths; |
|
3544 | + } else { |
|
3545 | + $json['error'] = __( 'ERROR: Could not create csv file. This is usually due to inconsistent file permissions.', 'geodirectory' ); |
|
3546 | + } |
|
3547 | + } |
|
3548 | + // WPML |
|
3549 | + if ($is_wpml) { |
|
3550 | + $sitepress->switch_lang($active_lang, true); |
|
3551 | + } |
|
3552 | + // WPML |
|
3553 | + wp_send_json( $json ); |
|
3554 | + } |
|
3555 | + } |
|
3556 | + break; |
|
3557 | + case 'export_locations': { |
|
3558 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3559 | + $file_name = 'gd_locations_' . date( 'dmyHi' ); |
|
3560 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3561 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3562 | + $file_path_temp = $csv_file_dir . '/gd_locations_' . $nonce . '.csv'; |
|
3563 | 3563 | |
3564 | - $items_count = (int)geodir_location_imex_count_locations(); |
|
3564 | + $items_count = (int)geodir_location_imex_count_locations(); |
|
3565 | 3565 | |
3566 | - if ( isset( $_REQUEST['_st'] ) ) { |
|
3567 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3568 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3569 | - $percentage = min( $percentage, 100 ); |
|
3566 | + if ( isset( $_REQUEST['_st'] ) ) { |
|
3567 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3568 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3569 | + $percentage = min( $percentage, 100 ); |
|
3570 | 3570 | |
3571 | - $json['percentage'] = $percentage; |
|
3572 | - wp_send_json( $json ); |
|
3573 | - } else { |
|
3574 | - $chunk_file_paths = array(); |
|
3571 | + $json['percentage'] = $percentage; |
|
3572 | + wp_send_json( $json ); |
|
3573 | + } else { |
|
3574 | + $chunk_file_paths = array(); |
|
3575 | 3575 | |
3576 | - if ( !$items_count > 0 ) { |
|
3577 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3578 | - } else { |
|
3579 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3580 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3576 | + if ( !$items_count > 0 ) { |
|
3577 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3578 | + } else { |
|
3579 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3580 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3581 | 3581 | |
3582 | - $j = $chunk_page_no; |
|
3583 | - $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
3582 | + $j = $chunk_page_no; |
|
3583 | + $chunk_save_items = geodir_location_imex_locations_data( $chunk_per_page, $j ); |
|
3584 | 3584 | |
3585 | - $per_page = 500; |
|
3586 | - $per_page = min( $per_page, $chunk_per_page ); |
|
3587 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3585 | + $per_page = 500; |
|
3586 | + $per_page = min( $per_page, $chunk_per_page ); |
|
3587 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3588 | 3588 | |
3589 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3590 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3589 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3590 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3591 | 3591 | |
3592 | - $clear = $i == 0 ? true : false; |
|
3593 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3594 | - } |
|
3592 | + $clear = $i == 0 ? true : false; |
|
3593 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3594 | + } |
|
3595 | 3595 | |
3596 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3597 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3598 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3599 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3600 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3596 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3597 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3598 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3599 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3600 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3601 | 3601 | |
3602 | - $file_url = $file_url_base . $chunk_file_name; |
|
3603 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3604 | - } |
|
3602 | + $file_url = $file_url_base . $chunk_file_name; |
|
3603 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3604 | + } |
|
3605 | 3605 | |
3606 | - if ( !empty($chunk_file_paths) ) { |
|
3607 | - $json['total'] = $items_count; |
|
3608 | - $json['files'] = $chunk_file_paths; |
|
3609 | - } else { |
|
3610 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3611 | - } |
|
3612 | - } |
|
3613 | - wp_send_json( $json ); |
|
3614 | - } |
|
3615 | - } |
|
3616 | - break; |
|
3617 | - case 'export_hoods': { |
|
3618 | - $file_url_base = geodir_path_import_export() . '/'; |
|
3619 | - $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
3620 | - $file_url = $file_url_base . $file_name . '.csv'; |
|
3621 | - $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3622 | - $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
3606 | + if ( !empty($chunk_file_paths) ) { |
|
3607 | + $json['total'] = $items_count; |
|
3608 | + $json['files'] = $chunk_file_paths; |
|
3609 | + } else { |
|
3610 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3611 | + } |
|
3612 | + } |
|
3613 | + wp_send_json( $json ); |
|
3614 | + } |
|
3615 | + } |
|
3616 | + break; |
|
3617 | + case 'export_hoods': { |
|
3618 | + $file_url_base = geodir_path_import_export() . '/'; |
|
3619 | + $file_name = 'gd_neighbourhoods_' . date( 'dmyHi' ); |
|
3620 | + $file_url = $file_url_base . $file_name . '.csv'; |
|
3621 | + $file_path = $csv_file_dir . '/' . $file_name . '.csv'; |
|
3622 | + $file_path_temp = $csv_file_dir . '/gd_neighbourhoods_' . $nonce . '.csv'; |
|
3623 | 3623 | |
3624 | - $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
3624 | + $items_count = (int)geodir_location_imex_count_neighbourhoods(); |
|
3625 | 3625 | |
3626 | - if ( isset( $_REQUEST['_st'] ) ) { |
|
3627 | - $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3628 | - $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3629 | - $percentage = min( $percentage, 100 ); |
|
3626 | + if ( isset( $_REQUEST['_st'] ) ) { |
|
3627 | + $line_count = (int)geodir_import_export_line_count( $file_path_temp ); |
|
3628 | + $percentage = count( $items_count ) > 0 && $line_count > 0 ? ceil( $line_count / $items_count ) * 100 : 0; |
|
3629 | + $percentage = min( $percentage, 100 ); |
|
3630 | 3630 | |
3631 | - $json['percentage'] = $percentage; |
|
3632 | - wp_send_json( $json ); |
|
3633 | - } else { |
|
3634 | - $chunk_file_paths = array(); |
|
3631 | + $json['percentage'] = $percentage; |
|
3632 | + wp_send_json( $json ); |
|
3633 | + } else { |
|
3634 | + $chunk_file_paths = array(); |
|
3635 | 3635 | |
3636 | - if ( !$items_count > 0 ) { |
|
3637 | - $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3638 | - } else { |
|
3639 | - $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3640 | - $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3636 | + if ( !$items_count > 0 ) { |
|
3637 | + $json['error'] = __( 'No records to export.', 'geodirectory' ); |
|
3638 | + } else { |
|
3639 | + $chunk_per_page = min( $chunk_per_page, $items_count ); |
|
3640 | + $chunk_total_pages = ceil( $items_count / $chunk_per_page ); |
|
3641 | 3641 | |
3642 | - $j = $chunk_page_no; |
|
3643 | - $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
3642 | + $j = $chunk_page_no; |
|
3643 | + $chunk_save_items = geodir_location_imex_neighbourhoods_data( $chunk_per_page, $j ); |
|
3644 | 3644 | |
3645 | - $per_page = 500; |
|
3646 | - $per_page = min( $per_page, $chunk_per_page ); |
|
3647 | - $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3645 | + $per_page = 500; |
|
3646 | + $per_page = min( $per_page, $chunk_per_page ); |
|
3647 | + $total_pages = ceil( $chunk_per_page / $per_page ); |
|
3648 | 3648 | |
3649 | - for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3650 | - $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3649 | + for ( $i = 0; $i <= $total_pages; $i++ ) { |
|
3650 | + $save_items = array_slice( $chunk_save_items , ( $i * $per_page ), $per_page ); |
|
3651 | 3651 | |
3652 | - $clear = $i == 0 ? true : false; |
|
3653 | - geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3654 | - } |
|
3652 | + $clear = $i == 0 ? true : false; |
|
3653 | + geodir_save_csv_data( $file_path_temp, $save_items, $clear ); |
|
3654 | + } |
|
3655 | 3655 | |
3656 | - if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3657 | - $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3658 | - $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3659 | - $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3660 | - $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3656 | + if ( $wp_filesystem->exists( $file_path_temp ) ) { |
|
3657 | + $chunk_page_no = $chunk_total_pages > 1 ? '-' . $j : ''; |
|
3658 | + $chunk_file_name = $file_name . $chunk_page_no . '.csv'; |
|
3659 | + $file_path = $csv_file_dir . '/' . $chunk_file_name; |
|
3660 | + $wp_filesystem->move( $file_path_temp, $file_path, true ); |
|
3661 | 3661 | |
3662 | - $file_url = $file_url_base . $chunk_file_name; |
|
3663 | - $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3664 | - } |
|
3662 | + $file_url = $file_url_base . $chunk_file_name; |
|
3663 | + $chunk_file_paths[] = array('i' => $j . '.', 'u' => $file_url, 's' => size_format(filesize($file_path), 2)); |
|
3664 | + } |
|
3665 | 3665 | |
3666 | - if ( !empty($chunk_file_paths) ) { |
|
3667 | - $json['total'] = $items_count; |
|
3668 | - $json['files'] = $chunk_file_paths; |
|
3669 | - } else { |
|
3670 | - $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3671 | - } |
|
3672 | - } |
|
3673 | - wp_send_json( $json ); |
|
3674 | - } |
|
3675 | - } |
|
3676 | - break; |
|
3677 | - case 'prepare_import': |
|
3678 | - case 'import_cat': |
|
3679 | - case 'import_post': |
|
3680 | - case 'import_loc': |
|
3681 | - case 'import_hood': { |
|
3682 | - // WPML |
|
3683 | - $is_wpml = geodir_is_wpml(); |
|
3684 | - if ($is_wpml) { |
|
3685 | - global $sitepress; |
|
3686 | - $active_lang = ICL_LANGUAGE_CODE; |
|
3687 | - } |
|
3688 | - // WPML |
|
3666 | + if ( !empty($chunk_file_paths) ) { |
|
3667 | + $json['total'] = $items_count; |
|
3668 | + $json['files'] = $chunk_file_paths; |
|
3669 | + } else { |
|
3670 | + $json['error'] = __( 'Fail, something wrong to create csv file.', 'geodirectory' ); |
|
3671 | + } |
|
3672 | + } |
|
3673 | + wp_send_json( $json ); |
|
3674 | + } |
|
3675 | + } |
|
3676 | + break; |
|
3677 | + case 'prepare_import': |
|
3678 | + case 'import_cat': |
|
3679 | + case 'import_post': |
|
3680 | + case 'import_loc': |
|
3681 | + case 'import_hood': { |
|
3682 | + // WPML |
|
3683 | + $is_wpml = geodir_is_wpml(); |
|
3684 | + if ($is_wpml) { |
|
3685 | + global $sitepress; |
|
3686 | + $active_lang = ICL_LANGUAGE_CODE; |
|
3687 | + } |
|
3688 | + // WPML |
|
3689 | 3689 | |
3690 | - ini_set( 'auto_detect_line_endings', true ); |
|
3690 | + ini_set( 'auto_detect_line_endings', true ); |
|
3691 | 3691 | |
3692 | - $uploads = wp_upload_dir(); |
|
3693 | - $uploads_dir = $uploads['path']; |
|
3694 | - $uploads_subdir = $uploads['subdir']; |
|
3692 | + $uploads = wp_upload_dir(); |
|
3693 | + $uploads_dir = $uploads['path']; |
|
3694 | + $uploads_subdir = $uploads['subdir']; |
|
3695 | 3695 | |
3696 | - $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
3697 | - $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
3696 | + $csv_file = isset( $_POST['_file'] ) ? $_POST['_file'] : NULL; |
|
3697 | + $import_choice = isset( $_REQUEST['_ch'] ) ? $_REQUEST['_ch'] : 'skip'; |
|
3698 | 3698 | |
3699 | - $csv_file_arr = explode( '/', $csv_file ); |
|
3700 | - $csv_filename = end( $csv_file_arr ); |
|
3701 | - $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
3699 | + $csv_file_arr = explode( '/', $csv_file ); |
|
3700 | + $csv_filename = end( $csv_file_arr ); |
|
3701 | + $target_path = $uploads_dir . '/temp_' . $current_user->data->ID . '/' . $csv_filename; |
|
3702 | 3702 | |
3703 | - $json['file'] = $csv_file; |
|
3704 | - $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
3705 | - $file = array(); |
|
3703 | + $json['file'] = $csv_file; |
|
3704 | + $json['error'] = __( 'The uploaded file is not a valid csv file. Please try again.', 'geodirectory' ); |
|
3705 | + $file = array(); |
|
3706 | 3706 | |
3707 | - if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) { |
|
3708 | - $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
3707 | + if ( $csv_file && $wp_filesystem->is_file( $target_path ) && $wp_filesystem->exists( $target_path ) ) { |
|
3708 | + $wp_filetype = wp_check_filetype_and_ext( $target_path, $csv_filename ); |
|
3709 | 3709 | |
3710 | - if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
3711 | - $json['error'] = NULL; |
|
3712 | - $json['rows'] = 0; |
|
3710 | + if (!empty($wp_filetype) && isset($wp_filetype['ext']) && geodir_strtolower($wp_filetype['ext']) == 'csv') { |
|
3711 | + $json['error'] = NULL; |
|
3712 | + $json['rows'] = 0; |
|
3713 | 3713 | |
3714 | - $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
3715 | - setlocale(LC_ALL, 'en_US.UTF-8'); |
|
3716 | - if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) { |
|
3717 | - while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) { |
|
3718 | - if ( !empty( $data ) ) { |
|
3719 | - $file[] = $data; |
|
3720 | - } |
|
3721 | - } |
|
3722 | - fclose($handle); |
|
3723 | - } |
|
3724 | - setlocale(LC_ALL, $lc_all); |
|
3714 | + $lc_all = setlocale(LC_ALL, 0); // Fix issue of fgetcsv ignores special characters when they are at the beginning of line |
|
3715 | + setlocale(LC_ALL, 'en_US.UTF-8'); |
|
3716 | + if ( ( $handle = fopen($target_path, "r" ) ) !== FALSE ) { |
|
3717 | + while ( ( $data = fgetcsv( $handle, 100000, "," ) ) !== FALSE ) { |
|
3718 | + if ( !empty( $data ) ) { |
|
3719 | + $file[] = $data; |
|
3720 | + } |
|
3721 | + } |
|
3722 | + fclose($handle); |
|
3723 | + } |
|
3724 | + setlocale(LC_ALL, $lc_all); |
|
3725 | 3725 | |
3726 | - $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
3726 | + $json['rows'] = (!empty($file) && count($file) > 1) ? count($file) - 1 : 0; |
|
3727 | 3727 | |
3728 | - if (!$json['rows'] > 0) { |
|
3729 | - $json['error'] = __('No data found in csv file.', 'geodirectory'); |
|
3730 | - } |
|
3731 | - } else { |
|
3732 | - wp_send_json( $json ); |
|
3733 | - } |
|
3734 | - } else { |
|
3735 | - wp_send_json( $json ); |
|
3736 | - } |
|
3728 | + if (!$json['rows'] > 0) { |
|
3729 | + $json['error'] = __('No data found in csv file.', 'geodirectory'); |
|
3730 | + } |
|
3731 | + } else { |
|
3732 | + wp_send_json( $json ); |
|
3733 | + } |
|
3734 | + } else { |
|
3735 | + wp_send_json( $json ); |
|
3736 | + } |
|
3737 | 3737 | |
3738 | - if ( $task == 'prepare_import' || !empty( $json['error'] ) ) { |
|
3739 | - wp_send_json( $json ); |
|
3740 | - } |
|
3738 | + if ( $task == 'prepare_import' || !empty( $json['error'] ) ) { |
|
3739 | + wp_send_json( $json ); |
|
3740 | + } |
|
3741 | 3741 | |
3742 | - $total = $json['rows']; |
|
3743 | - $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
3744 | - $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
3742 | + $total = $json['rows']; |
|
3743 | + $limit = isset($_POST['limit']) ? (int)$_POST['limit'] : 1; |
|
3744 | + $processed = isset($_POST['processed']) ? (int)$_POST['processed'] : 0; |
|
3745 | 3745 | |
3746 | - $count = $limit; |
|
3746 | + $count = $limit; |
|
3747 | 3747 | |
3748 | - if ($count < $total) { |
|
3749 | - $count = $processed + $count; |
|
3750 | - if ($count > $total) { |
|
3751 | - $count = $total; |
|
3752 | - } |
|
3753 | - } else { |
|
3754 | - $count = $total; |
|
3755 | - } |
|
3748 | + if ($count < $total) { |
|
3749 | + $count = $processed + $count; |
|
3750 | + if ($count > $total) { |
|
3751 | + $count = $total; |
|
3752 | + } |
|
3753 | + } else { |
|
3754 | + $count = $total; |
|
3755 | + } |
|
3756 | 3756 | |
3757 | - $created = 0; |
|
3758 | - $updated = 0; |
|
3759 | - $skipped = 0; |
|
3760 | - $invalid = 0; |
|
3761 | - $invalid_addr = 0; |
|
3762 | - $images = 0; |
|
3757 | + $created = 0; |
|
3758 | + $updated = 0; |
|
3759 | + $skipped = 0; |
|
3760 | + $invalid = 0; |
|
3761 | + $invalid_addr = 0; |
|
3762 | + $images = 0; |
|
3763 | 3763 | |
3764 | - $gd_post_info = array(); |
|
3765 | - $countpost = 0; |
|
3764 | + $gd_post_info = array(); |
|
3765 | + $countpost = 0; |
|
3766 | 3766 | |
3767 | - $post_types = geodir_get_posttypes(); |
|
3767 | + $post_types = geodir_get_posttypes(); |
|
3768 | 3768 | |
3769 | - if ( $task == 'import_cat' ) { |
|
3770 | - if (!empty($file)) { |
|
3771 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
3769 | + if ( $task == 'import_cat' ) { |
|
3770 | + if (!empty($file)) { |
|
3771 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
3772 | 3772 | |
3773 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
3774 | - $json['error'] = CSV_INVAILD_FILE; |
|
3775 | - wp_send_json( $json ); |
|
3776 | - exit; |
|
3777 | - } |
|
3773 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
3774 | + $json['error'] = CSV_INVAILD_FILE; |
|
3775 | + wp_send_json( $json ); |
|
3776 | + exit; |
|
3777 | + } |
|
3778 | 3778 | |
3779 | - $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory'); |
|
3779 | + $gd_error_log = __('GD IMPORT CATEGORIES [ROW %d]:', 'geodirectory'); |
|
3780 | 3780 | |
3781 | - for ($i = 1; $i <= $limit; $i++) { |
|
3782 | - $index = $processed + $i; |
|
3781 | + for ($i = 1; $i <= $limit; $i++) { |
|
3782 | + $index = $processed + $i; |
|
3783 | 3783 | |
3784 | - if (isset($file[$index])) { |
|
3785 | - $row = $file[$index]; |
|
3786 | - $row = array_map( 'trim', $row ); |
|
3787 | - //$row = array_map( 'utf8_encode', $row ); |
|
3784 | + if (isset($file[$index])) { |
|
3785 | + $row = $file[$index]; |
|
3786 | + $row = array_map( 'trim', $row ); |
|
3787 | + //$row = array_map( 'utf8_encode', $row ); |
|
3788 | 3788 | |
3789 | - $cat_id = ''; |
|
3790 | - $cat_name = ''; |
|
3791 | - $cat_slug = ''; |
|
3792 | - $cat_posttype = ''; |
|
3793 | - $cat_parent = ''; |
|
3794 | - $cat_description = ''; |
|
3795 | - $cat_schema = ''; |
|
3796 | - $cat_top_description = ''; |
|
3797 | - $cat_image = ''; |
|
3798 | - $cat_icon = ''; |
|
3799 | - $cat_language = ''; |
|
3800 | - $cat_id_original = ''; |
|
3789 | + $cat_id = ''; |
|
3790 | + $cat_name = ''; |
|
3791 | + $cat_slug = ''; |
|
3792 | + $cat_posttype = ''; |
|
3793 | + $cat_parent = ''; |
|
3794 | + $cat_description = ''; |
|
3795 | + $cat_schema = ''; |
|
3796 | + $cat_top_description = ''; |
|
3797 | + $cat_image = ''; |
|
3798 | + $cat_icon = ''; |
|
3799 | + $cat_language = ''; |
|
3800 | + $cat_id_original = ''; |
|
3801 | 3801 | |
3802 | - $c = 0; |
|
3803 | - foreach ($columns as $column ) { |
|
3804 | - if ( $column == 'cat_id' ) { |
|
3805 | - $cat_id = (int)$row[$c]; |
|
3806 | - } else if ( $column == 'cat_name' ) { |
|
3807 | - $cat_name = $row[$c]; |
|
3808 | - } else if ( $column == 'cat_slug' ) { |
|
3809 | - $cat_slug = $row[$c]; |
|
3810 | - } else if ( $column == 'cat_posttype' ) { |
|
3811 | - $cat_posttype = $row[$c]; |
|
3812 | - } else if ( $column == 'cat_parent' ) { |
|
3813 | - $cat_parent = trim($row[$c]); |
|
3814 | - } else if ( $column == 'cat_schema' && $row[$c] != '' ) { |
|
3815 | - $cat_schema = $row[$c]; |
|
3816 | - } else if ( $column == 'cat_description' ) { |
|
3817 | - $cat_description = $row[$c]; |
|
3818 | - } else if ( $column == 'cat_top_description' ) { |
|
3819 | - $cat_top_description = $row[$c]; |
|
3820 | - } else if ( $column == 'cat_image' ) { |
|
3821 | - $cat_image = $row[$c]; |
|
3822 | - } else if ( $column == 'cat_icon' ) { |
|
3823 | - $cat_icon = $row[$c]; |
|
3824 | - } |
|
3825 | - // WPML |
|
3826 | - if ( $is_wpml ) { |
|
3827 | - if ( $column == 'cat_language' ) { |
|
3828 | - $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
3829 | - } else if ( $column == 'cat_id_original' ) { |
|
3830 | - $cat_id_original = (int)$row[$c]; |
|
3831 | - } |
|
3832 | - } |
|
3833 | - // WPML |
|
3834 | - $c++; |
|
3835 | - } |
|
3802 | + $c = 0; |
|
3803 | + foreach ($columns as $column ) { |
|
3804 | + if ( $column == 'cat_id' ) { |
|
3805 | + $cat_id = (int)$row[$c]; |
|
3806 | + } else if ( $column == 'cat_name' ) { |
|
3807 | + $cat_name = $row[$c]; |
|
3808 | + } else if ( $column == 'cat_slug' ) { |
|
3809 | + $cat_slug = $row[$c]; |
|
3810 | + } else if ( $column == 'cat_posttype' ) { |
|
3811 | + $cat_posttype = $row[$c]; |
|
3812 | + } else if ( $column == 'cat_parent' ) { |
|
3813 | + $cat_parent = trim($row[$c]); |
|
3814 | + } else if ( $column == 'cat_schema' && $row[$c] != '' ) { |
|
3815 | + $cat_schema = $row[$c]; |
|
3816 | + } else if ( $column == 'cat_description' ) { |
|
3817 | + $cat_description = $row[$c]; |
|
3818 | + } else if ( $column == 'cat_top_description' ) { |
|
3819 | + $cat_top_description = $row[$c]; |
|
3820 | + } else if ( $column == 'cat_image' ) { |
|
3821 | + $cat_image = $row[$c]; |
|
3822 | + } else if ( $column == 'cat_icon' ) { |
|
3823 | + $cat_icon = $row[$c]; |
|
3824 | + } |
|
3825 | + // WPML |
|
3826 | + if ( $is_wpml ) { |
|
3827 | + if ( $column == 'cat_language' ) { |
|
3828 | + $cat_language = geodir_strtolower( trim( $row[$c] ) ); |
|
3829 | + } else if ( $column == 'cat_id_original' ) { |
|
3830 | + $cat_id_original = (int)$row[$c]; |
|
3831 | + } |
|
3832 | + } |
|
3833 | + // WPML |
|
3834 | + $c++; |
|
3835 | + } |
|
3836 | 3836 | |
3837 | - if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) { |
|
3838 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
3837 | + if ( $cat_name == '' || !in_array( $cat_posttype, $post_types ) ) { |
|
3838 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
3839 | 3839 | |
3840 | - $invalid++; |
|
3841 | - continue; |
|
3842 | - } |
|
3840 | + $invalid++; |
|
3841 | + continue; |
|
3842 | + } |
|
3843 | 3843 | |
3844 | - // WPML |
|
3845 | - if ($is_wpml && $cat_language != '') { |
|
3846 | - $sitepress->switch_lang($cat_language, true); |
|
3847 | - } |
|
3848 | - // WPML |
|
3844 | + // WPML |
|
3845 | + if ($is_wpml && $cat_language != '') { |
|
3846 | + $sitepress->switch_lang($cat_language, true); |
|
3847 | + } |
|
3848 | + // WPML |
|
3849 | 3849 | |
3850 | - $term_data = array(); |
|
3851 | - $term_data['name'] = $cat_name; |
|
3852 | - $term_data['slug'] = $cat_slug; |
|
3853 | - $term_data['description'] = $cat_description; |
|
3854 | - $term_data['cat_schema'] = $cat_schema; |
|
3855 | - $term_data['top_description'] = $cat_top_description; |
|
3856 | - $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
3857 | - $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
3850 | + $term_data = array(); |
|
3851 | + $term_data['name'] = $cat_name; |
|
3852 | + $term_data['slug'] = $cat_slug; |
|
3853 | + $term_data['description'] = $cat_description; |
|
3854 | + $term_data['cat_schema'] = $cat_schema; |
|
3855 | + $term_data['top_description'] = $cat_top_description; |
|
3856 | + $term_data['image'] = $cat_image != '' ? basename( $cat_image ) : ''; |
|
3857 | + $term_data['icon'] = $cat_icon != '' ? basename( $cat_icon ) : ''; |
|
3858 | 3858 | |
3859 | - //$term_data = array_map( 'utf8_encode', $term_data ); |
|
3859 | + //$term_data = array_map( 'utf8_encode', $term_data ); |
|
3860 | 3860 | |
3861 | - $taxonomy = $cat_posttype . 'category'; |
|
3861 | + $taxonomy = $cat_posttype . 'category'; |
|
3862 | 3862 | |
3863 | - $term_data['taxonomy'] = $taxonomy; |
|
3863 | + $term_data['taxonomy'] = $taxonomy; |
|
3864 | 3864 | |
3865 | - $term_parent_id = 0; |
|
3866 | - if ($cat_parent != "" || (int)$cat_parent > 0) { |
|
3867 | - $term_parent = ''; |
|
3865 | + $term_parent_id = 0; |
|
3866 | + if ($cat_parent != "" || (int)$cat_parent > 0) { |
|
3867 | + $term_parent = ''; |
|
3868 | 3868 | |
3869 | - if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) { |
|
3870 | - // |
|
3871 | - } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) { |
|
3872 | - // |
|
3873 | - } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) { |
|
3874 | - // |
|
3875 | - } else { |
|
3876 | - $term_parent_data = array(); |
|
3877 | - $term_parent_data['name'] = $cat_parent; |
|
3878 | - //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
3879 | - $term_parent_data['taxonomy'] = $taxonomy; |
|
3869 | + if ( $term_parent = get_term_by( 'name', $cat_parent, $taxonomy ) ) { |
|
3870 | + // |
|
3871 | + } else if ( $term_parent = get_term_by( 'slug', $cat_parent, $taxonomy ) ) { |
|
3872 | + // |
|
3873 | + } else if ( $term_parent = get_term_by( 'id', $cat_parent, $taxonomy ) ) { |
|
3874 | + // |
|
3875 | + } else { |
|
3876 | + $term_parent_data = array(); |
|
3877 | + $term_parent_data['name'] = $cat_parent; |
|
3878 | + //$term_parent_data = array_map( 'utf8_encode', $term_parent_data ); |
|
3879 | + $term_parent_data['taxonomy'] = $taxonomy; |
|
3880 | 3880 | |
3881 | - $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
3882 | - } |
|
3881 | + $term_parent_id = (int)geodir_imex_insert_term( $taxonomy, $term_parent_data ); |
|
3882 | + } |
|
3883 | 3883 | |
3884 | - if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) { |
|
3885 | - $term_parent_id = (int)$term_parent->term_id; |
|
3886 | - } |
|
3887 | - } |
|
3888 | - $term_data['parent'] = (int)$term_parent_id; |
|
3884 | + if ( !empty( $term_parent ) && !is_wp_error( $term_parent ) ) { |
|
3885 | + $term_parent_id = (int)$term_parent->term_id; |
|
3886 | + } |
|
3887 | + } |
|
3888 | + $term_data['parent'] = (int)$term_parent_id; |
|
3889 | 3889 | |
3890 | - $term_id = NULL; |
|
3891 | - if ( $import_choice == 'update' ) { |
|
3892 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3893 | - $term_data['term_id'] = $term['term_id']; |
|
3890 | + $term_id = NULL; |
|
3891 | + if ( $import_choice == 'update' ) { |
|
3892 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3893 | + $term_data['term_id'] = $term['term_id']; |
|
3894 | 3894 | |
3895 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3896 | - $updated++; |
|
3897 | - } else { |
|
3898 | - $invalid++; |
|
3899 | - 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' ) ); |
|
3900 | - } |
|
3901 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3902 | - $term_data['term_id'] = $term['term_id']; |
|
3895 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3896 | + $updated++; |
|
3897 | + } else { |
|
3898 | + $invalid++; |
|
3899 | + 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' ) ); |
|
3900 | + } |
|
3901 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3902 | + $term_data['term_id'] = $term['term_id']; |
|
3903 | 3903 | |
3904 | - if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3905 | - $updated++; |
|
3906 | - } else { |
|
3907 | - $invalid++; |
|
3908 | - 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' ) ); |
|
3909 | - } |
|
3910 | - } else { |
|
3911 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3912 | - $created++; |
|
3913 | - } else { |
|
3914 | - $invalid++; |
|
3915 | - 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' ) ); |
|
3916 | - } |
|
3917 | - } |
|
3918 | - } else if ( $import_choice == 'skip' ) { |
|
3919 | - if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3920 | - $skipped++; |
|
3921 | - } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3922 | - $skipped++; |
|
3923 | - } else { |
|
3924 | - if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3925 | - $created++; |
|
3926 | - } else { |
|
3927 | - $invalid++; |
|
3928 | - 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' ) ); |
|
3929 | - } |
|
3930 | - } |
|
3931 | - } else { |
|
3932 | - $invalid++; |
|
3933 | - 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' ) ); |
|
3934 | - } |
|
3904 | + if ( $term_id = geodir_imex_update_term( $taxonomy, $term_data ) ) { |
|
3905 | + $updated++; |
|
3906 | + } else { |
|
3907 | + $invalid++; |
|
3908 | + 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' ) ); |
|
3909 | + } |
|
3910 | + } else { |
|
3911 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3912 | + $created++; |
|
3913 | + } else { |
|
3914 | + $invalid++; |
|
3915 | + 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' ) ); |
|
3916 | + } |
|
3917 | + } |
|
3918 | + } else if ( $import_choice == 'skip' ) { |
|
3919 | + if ( $cat_id > 0 && $term = (array)term_exists( $cat_id, $taxonomy ) ) { |
|
3920 | + $skipped++; |
|
3921 | + } else if ( $term_data['slug'] != '' && $term = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
|
3922 | + $skipped++; |
|
3923 | + } else { |
|
3924 | + if ( $term_id = geodir_imex_insert_term( $taxonomy, $term_data ) ) { |
|
3925 | + $created++; |
|
3926 | + } else { |
|
3927 | + $invalid++; |
|
3928 | + 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' ) ); |
|
3929 | + } |
|
3930 | + } |
|
3931 | + } else { |
|
3932 | + $invalid++; |
|
3933 | + 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' ) ); |
|
3934 | + } |
|
3935 | 3935 | |
3936 | - if ( $term_id ) { |
|
3937 | - // WPML |
|
3938 | - if ($is_wpml && $cat_id_original > 0 && $cat_language != '') { |
|
3939 | - $wpml_element_type = 'tax_' . $taxonomy; |
|
3940 | - $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
3941 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
3942 | - |
|
3943 | - $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
3936 | + if ( $term_id ) { |
|
3937 | + // WPML |
|
3938 | + if ($is_wpml && $cat_id_original > 0 && $cat_language != '') { |
|
3939 | + $wpml_element_type = 'tax_' . $taxonomy; |
|
3940 | + $source_language = geodir_get_language_for_element( $cat_id_original, $wpml_element_type ); |
|
3941 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
3942 | + |
|
3943 | + $trid = $sitepress->get_element_trid( $cat_id_original, $wpml_element_type ); |
|
3944 | 3944 | |
3945 | - $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
3946 | - } |
|
3947 | - // WPML |
|
3945 | + $sitepress->set_element_language_details( $term_id, $wpml_element_type, $trid, $cat_language, $source_language ); |
|
3946 | + } |
|
3947 | + // WPML |
|
3948 | 3948 | |
3949 | - if ( isset( $term_data['top_description'] ) ) { |
|
3950 | - update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
3951 | - } |
|
3949 | + if ( isset( $term_data['top_description'] ) ) { |
|
3950 | + update_tax_meta( $term_id, 'ct_cat_top_desc', $term_data['top_description'], $cat_posttype ); |
|
3951 | + } |
|
3952 | 3952 | |
3953 | - if ( isset( $term_data['cat_schema'] ) ) { |
|
3954 | - update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
3955 | - } |
|
3953 | + if ( isset( $term_data['cat_schema'] ) ) { |
|
3954 | + update_tax_meta( $term_id, 'ct_cat_schema', $term_data['cat_schema'], $cat_posttype ); |
|
3955 | + } |
|
3956 | 3956 | |
3957 | - $attachment = false; |
|
3958 | - if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) { |
|
3959 | - $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
3960 | - $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
3957 | + $attachment = false; |
|
3958 | + if ( isset( $term_data['image'] ) && $term_data['image'] != '' ) { |
|
3959 | + $cat_image = geodir_get_default_catimage( $term_id, $cat_posttype ); |
|
3960 | + $cat_image = !empty( $cat_image ) && isset( $cat_image['src'] ) ? $cat_image['src'] : ''; |
|
3961 | 3961 | |
3962 | - if ( basename($cat_image) != $term_data['image'] ) { |
|
3963 | - $attachment = true; |
|
3964 | - update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
3965 | - } |
|
3966 | - } |
|
3962 | + if ( basename($cat_image) != $term_data['image'] ) { |
|
3963 | + $attachment = true; |
|
3964 | + update_tax_meta( $term_id, 'ct_cat_default_img', array( 'id' => 'image', 'src' => $uploads['url'] . '/' . $term_data['image'] ), $cat_posttype ); |
|
3965 | + } |
|
3966 | + } |
|
3967 | 3967 | |
3968 | - if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) { |
|
3969 | - $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
3970 | - $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
3968 | + if ( isset( $term_data['icon'] ) && $term_data['icon'] != '' ) { |
|
3969 | + $cat_icon = get_tax_meta( $term_id, 'ct_cat_icon', false, $cat_posttype ); |
|
3970 | + $cat_icon = !empty( $cat_icon ) && isset( $cat_icon['src'] ) ? $cat_icon['src'] : ''; |
|
3971 | 3971 | |
3972 | - if ( basename($cat_icon) != $term_data['icon'] ) { |
|
3973 | - $attachment = true; |
|
3974 | - update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
3975 | - } |
|
3976 | - } |
|
3972 | + if ( basename($cat_icon) != $term_data['icon'] ) { |
|
3973 | + $attachment = true; |
|
3974 | + update_tax_meta( $term_id, 'ct_cat_icon', array( 'id' => 'icon', 'src' => $uploads['url'] . '/' . $term_data['icon'] ), $cat_posttype ); |
|
3975 | + } |
|
3976 | + } |
|
3977 | 3977 | |
3978 | - if ( $attachment ) { |
|
3979 | - $images++; |
|
3980 | - } |
|
3981 | - } |
|
3978 | + if ( $attachment ) { |
|
3979 | + $images++; |
|
3980 | + } |
|
3981 | + } |
|
3982 | 3982 | |
3983 | - // WPML |
|
3984 | - if ($is_wpml && $cat_language != '') { |
|
3985 | - $sitepress->switch_lang($active_lang, true); |
|
3986 | - } |
|
3987 | - // WPML |
|
3988 | - } |
|
3989 | - } |
|
3990 | - } |
|
3983 | + // WPML |
|
3984 | + if ($is_wpml && $cat_language != '') { |
|
3985 | + $sitepress->switch_lang($active_lang, true); |
|
3986 | + } |
|
3987 | + // WPML |
|
3988 | + } |
|
3989 | + } |
|
3990 | + } |
|
3991 | 3991 | |
3992 | - $json = array(); |
|
3993 | - $json['processed'] = $limit; |
|
3994 | - $json['created'] = $created; |
|
3995 | - $json['updated'] = $updated; |
|
3996 | - $json['skipped'] = $skipped; |
|
3997 | - $json['invalid'] = $invalid; |
|
3998 | - $json['images'] = $images; |
|
3992 | + $json = array(); |
|
3993 | + $json['processed'] = $limit; |
|
3994 | + $json['created'] = $created; |
|
3995 | + $json['updated'] = $updated; |
|
3996 | + $json['skipped'] = $skipped; |
|
3997 | + $json['invalid'] = $invalid; |
|
3998 | + $json['images'] = $images; |
|
3999 | 3999 | |
4000 | - wp_send_json( $json ); |
|
4001 | - exit; |
|
4002 | - } else if ( $task == 'import_post' ) { |
|
4003 | - //run some stuff to make the import quicker |
|
4004 | - wp_defer_term_counting( true ); |
|
4005 | - wp_defer_comment_counting( true ); |
|
4006 | - $wpdb->query( 'SET autocommit = 0;' ); |
|
4007 | - |
|
4008 | - //remove_all_actions('publish_post'); |
|
4009 | - //remove_all_actions('transition_post_status'); |
|
4010 | - //remove_all_actions('publish_future_post'); |
|
4011 | - |
|
4012 | - if (!empty($file)) { |
|
4013 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false; |
|
4014 | - $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
4015 | - $default_status = 'publish'; |
|
4016 | - $current_date = date_i18n( 'Y-m-d', time() ); |
|
4000 | + wp_send_json( $json ); |
|
4001 | + exit; |
|
4002 | + } else if ( $task == 'import_post' ) { |
|
4003 | + //run some stuff to make the import quicker |
|
4004 | + wp_defer_term_counting( true ); |
|
4005 | + wp_defer_comment_counting( true ); |
|
4006 | + $wpdb->query( 'SET autocommit = 0;' ); |
|
4007 | + |
|
4008 | + //remove_all_actions('publish_post'); |
|
4009 | + //remove_all_actions('transition_post_status'); |
|
4010 | + //remove_all_actions('publish_future_post'); |
|
4011 | + |
|
4012 | + if (!empty($file)) { |
|
4013 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false; |
|
4014 | + $wp_post_statuses = get_post_statuses(); // All of the WordPress supported post statuses. |
|
4015 | + $default_status = 'publish'; |
|
4016 | + $current_date = date_i18n( 'Y-m-d', time() ); |
|
4017 | 4017 | |
4018 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
4018 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
4019 | 4019 | |
4020 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4021 | - $json['error'] = CSV_INVAILD_FILE; |
|
4022 | - wp_send_json( $json ); |
|
4023 | - exit; |
|
4024 | - } |
|
4020 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4021 | + $json['error'] = CSV_INVAILD_FILE; |
|
4022 | + wp_send_json( $json ); |
|
4023 | + exit; |
|
4024 | + } |
|
4025 | 4025 | |
4026 | - $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory'); |
|
4027 | - $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
4028 | - $processed_actual = 0; |
|
4029 | - for ($i = 1; $i <= $limit; $i++) { |
|
4030 | - $index = $processed + $i; |
|
4031 | - $gd_post = array(); |
|
4026 | + $gd_error_log = __('GD IMPORT LISTINGS [ROW %d]:', 'geodirectory'); |
|
4027 | + $wp_chars_error = __( '(check & remove if any invalid characters used in data)', 'geodirectory' ); |
|
4028 | + $processed_actual = 0; |
|
4029 | + for ($i = 1; $i <= $limit; $i++) { |
|
4030 | + $index = $processed + $i; |
|
4031 | + $gd_post = array(); |
|
4032 | 4032 | |
4033 | - if (isset($file[$index])) { |
|
4034 | - $processed_actual++; |
|
4035 | - $row = $file[$index]; |
|
4036 | - $row = array_map( 'trim', $row ); |
|
4037 | - //$row = array_map( 'utf8_encode', $row ); |
|
4038 | - $row = array_map( 'addslashes_gpc', $row ); |
|
4033 | + if (isset($file[$index])) { |
|
4034 | + $processed_actual++; |
|
4035 | + $row = $file[$index]; |
|
4036 | + $row = array_map( 'trim', $row ); |
|
4037 | + //$row = array_map( 'utf8_encode', $row ); |
|
4038 | + $row = array_map( 'addslashes_gpc', $row ); |
|
4039 | 4039 | |
4040 | - $post_id = ''; |
|
4041 | - $post_title = ''; |
|
4042 | - $post_author = ''; |
|
4043 | - $post_content = ''; |
|
4044 | - $post_category_arr = array(); |
|
4045 | - $default_category = ''; |
|
4046 | - $post_tags = array(); |
|
4047 | - $post_type = ''; |
|
4048 | - $post_status = ''; |
|
4049 | - $geodir_video = ''; |
|
4050 | - $post_address = ''; |
|
4051 | - $post_city = ''; |
|
4052 | - $post_region = ''; |
|
4053 | - $post_country = ''; |
|
4054 | - $post_zip = ''; |
|
4055 | - $post_latitude = ''; |
|
4056 | - $post_longitude = ''; |
|
4057 | - $post_neighbourhood = ''; |
|
4058 | - $neighbourhood_latitude = ''; |
|
4059 | - $neighbourhood_longitude = ''; |
|
4060 | - $geodir_timing = ''; |
|
4061 | - $geodir_contact = ''; |
|
4062 | - $geodir_email = ''; |
|
4063 | - $geodir_website = ''; |
|
4064 | - $geodir_twitter = ''; |
|
4065 | - $geodir_facebook = ''; |
|
4066 | - $geodir_twitter = ''; |
|
4067 | - $post_images = array(); |
|
4040 | + $post_id = ''; |
|
4041 | + $post_title = ''; |
|
4042 | + $post_author = ''; |
|
4043 | + $post_content = ''; |
|
4044 | + $post_category_arr = array(); |
|
4045 | + $default_category = ''; |
|
4046 | + $post_tags = array(); |
|
4047 | + $post_type = ''; |
|
4048 | + $post_status = ''; |
|
4049 | + $geodir_video = ''; |
|
4050 | + $post_address = ''; |
|
4051 | + $post_city = ''; |
|
4052 | + $post_region = ''; |
|
4053 | + $post_country = ''; |
|
4054 | + $post_zip = ''; |
|
4055 | + $post_latitude = ''; |
|
4056 | + $post_longitude = ''; |
|
4057 | + $post_neighbourhood = ''; |
|
4058 | + $neighbourhood_latitude = ''; |
|
4059 | + $neighbourhood_longitude = ''; |
|
4060 | + $geodir_timing = ''; |
|
4061 | + $geodir_contact = ''; |
|
4062 | + $geodir_email = ''; |
|
4063 | + $geodir_website = ''; |
|
4064 | + $geodir_twitter = ''; |
|
4065 | + $geodir_facebook = ''; |
|
4066 | + $geodir_twitter = ''; |
|
4067 | + $post_images = array(); |
|
4068 | 4068 | |
4069 | - $expire_date = 'Never'; |
|
4069 | + $expire_date = 'Never'; |
|
4070 | 4070 | |
4071 | - $language = ''; |
|
4072 | - $original_post_id = ''; |
|
4071 | + $language = ''; |
|
4072 | + $original_post_id = ''; |
|
4073 | 4073 | |
4074 | - $c = 0; |
|
4075 | - foreach ($columns as $column ) { |
|
4076 | - $gd_post[$column] = $row[$c]; |
|
4074 | + $c = 0; |
|
4075 | + foreach ($columns as $column ) { |
|
4076 | + $gd_post[$column] = $row[$c]; |
|
4077 | 4077 | |
4078 | - if ( $column == 'post_id' ) { |
|
4079 | - $post_id = $row[$c]; |
|
4080 | - } else if ( $column == 'post_title' ) { |
|
4081 | - $post_title = sanitize_text_field($row[$c]); |
|
4082 | - } else if ( $column == 'post_author' ) { |
|
4083 | - $post_author = $row[$c]; |
|
4084 | - } else if ( $column == 'post_content' ) { |
|
4085 | - $post_content = $row[$c]; |
|
4086 | - } else if ( $column == 'post_category' && $row[$c] != '' ) { |
|
4087 | - $post_category_arr = explode( ',', $row[$c] ); |
|
4088 | - } else if ( $column == 'default_category' ) { |
|
4089 | - $default_category = wp_kses_normalize_entities($row[$c]); |
|
4090 | - } else if ( $column == 'post_tags' && $row[$c] != '' ) { |
|
4091 | - $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
4092 | - } else if ( $column == 'post_type' ) { |
|
4093 | - $post_type = $row[$c]; |
|
4094 | - } else if ( $column == 'post_status' ) { |
|
4095 | - $post_status = sanitize_key( $row[$c] ); |
|
4096 | - } else if ( $column == 'is_featured' ) { |
|
4097 | - $is_featured = (int)$row[$c]; |
|
4098 | - } else if ( $column == 'geodir_video' ) { |
|
4099 | - $geodir_video = $row[$c]; |
|
4100 | - } else if ( $column == 'post_address' ) { |
|
4101 | - $post_address = sanitize_text_field($row[$c]); |
|
4102 | - } else if ( $column == 'post_city' ) { |
|
4103 | - $post_city = sanitize_text_field($row[$c]); |
|
4104 | - } else if ( $column == 'post_region' ) { |
|
4105 | - $post_region = sanitize_text_field($row[$c]); |
|
4106 | - } else if ( $column == 'post_country' ) { |
|
4107 | - $post_country = sanitize_text_field($row[$c]); |
|
4108 | - } else if ( $column == 'post_zip' ) { |
|
4109 | - $post_zip = sanitize_text_field($row[$c]); |
|
4110 | - } else if ( $column == 'post_latitude' ) { |
|
4111 | - $post_latitude = sanitize_text_field($row[$c]); |
|
4112 | - } else if ( $column == 'post_longitude' ) { |
|
4113 | - $post_longitude = sanitize_text_field($row[$c]); |
|
4114 | - } else if ( $column == 'post_neighbourhood' ) { |
|
4115 | - $post_neighbourhood = sanitize_text_field($row[$c]); |
|
4116 | - unset($gd_post[$column]); |
|
4117 | - } else if ( $column == 'neighbourhood_latitude' ) { |
|
4118 | - $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
4119 | - } else if ( $column == 'neighbourhood_longitude' ) { |
|
4120 | - $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
4121 | - } else if ( $column == 'geodir_timing' ) { |
|
4122 | - $geodir_timing = sanitize_text_field($row[$c]); |
|
4123 | - } else if ( $column == 'geodir_contact' ) { |
|
4124 | - $geodir_contact = sanitize_text_field($row[$c]); |
|
4125 | - } else if ( $column == 'geodir_email' ) { |
|
4126 | - $geodir_email = sanitize_email($row[$c]); |
|
4127 | - } else if ( $column == 'geodir_website' ) { |
|
4128 | - $geodir_website = sanitize_text_field($row[$c]); |
|
4129 | - } else if ( $column == 'geodir_twitter' ) { |
|
4130 | - $geodir_twitter = sanitize_text_field($row[$c]); |
|
4131 | - } else if ( $column == 'geodir_facebook' ) { |
|
4132 | - $geodir_facebook = sanitize_text_field($row[$c]); |
|
4133 | - } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) { |
|
4134 | - $post_images[] = $row[$c]; |
|
4135 | - } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) { |
|
4136 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
4137 | - } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) { |
|
4138 | - $row[$c] = str_replace('/', '-', $row[$c]); |
|
4139 | - $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
4140 | - } |
|
4141 | - // WPML |
|
4142 | - if ($is_wpml) { |
|
4143 | - if ($column == 'language') { |
|
4144 | - $language = geodir_strtolower(trim($row[$c])); |
|
4145 | - } else if ($column == 'original_post_id') { |
|
4146 | - $original_post_id = (int)$row[$c]; |
|
4147 | - } |
|
4148 | - } |
|
4149 | - // WPML |
|
4150 | - $c++; |
|
4151 | - } |
|
4152 | - // listing claimed or not |
|
4153 | - if ($is_claim_active && isset($gd_post['claimed'])) { |
|
4154 | - $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
4155 | - } |
|
4078 | + if ( $column == 'post_id' ) { |
|
4079 | + $post_id = $row[$c]; |
|
4080 | + } else if ( $column == 'post_title' ) { |
|
4081 | + $post_title = sanitize_text_field($row[$c]); |
|
4082 | + } else if ( $column == 'post_author' ) { |
|
4083 | + $post_author = $row[$c]; |
|
4084 | + } else if ( $column == 'post_content' ) { |
|
4085 | + $post_content = $row[$c]; |
|
4086 | + } else if ( $column == 'post_category' && $row[$c] != '' ) { |
|
4087 | + $post_category_arr = explode( ',', $row[$c] ); |
|
4088 | + } else if ( $column == 'default_category' ) { |
|
4089 | + $default_category = wp_kses_normalize_entities($row[$c]); |
|
4090 | + } else if ( $column == 'post_tags' && $row[$c] != '' ) { |
|
4091 | + $post_tags = explode( ',', sanitize_text_field($row[$c]) ); |
|
4092 | + } else if ( $column == 'post_type' ) { |
|
4093 | + $post_type = $row[$c]; |
|
4094 | + } else if ( $column == 'post_status' ) { |
|
4095 | + $post_status = sanitize_key( $row[$c] ); |
|
4096 | + } else if ( $column == 'is_featured' ) { |
|
4097 | + $is_featured = (int)$row[$c]; |
|
4098 | + } else if ( $column == 'geodir_video' ) { |
|
4099 | + $geodir_video = $row[$c]; |
|
4100 | + } else if ( $column == 'post_address' ) { |
|
4101 | + $post_address = sanitize_text_field($row[$c]); |
|
4102 | + } else if ( $column == 'post_city' ) { |
|
4103 | + $post_city = sanitize_text_field($row[$c]); |
|
4104 | + } else if ( $column == 'post_region' ) { |
|
4105 | + $post_region = sanitize_text_field($row[$c]); |
|
4106 | + } else if ( $column == 'post_country' ) { |
|
4107 | + $post_country = sanitize_text_field($row[$c]); |
|
4108 | + } else if ( $column == 'post_zip' ) { |
|
4109 | + $post_zip = sanitize_text_field($row[$c]); |
|
4110 | + } else if ( $column == 'post_latitude' ) { |
|
4111 | + $post_latitude = sanitize_text_field($row[$c]); |
|
4112 | + } else if ( $column == 'post_longitude' ) { |
|
4113 | + $post_longitude = sanitize_text_field($row[$c]); |
|
4114 | + } else if ( $column == 'post_neighbourhood' ) { |
|
4115 | + $post_neighbourhood = sanitize_text_field($row[$c]); |
|
4116 | + unset($gd_post[$column]); |
|
4117 | + } else if ( $column == 'neighbourhood_latitude' ) { |
|
4118 | + $neighbourhood_latitude = sanitize_text_field($row[$c]); |
|
4119 | + } else if ( $column == 'neighbourhood_longitude' ) { |
|
4120 | + $neighbourhood_longitude = sanitize_text_field($row[$c]); |
|
4121 | + } else if ( $column == 'geodir_timing' ) { |
|
4122 | + $geodir_timing = sanitize_text_field($row[$c]); |
|
4123 | + } else if ( $column == 'geodir_contact' ) { |
|
4124 | + $geodir_contact = sanitize_text_field($row[$c]); |
|
4125 | + } else if ( $column == 'geodir_email' ) { |
|
4126 | + $geodir_email = sanitize_email($row[$c]); |
|
4127 | + } else if ( $column == 'geodir_website' ) { |
|
4128 | + $geodir_website = sanitize_text_field($row[$c]); |
|
4129 | + } else if ( $column == 'geodir_twitter' ) { |
|
4130 | + $geodir_twitter = sanitize_text_field($row[$c]); |
|
4131 | + } else if ( $column == 'geodir_facebook' ) { |
|
4132 | + $geodir_facebook = sanitize_text_field($row[$c]); |
|
4133 | + } else if ( $column == 'IMAGE' && !empty( $row[$c] ) && $row[$c] != '' ) { |
|
4134 | + $post_images[] = $row[$c]; |
|
4135 | + } else if ( $column == 'alive_days' && (int)$row[$c] > 0 ) { |
|
4136 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$row[$c] . ' days' ) ); |
|
4137 | + } else if ( $column == 'expire_date' && $row[$c] != '' && geodir_strtolower($row[$c]) != 'never' ) { |
|
4138 | + $row[$c] = str_replace('/', '-', $row[$c]); |
|
4139 | + $expire_date = date_i18n( 'Y-m-d', strtotime( $row[$c] ) ); |
|
4140 | + } |
|
4141 | + // WPML |
|
4142 | + if ($is_wpml) { |
|
4143 | + if ($column == 'language') { |
|
4144 | + $language = geodir_strtolower(trim($row[$c])); |
|
4145 | + } else if ($column == 'original_post_id') { |
|
4146 | + $original_post_id = (int)$row[$c]; |
|
4147 | + } |
|
4148 | + } |
|
4149 | + // WPML |
|
4150 | + $c++; |
|
4151 | + } |
|
4152 | + // listing claimed or not |
|
4153 | + if ($is_claim_active && isset($gd_post['claimed'])) { |
|
4154 | + $gd_post['claimed'] = (int)$gd_post['claimed'] == 1 ? 1 : 0; |
|
4155 | + } |
|
4156 | 4156 | |
4157 | - // WPML |
|
4158 | - if ($is_wpml && $language != '') { |
|
4159 | - $sitepress->switch_lang($language, true); |
|
4160 | - } |
|
4161 | - // WPML |
|
4157 | + // WPML |
|
4158 | + if ($is_wpml && $language != '') { |
|
4159 | + $sitepress->switch_lang($language, true); |
|
4160 | + } |
|
4161 | + // WPML |
|
4162 | 4162 | |
4163 | - $gd_post['IMAGE'] = $post_images; |
|
4163 | + $gd_post['IMAGE'] = $post_images; |
|
4164 | 4164 | |
4165 | - $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
4166 | - $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
4165 | + $post_status = !empty( $post_status ) ? sanitize_key( $post_status ) : $default_status; |
|
4166 | + $post_status = !empty( $wp_post_statuses ) && !isset( $wp_post_statuses[$post_status] ) ? $default_status : $post_status; |
|
4167 | 4167 | |
4168 | - $valid = true; |
|
4168 | + $valid = true; |
|
4169 | 4169 | |
4170 | - if ( $post_title == '' || !in_array( $post_type, $post_types ) ) { |
|
4171 | - $invalid++; |
|
4172 | - $valid = false; |
|
4173 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
4174 | - } |
|
4170 | + if ( $post_title == '' || !in_array( $post_type, $post_types ) ) { |
|
4171 | + $invalid++; |
|
4172 | + $valid = false; |
|
4173 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . __( 'Could not be added due to blank title/invalid post type', 'geodirectory' ) ); |
|
4174 | + } |
|
4175 | 4175 | |
4176 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
4177 | - if ( $location_allowed ) { |
|
4178 | - $location_result = geodir_get_default_location(); |
|
4179 | - if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) { |
|
4180 | - $invalid_addr++; |
|
4181 | - $valid = false; |
|
4182 | - 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' ) ); |
|
4183 | - } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) { |
|
4184 | - 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 ) ) ) { |
|
4185 | - $invalid_addr++; |
|
4186 | - $valid = false; |
|
4187 | - 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' ) ); |
|
4188 | - } else { |
|
4189 | - if (!$location_manager) { |
|
4190 | - $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. |
|
4191 | - } |
|
4192 | - } |
|
4193 | - } |
|
4194 | - } |
|
4176 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
4177 | + if ( $location_allowed ) { |
|
4178 | + $location_result = geodir_get_default_location(); |
|
4179 | + if ( $post_address == '' || $post_city == '' || $post_region == '' || $post_country == '' || $post_latitude == '' || $post_longitude == '' ) { |
|
4180 | + $invalid_addr++; |
|
4181 | + $valid = false; |
|
4182 | + 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' ) ); |
|
4183 | + } else if ( !empty( $location_result ) && $location_result->location_id == 0 ) { |
|
4184 | + 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 ) ) ) { |
|
4185 | + $invalid_addr++; |
|
4186 | + $valid = false; |
|
4187 | + 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' ) ); |
|
4188 | + } else { |
|
4189 | + if (!$location_manager) { |
|
4190 | + $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. |
|
4191 | + } |
|
4192 | + } |
|
4193 | + } |
|
4194 | + } |
|
4195 | 4195 | |
4196 | - if ( !$valid ) { |
|
4197 | - continue; |
|
4198 | - } |
|
4196 | + if ( !$valid ) { |
|
4197 | + continue; |
|
4198 | + } |
|
4199 | 4199 | |
4200 | - $cat_taxonomy = $post_type . 'category'; |
|
4201 | - $tags_taxonomy = $post_type . '_tags'; |
|
4200 | + $cat_taxonomy = $post_type . 'category'; |
|
4201 | + $tags_taxonomy = $post_type . '_tags'; |
|
4202 | 4202 | |
4203 | - if ($default_category != '' && !in_array($default_category, $post_category_arr)) { |
|
4204 | - $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
4205 | - } |
|
4203 | + if ($default_category != '' && !in_array($default_category, $post_category_arr)) { |
|
4204 | + $post_category_arr = array_merge(array($default_category), $post_category_arr); |
|
4205 | + } |
|
4206 | 4206 | |
4207 | - $post_category = array(); |
|
4208 | - $default_category_id = NULL; |
|
4209 | - if ( !empty( $post_category_arr ) ) { |
|
4210 | - foreach ( $post_category_arr as $value ) { |
|
4211 | - $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
4207 | + $post_category = array(); |
|
4208 | + $default_category_id = NULL; |
|
4209 | + if ( !empty( $post_category_arr ) ) { |
|
4210 | + foreach ( $post_category_arr as $value ) { |
|
4211 | + $category_name = wp_kses_normalize_entities( trim( $value ) ); |
|
4212 | 4212 | |
4213 | - if ( $category_name != '' ) { |
|
4214 | - $term_category = array(); |
|
4213 | + if ( $category_name != '' ) { |
|
4214 | + $term_category = array(); |
|
4215 | 4215 | |
4216 | - if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) { |
|
4217 | - $term_category = $term; |
|
4218 | - } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) { |
|
4219 | - $term_category = $term; |
|
4220 | - } else { |
|
4221 | - $term_data = array(); |
|
4222 | - $term_data['name'] = $category_name; |
|
4223 | - $term_data['taxonomy'] = $cat_taxonomy; |
|
4216 | + if ( $term = get_term_by( 'name', $category_name, $cat_taxonomy ) ) { |
|
4217 | + $term_category = $term; |
|
4218 | + } else if ( $term = get_term_by( 'slug', $category_name, $cat_taxonomy ) ) { |
|
4219 | + $term_category = $term; |
|
4220 | + } else { |
|
4221 | + $term_data = array(); |
|
4222 | + $term_data['name'] = $category_name; |
|
4223 | + $term_data['taxonomy'] = $cat_taxonomy; |
|
4224 | 4224 | |
4225 | - $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
4226 | - if ( $term_id ) { |
|
4227 | - $term_category = get_term( $term_id, $cat_taxonomy ); |
|
4228 | - } |
|
4229 | - } |
|
4225 | + $term_id = geodir_imex_insert_term( $cat_taxonomy, $term_data ); |
|
4226 | + if ( $term_id ) { |
|
4227 | + $term_category = get_term( $term_id, $cat_taxonomy ); |
|
4228 | + } |
|
4229 | + } |
|
4230 | 4230 | |
4231 | - if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) { |
|
4232 | - $post_category[] = intval($term_category->term_id); |
|
4231 | + if ( !empty( $term_category ) && !is_wp_error( $term_category ) ) { |
|
4232 | + $post_category[] = intval($term_category->term_id); |
|
4233 | 4233 | |
4234 | - if ($category_name == $default_category) { |
|
4235 | - $default_category_id = intval($term_category->term_id); |
|
4236 | - } |
|
4237 | - } |
|
4238 | - } |
|
4239 | - } |
|
4240 | - } |
|
4234 | + if ($category_name == $default_category) { |
|
4235 | + $default_category_id = intval($term_category->term_id); |
|
4236 | + } |
|
4237 | + } |
|
4238 | + } |
|
4239 | + } |
|
4240 | + } |
|
4241 | 4241 | |
4242 | - $save_post = array(); |
|
4243 | - $save_post['post_title'] = $post_title; |
|
4244 | - $save_post['post_content'] = $post_content; |
|
4245 | - $save_post['post_type'] = $post_type; |
|
4246 | - $save_post['post_author'] = $post_author; |
|
4247 | - $save_post['post_status'] = $post_status; |
|
4248 | - $save_post['post_category'] = $post_category; |
|
4249 | - $save_post['post_tags'] = $post_tags; |
|
4250 | - |
|
4251 | - $saved_post_id = NULL; |
|
4252 | - if ( $import_choice == 'update' ) { |
|
4253 | - $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
4242 | + $save_post = array(); |
|
4243 | + $save_post['post_title'] = $post_title; |
|
4244 | + $save_post['post_content'] = $post_content; |
|
4245 | + $save_post['post_type'] = $post_type; |
|
4246 | + $save_post['post_author'] = $post_author; |
|
4247 | + $save_post['post_status'] = $post_status; |
|
4248 | + $save_post['post_category'] = $post_category; |
|
4249 | + $save_post['post_tags'] = $post_tags; |
|
4250 | + |
|
4251 | + $saved_post_id = NULL; |
|
4252 | + if ( $import_choice == 'update' ) { |
|
4253 | + $gd_wp_error = __( 'Unable to add listing, please check the listing data.', 'geodirectory' ); |
|
4254 | 4254 | |
4255 | - if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4256 | - $save_post['ID'] = $post_id; |
|
4255 | + if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4256 | + $save_post['ID'] = $post_id; |
|
4257 | 4257 | |
4258 | - if ( $saved_post_id = wp_update_post( $save_post, true ) ) { |
|
4259 | - if ( is_wp_error( $saved_post_id ) ) { |
|
4260 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4261 | - $saved_post_id = 0; |
|
4262 | - } else { |
|
4263 | - $saved_post_id = $post_id; |
|
4264 | - $updated++; |
|
4265 | - } |
|
4266 | - } |
|
4267 | - } else { |
|
4268 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4269 | - if ( is_wp_error( $saved_post_id ) ) { |
|
4270 | - $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4271 | - $saved_post_id = 0; |
|
4272 | - } else { |
|
4273 | - $created++; |
|
4274 | - } |
|
4275 | - } |
|
4276 | - } |
|
4258 | + if ( $saved_post_id = wp_update_post( $save_post, true ) ) { |
|
4259 | + if ( is_wp_error( $saved_post_id ) ) { |
|
4260 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4261 | + $saved_post_id = 0; |
|
4262 | + } else { |
|
4263 | + $saved_post_id = $post_id; |
|
4264 | + $updated++; |
|
4265 | + } |
|
4266 | + } |
|
4267 | + } else { |
|
4268 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4269 | + if ( is_wp_error( $saved_post_id ) ) { |
|
4270 | + $gd_wp_error = $saved_post_id->get_error_message() . ' ' . $wp_chars_error; |
|
4271 | + $saved_post_id = 0; |
|
4272 | + } else { |
|
4273 | + $created++; |
|
4274 | + } |
|
4275 | + } |
|
4276 | + } |
|
4277 | 4277 | |
4278 | - if ( !$saved_post_id > 0 ) { |
|
4279 | - $invalid++; |
|
4280 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
4281 | - } |
|
4282 | - } else if ( $import_choice == 'skip' ) { |
|
4283 | - if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4284 | - $skipped++; |
|
4285 | - } else { |
|
4286 | - if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4287 | - if ( is_wp_error( $saved_post_id ) ) { |
|
4288 | - $invalid++; |
|
4278 | + if ( !$saved_post_id > 0 ) { |
|
4279 | + $invalid++; |
|
4280 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_wp_error ); |
|
4281 | + } |
|
4282 | + } else if ( $import_choice == 'skip' ) { |
|
4283 | + if ( $post_id > 0 && get_post( $post_id ) ) { |
|
4284 | + $skipped++; |
|
4285 | + } else { |
|
4286 | + if ( $saved_post_id = wp_insert_post( $save_post, true ) ) { |
|
4287 | + if ( is_wp_error( $saved_post_id ) ) { |
|
4288 | + $invalid++; |
|
4289 | 4289 | |
4290 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
4291 | - $saved_post_id = 0; |
|
4292 | - } else { |
|
4293 | - $created++; |
|
4294 | - } |
|
4295 | - } else { |
|
4296 | - $invalid++; |
|
4290 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $saved_post_id->get_error_message() . ' ' . $wp_chars_error ); |
|
4291 | + $saved_post_id = 0; |
|
4292 | + } else { |
|
4293 | + $created++; |
|
4294 | + } |
|
4295 | + } else { |
|
4296 | + $invalid++; |
|
4297 | 4297 | |
4298 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4299 | - } |
|
4300 | - } |
|
4301 | - } else { |
|
4302 | - $invalid++; |
|
4298 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4299 | + } |
|
4300 | + } |
|
4301 | + } else { |
|
4302 | + $invalid++; |
|
4303 | 4303 | |
4304 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4305 | - } |
|
4304 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $wp_chars_error ); |
|
4305 | + } |
|
4306 | 4306 | |
4307 | - if ( (int)$saved_post_id > 0 ) { |
|
4308 | - // WPML |
|
4309 | - if ($is_wpml && $original_post_id > 0 && $language != '') { |
|
4310 | - $wpml_post_type = 'post_' . $post_type; |
|
4311 | - $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
4312 | - $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
4307 | + if ( (int)$saved_post_id > 0 ) { |
|
4308 | + // WPML |
|
4309 | + if ($is_wpml && $original_post_id > 0 && $language != '') { |
|
4310 | + $wpml_post_type = 'post_' . $post_type; |
|
4311 | + $source_language = geodir_get_language_for_element( $original_post_id, $wpml_post_type ); |
|
4312 | + $source_language = $source_language != '' ? $source_language : $sitepress->get_default_language(); |
|
4313 | 4313 | |
4314 | - $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
4314 | + $trid = $sitepress->get_element_trid( $original_post_id, $wpml_post_type ); |
|
4315 | 4315 | |
4316 | - $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
4317 | - } |
|
4318 | - // WPML |
|
4319 | - $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
4316 | + $sitepress->set_element_language_details( $saved_post_id, $wpml_post_type, $trid, $language, $source_language ); |
|
4317 | + } |
|
4318 | + // WPML |
|
4319 | + $gd_post_info = geodir_get_post_info( $saved_post_id ); |
|
4320 | 4320 | |
4321 | - $gd_post['post_id'] = $saved_post_id; |
|
4322 | - $gd_post['ID'] = $saved_post_id; |
|
4323 | - $gd_post['post_tags'] = $post_tags; |
|
4324 | - $gd_post['post_title'] = $post_title; |
|
4325 | - $gd_post['post_status'] = $post_status; |
|
4326 | - $gd_post['submit_time'] = time(); |
|
4327 | - $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
4321 | + $gd_post['post_id'] = $saved_post_id; |
|
4322 | + $gd_post['ID'] = $saved_post_id; |
|
4323 | + $gd_post['post_tags'] = $post_tags; |
|
4324 | + $gd_post['post_title'] = $post_title; |
|
4325 | + $gd_post['post_status'] = $post_status; |
|
4326 | + $gd_post['submit_time'] = time(); |
|
4327 | + $gd_post['submit_ip'] = $_SERVER['REMOTE_ADDR']; |
|
4328 | 4328 | |
4329 | - // post location |
|
4330 | - $post_location_id = 0; |
|
4331 | - if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) { |
|
4332 | - $gd_post['post_neighbourhood'] = ''; |
|
4329 | + // post location |
|
4330 | + $post_location_id = 0; |
|
4331 | + if ( $location_allowed && !empty( $location_result ) && $location_result->location_id > 0 ) { |
|
4332 | + $gd_post['post_neighbourhood'] = ''; |
|
4333 | 4333 | |
4334 | - $post_location_info = array( |
|
4335 | - 'city' => $post_city, |
|
4336 | - 'region' => $post_region, |
|
4337 | - 'country' => $post_country, |
|
4338 | - 'geo_lat' => $post_latitude, |
|
4339 | - 'geo_lng' => $post_longitude |
|
4340 | - ); |
|
4341 | - if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) { |
|
4342 | - $post_location_id = $location_id; |
|
4343 | - } |
|
4334 | + $post_location_info = array( |
|
4335 | + 'city' => $post_city, |
|
4336 | + 'region' => $post_region, |
|
4337 | + 'country' => $post_country, |
|
4338 | + 'geo_lat' => $post_latitude, |
|
4339 | + 'geo_lng' => $post_longitude |
|
4340 | + ); |
|
4341 | + if ( $location_id = (int)geodir_add_new_location( $post_location_info ) ) { |
|
4342 | + $post_location_id = $location_id; |
|
4343 | + } |
|
4344 | 4344 | |
4345 | - if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) { |
|
4346 | - $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
4345 | + if ($post_location_id > 0 && $neighbourhood_active && !empty($post_neighbourhood)) { |
|
4346 | + $neighbourhood_info = geodir_location_neighbourhood_by_name_loc_id($post_neighbourhood, $post_location_id); |
|
4347 | 4347 | |
4348 | - $hood_data = array(); |
|
4349 | - $hood_data['hood_location_id'] = $post_location_id; |
|
4350 | - $hood_data['hood_name'] = $post_neighbourhood; |
|
4348 | + $hood_data = array(); |
|
4349 | + $hood_data['hood_location_id'] = $post_location_id; |
|
4350 | + $hood_data['hood_name'] = $post_neighbourhood; |
|
4351 | 4351 | |
4352 | - if (!empty($neighbourhood_info)) { |
|
4353 | - $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
4354 | - $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
4352 | + if (!empty($neighbourhood_info)) { |
|
4353 | + $hood_data['hood_id'] = $neighbourhood_info->hood_id; |
|
4354 | + $hood_data['hood_slug'] = $neighbourhood_info->hood_slug; |
|
4355 | 4355 | |
4356 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4357 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4358 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4359 | - } |
|
4360 | - } |
|
4356 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4357 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4358 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4359 | + } |
|
4360 | + } |
|
4361 | 4361 | |
4362 | - if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4363 | - $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4364 | - $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4365 | - } |
|
4362 | + if (empty($neighbourhood_latitude) || empty($neighbourhood_longitude)) { |
|
4363 | + $neighbourhood_latitude = $neighbourhood_info->hood_latitude; |
|
4364 | + $neighbourhood_longitude = $neighbourhood_info->hood_longitude; |
|
4365 | + } |
|
4366 | 4366 | |
4367 | - $hood_data['hood_latitude'] = $post_latitude; |
|
4368 | - $hood_data['hood_longitude'] = $post_longitude; |
|
4369 | - |
|
4370 | - $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
4371 | - if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) { |
|
4372 | - $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
4373 | - } |
|
4374 | - } |
|
4375 | - } |
|
4376 | - $gd_post['post_location_id'] = $post_location_id; |
|
4367 | + $hood_data['hood_latitude'] = $post_latitude; |
|
4368 | + $hood_data['hood_longitude'] = $post_longitude; |
|
4369 | + |
|
4370 | + $neighbourhood_info = geodir_location_insert_update_neighbourhood($hood_data); |
|
4371 | + if (!empty($neighbourhood_info) && isset($neighbourhood_info->hood_slug)) { |
|
4372 | + $gd_post['post_neighbourhood'] = $neighbourhood_info->hood_slug; |
|
4373 | + } |
|
4374 | + } |
|
4375 | + } |
|
4376 | + $gd_post['post_location_id'] = $post_location_id; |
|
4377 | 4377 | |
4378 | - // post package info |
|
4379 | - $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
4380 | - if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) { |
|
4381 | - $package_id = $gd_post_info->package_id; |
|
4382 | - } |
|
4378 | + // post package info |
|
4379 | + $package_id = isset( $gd_post['package_id'] ) && !empty( $gd_post['package_id'] ) ? (int)$gd_post['package_id'] : 0; |
|
4380 | + if (!$package_id && !empty($gd_post_info) && isset($gd_post_info->package_id) && $gd_post_info->package_id) { |
|
4381 | + $package_id = $gd_post_info->package_id; |
|
4382 | + } |
|
4383 | 4383 | |
4384 | - $package_info = array(); |
|
4385 | - if ($package_id && function_exists('geodir_get_package_info_by_id')) { |
|
4386 | - $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
4384 | + $package_info = array(); |
|
4385 | + if ($package_id && function_exists('geodir_get_package_info_by_id')) { |
|
4386 | + $package_info = (array)geodir_get_package_info_by_id($package_id); |
|
4387 | 4387 | |
4388 | - if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) { |
|
4389 | - $package_info = array(); |
|
4390 | - } |
|
4391 | - } |
|
4388 | + if (!(!empty($package_info) && isset($package_info['post_type']) && $package_info['post_type'] == $post_type)) { |
|
4389 | + $package_info = array(); |
|
4390 | + } |
|
4391 | + } |
|
4392 | 4392 | |
4393 | - if (empty($package_info)) { |
|
4394 | - $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
4395 | - } |
|
4393 | + if (empty($package_info)) { |
|
4394 | + $package_info = (array)geodir_post_package_info( array(), '', $post_type ); |
|
4395 | + } |
|
4396 | 4396 | |
4397 | - if (!empty($package_info)) { |
|
4398 | - $package_id = $package_info['pid']; |
|
4397 | + if (!empty($package_info)) { |
|
4398 | + $package_id = $package_info['pid']; |
|
4399 | 4399 | |
4400 | - if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) { |
|
4401 | - $gd_post['expire_date'] = $expire_date; |
|
4402 | - } else { |
|
4403 | - if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) { |
|
4404 | - $gd_post['alive_days'] = (int)$package_info['days']; |
|
4405 | - $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
4406 | - } else { |
|
4407 | - $gd_post['expire_date'] = 'Never'; |
|
4408 | - } |
|
4409 | - } |
|
4400 | + if (isset($gd_post['alive_days']) || isset($gd_post['expire_date'])) { |
|
4401 | + $gd_post['expire_date'] = $expire_date; |
|
4402 | + } else { |
|
4403 | + if ( isset( $package_info['days'] ) && (int)$package_info['days'] > 0 ) { |
|
4404 | + $gd_post['alive_days'] = (int)$package_info['days']; |
|
4405 | + $gd_post['expire_date'] = date_i18n( 'Y-m-d', strtotime( $current_date . '+' . (int)$package_info['days'] . ' days' ) ); |
|
4406 | + } else { |
|
4407 | + $gd_post['expire_date'] = 'Never'; |
|
4408 | + } |
|
4409 | + } |
|
4410 | 4410 | |
4411 | - $gd_post['package_id'] = $package_id; |
|
4412 | - } |
|
4411 | + $gd_post['package_id'] = $package_id; |
|
4412 | + } |
|
4413 | 4413 | |
4414 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
4414 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
4415 | 4415 | |
4416 | - if ($post_type == 'gd_event') { |
|
4417 | - $gd_post = geodir_imex_process_event_data($gd_post); |
|
4418 | - } |
|
4416 | + if ($post_type == 'gd_event') { |
|
4417 | + $gd_post = geodir_imex_process_event_data($gd_post); |
|
4418 | + } |
|
4419 | 4419 | |
4420 | - if (isset($gd_post['post_id'])) { |
|
4421 | - unset($gd_post['post_id']); |
|
4422 | - } |
|
4420 | + if (isset($gd_post['post_id'])) { |
|
4421 | + unset($gd_post['post_id']); |
|
4422 | + } |
|
4423 | 4423 | |
4424 | - // Export franchise fields |
|
4425 | - $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
4426 | - if ($is_franchise_active) { |
|
4427 | - if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) { |
|
4428 | - $gd_franchise_lock = array(); |
|
4424 | + // Export franchise fields |
|
4425 | + $is_franchise_active = is_plugin_active( 'geodir_franchise/geodir_franchise.php' ) && geodir_franchise_enabled( $post_type ) ? true : false; |
|
4426 | + if ($is_franchise_active) { |
|
4427 | + if ( isset( $gd_post['gd_is_franchise'] ) && (int)$gd_post['gd_is_franchise'] == 1 ) { |
|
4428 | + $gd_franchise_lock = array(); |
|
4429 | 4429 | |
4430 | - if ( isset( $gd_post['gd_franchise_lock'] ) ) { |
|
4431 | - $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] ); |
|
4432 | - $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
4433 | - $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
4434 | - } |
|
4430 | + if ( isset( $gd_post['gd_franchise_lock'] ) ) { |
|
4431 | + $gd_franchise_lock = str_replace(" ", "", $gd_post['gd_franchise_lock'] ); |
|
4432 | + $gd_franchise_lock = trim( $gd_franchise_lock ); |
|
4433 | + $gd_franchise_lock = explode( ",", $gd_franchise_lock ); |
|
4434 | + } |
|
4435 | 4435 | |
4436 | - update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
4437 | - update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
4438 | - } else { |
|
4439 | - if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) { |
|
4440 | - geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
4441 | - } |
|
4442 | - } |
|
4443 | - } |
|
4436 | + update_post_meta( $saved_post_id, 'gd_is_franchise', 1 ); |
|
4437 | + update_post_meta( $saved_post_id, 'gd_franchise_lock', $gd_franchise_lock ); |
|
4438 | + } else { |
|
4439 | + if ( isset( $gd_post['franchise'] ) && (int)$gd_post['franchise'] > 0 && geodir_franchise_check( (int)$gd_post['franchise'] ) ) { |
|
4440 | + geodir_save_post_meta( $saved_post_id, 'franchise', (int)$gd_post['franchise'] ); |
|
4441 | + } |
|
4442 | + } |
|
4443 | + } |
|
4444 | 4444 | |
4445 | - if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) { |
|
4446 | - $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
4447 | - if ($default_category_id) { |
|
4448 | - $save_post['post_default_category'] = $default_category_id; |
|
4449 | - $gd_post['default_category'] = $default_category_id; |
|
4450 | - } |
|
4451 | - $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
4452 | - } |
|
4445 | + if (!empty($save_post['post_category']) && is_array($save_post['post_category'])) { |
|
4446 | + $save_post['post_category'] = array_unique( array_map( 'intval', $save_post['post_category'] ) ); |
|
4447 | + if ($default_category_id) { |
|
4448 | + $save_post['post_default_category'] = $default_category_id; |
|
4449 | + $gd_post['default_category'] = $default_category_id; |
|
4450 | + } |
|
4451 | + $gd_post[$cat_taxonomy] = $save_post['post_category']; |
|
4452 | + } |
|
4453 | 4453 | |
4454 | - // Save post info |
|
4455 | - geodir_save_post_info( $saved_post_id, $gd_post ); |
|
4456 | - // post taxonomies |
|
4457 | - if ( !empty( $save_post['post_category'] ) ) { |
|
4458 | - wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
4454 | + // Save post info |
|
4455 | + geodir_save_post_info( $saved_post_id, $gd_post ); |
|
4456 | + // post taxonomies |
|
4457 | + if ( !empty( $save_post['post_category'] ) ) { |
|
4458 | + wp_set_object_terms( $saved_post_id, $save_post['post_category'], $cat_taxonomy ); |
|
4459 | 4459 | |
4460 | - $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
4461 | - if ($default_category_id) { |
|
4462 | - $post_default_category = $default_category_id; |
|
4463 | - } |
|
4464 | - $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
4465 | - $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category']; |
|
4466 | - $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : ''; |
|
4460 | + $post_default_category = isset( $save_post['post_default_category'] ) ? $save_post['post_default_category'] : ''; |
|
4461 | + if ($default_category_id) { |
|
4462 | + $post_default_category = $default_category_id; |
|
4463 | + } |
|
4464 | + $post_cat_ids = geodir_get_post_meta($saved_post_id, $cat_taxonomy); |
|
4465 | + $save_post['post_category'] = !empty($post_cat_ids) ? explode(",", trim($post_cat_ids, ",")) : $save_post['post_category']; |
|
4466 | + $post_category_str = !empty($save_post['post_category']) ? implode(",y:#", $save_post['post_category']) . ',y:' : ''; |
|
4467 | 4467 | |
4468 | - if ($post_category_str != '' && $post_default_category) { |
|
4469 | - $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
4470 | - } |
|
4468 | + if ($post_category_str != '' && $post_default_category) { |
|
4469 | + $post_category_str = str_replace($post_default_category . ',y:', $post_default_category . ',y,d:', $post_category_str); |
|
4470 | + } |
|
4471 | 4471 | |
4472 | - $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
4472 | + $post_category_str = $post_category_str != '' ? array($cat_taxonomy => $post_category_str) : ''; |
|
4473 | 4473 | |
4474 | - geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
4475 | - } |
|
4474 | + geodir_set_postcat_structure( $saved_post_id, $cat_taxonomy, $post_default_category, $post_category_str ); |
|
4475 | + } |
|
4476 | 4476 | |
4477 | - if ( !empty( $save_post['post_tags'] ) ) { |
|
4478 | - wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
4479 | - } |
|
4477 | + if ( !empty( $save_post['post_tags'] ) ) { |
|
4478 | + wp_set_object_terms( $saved_post_id, $save_post['post_tags'], $tags_taxonomy ); |
|
4479 | + } |
|
4480 | 4480 | |
4481 | - // Post images |
|
4482 | - if ( !empty( $post_images ) ) { |
|
4483 | - $post_images = array_unique($post_images); |
|
4481 | + // Post images |
|
4482 | + if ( !empty( $post_images ) ) { |
|
4483 | + $post_images = array_unique($post_images); |
|
4484 | 4484 | |
4485 | - $old_post_images_arr = array(); |
|
4486 | - $saved_post_images_arr = array(); |
|
4485 | + $old_post_images_arr = array(); |
|
4486 | + $saved_post_images_arr = array(); |
|
4487 | 4487 | |
4488 | - $order = 1; |
|
4488 | + $order = 1; |
|
4489 | 4489 | |
4490 | - $old_post_images = geodir_get_images( $saved_post_id ); |
|
4491 | - if (!empty($old_post_images)) { |
|
4492 | - foreach( $old_post_images as $old_post_image ) { |
|
4493 | - if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') { |
|
4494 | - $old_post_images_arr[] = $old_post_image->file; |
|
4495 | - } |
|
4496 | - } |
|
4497 | - } |
|
4490 | + $old_post_images = geodir_get_images( $saved_post_id ); |
|
4491 | + if (!empty($old_post_images)) { |
|
4492 | + foreach( $old_post_images as $old_post_image ) { |
|
4493 | + if (!empty($old_post_image) && isset($old_post_image->file) && $old_post_image->file != '') { |
|
4494 | + $old_post_images_arr[] = $old_post_image->file; |
|
4495 | + } |
|
4496 | + } |
|
4497 | + } |
|
4498 | 4498 | |
4499 | - foreach ( $post_images as $post_image ) { |
|
4500 | - $image_name = basename( $post_image ); |
|
4501 | - $saved_post_images_arr[] = $image_name; |
|
4499 | + foreach ( $post_images as $post_image ) { |
|
4500 | + $image_name = basename( $post_image ); |
|
4501 | + $saved_post_images_arr[] = $image_name; |
|
4502 | 4502 | |
4503 | - if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) { |
|
4504 | - continue; // Skip if image already exists. |
|
4505 | - } |
|
4503 | + if (!empty($old_post_images_arr) && in_array( $image_name, $old_post_images_arr) ) { |
|
4504 | + continue; // Skip if image already exists. |
|
4505 | + } |
|
4506 | 4506 | |
4507 | - $image_name_parts = explode( '.', $image_name ); |
|
4508 | - array_pop( $image_name_parts ); |
|
4509 | - $proper_image_name = implode( '.', $image_name_parts ); |
|
4507 | + $image_name_parts = explode( '.', $image_name ); |
|
4508 | + array_pop( $image_name_parts ); |
|
4509 | + $proper_image_name = implode( '.', $image_name_parts ); |
|
4510 | 4510 | |
4511 | - $arr_file_type = wp_check_filetype( $image_name ); |
|
4511 | + $arr_file_type = wp_check_filetype( $image_name ); |
|
4512 | 4512 | |
4513 | - if ( !empty( $arr_file_type ) ) { |
|
4514 | - $uploaded_file_type = $arr_file_type['type']; |
|
4513 | + if ( !empty( $arr_file_type ) ) { |
|
4514 | + $uploaded_file_type = $arr_file_type['type']; |
|
4515 | 4515 | |
4516 | - $attachment = array(); |
|
4517 | - $attachment['post_id'] = $saved_post_id; |
|
4518 | - $attachment['title'] = $proper_image_name; |
|
4519 | - $attachment['content'] = ''; |
|
4520 | - $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
4521 | - $attachment['mime_type'] = $uploaded_file_type; |
|
4522 | - $attachment['menu_order'] = $order; |
|
4523 | - $attachment['is_featured'] = 0; |
|
4524 | - |
|
4525 | - $attachment_set = ''; |
|
4526 | - foreach ( $attachment as $key => $val ) { |
|
4527 | - if ( $val != '' ) { |
|
4528 | - $attachment_set .= $key . " = '" . $val . "', "; |
|
4529 | - } |
|
4530 | - } |
|
4531 | - $attachment_set = trim( $attachment_set, ", " ); |
|
4516 | + $attachment = array(); |
|
4517 | + $attachment['post_id'] = $saved_post_id; |
|
4518 | + $attachment['title'] = $proper_image_name; |
|
4519 | + $attachment['content'] = ''; |
|
4520 | + $attachment['file'] = $uploads_subdir . '/' . $image_name; |
|
4521 | + $attachment['mime_type'] = $uploaded_file_type; |
|
4522 | + $attachment['menu_order'] = $order; |
|
4523 | + $attachment['is_featured'] = 0; |
|
4524 | + |
|
4525 | + $attachment_set = ''; |
|
4526 | + foreach ( $attachment as $key => $val ) { |
|
4527 | + if ( $val != '' ) { |
|
4528 | + $attachment_set .= $key . " = '" . $val . "', "; |
|
4529 | + } |
|
4530 | + } |
|
4531 | + $attachment_set = trim( $attachment_set, ", " ); |
|
4532 | 4532 | |
4533 | - // Add new attachment |
|
4534 | - $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
4533 | + // Add new attachment |
|
4534 | + $wpdb->query( "INSERT INTO " . GEODIR_ATTACHMENT_TABLE . " SET " . $attachment_set ); |
|
4535 | 4535 | |
4536 | - $order++; |
|
4537 | - } |
|
4538 | - } |
|
4536 | + $order++; |
|
4537 | + } |
|
4538 | + } |
|
4539 | 4539 | |
4540 | - $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : ''; |
|
4541 | - // Remove previous attachment |
|
4542 | - $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
4540 | + $saved_post_images_sql = !empty($saved_post_images_arr) ? " AND ( file NOT LIKE '%/" . implode("' AND file NOT LIKE '%/", $saved_post_images_arr) . "' )" : ''; |
|
4541 | + // Remove previous attachment |
|
4542 | + $wpdb->query( "DELETE FROM " . GEODIR_ATTACHMENT_TABLE . " WHERE post_id = " . (int)$saved_post_id . " " . $saved_post_images_sql ); |
|
4543 | 4543 | |
4544 | - if ( !empty( $saved_post_images_arr ) ) { |
|
4545 | - geodir_set_wp_featured_image($saved_post_id); |
|
4546 | - /* |
|
4544 | + if ( !empty( $saved_post_images_arr ) ) { |
|
4545 | + geodir_set_wp_featured_image($saved_post_id); |
|
4546 | + /* |
|
4547 | 4547 | $menu_order = 1; |
4548 | 4548 | |
4549 | 4549 | foreach ( $saved_post_images_arr as $img_name ) { |
@@ -4556,284 +4556,284 @@ discard block |
||
4556 | 4556 | } |
4557 | 4557 | $menu_order++; |
4558 | 4558 | }*/ |
4559 | - } |
|
4559 | + } |
|
4560 | 4560 | |
4561 | - if ( $order > 1 ) { |
|
4562 | - $images++; |
|
4563 | - } |
|
4564 | - } |
|
4561 | + if ( $order > 1 ) { |
|
4562 | + $images++; |
|
4563 | + } |
|
4564 | + } |
|
4565 | 4565 | |
4566 | - /** This action is documented in geodirectory-functions/post-functions.php */ |
|
4567 | - do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
4566 | + /** This action is documented in geodirectory-functions/post-functions.php */ |
|
4567 | + do_action( 'geodir_after_save_listing', $saved_post_id, $gd_post ); |
|
4568 | 4568 | |
4569 | - if (isset($is_featured)) { |
|
4570 | - geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
4571 | - } |
|
4572 | - if (isset($gd_post['alive_days'])) { |
|
4573 | - geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
4574 | - } |
|
4575 | - if (isset($gd_post['expire_date'])) { |
|
4576 | - geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
4577 | - } |
|
4578 | - } |
|
4569 | + if (isset($is_featured)) { |
|
4570 | + geodir_save_post_meta($saved_post_id, 'is_featured', $is_featured); |
|
4571 | + } |
|
4572 | + if (isset($gd_post['alive_days'])) { |
|
4573 | + geodir_save_post_meta($saved_post_id, 'alive_days', $gd_post['alive_days']); |
|
4574 | + } |
|
4575 | + if (isset($gd_post['expire_date'])) { |
|
4576 | + geodir_save_post_meta($saved_post_id, 'expire_date', $gd_post['expire_date']); |
|
4577 | + } |
|
4578 | + } |
|
4579 | 4579 | |
4580 | - // WPML |
|
4581 | - if ($is_wpml && $language != '') { |
|
4582 | - $sitepress->switch_lang($active_lang, true); |
|
4583 | - } |
|
4584 | - // WPML |
|
4585 | - } |
|
4586 | - } |
|
4587 | - } |
|
4580 | + // WPML |
|
4581 | + if ($is_wpml && $language != '') { |
|
4582 | + $sitepress->switch_lang($active_lang, true); |
|
4583 | + } |
|
4584 | + // WPML |
|
4585 | + } |
|
4586 | + } |
|
4587 | + } |
|
4588 | 4588 | |
4589 | - //undo some stuff to make the import quicker |
|
4590 | - wp_defer_term_counting( false ); |
|
4591 | - wp_defer_comment_counting( false ); |
|
4592 | - $wpdb->query( 'COMMIT;' ); |
|
4593 | - $wpdb->query( 'SET autocommit = 1;' ); |
|
4594 | - |
|
4595 | - $json = array(); |
|
4596 | - $json['processed'] = $processed_actual; |
|
4597 | - $json['created'] = $created; |
|
4598 | - $json['updated'] = $updated; |
|
4599 | - $json['skipped'] = $skipped; |
|
4600 | - $json['invalid'] = $invalid; |
|
4601 | - $json['invalid_addr'] = $invalid_addr; |
|
4602 | - $json['images'] = $images; |
|
4589 | + //undo some stuff to make the import quicker |
|
4590 | + wp_defer_term_counting( false ); |
|
4591 | + wp_defer_comment_counting( false ); |
|
4592 | + $wpdb->query( 'COMMIT;' ); |
|
4593 | + $wpdb->query( 'SET autocommit = 1;' ); |
|
4594 | + |
|
4595 | + $json = array(); |
|
4596 | + $json['processed'] = $processed_actual; |
|
4597 | + $json['created'] = $created; |
|
4598 | + $json['updated'] = $updated; |
|
4599 | + $json['skipped'] = $skipped; |
|
4600 | + $json['invalid'] = $invalid; |
|
4601 | + $json['invalid_addr'] = $invalid_addr; |
|
4602 | + $json['images'] = $images; |
|
4603 | 4603 | |
4604 | - wp_send_json( $json ); |
|
4605 | - exit; |
|
4606 | - } else if ( $task == 'import_loc' ) { |
|
4607 | - global $gd_post_types; |
|
4608 | - $gd_post_types = $post_types; |
|
4604 | + wp_send_json( $json ); |
|
4605 | + exit; |
|
4606 | + } else if ( $task == 'import_loc' ) { |
|
4607 | + global $gd_post_types; |
|
4608 | + $gd_post_types = $post_types; |
|
4609 | 4609 | |
4610 | - if (!empty($file)) { |
|
4611 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
4610 | + if (!empty($file)) { |
|
4611 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
4612 | 4612 | |
4613 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4614 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory'); |
|
4615 | - wp_send_json( $json ); |
|
4616 | - } |
|
4613 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4614 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory'); |
|
4615 | + wp_send_json( $json ); |
|
4616 | + } |
|
4617 | 4617 | |
4618 | - $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory'); |
|
4619 | - $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
4620 | - for ($i = 1; $i <= $limit; $i++) { |
|
4621 | - $index = $processed + $i; |
|
4618 | + $gd_error_log = __('GD IMPORT LOCATIONS [ROW %d]:', 'geodirectory'); |
|
4619 | + $gd_error_location = __( 'Could not be saved due to blank/invalid address(city, region, country, latitude, longitude)', 'geodirectory' ); |
|
4620 | + for ($i = 1; $i <= $limit; $i++) { |
|
4621 | + $index = $processed + $i; |
|
4622 | 4622 | |
4623 | - if (isset($file[$index])) { |
|
4624 | - $row = $file[$index]; |
|
4625 | - $row = array_map( 'trim', $row ); |
|
4626 | - $data = array(); |
|
4623 | + if (isset($file[$index])) { |
|
4624 | + $row = $file[$index]; |
|
4625 | + $row = array_map( 'trim', $row ); |
|
4626 | + $data = array(); |
|
4627 | 4627 | |
4628 | - foreach ($columns as $c => $column ) { |
|
4629 | - 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'))) { |
|
4630 | - $data[$column] = $row[$c]; |
|
4631 | - } |
|
4632 | - } |
|
4628 | + foreach ($columns as $c => $column ) { |
|
4629 | + 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'))) { |
|
4630 | + $data[$column] = $row[$c]; |
|
4631 | + } |
|
4632 | + } |
|
4633 | 4633 | |
4634 | - if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) { |
|
4635 | - $invalid++; |
|
4636 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4637 | - continue; |
|
4638 | - } |
|
4634 | + if ( empty($data['city']) || empty($data['region']) || empty($data['country']) || empty($data['latitude']) || empty($data['longitude']) ) { |
|
4635 | + $invalid++; |
|
4636 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4637 | + continue; |
|
4638 | + } |
|
4639 | 4639 | |
4640 | - $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
4640 | + $data['location_id'] = isset($data['location_id']) ? absint($data['location_id']) : 0; |
|
4641 | 4641 | |
4642 | - if ( $import_choice == 'update' ) { |
|
4643 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4644 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4645 | - $updated++; |
|
4646 | - } else { |
|
4647 | - $invalid++; |
|
4648 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4649 | - } |
|
4650 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4651 | - $data['location_id'] = (int)$location->location_id; |
|
4642 | + if ( $import_choice == 'update' ) { |
|
4643 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4644 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4645 | + $updated++; |
|
4646 | + } else { |
|
4647 | + $invalid++; |
|
4648 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4649 | + } |
|
4650 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4651 | + $data['location_id'] = (int)$location->location_id; |
|
4652 | 4652 | |
4653 | - if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) { |
|
4654 | - $data['location_id'] = (int)$location->location_id; |
|
4655 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) { |
|
4656 | - $data['location_id'] = (int)$location->location_id; |
|
4657 | - } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) { |
|
4658 | - $data['location_id'] = (int)$location->location_id; |
|
4659 | - } |
|
4653 | + if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'], 'region' => $data['region'] ) ) ) { |
|
4654 | + $data['location_id'] = (int)$location->location_id; |
|
4655 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'region' => $data['region'] ) ) ) { |
|
4656 | + $data['location_id'] = (int)$location->location_id; |
|
4657 | + } else if ( $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'], 'country' => $data['country'] ) ) ) { |
|
4658 | + $data['location_id'] = (int)$location->location_id; |
|
4659 | + } |
|
4660 | 4660 | |
4661 | - if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4662 | - $updated++; |
|
4663 | - } else { |
|
4664 | - $invalid++; |
|
4665 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4666 | - } |
|
4667 | - } else { |
|
4668 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4669 | - $created++; |
|
4670 | - } else { |
|
4671 | - $invalid++; |
|
4672 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4673 | - } |
|
4674 | - } |
|
4675 | - } elseif ( $import_choice == 'skip' ) { |
|
4676 | - if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4677 | - $skipped++; |
|
4678 | - } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4679 | - $skipped++; |
|
4680 | - } else { |
|
4681 | - if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4682 | - $created++; |
|
4683 | - } else { |
|
4684 | - $invalid++; |
|
4685 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4686 | - } |
|
4687 | - } |
|
4688 | - } else { |
|
4689 | - $invalid++; |
|
4690 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4691 | - } |
|
4692 | - } |
|
4693 | - } |
|
4694 | - } |
|
4661 | + if ( $location_id = geodir_location_update_city( $data, true, $location ) ) { |
|
4662 | + $updated++; |
|
4663 | + } else { |
|
4664 | + $invalid++; |
|
4665 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4666 | + } |
|
4667 | + } else { |
|
4668 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4669 | + $created++; |
|
4670 | + } else { |
|
4671 | + $invalid++; |
|
4672 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4673 | + } |
|
4674 | + } |
|
4675 | + } elseif ( $import_choice == 'skip' ) { |
|
4676 | + if ( (int)$data['location_id'] > 0 && $location = geodir_get_location_by_id( '', (int)$data['location_id'] ) ) { |
|
4677 | + $skipped++; |
|
4678 | + } else if ( !empty( $data['city_slug'] ) && $location = geodir_get_location_by_slug( 'city', array( 'city_slug' => $data['city_slug'] ) ) ) { |
|
4679 | + $skipped++; |
|
4680 | + } else { |
|
4681 | + if ( $location_id = geodir_location_insert_city( $data, true ) ) { |
|
4682 | + $created++; |
|
4683 | + } else { |
|
4684 | + $invalid++; |
|
4685 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4686 | + } |
|
4687 | + } |
|
4688 | + } else { |
|
4689 | + $invalid++; |
|
4690 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_location ); |
|
4691 | + } |
|
4692 | + } |
|
4693 | + } |
|
4694 | + } |
|
4695 | 4695 | |
4696 | - $json = array(); |
|
4697 | - $json['processed'] = $limit; |
|
4698 | - $json['created'] = $created; |
|
4699 | - $json['updated'] = $updated; |
|
4700 | - $json['skipped'] = $skipped; |
|
4701 | - $json['invalid'] = $invalid; |
|
4702 | - $json['images'] = $images; |
|
4696 | + $json = array(); |
|
4697 | + $json['processed'] = $limit; |
|
4698 | + $json['created'] = $created; |
|
4699 | + $json['updated'] = $updated; |
|
4700 | + $json['skipped'] = $skipped; |
|
4701 | + $json['invalid'] = $invalid; |
|
4702 | + $json['images'] = $images; |
|
4703 | 4703 | |
4704 | - wp_send_json( $json ); |
|
4705 | - } else if ( $task == 'import_hood' ) { |
|
4706 | - if (!empty($file)) { |
|
4707 | - $columns = isset($file[0]) ? $file[0] : NULL; |
|
4704 | + wp_send_json( $json ); |
|
4705 | + } else if ( $task == 'import_hood' ) { |
|
4706 | + if (!empty($file)) { |
|
4707 | + $columns = isset($file[0]) ? $file[0] : NULL; |
|
4708 | 4708 | |
4709 | - if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4710 | - $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory'); |
|
4711 | - wp_send_json( $json ); |
|
4712 | - } |
|
4709 | + if (empty($columns) || (!empty($columns) && $columns[0] == '')) { |
|
4710 | + $json['error'] = __('File you are uploading is not valid. Columns does not matching.', 'geodirectory'); |
|
4711 | + wp_send_json( $json ); |
|
4712 | + } |
|
4713 | 4713 | |
4714 | - $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory'); |
|
4715 | - $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' ); |
|
4716 | - for ($i = 1; $i <= $limit; $i++) { |
|
4717 | - $index = $processed + $i; |
|
4714 | + $gd_error_log = __('GD IMPORT NEIGHBOURHOODS [ROW %d]:', 'geodirectory'); |
|
4715 | + $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' ); |
|
4716 | + for ($i = 1; $i <= $limit; $i++) { |
|
4717 | + $index = $processed + $i; |
|
4718 | 4718 | |
4719 | - if (isset($file[$index])) { |
|
4720 | - $row = $file[$index]; |
|
4721 | - $row = array_map( 'trim', $row ); |
|
4722 | - $data = array(); |
|
4719 | + if (isset($file[$index])) { |
|
4720 | + $row = $file[$index]; |
|
4721 | + $row = array_map( 'trim', $row ); |
|
4722 | + $data = array(); |
|
4723 | 4723 | |
4724 | - foreach ($columns as $c => $column) { |
|
4725 | - if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) { |
|
4726 | - $data[$column] = sanitize_text_field($row[$c]); |
|
4727 | - } |
|
4728 | - } |
|
4724 | + foreach ($columns as $c => $column) { |
|
4725 | + if (in_array($column, array('neighbourhood_id', 'neighbourhood_name', 'neighbourhood_slug', 'latitude', 'longitude', 'location_id', 'city', 'region', 'country'))) { |
|
4726 | + $data[$column] = sanitize_text_field($row[$c]); |
|
4727 | + } |
|
4728 | + } |
|
4729 | 4729 | |
4730 | - if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) { |
|
4731 | - $invalid++; |
|
4732 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4733 | - continue; |
|
4734 | - } |
|
4730 | + if (empty($data['neighbourhood_name']) || empty($data['latitude']) || empty($data['longitude'])) { |
|
4731 | + $invalid++; |
|
4732 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4733 | + continue; |
|
4734 | + } |
|
4735 | 4735 | |
4736 | - $location_info = array(); |
|
4737 | - if (!empty($data['location_id']) && (int)$data['location_id'] > 0) { |
|
4738 | - $location_info = geodir_get_location_by_id('', (int)$data['location_id']); |
|
4739 | - } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) { |
|
4740 | - $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region'])); |
|
4741 | - } |
|
4736 | + $location_info = array(); |
|
4737 | + if (!empty($data['location_id']) && (int)$data['location_id'] > 0) { |
|
4738 | + $location_info = geodir_get_location_by_id('', (int)$data['location_id']); |
|
4739 | + } else if (!empty($data['city']) && !empty($data['region']) && !empty($data['country'])) { |
|
4740 | + $location_info = geodir_get_location_by_slug('city', array('fields' => 'location_id', 'city' => $data['city'], 'country' => $data['country'], 'region' => $data['region'])); |
|
4741 | + } |
|
4742 | 4742 | |
4743 | - if (empty($location_info)) { |
|
4744 | - $invalid++; |
|
4745 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4746 | - continue; |
|
4747 | - } |
|
4743 | + if (empty($location_info)) { |
|
4744 | + $invalid++; |
|
4745 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4746 | + continue; |
|
4747 | + } |
|
4748 | 4748 | |
4749 | - $location_id = $location_info->location_id; |
|
4749 | + $location_id = $location_info->location_id; |
|
4750 | 4750 | |
4751 | - $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
4751 | + $data['neighbourhood_id'] = isset($data['neighbourhood_id']) ? absint($data['neighbourhood_id']) : 0; |
|
4752 | 4752 | |
4753 | - $hood_data = array(); |
|
4754 | - $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
4755 | - $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
4756 | - $hood_data['hood_latitude'] = $data['latitude']; |
|
4757 | - $hood_data['hood_longitude'] = $data['longitude']; |
|
4758 | - $hood_data['hood_location_id'] = $location_id; |
|
4753 | + $hood_data = array(); |
|
4754 | + $hood_data['hood_name'] = $data['neighbourhood_name']; |
|
4755 | + $hood_data['hood_slug'] = $data['neighbourhood_slug']; |
|
4756 | + $hood_data['hood_latitude'] = $data['latitude']; |
|
4757 | + $hood_data['hood_longitude'] = $data['longitude']; |
|
4758 | + $hood_data['hood_location_id'] = $location_id; |
|
4759 | 4759 | |
4760 | - if ( $import_choice == 'update' ) { |
|
4761 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4762 | - $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
4760 | + if ( $import_choice == 'update' ) { |
|
4761 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4762 | + $hood_data['hood_id'] = (int)$data['neighbourhood_id']; |
|
4763 | 4763 | |
4764 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4765 | - $updated++; |
|
4766 | - } else { |
|
4767 | - $invalid++; |
|
4768 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4769 | - } |
|
4770 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4771 | - $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
4764 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4765 | + $updated++; |
|
4766 | + } else { |
|
4767 | + $invalid++; |
|
4768 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4769 | + } |
|
4770 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4771 | + $hood_data['hood_id'] = (int)$neighbourhood->hood_id; |
|
4772 | 4772 | |
4773 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4774 | - $updated++; |
|
4775 | - } else { |
|
4776 | - $invalid++; |
|
4777 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4778 | - } |
|
4779 | - } else { |
|
4780 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4781 | - $created++; |
|
4782 | - } else { |
|
4783 | - $invalid++; |
|
4784 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4785 | - } |
|
4786 | - } |
|
4787 | - } elseif ( $import_choice == 'skip' ) { |
|
4788 | - if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4789 | - $skipped++; |
|
4790 | - } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4791 | - $skipped++; |
|
4792 | - } else { |
|
4773 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4774 | + $updated++; |
|
4775 | + } else { |
|
4776 | + $invalid++; |
|
4777 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4778 | + } |
|
4779 | + } else { |
|
4780 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4781 | + $created++; |
|
4782 | + } else { |
|
4783 | + $invalid++; |
|
4784 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4785 | + } |
|
4786 | + } |
|
4787 | + } elseif ( $import_choice == 'skip' ) { |
|
4788 | + if ((int)$data['neighbourhood_id'] > 0 && ($neighbourhood = geodir_location_get_neighbourhood_by_id((int)$data['neighbourhood_id']))) { |
|
4789 | + $skipped++; |
|
4790 | + } else if (!empty($data['neighbourhood_slug']) && ($neighbourhood = geodir_location_get_neighbourhood_by_id($data['neighbourhood_slug'], true))) { |
|
4791 | + $skipped++; |
|
4792 | + } else { |
|
4793 | 4793 | |
4794 | - if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4795 | - $created++; |
|
4796 | - } else { |
|
4797 | - $invalid++; |
|
4798 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4799 | - } |
|
4800 | - } |
|
4801 | - } else { |
|
4802 | - $invalid++; |
|
4803 | - geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4804 | - } |
|
4805 | - } |
|
4806 | - } |
|
4807 | - } |
|
4794 | + if ($neighbourhood = geodir_location_insert_update_neighbourhood($hood_data)) { |
|
4795 | + $created++; |
|
4796 | + } else { |
|
4797 | + $invalid++; |
|
4798 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4799 | + } |
|
4800 | + } |
|
4801 | + } else { |
|
4802 | + $invalid++; |
|
4803 | + geodir_error_log( wp_sprintf( $gd_error_log, ($index + 1) ) . ' ' . $gd_error_hood ); |
|
4804 | + } |
|
4805 | + } |
|
4806 | + } |
|
4807 | + } |
|
4808 | 4808 | |
4809 | - $json = array(); |
|
4810 | - $json['processed'] = $limit; |
|
4811 | - $json['created'] = $created; |
|
4812 | - $json['updated'] = $updated; |
|
4813 | - $json['skipped'] = $skipped; |
|
4814 | - $json['invalid'] = $invalid; |
|
4815 | - $json['images'] = $images; |
|
4809 | + $json = array(); |
|
4810 | + $json['processed'] = $limit; |
|
4811 | + $json['created'] = $created; |
|
4812 | + $json['updated'] = $updated; |
|
4813 | + $json['skipped'] = $skipped; |
|
4814 | + $json['invalid'] = $invalid; |
|
4815 | + $json['images'] = $images; |
|
4816 | 4816 | |
4817 | - wp_send_json( $json ); |
|
4818 | - } |
|
4819 | - } |
|
4820 | - break; |
|
4821 | - case 'import_finish':{ |
|
4822 | - /** |
|
4823 | - * Run an action when an import finishes. |
|
4824 | - * |
|
4825 | - * This action can be used to fire functions after an import ends. |
|
4826 | - * |
|
4827 | - * @since 1.5.3 |
|
4828 | - * @package GeoDirectory |
|
4829 | - */ |
|
4830 | - do_action('geodir_import_finished'); |
|
4831 | - } |
|
4832 | - break; |
|
4817 | + wp_send_json( $json ); |
|
4818 | + } |
|
4819 | + } |
|
4820 | + break; |
|
4821 | + case 'import_finish':{ |
|
4822 | + /** |
|
4823 | + * Run an action when an import finishes. |
|
4824 | + * |
|
4825 | + * This action can be used to fire functions after an import ends. |
|
4826 | + * |
|
4827 | + * @since 1.5.3 |
|
4828 | + * @package GeoDirectory |
|
4829 | + */ |
|
4830 | + do_action('geodir_import_finished'); |
|
4831 | + } |
|
4832 | + break; |
|
4833 | 4833 | |
4834 | - } |
|
4835 | - echo '0'; |
|
4836 | - gd_die(); |
|
4834 | + } |
|
4835 | + echo '0'; |
|
4836 | + gd_die(); |
|
4837 | 4837 | } |
4838 | 4838 | |
4839 | 4839 | /** |
@@ -4877,12 +4877,12 @@ discard block |
||
4877 | 4877 | $args['slug'] = wp_unique_term_slug( $args['slug'], (object)$term_args ); |
4878 | 4878 | } |
4879 | 4879 | |
4880 | - if( !empty( $term ) ) { |
|
4880 | + if( !empty( $term ) ) { |
|
4881 | 4881 | $result = wp_insert_term( $term, $taxonomy, $args ); |
4882 | - if( !is_wp_error( $result ) ) { |
|
4883 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4884 | - } |
|
4885 | - } |
|
4882 | + if( !is_wp_error( $result ) ) { |
|
4883 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4884 | + } |
|
4885 | + } |
|
4886 | 4886 | |
4887 | 4887 | return false; |
4888 | 4888 | } |
@@ -4928,16 +4928,16 @@ discard block |
||
4928 | 4928 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
4929 | 4929 | |
4930 | 4930 | if( !is_wp_error( $result ) ) { |
4931 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4932 | - } |
|
4931 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4932 | + } |
|
4933 | 4933 | } else if ( $term_data['slug'] != '' && $term_info = (array)term_exists( $term_data['slug'], $taxonomy ) ) { |
4934 | 4934 | $term_data['term_id'] = $term_info['term_id']; |
4935 | 4935 | |
4936 | 4936 | $result = wp_update_term( $term_data['term_id'], $taxonomy, $term_data ); |
4937 | 4937 | |
4938 | 4938 | if( !is_wp_error( $result ) ) { |
4939 | - return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4940 | - } |
|
4939 | + return isset( $result['term_id'] ) ? $result['term_id'] : 0; |
|
4940 | + } |
|
4941 | 4941 | } else { |
4942 | 4942 | return geodir_imex_insert_term( $taxonomy, $term_data ); |
4943 | 4943 | } |
@@ -4959,47 +4959,47 @@ discard block |
||
4959 | 4959 | * @return int Posts count. |
4960 | 4960 | */ |
4961 | 4961 | function geodir_get_posts_count( $post_type ) { |
4962 | - global $wpdb, $plugin_prefix; |
|
4962 | + global $wpdb, $plugin_prefix; |
|
4963 | 4963 | |
4964 | - if ( !post_type_exists( $post_type ) ) { |
|
4965 | - return 0; |
|
4966 | - } |
|
4964 | + if ( !post_type_exists( $post_type ) ) { |
|
4965 | + return 0; |
|
4966 | + } |
|
4967 | 4967 | |
4968 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
4968 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
4969 | 4969 | |
4970 | - // Skip listing with statuses trash, auto-draft etc... |
|
4971 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
4972 | - $where_statuses = ''; |
|
4973 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
4974 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
4975 | - } |
|
4970 | + // Skip listing with statuses trash, auto-draft etc... |
|
4971 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
4972 | + $where_statuses = ''; |
|
4973 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
4974 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
4975 | + } |
|
4976 | 4976 | |
4977 | - /** |
|
4978 | - * Filter the SQL where clause part to filter posts count in import/export. |
|
4979 | - * |
|
4980 | - * @since 1.6.4 |
|
4981 | - * @package GeoDirectory |
|
4982 | - * |
|
4983 | - * @param string $where SQL where clause part. |
|
4984 | - */ |
|
4985 | - $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
4986 | - |
|
4987 | - $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 ); |
|
4988 | - |
|
4989 | - $posts_count = (int)$wpdb->get_var( $query ); |
|
4977 | + /** |
|
4978 | + * Filter the SQL where clause part to filter posts count in import/export. |
|
4979 | + * |
|
4980 | + * @since 1.6.4 |
|
4981 | + * @package GeoDirectory |
|
4982 | + * |
|
4983 | + * @param string $where SQL where clause part. |
|
4984 | + */ |
|
4985 | + $where_statuses = apply_filters( 'geodir_get_posts_count', $where_statuses, $post_type ); |
|
4986 | + |
|
4987 | + $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 ); |
|
4988 | + |
|
4989 | + $posts_count = (int)$wpdb->get_var( $query ); |
|
4990 | 4990 | |
4991 | - /** |
|
4992 | - * Modify returned post counts for the current post type. |
|
4993 | - * |
|
4994 | - * @since 1.4.6 |
|
4995 | - * @package GeoDirectory |
|
4996 | - * |
|
4997 | - * @param int $posts_count Post counts. |
|
4998 | - * @param string $post_type Post type. |
|
4999 | - */ |
|
5000 | - $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
5001 | - |
|
5002 | - return $posts_count; |
|
4991 | + /** |
|
4992 | + * Modify returned post counts for the current post type. |
|
4993 | + * |
|
4994 | + * @since 1.4.6 |
|
4995 | + * @package GeoDirectory |
|
4996 | + * |
|
4997 | + * @param int $posts_count Post counts. |
|
4998 | + * @param string $post_type Post type. |
|
4999 | + */ |
|
5000 | + $posts_count = apply_filters( 'geodir_imex_count_posts', $posts_count, $post_type ); |
|
5001 | + |
|
5002 | + return $posts_count; |
|
5003 | 5003 | } |
5004 | 5004 | |
5005 | 5005 | /** |
@@ -5028,10 +5028,10 @@ discard block |
||
5028 | 5028 | |
5029 | 5029 | if ( !empty( $posts ) ) { |
5030 | 5030 | $is_payment_plugin = is_plugin_active( 'geodir_payment_manager/geodir_payment_manager.php' ); |
5031 | - $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active. |
|
5032 | - $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
5033 | - $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false; |
|
5034 | - $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false; |
|
5031 | + $location_manager = function_exists('geodir_location_plugin_activated') ? true : false; // Check location manager installed & active. |
|
5032 | + $location_allowed = function_exists( 'geodir_cpt_no_location' ) && geodir_cpt_no_location( $post_type ) ? false : true; |
|
5033 | + $neighbourhood_active = $location_manager && $location_allowed && get_option('location_neighbourhoods') ? true : false; |
|
5034 | + $is_claim_active = is_plugin_active( 'geodir_claim_listing/geodir_claim_listing.php' ) && get_option('geodir_claim_enable') === 'yes' ? true : false; |
|
5035 | 5035 | |
5036 | 5036 | $csv_row = array(); |
5037 | 5037 | $csv_row[] = 'post_id'; |
@@ -5063,7 +5063,7 @@ discard block |
||
5063 | 5063 | } |
5064 | 5064 | $csv_row[] = 'post_status'; |
5065 | 5065 | $csv_row[] = 'is_featured'; |
5066 | - // Export claim listing field |
|
5066 | + // Export claim listing field |
|
5067 | 5067 | if ($is_claim_active) { |
5068 | 5068 | $csv_row[] = 'claimed'; |
5069 | 5069 | } |
@@ -5072,7 +5072,7 @@ discard block |
||
5072 | 5072 | $csv_row[] = 'alive_days'; |
5073 | 5073 | $csv_row[] = 'expire_date'; |
5074 | 5074 | } |
5075 | - $csv_row[] = 'post_date'; |
|
5075 | + $csv_row[] = 'post_date'; |
|
5076 | 5076 | $csv_row[] = 'post_address'; |
5077 | 5077 | $csv_row[] = 'post_city'; |
5078 | 5078 | $csv_row[] = 'post_region'; |
@@ -5080,11 +5080,11 @@ discard block |
||
5080 | 5080 | $csv_row[] = 'post_zip'; |
5081 | 5081 | $csv_row[] = 'post_latitude'; |
5082 | 5082 | $csv_row[] = 'post_longitude'; |
5083 | - if ($neighbourhood_active) { |
|
5084 | - $csv_row[] = 'post_neighbourhood'; |
|
5085 | - $csv_row[] = 'neighbourhood_latitude'; |
|
5086 | - $csv_row[] = 'neighbourhood_longitude'; |
|
5087 | - } |
|
5083 | + if ($neighbourhood_active) { |
|
5084 | + $csv_row[] = 'post_neighbourhood'; |
|
5085 | + $csv_row[] = 'neighbourhood_latitude'; |
|
5086 | + $csv_row[] = 'neighbourhood_longitude'; |
|
5087 | + } |
|
5088 | 5088 | $csv_row[] = 'geodir_timing'; |
5089 | 5089 | $csv_row[] = 'geodir_contact'; |
5090 | 5090 | $csv_row[] = 'geodir_email'; |
@@ -5116,21 +5116,21 @@ discard block |
||
5116 | 5116 | $csv_row[] = 'franchise'; |
5117 | 5117 | } |
5118 | 5118 | |
5119 | - /** |
|
5120 | - * Filter columns field names of gd export listings csv. |
|
5121 | - * |
|
5122 | - * @since 1.6.5 |
|
5123 | - * @package GeoDirectory |
|
5124 | - * |
|
5125 | - * @param array $csv_row Column names being exported in csv. |
|
5126 | - * @param string $post_type The post type. |
|
5127 | - */ |
|
5128 | - $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type); |
|
5119 | + /** |
|
5120 | + * Filter columns field names of gd export listings csv. |
|
5121 | + * |
|
5122 | + * @since 1.6.5 |
|
5123 | + * @package GeoDirectory |
|
5124 | + * |
|
5125 | + * @param array $csv_row Column names being exported in csv. |
|
5126 | + * @param string $post_type The post type. |
|
5127 | + */ |
|
5128 | + $csv_row = apply_filters('geodir_export_listing_csv_column_names', $csv_row, $post_type); |
|
5129 | 5129 | |
5130 | 5130 | $csv_rows[] = $csv_row; |
5131 | 5131 | |
5132 | 5132 | $images_count = 5; |
5133 | - $xx=0; |
|
5133 | + $xx=0; |
|
5134 | 5134 | foreach ( $posts as $post ) {$xx++; |
5135 | 5135 | $post_id = $post['ID']; |
5136 | 5136 | |
@@ -5261,15 +5261,15 @@ discard block |
||
5261 | 5261 | } |
5262 | 5262 | $csv_row[] = $post_info['post_status']; // post_status |
5263 | 5263 | $csv_row[] = (int)$post_info['is_featured'] == 1 ? 1 : ''; // is_featured |
5264 | - if ($is_claim_active) { |
|
5265 | - $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
5266 | - } |
|
5264 | + if ($is_claim_active) { |
|
5265 | + $csv_row[] = !empty($post_info['claimed']) && (int)$post_info['claimed'] == 1 ? 1 : ''; // claimed |
|
5266 | + } |
|
5267 | 5267 | if ($is_payment_plugin) { |
5268 | 5268 | $csv_row[] = (int)$post_info['package_id']; // package_id |
5269 | 5269 | $csv_row[] = $post_info['alive_days'] !== '' ? absint($post_info['alive_days']) : ''; // alive_days |
5270 | 5270 | $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 |
5271 | 5271 | } |
5272 | - $csv_row[] = $post_info['post_date']; // post_date |
|
5272 | + $csv_row[] = $post_info['post_date']; // post_date |
|
5273 | 5273 | $csv_row[] = stripslashes($post_info['post_address']); // post_address |
5274 | 5274 | $csv_row[] = stripslashes($post_info['post_city']); // post_city |
5275 | 5275 | $csv_row[] = stripslashes($post_info['post_region']); // post_region |
@@ -5277,21 +5277,21 @@ discard block |
||
5277 | 5277 | $csv_row[] = stripslashes($post_info['post_zip']); // post_zip |
5278 | 5278 | $csv_row[] = $post_info['post_latitude']; // post_latitude |
5279 | 5279 | $csv_row[] = $post_info['post_longitude']; // post_longitude |
5280 | - if ($neighbourhood_active) { |
|
5281 | - $post_neighbourhood = ''; |
|
5282 | - $neighbourhood_latitude = ''; |
|
5283 | - $neighbourhood_longitude = ''; |
|
5284 | - if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) { |
|
5285 | - if (!empty($hood_info)) { |
|
5286 | - $post_neighbourhood = $hood_info->hood_name; |
|
5287 | - $neighbourhood_latitude = $hood_info->hood_latitude; |
|
5288 | - $neighbourhood_longitude = $hood_info->hood_longitude; |
|
5289 | - } |
|
5290 | - } |
|
5291 | - $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
5292 | - $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
5293 | - $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
5294 | - } |
|
5280 | + if ($neighbourhood_active) { |
|
5281 | + $post_neighbourhood = ''; |
|
5282 | + $neighbourhood_latitude = ''; |
|
5283 | + $neighbourhood_longitude = ''; |
|
5284 | + if (!empty($post_info['post_neighbourhood']) && ($hood_info = geodir_location_get_neighbourhood_by_id($post_info['post_neighbourhood'], true, $post_info['post_location_id']))) { |
|
5285 | + if (!empty($hood_info)) { |
|
5286 | + $post_neighbourhood = $hood_info->hood_name; |
|
5287 | + $neighbourhood_latitude = $hood_info->hood_latitude; |
|
5288 | + $neighbourhood_longitude = $hood_info->hood_longitude; |
|
5289 | + } |
|
5290 | + } |
|
5291 | + $csv_row[] = stripslashes($post_neighbourhood); // post_neighbourhood |
|
5292 | + $csv_row[] = $neighbourhood_latitude; // neighbourhood_latitude |
|
5293 | + $csv_row[] = $neighbourhood_longitude; // neighbourhood_longitude |
|
5294 | + } |
|
5295 | 5295 | $csv_row[] = stripslashes($post_info['geodir_timing']); // geodir_timing |
5296 | 5296 | $csv_row[] = stripslashes($post_info['geodir_contact']); // geodir_contact |
5297 | 5297 | $csv_row[] = stripslashes($post_info['geodir_email']); // geodir_email |
@@ -5331,16 +5331,16 @@ discard block |
||
5331 | 5331 | $csv_row[] = (int)$franchise; // franchise id |
5332 | 5332 | } |
5333 | 5333 | |
5334 | - /** |
|
5335 | - * Filter columns values of gd export listings csv file |
|
5336 | - * |
|
5337 | - * @since 1.6.5 |
|
5338 | - * @package GeoDirectory |
|
5339 | - * |
|
5340 | - * @param array $csv_row Field values being exported in csv. |
|
5341 | - * @param array $post_info The post info. |
|
5342 | - */ |
|
5343 | - $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info); |
|
5334 | + /** |
|
5335 | + * Filter columns values of gd export listings csv file |
|
5336 | + * |
|
5337 | + * @since 1.6.5 |
|
5338 | + * @package GeoDirectory |
|
5339 | + * |
|
5340 | + * @param array $csv_row Field values being exported in csv. |
|
5341 | + * @param array $post_info The post info. |
|
5342 | + */ |
|
5343 | + $csv_row = apply_filters('geodir_export_listing_csv_column_values', $csv_row, $post_info); |
|
5344 | 5344 | |
5345 | 5345 | for ( $c = 0; $c < $images_count; $c++ ) { |
5346 | 5346 | $csv_row[] = isset( $current_images[$c] ) ? $current_images[$c] : ''; // IMAGE |
@@ -5373,64 +5373,64 @@ discard block |
||
5373 | 5373 | * @return array Array of posts data. |
5374 | 5374 | */ |
5375 | 5375 | function geodir_get_export_posts( $post_type, $per_page = 0, $page_no = 0 ) { |
5376 | - global $wpdb, $plugin_prefix; |
|
5376 | + global $wpdb, $plugin_prefix; |
|
5377 | 5377 | |
5378 | - if ( ! post_type_exists( $post_type ) ) |
|
5379 | - return new stdClass; |
|
5378 | + if ( ! post_type_exists( $post_type ) ) |
|
5379 | + return new stdClass; |
|
5380 | 5380 | |
5381 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
5381 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
5382 | 5382 | |
5383 | - $limit = ''; |
|
5384 | - if ( $per_page > 0 && $page_no > 0 ) { |
|
5385 | - $offset = ( $page_no - 1 ) * $per_page; |
|
5383 | + $limit = ''; |
|
5384 | + if ( $per_page > 0 && $page_no > 0 ) { |
|
5385 | + $offset = ( $page_no - 1 ) * $per_page; |
|
5386 | 5386 | |
5387 | - if ( $offset > 0 ) { |
|
5388 | - $limit = " LIMIT " . $offset . "," . $per_page; |
|
5389 | - } else { |
|
5390 | - $limit = " LIMIT " . $per_page; |
|
5391 | - } |
|
5392 | - } |
|
5387 | + if ( $offset > 0 ) { |
|
5388 | + $limit = " LIMIT " . $offset . "," . $per_page; |
|
5389 | + } else { |
|
5390 | + $limit = " LIMIT " . $per_page; |
|
5391 | + } |
|
5392 | + } |
|
5393 | 5393 | |
5394 | - // Skip listing with statuses trash, auto-draft etc... |
|
5395 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5396 | - $where_statuses = ''; |
|
5397 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5398 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5399 | - } |
|
5394 | + // Skip listing with statuses trash, auto-draft etc... |
|
5395 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5396 | + $where_statuses = ''; |
|
5397 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5398 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5399 | + } |
|
5400 | 5400 | |
5401 | - /** |
|
5402 | - * Filter the SQL where clause part to filter posts in import/export. |
|
5403 | - * |
|
5404 | - * @since 1.6.4 |
|
5405 | - * @package GeoDirectory |
|
5406 | - * |
|
5407 | - * @param string $where SQL where clause part. |
|
5408 | - */ |
|
5409 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5410 | - |
|
5411 | - $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 ); |
|
5412 | - /** |
|
5413 | - * Modify returned posts SQL query for the current post type. |
|
5414 | - * |
|
5415 | - * @since 1.4.6 |
|
5416 | - * @package GeoDirectory |
|
5417 | - * |
|
5418 | - * @param int $query The SQL query. |
|
5419 | - * @param string $post_type Post type. |
|
5420 | - */ |
|
5421 | - $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
5422 | - $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
5423 | - |
|
5424 | - /** |
|
5425 | - * Modify returned post results for the current post type. |
|
5426 | - * |
|
5427 | - * @since 1.4.6 |
|
5428 | - * @package GeoDirectory |
|
5429 | - * |
|
5430 | - * @param object $results An object containing all post ids. |
|
5431 | - * @param string $post_type Post type. |
|
5432 | - */ |
|
5433 | - return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
5401 | + /** |
|
5402 | + * Filter the SQL where clause part to filter posts in import/export. |
|
5403 | + * |
|
5404 | + * @since 1.6.4 |
|
5405 | + * @package GeoDirectory |
|
5406 | + * |
|
5407 | + * @param string $where SQL where clause part. |
|
5408 | + */ |
|
5409 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5410 | + |
|
5411 | + $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 ); |
|
5412 | + /** |
|
5413 | + * Modify returned posts SQL query for the current post type. |
|
5414 | + * |
|
5415 | + * @since 1.4.6 |
|
5416 | + * @package GeoDirectory |
|
5417 | + * |
|
5418 | + * @param int $query The SQL query. |
|
5419 | + * @param string $post_type Post type. |
|
5420 | + */ |
|
5421 | + $query = apply_filters( 'geodir_imex_export_posts_query', $query, $post_type ); |
|
5422 | + $results = (array)$wpdb->get_results( $wpdb->prepare( $query, $post_type ), ARRAY_A ); |
|
5423 | + |
|
5424 | + /** |
|
5425 | + * Modify returned post results for the current post type. |
|
5426 | + * |
|
5427 | + * @since 1.4.6 |
|
5428 | + * @package GeoDirectory |
|
5429 | + * |
|
5430 | + * @param object $results An object containing all post ids. |
|
5431 | + * @param string $post_type Post type. |
|
5432 | + */ |
|
5433 | + return apply_filters( 'geodir_export_posts', $results, $post_type ); |
|
5434 | 5434 | } |
5435 | 5435 | |
5436 | 5436 | /** |
@@ -5449,26 +5449,26 @@ discard block |
||
5449 | 5449 | * @return string The SQL query. |
5450 | 5450 | */ |
5451 | 5451 | function geodir_imex_get_events_query( $query, $post_type ) { |
5452 | - if ( $post_type == 'gd_event' ) { |
|
5453 | - global $wpdb, $plugin_prefix; |
|
5452 | + if ( $post_type == 'gd_event' ) { |
|
5453 | + global $wpdb, $plugin_prefix; |
|
5454 | 5454 | |
5455 | - $table = $plugin_prefix . $post_type . '_detail'; |
|
5456 | - $schedule_table = EVENT_SCHEDULE; |
|
5455 | + $table = $plugin_prefix . $post_type . '_detail'; |
|
5456 | + $schedule_table = EVENT_SCHEDULE; |
|
5457 | 5457 | |
5458 | - // Skip listing with statuses trash, auto-draft etc... |
|
5459 | - $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5460 | - $where_statuses = ''; |
|
5461 | - if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5462 | - $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5463 | - } |
|
5458 | + // Skip listing with statuses trash, auto-draft etc... |
|
5459 | + $skip_statuses = geodir_imex_export_skip_statuses(); |
|
5460 | + $where_statuses = ''; |
|
5461 | + if ( !empty( $skip_statuses ) && is_array( $skip_statuses ) ) { |
|
5462 | + $where_statuses = "AND `" . $wpdb->posts . "`.`post_status` NOT IN('" . implode( "','", $skip_statuses ) . "')"; |
|
5463 | + } |
|
5464 | 5464 | |
5465 | - /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
5466 | - $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5465 | + /** This action is documented in geodirectory-functions/geodirectory-admin/admin_functions.php */ |
|
5466 | + $where_statuses = apply_filters( 'geodir_get_export_posts', $where_statuses, $post_type ); |
|
5467 | 5467 | |
5468 | - $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 ); |
|
5469 | - } |
|
5468 | + $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 ); |
|
5469 | + } |
|
5470 | 5470 | |
5471 | - return $query; |
|
5471 | + return $query; |
|
5472 | 5472 | } |
5473 | 5473 | |
5474 | 5474 | /** |
@@ -5490,36 +5490,36 @@ discard block |
||
5490 | 5490 | * @return int Total terms count. |
5491 | 5491 | */ |
5492 | 5492 | function geodir_get_terms_count( $post_type ) { |
5493 | - $args = array( 'hide_empty' => 0 ); |
|
5493 | + $args = array( 'hide_empty' => 0 ); |
|
5494 | 5494 | |
5495 | - remove_all_filters( 'get_terms' ); |
|
5495 | + remove_all_filters( 'get_terms' ); |
|
5496 | 5496 | |
5497 | - $taxonomy = $post_type . 'category'; |
|
5497 | + $taxonomy = $post_type . 'category'; |
|
5498 | 5498 | |
5499 | - // WPML |
|
5500 | - $is_wpml = geodir_is_wpml(); |
|
5501 | - $active_lang = 'all'; |
|
5502 | - if ( $is_wpml ) { |
|
5503 | - global $sitepress; |
|
5504 | - $active_lang = $sitepress->get_current_language(); |
|
5499 | + // WPML |
|
5500 | + $is_wpml = geodir_is_wpml(); |
|
5501 | + $active_lang = 'all'; |
|
5502 | + if ( $is_wpml ) { |
|
5503 | + global $sitepress; |
|
5504 | + $active_lang = $sitepress->get_current_language(); |
|
5505 | 5505 | |
5506 | - if ( $active_lang != 'all' ) { |
|
5507 | - $sitepress->switch_lang( 'all', true ); |
|
5508 | - } |
|
5509 | - } |
|
5510 | - // WPML |
|
5506 | + if ( $active_lang != 'all' ) { |
|
5507 | + $sitepress->switch_lang( 'all', true ); |
|
5508 | + } |
|
5509 | + } |
|
5510 | + // WPML |
|
5511 | 5511 | |
5512 | - $count_terms = wp_count_terms( $taxonomy, $args ); |
|
5512 | + $count_terms = wp_count_terms( $taxonomy, $args ); |
|
5513 | 5513 | |
5514 | - // WPML |
|
5515 | - if ( $is_wpml && $active_lang !== 'all' ) { |
|
5516 | - global $sitepress; |
|
5517 | - $sitepress->switch_lang( $active_lang, true ); |
|
5518 | - } |
|
5519 | - // WPML |
|
5520 | - $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
5514 | + // WPML |
|
5515 | + if ( $is_wpml && $active_lang !== 'all' ) { |
|
5516 | + global $sitepress; |
|
5517 | + $sitepress->switch_lang( $active_lang, true ); |
|
5518 | + } |
|
5519 | + // WPML |
|
5520 | + $count_terms = !is_wp_error( $count_terms ) ? $count_terms : 0; |
|
5521 | 5521 | |
5522 | - return $count_terms; |
|
5522 | + return $count_terms; |
|
5523 | 5523 | } |
5524 | 5524 | |
5525 | 5525 | /** |
@@ -5558,11 +5558,11 @@ discard block |
||
5558 | 5558 | $csv_row[] = 'cat_posttype'; |
5559 | 5559 | $csv_row[] = 'cat_parent'; |
5560 | 5560 | $csv_row[] = 'cat_schema'; |
5561 | - // WPML |
|
5561 | + // WPML |
|
5562 | 5562 | $is_wpml = geodir_is_wpml(); |
5563 | 5563 | if ($is_wpml) { |
5564 | 5564 | $csv_row[] = 'cat_language'; |
5565 | - $csv_row[] = 'cat_id_original'; |
|
5565 | + $csv_row[] = 'cat_id_original'; |
|
5566 | 5566 | } |
5567 | 5567 | // WPML |
5568 | 5568 | $csv_row[] = 'cat_description'; |
@@ -5592,10 +5592,10 @@ discard block |
||
5592 | 5592 | $csv_row[] = $post_type; |
5593 | 5593 | $csv_row[] = $cat_parent; |
5594 | 5594 | $csv_row[] = get_tax_meta( $term->term_id, 'ct_cat_schema', false, $post_type ); |
5595 | - // WPML |
|
5595 | + // WPML |
|
5596 | 5596 | if ($is_wpml) { |
5597 | 5597 | $csv_row[] = geodir_get_language_for_element( $term->term_id, 'tax_' . $taxonomy ); |
5598 | - $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
5598 | + $csv_row[] = geodir_imex_original_post_id( $term->term_id, 'tax_' . $taxonomy ); |
|
5599 | 5599 | } |
5600 | 5600 | // WPML |
5601 | 5601 | $csv_row[] = $term->description; |
@@ -6191,43 +6191,43 @@ discard block |
||
6191 | 6191 | * @param string $status Post status. |
6192 | 6192 | */ |
6193 | 6193 | function geodir_create_page($slug, $option, $page_title = '', $page_content = '', $post_parent = 0, $status = 'publish') { |
6194 | - global $wpdb, $current_user; |
|
6195 | - |
|
6196 | - $option_value = get_option($option); |
|
6197 | - |
|
6198 | - if ($option_value > 0) : |
|
6199 | - if (get_post($option_value)) : |
|
6200 | - // Page exists |
|
6201 | - return; |
|
6202 | - endif; |
|
6203 | - endif; |
|
6204 | - |
|
6205 | - $page_found = $wpdb->get_var( |
|
6206 | - $wpdb->prepare( |
|
6207 | - "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
6208 | - array($slug) |
|
6209 | - ) |
|
6210 | - ); |
|
6211 | - |
|
6212 | - if ($page_found) : |
|
6213 | - // Page exists |
|
6214 | - if (!$option_value) update_option($option, $page_found); |
|
6215 | - return; |
|
6216 | - endif; |
|
6217 | - |
|
6218 | - $page_data = array( |
|
6219 | - 'post_status' => $status, |
|
6220 | - 'post_type' => 'page', |
|
6221 | - 'post_author' => $current_user->ID, |
|
6222 | - 'post_name' => $slug, |
|
6223 | - 'post_title' => $page_title, |
|
6224 | - 'post_content' => $page_content, |
|
6225 | - 'post_parent' => $post_parent, |
|
6226 | - 'comment_status' => 'closed' |
|
6227 | - ); |
|
6228 | - $page_id = wp_insert_post($page_data); |
|
6229 | - |
|
6230 | - add_option($option, $page_id); |
|
6194 | + global $wpdb, $current_user; |
|
6195 | + |
|
6196 | + $option_value = get_option($option); |
|
6197 | + |
|
6198 | + if ($option_value > 0) : |
|
6199 | + if (get_post($option_value)) : |
|
6200 | + // Page exists |
|
6201 | + return; |
|
6202 | + endif; |
|
6203 | + endif; |
|
6204 | + |
|
6205 | + $page_found = $wpdb->get_var( |
|
6206 | + $wpdb->prepare( |
|
6207 | + "SELECT ID FROM " . $wpdb->posts . " WHERE post_name = %s LIMIT 1;", |
|
6208 | + array($slug) |
|
6209 | + ) |
|
6210 | + ); |
|
6211 | + |
|
6212 | + if ($page_found) : |
|
6213 | + // Page exists |
|
6214 | + if (!$option_value) update_option($option, $page_found); |
|
6215 | + return; |
|
6216 | + endif; |
|
6217 | + |
|
6218 | + $page_data = array( |
|
6219 | + 'post_status' => $status, |
|
6220 | + 'post_type' => 'page', |
|
6221 | + 'post_author' => $current_user->ID, |
|
6222 | + 'post_name' => $slug, |
|
6223 | + 'post_title' => $page_title, |
|
6224 | + 'post_content' => $page_content, |
|
6225 | + 'post_parent' => $post_parent, |
|
6226 | + 'comment_status' => 'closed' |
|
6227 | + ); |
|
6228 | + $page_id = wp_insert_post($page_data); |
|
6229 | + |
|
6230 | + add_option($option, $page_id); |
|
6231 | 6231 | |
6232 | 6232 | } |
6233 | 6233 | |
@@ -6258,9 +6258,9 @@ discard block |
||
6258 | 6258 | * @package GeoDirectory |
6259 | 6259 | */ |
6260 | 6260 | function geodir_admin_upgrade_notice() { |
6261 | - $class = "error"; |
|
6262 | - $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory"); |
|
6263 | - echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
6261 | + $class = "error"; |
|
6262 | + $message = __("Please update core GeoDirectory or some addons may not function correctly.","geodirectory"); |
|
6263 | + echo"<div class=\"$class\"> <p>$message</p></div>"; |
|
6264 | 6264 | } |
6265 | 6265 | |
6266 | 6266 | /** |
@@ -6273,18 +6273,18 @@ discard block |
||
6273 | 6273 | */ |
6274 | 6274 | function geodire_admin_upgrade_notice( $plugin_data, $r ) |
6275 | 6275 | { |
6276 | - // readme contents |
|
6277 | - $args = array( |
|
6278 | - 'timeout' => 15, |
|
6279 | - 'redirection' => 5 |
|
6280 | - ); |
|
6281 | - $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
6282 | - $data = wp_remote_get( $url, $args ); |
|
6276 | + // readme contents |
|
6277 | + $args = array( |
|
6278 | + 'timeout' => 15, |
|
6279 | + 'redirection' => 5 |
|
6280 | + ); |
|
6281 | + $url = "http://plugins.svn.wordpress.org/geodirectory/trunk/readme.txt"; |
|
6282 | + $data = wp_remote_get( $url, $args ); |
|
6283 | 6283 | |
6284 | - if (!is_wp_error($data) && $data['response']['code'] == 200) { |
|
6284 | + if (!is_wp_error($data) && $data['response']['code'] == 200) { |
|
6285 | 6285 | |
6286 | - geodir_in_plugin_update_message($data['body']); |
|
6287 | - } |
|
6286 | + geodir_in_plugin_update_message($data['body']); |
|
6287 | + } |
|
6288 | 6288 | } |
6289 | 6289 | |
6290 | 6290 | |
@@ -6292,28 +6292,28 @@ discard block |
||
6292 | 6292 | * @param string $content http response body |
6293 | 6293 | */ |
6294 | 6294 | function geodir_in_plugin_update_message($content) { |
6295 | - // Output Upgrade Notice |
|
6296 | - $matches = null; |
|
6297 | - $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
6298 | - $upgrade_notice = ''; |
|
6299 | - if ( preg_match( $regexp, $content, $matches ) ) { |
|
6300 | - if(empty($matches)){return;} |
|
6301 | - |
|
6302 | - $version = trim( $matches[1] ); |
|
6303 | - if($version && $version>GEODIRECTORY_VERSION){ |
|
6304 | - |
|
6305 | - |
|
6306 | - $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) ); |
|
6307 | - if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) { |
|
6308 | - $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
6309 | - foreach ( $notices as $index => $line ) { |
|
6310 | - $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) ); |
|
6311 | - } |
|
6312 | - $upgrade_notice .= '</div> '; |
|
6313 | - } |
|
6314 | - } |
|
6315 | - } |
|
6316 | - echo $upgrade_notice; |
|
6295 | + // Output Upgrade Notice |
|
6296 | + $matches = null; |
|
6297 | + $regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( GEODIRECTORY_VERSION ) . '\s*=|$)~Uis'; |
|
6298 | + $upgrade_notice = ''; |
|
6299 | + if ( preg_match( $regexp, $content, $matches ) ) { |
|
6300 | + if(empty($matches)){return;} |
|
6301 | + |
|
6302 | + $version = trim( $matches[1] ); |
|
6303 | + if($version && $version>GEODIRECTORY_VERSION){ |
|
6304 | + |
|
6305 | + |
|
6306 | + $notices = (array) preg_split('~[\r\n]+~', trim( $matches[2] ) ); |
|
6307 | + if ( version_compare( GEODIRECTORY_VERSION, $version, '<' ) ) { |
|
6308 | + $upgrade_notice .= '<div class="geodir_plugin_upgrade_notice">'; |
|
6309 | + foreach ( $notices as $index => $line ) { |
|
6310 | + $upgrade_notice .= wp_kses_post( preg_replace( '~\[([^\]]*)\]\(([^\)]*)\)~', '<a href="${2}">${1}</a>', $line ) ); |
|
6311 | + } |
|
6312 | + $upgrade_notice .= '</div> '; |
|
6313 | + } |
|
6314 | + } |
|
6315 | + } |
|
6316 | + echo $upgrade_notice; |
|
6317 | 6317 | } |
6318 | 6318 | |
6319 | 6319 | /** |
@@ -6346,19 +6346,19 @@ discard block |
||
6346 | 6346 | * @param array Listing statuses to be skipped. |
6347 | 6347 | */ |
6348 | 6348 | function geodir_imex_export_skip_statuses() { |
6349 | - $statuses = array( 'trash', 'auto-draft' ); |
|
6349 | + $statuses = array( 'trash', 'auto-draft' ); |
|
6350 | 6350 | |
6351 | - /** |
|
6352 | - * Filter the statuses to skip during GD export listings. |
|
6353 | - * |
|
6354 | - * @since 1.6.0 |
|
6355 | - * @package GeoDirectory |
|
6356 | - * |
|
6357 | - * @param array $statuses Listing statuses to be skipped. |
|
6358 | - */ |
|
6359 | - $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
6351 | + /** |
|
6352 | + * Filter the statuses to skip during GD export listings. |
|
6353 | + * |
|
6354 | + * @since 1.6.0 |
|
6355 | + * @package GeoDirectory |
|
6356 | + * |
|
6357 | + * @param array $statuses Listing statuses to be skipped. |
|
6358 | + */ |
|
6359 | + $statuses = apply_filters( 'geodir_imex_export_skip_statuses', $statuses ); |
|
6360 | 6360 | |
6361 | - return $statuses; |
|
6361 | + return $statuses; |
|
6362 | 6362 | } |
6363 | 6363 | |
6364 | 6364 | /** |
@@ -6370,15 +6370,15 @@ discard block |
||
6370 | 6370 | * @since 1.6.3 |
6371 | 6371 | */ |
6372 | 6372 | function geodir_admin_dequeue_scripts() { |
6373 | - // EDD |
|
6374 | - if (wp_script_is('jquery-chosen', 'enqueued')) { |
|
6375 | - wp_dequeue_script('jquery-chosen'); |
|
6376 | - } |
|
6373 | + // EDD |
|
6374 | + if (wp_script_is('jquery-chosen', 'enqueued')) { |
|
6375 | + wp_dequeue_script('jquery-chosen'); |
|
6376 | + } |
|
6377 | 6377 | |
6378 | - // Ultimate Addons for Visual Composer |
|
6379 | - if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) { |
|
6380 | - wp_dequeue_script('ultimate-vc-backend-script'); |
|
6381 | - } |
|
6378 | + // Ultimate Addons for Visual Composer |
|
6379 | + if (wp_script_is('ultimate-vc-backend-script', 'enqueued')) { |
|
6380 | + wp_dequeue_script('ultimate-vc-backend-script'); |
|
6381 | + } |
|
6382 | 6382 | } |
6383 | 6383 | |
6384 | 6384 | /** |
@@ -6394,48 +6394,48 @@ discard block |
||
6394 | 6394 | * @return string SQL where clause part. |
6395 | 6395 | */ |
6396 | 6396 | function geodir_imex_get_filter_where($where = '', $post_type = '') { |
6397 | - global $wpdb; |
|
6397 | + global $wpdb; |
|
6398 | 6398 | |
6399 | - $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
6399 | + $filters = !empty( $_REQUEST['gd_imex'] ) && is_array( $_REQUEST['gd_imex'] ) ? $_REQUEST['gd_imex'] : NULL; |
|
6400 | 6400 | |
6401 | - if ( !empty( $filters ) ) { |
|
6402 | - foreach ( $filters as $field => $value ) { |
|
6403 | - switch ($field) { |
|
6404 | - case 'start_date': |
|
6405 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
6406 | - break; |
|
6407 | - case 'end_date': |
|
6408 | - $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
6409 | - break; |
|
6410 | - } |
|
6411 | - } |
|
6412 | - } |
|
6401 | + if ( !empty( $filters ) ) { |
|
6402 | + foreach ( $filters as $field => $value ) { |
|
6403 | + switch ($field) { |
|
6404 | + case 'start_date': |
|
6405 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` >= '" . sanitize_text_field( $value ) . " 00:00:00'"; |
|
6406 | + break; |
|
6407 | + case 'end_date': |
|
6408 | + $where .= " AND `" . $wpdb->posts . "`.`post_date` <= '" . sanitize_text_field( $value ) . " 23:59:59'"; |
|
6409 | + break; |
|
6410 | + } |
|
6411 | + } |
|
6412 | + } |
|
6413 | 6413 | |
6414 | - return $where; |
|
6414 | + return $where; |
|
6415 | 6415 | } |
6416 | 6416 | add_filter('geodir_get_posts_count', 'geodir_imex_get_filter_where', 10, 2); |
6417 | 6417 | add_filter('geodir_get_export_posts', 'geodir_imex_get_filter_where', 10, 2); |
6418 | 6418 | |
6419 | 6419 | |
6420 | 6420 | function geodir_fix_for_primer_theme(){ |
6421 | - if(!defined( 'PRIMER_VERSION' )){return;} |
|
6422 | - global $pagenow; |
|
6421 | + if(!defined( 'PRIMER_VERSION' )){return;} |
|
6422 | + global $pagenow; |
|
6423 | 6423 | |
6424 | - if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){ |
|
6424 | + if ( ( 'post.php' === $pagenow || 'post-new.php' === $pagenow ) && (isset($_REQUEST['post_type']) || isset($_REQUEST['post']) ) ){ |
|
6425 | 6425 | |
6426 | - $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
6426 | + $post_type = isset($_REQUEST['post_type']) ? esc_attr($_REQUEST['post_type']) : get_post_type( $_GET['post'] ); |
|
6427 | 6427 | |
6428 | - $post_types = geodir_get_posttypes(); |
|
6429 | - if ($post_type && in_array($post_type, $post_types) ) { |
|
6430 | - global $primer_customizer_layouts; |
|
6431 | - remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
6432 | - } |
|
6433 | - } |
|
6428 | + $post_types = geodir_get_posttypes(); |
|
6429 | + if ($post_type && in_array($post_type, $post_types) ) { |
|
6430 | + global $primer_customizer_layouts; |
|
6431 | + remove_action( 'add_meta_boxes', array( $primer_customizer_layouts, 'add_meta_box' ), 10); |
|
6432 | + } |
|
6433 | + } |
|
6434 | 6434 | |
6435 | 6435 | } |
6436 | 6436 | |
6437 | 6437 | if(is_admin()){ |
6438 | - add_action('add_meta_boxes','geodir_fix_for_primer_theme',0); |
|
6438 | + add_action('add_meta_boxes','geodir_fix_for_primer_theme',0); |
|
6439 | 6439 | } |
6440 | 6440 | |
6441 | 6441 | |
@@ -6568,65 +6568,65 @@ discard block |
||
6568 | 6568 | |
6569 | 6569 | function geodir_ga_activation_url() { |
6570 | 6570 | |
6571 | - return add_query_arg( array( |
|
6572 | - 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"), |
|
6573 | - 'scope' => GEODIR_GA_SCOPE, |
|
6574 | - 'response_type' => 'code', |
|
6575 | - 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
6576 | - 'client_id' => GEODIR_GA_CLIENTID, |
|
6577 | - ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
6571 | + return add_query_arg( array( |
|
6572 | + 'next' => admin_url("admin.php?page=geodirectory&active_tab=google_analytic_settings"), |
|
6573 | + 'scope' => GEODIR_GA_SCOPE, |
|
6574 | + 'response_type' => 'code', |
|
6575 | + 'redirect_uri' => GEODIR_GA_REDIRECT, |
|
6576 | + 'client_id' => GEODIR_GA_CLIENTID, |
|
6577 | + ), 'https://accounts.google.com/o/oauth2/auth' ); |
|
6578 | 6578 | |
6579 | - return $url; |
|
6579 | + return $url; |
|
6580 | 6580 | } |
6581 | 6581 | |
6582 | 6582 | function geodir_gd_accounts(){ |
6583 | - $accounts = array(); |
|
6584 | - $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
6585 | - if($useAuth){ |
|
6586 | - $accounts = geodir_ga_get_analytics_accounts(); |
|
6587 | - if(is_array($accounts)){ |
|
6588 | - $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts); |
|
6589 | - }elseif(get_option('geodir_ga_account_id')){ |
|
6590 | - $accounts = array(); |
|
6591 | - $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')'; |
|
6592 | - } |
|
6593 | - } |
|
6594 | - return $accounts; |
|
6583 | + $accounts = array(); |
|
6584 | + $useAuth = ( get_option( 'geodir_ga_auth_code' ) == '' ? false : true ); |
|
6585 | + if($useAuth){ |
|
6586 | + $accounts = geodir_ga_get_analytics_accounts(); |
|
6587 | + if(is_array($accounts)){ |
|
6588 | + $accounts = array_merge(array(__('Select Account','geodirectory')),$accounts); |
|
6589 | + }elseif(get_option('geodir_ga_account_id')){ |
|
6590 | + $accounts = array(); |
|
6591 | + $accounts[get_option('geodir_ga_account_id')] = __('Account re-authorization may be required','geodirectory').' ('.get_option('geodir_ga_account_id').')'; |
|
6592 | + } |
|
6593 | + } |
|
6594 | + return $accounts; |
|
6595 | 6595 | } |
6596 | 6596 | |
6597 | 6597 | function geodir_ga_get_analytics_accounts() |
6598 | 6598 | { |
6599 | - $accounts = array(); |
|
6599 | + $accounts = array(); |
|
6600 | 6600 | |
6601 | - if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');} |
|
6601 | + if(get_option('geodir_ga_auth_token')===false){update_option('geodir_ga_auth_token','');} |
|
6602 | 6602 | |
6603 | 6603 | |
6604 | - if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){ |
|
6605 | - return get_option('geodir_gd_uids'); |
|
6606 | - } |
|
6604 | + if(get_option('geodir_gd_uids') && !isset($_POST['geodir_ga_auth_code'])){ |
|
6605 | + return get_option('geodir_gd_uids'); |
|
6606 | + } |
|
6607 | 6607 | |
6608 | 6608 | |
6609 | - # Create a new Gdata call |
|
6610 | - if ( trim(get_option('geodir_ga_auth_code')) != '' ) |
|
6611 | - $stats = new GDGoogleAnalyticsStats(); |
|
6612 | - else |
|
6613 | - return false; |
|
6609 | + # Create a new Gdata call |
|
6610 | + if ( trim(get_option('geodir_ga_auth_code')) != '' ) |
|
6611 | + $stats = new GDGoogleAnalyticsStats(); |
|
6612 | + else |
|
6613 | + return false; |
|
6614 | 6614 | |
6615 | - # Check if Google sucessfully logged in |
|
6616 | - if ( ! $stats->checkLogin() ) |
|
6617 | - return false; |
|
6615 | + # Check if Google sucessfully logged in |
|
6616 | + if ( ! $stats->checkLogin() ) |
|
6617 | + return false; |
|
6618 | 6618 | |
6619 | - # Get a list of accounts |
|
6620 | - $accounts = $stats->getAllProfiles(); |
|
6619 | + # Get a list of accounts |
|
6620 | + $accounts = $stats->getAllProfiles(); |
|
6621 | 6621 | |
6622 | - natcasesort ($accounts); |
|
6622 | + natcasesort ($accounts); |
|
6623 | 6623 | |
6624 | - # Return the account array if there are accounts |
|
6625 | - if ( count($accounts) > 0 ){ |
|
6626 | - update_option('geodir_gd_uids',$accounts); |
|
6627 | - return $accounts; |
|
6628 | - } |
|
6629 | - else |
|
6630 | - return false; |
|
6624 | + # Return the account array if there are accounts |
|
6625 | + if ( count($accounts) > 0 ){ |
|
6626 | + update_option('geodir_gd_uids',$accounts); |
|
6627 | + return $accounts; |
|
6628 | + } |
|
6629 | + else |
|
6630 | + return false; |
|
6631 | 6631 | } |
6632 | 6632 |